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
This commit is contained in:
Daniel Stenberg
2026-01-09 17:49:26 +01:00
parent 8806035344
commit 0159100f4f
16 changed files with 30 additions and 277 deletions

View File

@@ -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,
);

View 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()

View 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()

View 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

View 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

View 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
@@ -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

View File

@@ -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

View File

@@ -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 */

View File

@@ -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

View File

@@ -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

View File

@@ -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}

View File

@@ -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))

View 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];
};

View 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?

View 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

View 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