summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexei Podtelezhnikov <apodtele@gmail.com>2021-08-19 20:41:55 -0400
committerAlexei Podtelezhnikov <apodtele@gmail.com>2021-08-19 20:41:55 -0400
commitffdac8d67e21452b3c076857a707c9b0618e9e0a (patch)
tree4e543b0d2cf2988dc0b6f24dce21143a7f64af7f
parent633fe0876486de84b421fef432b63f2e2e15d83e (diff)
downloadfreetype2-ffdac8d67e21452b3c076857a707c9b0618e9e0a.tar.gz
Determine `long long` availability based on its size.
MSVC, for example, used `long long` even without full C99 support. * include/freetype/config/ftstdlib.h: Check if `long long` limits are defined in <limits.h>. * include/freetype/config/integer-types.h: Check `long long` size and use it to typedef FT_Int64.
-rw-r--r--include/freetype/config/ftstdlib.h12
-rw-r--r--include/freetype/config/integer-types.h14
2 files changed, 24 insertions, 2 deletions
diff --git a/include/freetype/config/ftstdlib.h b/include/freetype/config/ftstdlib.h
index fea21ffa4..a6812aec6 100644
--- a/include/freetype/config/ftstdlib.h
+++ b/include/freetype/config/ftstdlib.h
@@ -43,7 +43,8 @@
*
* `UINT_MAX` and `ULONG_MAX` are used to automatically compute the size of
* `int` and `long` in bytes at compile-time. So far, this works for all
- * platforms the library has been tested on.
+ * platforms the library has been tested on. We also check `ULLONG_MAX`
+ * to see if we can use 64-bit `long long` later.
*
* Note that on the extremely rare platforms that do not provide integer
* types that are _exactly_ 16 and 32~bits wide (e.g., some old Crays where
@@ -66,6 +67,15 @@
#define FT_LONG_MIN LONG_MIN
#define FT_LONG_MAX LONG_MAX
#define FT_ULONG_MAX ULONG_MAX
+#ifdef LLONG_MAX
+#define FT_LLONG_MAX LLONG_MAX
+#endif
+#ifdef LLONG_MIN
+#define FT_LLONG_MIN LLONG_MIN
+#endif
+#ifdef ULLONG_MAX
+#define FT_ULLONG_MAX ULLONG_MAX
+#endif
/**************************************************************************
diff --git a/include/freetype/config/integer-types.h b/include/freetype/config/integer-types.h
index 684aa5377..d1907d5c8 100644
--- a/include/freetype/config/integer-types.h
+++ b/include/freetype/config/integer-types.h
@@ -60,6 +60,18 @@
#endif /* !defined(FT_SIZEOF_LONG) */
+#ifndef FT_SIZEOF_LONG_LONG
+
+ /* The size of a `long long` type if available*/
+#if defined( FT_ULLONG_MAX ) && FT_ULLONG_MAX >= 0xFFFFFFFFFFFFFFFFULL
+#define FT_SIZEOF_LONG_LONG ( 64 / FT_CHAR_BIT )
+#else
+#define FT_SIZEOF_LONG_LONG 0
+#endif
+
+#endif /* !defined(FT_SIZEOF_LONG_LONG) */
+
+
/**************************************************************************
*
* @section:
@@ -180,7 +192,7 @@
#define FT_INT64 long
#define FT_UINT64 unsigned long
-#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L
+#elif FT_SIZEOF_LONG_LONG >= ( 64 / FT_CHAR_BIT )
#define FT_INT64 long long int
#define FT_UINT64 unsigned long long int