From: Daniel Stenberg Date: Fri, 9 Jan 2026 16:49:26 +0000 (+0100) Subject: lib: use (u)int64_t instead of long long X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0159100f4f782432fa3d27998dbea7b827ffba2d;p=thirdparty%2Fcurl.git lib: use (u)int64_t instead of long long Remove config-plan9.h because it does not support 64 bit, meaning it has not been working for years. Closes #20233 --- diff --git a/.github/scripts/cmp-config.pl b/.github/scripts/cmp-config.pl index e831a97211..eef6b24927 100755 --- a/.github/scripts/cmp-config.pl +++ b/.github/scripts/cmp-config.pl @@ -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, ); diff --git a/CMake/unix-cache.cmake b/CMake/unix-cache.cmake index f3db9f0e97..5a58d14d2d 100644 --- a/CMake/unix-cache.cmake +++ b/CMake/unix-cache.cmake @@ -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() diff --git a/CMakeLists.txt b/CMakeLists.txt index e42a3f7da0..92c6b92026 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/configure.ac b/configure.ac index 2700158326..4d3d8073da 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/Makefile.am b/lib/Makefile.am index f2fc303ab8..c81d8ce0fe 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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 diff --git a/lib/config-mac.h b/lib/config-mac.h index 6da544fe8f..6c8acad722 100644 --- a/lib/config-mac.h +++ b/lib/config-mac.h @@ -35,9 +35,6 @@ #endif #include -#if TYPE_LONGLONG -#define HAVE_LONGLONG 1 -#endif /* Define if you want the built-in manual */ #define USE_MANUAL 1 @@ -69,11 +66,7 @@ #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 diff --git a/lib/config-os400.h b/lib/config-os400.h index ec6c002efd..610b9cd36f 100644 --- a/lib/config-os400.h +++ b/lib/config-os400.h @@ -187,12 +187,6 @@ /* 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 index 5303ab3399..0000000000 --- a/lib/config-plan9.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef HEADER_CURL_CONFIG_PLAN9_H -#define HEADER_CURL_CONFIG_PLAN9_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) Daniel Stenberg, , 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 */ diff --git a/lib/config-riscos.h b/lib/config-riscos.h index 3158c984ee..ca8cd532b4 100644 --- a/lib/config-riscos.h +++ b/lib/config-riscos.h @@ -162,9 +162,6 @@ /* 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 diff --git a/lib/config-win32.h b/lib/config-win32.h index 002782c6ea..82e62d16df 100644 --- a/lib/config-win32.h +++ b/lib/config-win32.h @@ -282,11 +282,6 @@ /* 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 diff --git a/lib/curl_config-cmake.h.in b/lib/curl_config-cmake.h.in index d8d9d7ecbe..3889e7183f 100644 --- a/lib/curl_config-cmake.h.in +++ b/lib/curl_config-cmake.h.in @@ -394,9 +394,6 @@ /* 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} diff --git a/lib/mprintf.c b/lib/mprintf.c index 85aedf4992..34c3155d4e 100644 --- a/lib/mprintf.c +++ b/lib/mprintf.c @@ -27,29 +27,6 @@ #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)) diff --git a/lib/sha256.c b/lib/sha256.c index 7c3cad33bf..dbce88f46f 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -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]; }; diff --git a/m4/curl-wolfssl.m4 b/m4/curl-wolfssl.m4 index 4cbc6f5c0c..d20d00ffbd 100644 --- a/m4/curl-wolfssl.m4 +++ b/m4/curl-wolfssl.m4 @@ -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 #include ]],[[ @@ -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? diff --git a/packages/vms/config_h.com b/packages/vms/config_h.com index c6f3f69721..ba66434ba0 100644 --- a/packages/vms/config_h.com +++ b/packages/vms/config_h.com @@ -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 diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 02c041c4b1..81f174a647 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -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