]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: use (u)int64_t instead of long long
authorDaniel Stenberg <daniel@haxx.se>
Fri, 9 Jan 2026 16:49:26 +0000 (17:49 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 10 Jan 2026 11:40:54 +0000 (12:40 +0100)
Remove config-plan9.h because it does not support 64 bit, meaning it has
not been working for years.

Closes #20233

16 files changed:
.github/scripts/cmp-config.pl
CMake/unix-cache.cmake
CMakeLists.txt
configure.ac
lib/Makefile.am
lib/config-mac.h
lib/config-os400.h
lib/config-plan9.h [deleted file]
lib/config-riscos.h
lib/config-win32.h
lib/curl_config-cmake.h.in
lib/mprintf.c
lib/sha256.c
m4/curl-wolfssl.m4
packages/vms/config_h.com
tests/libtest/testutil.c

index e831a97211a548f582050beec313a003419f6fbd..eef6b24927db3b955f1dabd219d0c9c4c6fc1ee1 100755 (executable)
@@ -90,7 +90,6 @@ my %remove = (
     '#define PACKAGE_TARNAME "curl"' => 1,
     '#define PACKAGE_URL ""' => 1,
     '#define PACKAGE_VERSION "-"' => 1,
-    '#define SIZEOF_LONG_LONG 8' => 1,
     '#define VERSION "-"' => 1,
     '#define _FILE_OFFSET_BITS 64' => 1,
     );
index f3db9f0e974ce04f80249329424f6c10c77834a0..5a58d14d2dfa22577bb19fd7d9d79dcb6d48b94c 100644 (file)
@@ -170,7 +170,6 @@ else()
 endif()
 set(HAVE_LOCALE_H 1)
 set(HAVE_LOCALTIME_R 1)
-set(HAVE_LONGLONG 1)
 if(APPLE)
   set(HAVE_MACH_ABSOLUTE_TIME 1)
 endif()
index e42a3f7da0f8f261cc061576b278271c5b739cbf..92c6b920266ea9666c16006fc186b1b5f6577fa4 100644 (file)
@@ -1504,7 +1504,6 @@ endforeach()
 
 check_type_size("size_t"      SIZEOF_SIZE_T)
 check_type_size("ssize_t"     SIZEOF_SSIZE_T)
-check_type_size("long long"   SIZEOF_LONG_LONG)
 check_type_size("long"        SIZEOF_LONG)
 check_type_size("int"         SIZEOF_INT)
 check_type_size("__int64"     SIZEOF___INT64)
@@ -1520,9 +1519,6 @@ if(NOT HAVE_SIZEOF_SSIZE_T)
 endif()
 # off_t is sized later, after the HAVE_FILE_OFFSET_BITS test
 
-if(SIZEOF_LONG_LONG)
-  set(HAVE_LONGLONG 1)
-endif()
 if(SIZEOF_SUSECONDS_T)
   set(HAVE_SUSECONDS_T 1)
 endif()
index 2700158326349d376eceeb148802d31365daf21b..4d3d8073dad25acd21b51531085d80d21d02f763 100644 (file)
@@ -4104,11 +4104,6 @@ CURL_SIZEOF(curl_socket_t, [
 ])
 CPPFLAGS=$o
 
-AC_CHECK_TYPE(long long,
-  [AC_DEFINE(HAVE_LONGLONG, 1,
-    [Define to 1 if the compiler supports the 'long long' data type.])]
-)
-
 if test "$ac_cv_sizeof_curl_off_t" -lt 8; then
   AC_MSG_ERROR([64-bit curl_off_t is required])
 fi
index f2fc303ab8b29d09d7fb0d54e660b8616f2bad44..c81d8ce0fea79ddec8c9f19598c53915ff2b04b9 100644 (file)
@@ -28,9 +28,9 @@ include Makefile.inc
 
 CMAKE_DIST = CMakeLists.txt curl_config-cmake.h.in
 
-EXTRA_DIST = config-mac.h config-os400.h config-plan9.h config-riscos.h \
-  config-win32.h curl_config.h.in $(LIB_RCFILES) libcurl.def            \
-  $(CMAKE_DIST) Makefile.soname optiontable.pl
+EXTRA_DIST = config-mac.h config-os400.h config-riscos.h config-win32.h         \
+  curl_config.h.in $(LIB_RCFILES) libcurl.def $(CMAKE_DIST) Makefile.soname     \
+  optiontable.pl
 
 lib_LTLIBRARIES = libcurl.la
 
index 6da544fe8fa1f1d0d5648c47f6074c5e3b61faec..6c8acad72290ef76173b0d050d77df891effeb3c 100644 (file)
@@ -35,9 +35,6 @@
 #endif
 
 #include <ConditionalMacros.h>
-#if TYPE_LONGLONG
-#define HAVE_LONGLONG           1
-#endif
 
 /* Define if you want the built-in manual */
 #define USE_MANUAL              1
 #define SIZEOF_INT              4
 #define SIZEOF_LONG             4
 #define SIZEOF_SIZE_T           4
-#ifdef HAVE_LONGLONG
 #define SIZEOF_CURL_OFF_T       8
-#else
-#define SIZEOF_CURL_OFF_T       4
-#endif
 
 #define HAVE_RECV 1
 #define RECV_TYPE_ARG1 int
index ec6c002efd785a7940515a65cbbe6c4c10fbee64..610b9cd36f754dda32bb31d31ba23edd8fac55f4 100644 (file)
 /* The size of `int', as computed by sizeof. */
 #define SIZEOF_INT              4
 
-/* Define if the compiler supports the 'long long' data type. */
-#define HAVE_LONGLONG
-
-/* The size of a `long long', as computed by sizeof. */
-#define SIZEOF_LONG_LONG        8
-
 /* The size of `long', as computed by sizeof. */
 #define SIZEOF_LONG             4
 
diff --git a/lib/config-plan9.h b/lib/config-plan9.h
deleted file mode 100644 (file)
index 5303ab3..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-#ifndef HEADER_CURL_CONFIG_PLAN9_H
-#define HEADER_CURL_CONFIG_PLAN9_H
-/***************************************************************************
- *                                  _   _ ____  _
- *  Project                     ___| | | |  _ \| |
- *                             / __| | | | |_) | |
- *                            | (__| |_| |  _ <| |___
- *                             \___|\___/|_| \_\_____|
- *
- * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- * SPDX-License-Identifier: curl
- *
- ***************************************************************************/
-
-#define BUILDING_LIBCURL 1
-#define CURL_CA_BUNDLE "/sys/lib/tls/ca.pem"
-#define CURL_CA_PATH "/sys/lib/tls"
-#define CURL_STATICLIB 1
-#define USE_IPV6 1
-#define CURL_DISABLE_LDAP 1
-
-#define NEED_REENTRANT 1
-#ifndef CURL_OS
-#define CURL_OS "plan9"
-#endif
-
-#define STDC_HEADERS 1
-
-#ifdef _BITS64
-#error not implement
-#else
-#define SIZEOF_INT 4
-#define SIZEOF_LONG 4
-#define SIZEOF_OFF_T 8
-#define SIZEOF_CURL_OFF_T 4 /* curl_off_t = timediff_t = int */
-#define SIZEOF_SIZE_T 4
-#define SIZEOF_TIME_T 4
-#endif
-
-#define HAVE_RECV 1
-#define RECV_TYPE_ARG1 int
-#define RECV_TYPE_ARG2 void *
-#define RECV_TYPE_ARG3 int
-#define RECV_TYPE_ARG4 int
-#define RECV_TYPE_RETV int
-
-#define HAVE_SELECT 1
-
-#define HAVE_SEND 1
-#define SEND_TYPE_ARG1 int
-#define SEND_TYPE_ARG2 void *
-#define SEND_QUAL_ARG2
-#define SEND_TYPE_ARG3 int
-#define SEND_TYPE_ARG4 int
-#define SEND_TYPE_RETV int
-
-#define HAVE_ALARM 1
-#define HAVE_ARPA_INET_H 1
-#define HAVE_BASENAME 1
-#define HAVE_BOOL_T 1
-#define HAVE_FCNTL 1
-#define HAVE_FCNTL_H 1
-#define HAVE_FREEADDRINFO 1
-#define HAVE_FTRUNCATE 1
-#define HAVE_GETADDRINFO 1
-#define HAVE_GETEUID 1
-#define HAVE_GETHOSTNAME 1
-#define HAVE_GETPPID 1
-#define HAVE_GETPWUID 1
-#define HAVE_GETTIMEOFDAY 1
-#define HAVE_GMTIME_R 1
-#define HAVE_INET_NTOP 1
-#define HAVE_INET_PTON 1
-#define HAVE_LIBGEN_H 1
-#define HAVE_LIBZ 1
-#define HAVE_LOCALE_H 1
-#define HAVE_LOCALTIME_R 1
-#define HAVE_LONGLONG 1
-#define HAVE_NETDB_H 1
-#define HAVE_NETINET_IN_H 1
-#define HAVE_NETINET_TCP_H 1
-#define HAVE_PWD_H 1
-#define HAVE_SYS_SELECT_H 1
-
-#define USE_OPENSSL 1
-
-#define HAVE_PIPE 1
-#define HAVE_POLL 1
-#define HAVE_POLL_H 1
-#define HAVE_PTHREAD_H 1
-#define HAVE_SETLOCALE 1
-
-#define HAVE_SIGACTION 1
-#define HAVE_SIGNAL 1
-#define HAVE_SIGSETJMP 1
-#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
-#define HAVE_SOCKET 1
-#define HAVE_STDBOOL_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_STRCASECMP 1
-#define HAVE_STRDUP 1
-#define HAVE_STRUCT_TIMEVAL 1
-#define HAVE_SYS_IOCTL_H 1
-#define HAVE_SYS_PARAM_H 1
-#define HAVE_SYS_RESOURCE_H 1
-#define HAVE_SYS_TYPES_H 1
-#define HAVE_SYS_UN_H 1
-#define HAVE_TERMIOS_H 1
-#define HAVE_UNISTD_H 1
-#define HAVE_UTIME 1
-#define HAVE_UTIME_H 1
-
-#define HAVE_POSIX_STRERROR_R 1
-#define HAVE_STRERROR_R 1
-#define USE_MANUAL 1
-
-#define __attribute__(x)
-
-#ifndef __cplusplus
-#undef inline
-#endif
-
-#endif /* HEADER_CURL_CONFIG_PLAN9_H */
index 3158c984ee3615e31d7a302a3648da8d2865323e..ca8cd532b4ffb871edb37d75854a497d993a3fa0 100644 (file)
 /* The size of `int', as computed by sizeof. */
 #define SIZEOF_INT 4
 
-/* The size of `long long', as computed by sizeof. */
-#undef SIZEOF_LONG_LONG
-
 /* The size of `size_t', as computed by sizeof. */
 #define SIZEOF_SIZE_T 4
 
index 002782c6ea9e189edeecc0b3e320220a46567427..82e62d16df22539f80c4f8359e9eff7666786be6 100644 (file)
 /*                        COMPILER SPECIFIC                         */
 /* ---------------------------------------------------------------- */
 
-/* Define if the compiler supports the 'long long' data type. */
-#if defined(_MSC_VER) || defined(__MINGW32__)
-#define HAVE_LONGLONG 1
-#endif
-
 /* Default to 64-bit time_t unless _USE_32BIT_TIME_T is defined */
 #if defined(_MSC_VER) || defined(__MINGW32__)
 #  ifndef _USE_32BIT_TIME_T
index d8d9d7ecbe58d53952b908bd0f8640d742a83d94..3889e7183f4b579b90f68dda498dc95b3626b37c 100644 (file)
 /* Define to 1 if you have a working localtime_r function. */
 #cmakedefine HAVE_LOCALTIME_R 1
 
-/* Define to 1 if the compiler supports the 'long long' data type. */
-#cmakedefine HAVE_LONGLONG 1
-
 /* Define to 1 if you have the 'suseconds_t' data type. */
 #cmakedefine HAVE_SUSECONDS_T 1
 
@@ -640,9 +637,6 @@ ${SIZEOF_INT_CODE}
 /* The size of `long', as computed by sizeof. */
 ${SIZEOF_LONG_CODE}
 
-/* The size of `long long', as computed by sizeof. */
-${SIZEOF_LONG_LONG_CODE}
-
 /* The size of `off_t', as computed by sizeof. */
 ${SIZEOF_OFF_T_CODE}
 
index 85aedf4992f04c1af45fd99ac7feabd942e0050e..34c3155d4e8ac87e5720a052a2f1dc081c1a5970 100644 (file)
 #include "curl_printf.h"
 #include "curlx/strparse.h"
 
-#ifdef HAVE_LONGLONG
-#  define LONG_LONG_TYPE long long
-#  define HAVE_LONG_LONG_TYPE
-#elif defined(_MSC_VER)
-#  define LONG_LONG_TYPE __int64
-#  define HAVE_LONG_LONG_TYPE
-#else
-#  undef LONG_LONG_TYPE
-#  undef HAVE_LONG_LONG_TYPE
-#endif
-
-/*
- * Max integer data types that mprintf.c is capable
- */
-
-#ifdef HAVE_LONG_LONG_TYPE
-#  define mp_intmax_t LONG_LONG_TYPE
-#  define mp_uintmax_t unsigned LONG_LONG_TYPE
-#else
-#  define mp_intmax_t long
-#  define mp_uintmax_t unsigned long
-#endif
-
 #define BUFFSIZE 326 /* buffer for long-to-str and float-to-str calcs, should
                         fit negative DBL_MAX (317 letters) */
 #define MAX_PARAMETERS 128 /* number of input arguments */
@@ -128,8 +105,8 @@ struct va_input {
   union {
     const char *str;
     void *ptr;
-    mp_intmax_t nums; /* signed */
-    mp_uintmax_t numu; /* unsigned */
+    int64_t nums; /* signed */
+    uint64_t numu; /* unsigned */
     double dnum;
   } val;
 };
@@ -582,29 +559,29 @@ static int parsefmt(const char *format,
       break;
 
     case FORMAT_LONGLONGU:
-      iptr->val.numu = (mp_uintmax_t)va_arg(arglist, mp_uintmax_t);
+      iptr->val.numu = va_arg(arglist, uint64_t);
       break;
 
     case FORMAT_LONGLONG:
-      iptr->val.nums = (mp_intmax_t)va_arg(arglist, mp_intmax_t);
+      iptr->val.nums = va_arg(arglist, int64_t);
       break;
 
     case FORMAT_LONGU:
-      iptr->val.numu = (mp_uintmax_t)va_arg(arglist, unsigned long);
+      iptr->val.numu = va_arg(arglist, unsigned long);
       break;
 
     case FORMAT_LONG:
-      iptr->val.nums = (mp_intmax_t)va_arg(arglist, long);
+      iptr->val.nums = va_arg(arglist, long);
       break;
 
     case FORMAT_INTU:
-      iptr->val.numu = (mp_uintmax_t)va_arg(arglist, unsigned int);
+      iptr->val.numu = va_arg(arglist, unsigned int);
       break;
 
     case FORMAT_INT:
     case FORMAT_WIDTH:
     case FORMAT_PRECISION:
-      iptr->val.nums = (mp_intmax_t)va_arg(arglist, int);
+      iptr->val.nums = va_arg(arglist, int);
       break;
 
     case FORMAT_DOUBLE:
@@ -730,8 +707,8 @@ static bool out_double(void *userp,
 static bool out_number(void *userp,
                        int (*stream)(unsigned char, void *),
                        struct mproperty *p,
-                       mp_uintmax_t num,
-                       mp_intmax_t nums,
+                       uint64_t num,
+                       int64_t nums,
                        char *work, int *donep)
 {
   const unsigned char *digits = Curl_ldigits;
@@ -777,11 +754,11 @@ static bool out_number(void *userp,
     is_neg = (nums < 0);
     if(is_neg) {
       /* signed_num might fail to hold absolute negative minimum by 1 */
-      mp_intmax_t signed_num; /* Used to convert negative in positive.  */
-      signed_num = nums + (mp_intmax_t)1;
+      int64_t signed_num; /* Used to convert negative in positive.  */
+      signed_num = nums + (int64_t)1;
       signed_num = -signed_num;
-      num = (mp_uintmax_t)signed_num;
-      num += (mp_uintmax_t)1;
+      num = (uint64_t)signed_num;
+      num += (uint64_t)1;
     }
   }
 
@@ -1070,11 +1047,9 @@ static int formatf(void *userp, /* untouched by format(), just sent to the
 
     case FORMAT_INTPTR:
       /* Answer the count of characters written.  */
-#ifdef HAVE_LONG_LONG_TYPE
       if(p.flags & FLAGS_LONGLONG)
-        *(LONG_LONG_TYPE *)iptr->val.ptr = (LONG_LONG_TYPE)done;
+        *(int64_t *)iptr->val.ptr = (int64_t)done;
       else
-#endif
         if(p.flags & FLAGS_LONG)
           *(long *)iptr->val.ptr = (long)done;
       else if(!(p.flags & FLAGS_SHORT))
index 7c3cad33bfa4bfa4f776c9e9c5a7b4ac17a68a79..dbce88f46fefe6098f8f73068b86f627789840a7 100644 (file)
@@ -246,38 +246,20 @@ static void my_sha256_final(unsigned char *digest, void *in)
     (a)[3] = (unsigned char) (((unsigned long)(val)) & 0xff);        \
   } while(0)
 
-#ifdef HAVE_LONGLONG
 #define WPA_PUT_BE64(a, val)                                      \
   do {                                                            \
-    (a)[0] = (unsigned char)(((unsigned long long)(val)) >> 56);  \
-    (a)[1] = (unsigned char)(((unsigned long long)(val)) >> 48);  \
-    (a)[2] = (unsigned char)(((unsigned long long)(val)) >> 40);  \
-    (a)[3] = (unsigned char)(((unsigned long long)(val)) >> 32);  \
-    (a)[4] = (unsigned char)(((unsigned long long)(val)) >> 24);  \
-    (a)[5] = (unsigned char)(((unsigned long long)(val)) >> 16);  \
-    (a)[6] = (unsigned char)(((unsigned long long)(val)) >>  8);  \
-    (a)[7] = (unsigned char)(((unsigned long long)(val)) & 0xff); \
+    (a)[0] = (unsigned char)(((uint64_t)(val)) >> 56);  \
+    (a)[1] = (unsigned char)(((uint64_t)(val)) >> 48);  \
+    (a)[2] = (unsigned char)(((uint64_t)(val)) >> 40);  \
+    (a)[3] = (unsigned char)(((uint64_t)(val)) >> 32);  \
+    (a)[4] = (unsigned char)(((uint64_t)(val)) >> 24);  \
+    (a)[5] = (unsigned char)(((uint64_t)(val)) >> 16);  \
+    (a)[6] = (unsigned char)(((uint64_t)(val)) >>  8);  \
+    (a)[7] = (unsigned char)(((uint64_t)(val)) & 0xff); \
   } while(0)
-#else
-#define WPA_PUT_BE64(a, val)                                    \
-  do {                                                          \
-    (a)[0] = (unsigned char)(((unsigned __int64)(val)) >> 56);  \
-    (a)[1] = (unsigned char)(((unsigned __int64)(val)) >> 48);  \
-    (a)[2] = (unsigned char)(((unsigned __int64)(val)) >> 40);  \
-    (a)[3] = (unsigned char)(((unsigned __int64)(val)) >> 32);  \
-    (a)[4] = (unsigned char)(((unsigned __int64)(val)) >> 24);  \
-    (a)[5] = (unsigned char)(((unsigned __int64)(val)) >> 16);  \
-    (a)[6] = (unsigned char)(((unsigned __int64)(val)) >>  8);  \
-    (a)[7] = (unsigned char)(((unsigned __int64)(val)) & 0xff); \
-  } while(0)
-#endif
 
 struct sha256_state {
-#ifdef HAVE_LONGLONG
-  unsigned long long length;
-#else
-  unsigned __int64 length;
-#endif
+  uint64_t length;
   unsigned long state[8], curlen;
   unsigned char buf[64];
 };
index 4cbc6f5c0c4ed38390613d9d080668f967889948..d20d00ffbd04afe0cc317796dd7d3e0e17e26c40 100644 (file)
@@ -99,10 +99,6 @@ if test "$OPT_WOLFSSL" != "no"; then
       AC_MSG_CHECKING([for wolfSSL_Init in -lwolfssl])
       AC_LINK_IFELSE([
         AC_LANG_PROGRAM([[
-          /* These are not needed for detection and confuse wolfSSL.
-             They are set up properly later if it is detected.  */
-          #undef SIZEOF_LONG
-          #undef SIZEOF_LONG_LONG
           #include <wolfssl/options.h>
           #include <wolfssl/ssl.h>
         ]],[[
@@ -130,9 +126,6 @@ if test "$OPT_WOLFSSL" != "no"; then
       AC_MSG_NOTICE([detected wolfSSL])
       check_for_ca_bundle=1
 
-      dnl wolfssl/ctaocrypt/types.h needs SIZEOF_LONG_LONG defined!
-      CURL_SIZEOF(long long)
-
       LIBS="$addlib $LIBS"
 
       dnl is this wolfSSL providing the original QUIC API?
index c6f3f697217e2bb90ad3565c4977c4b08ac656cb..ba66434ba0fb9abc445af2c7f82741813ffe3ca9 100644 (file)
@@ -1172,17 +1172,6 @@ $                   write tf "#endif"
 $                   goto cfgh_in_loop1
 $               endif
 $!
-$               if keysym .eqs. "LONGLONG"
-$               then
-$                   write tf "#ifndef __VAX"
-$                   write tf "#pragma message disable longlongtype"
-$                   write tf "#ifndef HAVE_LONGLONG"
-$                   write tf "#define HAVE_LONGLONG 1"
-$                   write tf "#endif"
-$                   write tf "#endif"
-$                   goto cfgh_in_loop1
-$               endif
-$!
 $!              May need to test compiler version
 $!-----------------------------------------------
 $               if keysym .eqs. "LONG_LONG"
@@ -1471,12 +1460,6 @@ $               then
 $                   write tf "#ifndef SIZEOF_LONG"
 $                   write tf "#define SIZEOF_LONG 4"
 $                   write tf "#endif"
-$               else
-$                   write tf "#ifndef SIZEOF_LONG_LONG"
-$                   write tf "#ifndef __VAX"
-$                   write tf "#define SIZEOF_LONG_LONG 8"
-$                   write tf "#endif"
-$                   write tf "#endif"
 $               endif
 $               goto cfgh_in_loop1
 $           endif
index 02c041c4b132c0563ce2af02aae9499fa04a863e..81f174a647c2bdb8c8645e5d9166dac81beafd79 100644 (file)
@@ -38,16 +38,9 @@ void tutil_rlim2str(char *buf, size_t len, rlim_t val)
     return;
   }
 #endif
-#ifdef HAVE_LONGLONG
-  if(sizeof(rlim_t) > sizeof(long))
-    curl_msnprintf(buf, len, "%llu", (unsigned long long)val);
+  if(sizeof(rlim_t) == SIZEOF_INT)
+    curl_msnprintf(buf, len, "%u", (unsigned int)val);
   else
-#endif
-  {
-    if(sizeof(rlim_t) < sizeof(long))
-      curl_msnprintf(buf, len, "%u", (unsigned int)val);
-    else
-      curl_msnprintf(buf, len, "%lu", (unsigned long)val);
-  }
+    curl_msnprintf(buf, len, "%lu", (unsigned long)val);
 }
 #endif