Commit ffdac8d67e21452b3c076857a707c9b0618e9e0a

Alexei Podtelezhnikov 2021-08-19T20:41:55

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.

diff --git a/include/freetype/config/ftstdlib.h b/include/freetype/config/ftstdlib.h
index fea21ff..a6812ae 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 684aa53..d1907d5 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