]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl_setup.h: add curl_uint64_t internal type
authorEvgeny Grin <k2k@narod.ru>
Sat, 10 Feb 2024 18:28:27 +0000 (19:28 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 20 Feb 2024 10:35:05 +0000 (11:35 +0100)
The unsigned version of curl_off_t basically

lib/curl_setup.h

index 703e903fa8fc3cd41ae7bb08739d0d87b2bc2155..644a8e2742dd3c77a73cc48c844712a816c58747 100644 (file)
 
 #include <curl/system.h>
 
+/* Helper macro to expand and concatenate two macros.
+ * Direct macros concatenation does not work because macros
+ * are not expanded before direct concatenation.
+ */
+#define CURL_CONC_MACROS_(A,B) A ## B
+#define CURL_CONC_MACROS(A,B) CURL_CONC_MACROS_(A,B)
+
 /* curl uses its own printf() function internally. It understands the GNU
  * format. Use this format, so that is matches the GNU format attribute we
  * use with the mingw compiler, allowing it to verify them at compile-time.
 #endif
 #define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - CURL_OFF_T_C(1))
 
+#if (SIZEOF_CURL_OFF_T != 8)
+#  error "curl_off_t must be exactly 64 bits"
+#else
+  typedef unsigned CURL_TYPEOF_CURL_OFF_T curl_uint64_t;
+#  ifndef CURL_SUFFIX_CURL_OFF_TU
+#    error "CURL_SUFFIX_CURL_OFF_TU must be defined"
+#  endif
+#  define CURL_UINT64_SUFFIX  CURL_SUFFIX_CURL_OFF_TU
+#  define CURL_UINT64_C(val)  CURL_CONC_MACROS(val,CURL_UINT64_SUFFIX)
+#  define CURL_UINT64_CAST(expr) ((curl_uint64_t)(expr))
+#endif
+
 #if (SIZEOF_TIME_T == 4)
 #  ifdef HAVE_TIME_T_UNSIGNED
 #  define TIME_T_MAX UINT_MAX