feat/support_fiber #2

Merged
tqcq merged 57 commits from feat/support_fiber into master 2024-06-21 10:33:52 +08:00
2 changed files with 132 additions and 156 deletions
Showing only changes of commit 0e16e4ec08 - Show all commits

View File

@ -72,19 +72,6 @@ check_c_source_compiles("${_source_epilogue}
(void)ts; (void)ts;
return 0; return 0;
}" HAVE_STRUCT_TIMEVAL) }" HAVE_STRUCT_TIMEVAL)
if (HAVE_SYS_TIME_H)
check_c_source_compiles("${_source_epilogue}
#include <sys/time.h>
int main(void)
{
struct timeval ts;
ts.tv_sec = 0;
ts.tv_usec = 0;
(void)ts;
return 0;
}" HAVE_STRUCT_TIMEVAL_BY_SYS_TIMEVAL)
set(HAVE_STRUCT_TIMEVAL ${HAVE_STRUCT_TIMEVAL_BY_SYS_TIMEVAL})
endif()
unset(CMAKE_TRY_COMPILE_TARGET_TYPE) unset(CMAKE_TRY_COMPILE_TARGET_TYPE)

View File

@ -24,17 +24,16 @@
* *
***************************************************************************/ ***************************************************************************/
/* /*
* Inclusion of common header files. * Inclusion of common header files.
*/ */
#include <errno.h>
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h>
#include <time.h> #include <time.h>
#include <errno.h>
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
@ -57,8 +56,8 @@
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
#include <io.h>
#include <fcntl.h> #include <fcntl.h>
#include <io.h>
#endif #endif
#if defined(HAVE_STDBOOL_H) && defined(HAVE_BOOL_T) #if defined(HAVE_STDBOOL_H) && defined(HAVE_BOOL_T)
@ -76,18 +75,18 @@
#ifdef USE_SCHANNEL #ifdef USE_SCHANNEL
/* Must set this before <schannel.h> is included directly or indirectly by /* Must set this before <schannel.h> is included directly or indirectly by
another Windows header. */ another Windows header. */
# define SCHANNEL_USE_BLACKLISTS 1 #define SCHANNEL_USE_BLACKLISTS 1
#endif #endif
#ifdef __hpux #ifdef __hpux
# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL) #if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
# ifdef _APP32_64BIT_OFF_T #ifdef _APP32_64BIT_OFF_T
# define OLD_APP32_64BIT_OFF_T _APP32_64BIT_OFF_T #define OLD_APP32_64BIT_OFF_T _APP32_64BIT_OFF_T
# undef _APP32_64BIT_OFF_T #undef _APP32_64BIT_OFF_T
# else #else
# undef OLD_APP32_64BIT_OFF_T #undef OLD_APP32_64BIT_OFF_T
# endif #endif
# endif #endif
#endif #endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
@ -97,25 +96,28 @@
#include "functypes.h" #include "functypes.h"
#ifdef __hpux #ifdef __hpux
# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL) #if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
# ifdef OLD_APP32_64BIT_OFF_T #ifdef OLD_APP32_64BIT_OFF_T
# define _APP32_64BIT_OFF_T OLD_APP32_64BIT_OFF_T #define _APP32_64BIT_OFF_T OLD_APP32_64BIT_OFF_T
# undef OLD_APP32_64BIT_OFF_T #undef OLD_APP32_64BIT_OFF_T
# endif #endif
# endif #endif
#endif #endif
/* /*
* Definition of timeval struct for platforms that don't have it. * Definition of timeval struct for platforms that don't have it.
*/ */
#ifdef __GLIBC__
#if !defined(_POSIX_C_SOURCE) && !defined(_POSIX_SOURCE)
#ifndef HAVE_STRUCT_TIMEVAL #ifndef HAVE_STRUCT_TIMEVAL
struct timeval { struct timeval {
long tv_sec; long tv_sec;
long tv_usec; long tv_usec;
}; };
#endif #endif
#endif // _POSIX_C_SOURCE
#endif // __GLIBC__
/* /*
* If we have the MSG_NOSIGNAL define, make sure we use * If we have the MSG_NOSIGNAL define, make sure we use
@ -128,12 +130,10 @@ struct timeval {
#define SEND_4TH_ARG 0 #define SEND_4TH_ARG 0
#endif #endif
#if defined(__minix) #if defined(__minix)
/* Minix doesn't support recv on TCP sockets */ /* Minix doesn't support recv on TCP sockets */
#define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \ #define sread(x, y, z) \
(RECV_TYPE_ARG2)(y), \ (ssize_t) read((RECV_TYPE_ARG1)(x), (RECV_TYPE_ARG2)(y), (RECV_TYPE_ARG3)(z))
(RECV_TYPE_ARG3)(z))
#elif defined(HAVE_RECV) #elif defined(HAVE_RECV)
/* /*
@ -158,58 +158,53 @@ struct timeval {
* SEND_TYPE_RETV must also be defined. * SEND_TYPE_RETV must also be defined.
*/ */
#define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \ #define sread(x, y, z) \
(RECV_TYPE_ARG2)(y), \ (ssize_t) recv((RECV_TYPE_ARG1)(x), (RECV_TYPE_ARG2)(y), \
(RECV_TYPE_ARG3)(z), \ (RECV_TYPE_ARG3)(z), (RECV_TYPE_ARG4)(0))
(RECV_TYPE_ARG4)(0))
#else /* HAVE_RECV */ #else /* HAVE_RECV */
#ifndef sread #ifndef sread
#error "Missing definition of macro sread!" #error "Missing definition of macro sread!"
#endif #endif
#endif /* HAVE_RECV */ #endif /* HAVE_RECV */
#if defined(__minix) #if defined(__minix)
/* Minix doesn't support send on TCP sockets */ /* Minix doesn't support send on TCP sockets */
#define swrite(x,y,z) (ssize_t)write((SEND_TYPE_ARG1)(x), \ #define swrite(x, y, z) \
(SEND_TYPE_ARG2)(y), \ (ssize_t) write((SEND_TYPE_ARG1)(x), (SEND_TYPE_ARG2)(y), (SEND_TYPE_ARG3)(z))
(SEND_TYPE_ARG3)(z))
#elif defined(HAVE_SEND) #elif defined(HAVE_SEND)
#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \ #define swrite(x, y, z) \
(SEND_QUAL_ARG2 SEND_TYPE_ARG2)(y), \ (ssize_t) send((SEND_TYPE_ARG1)(x), (SEND_QUAL_ARG2 SEND_TYPE_ARG2)(y), \
(SEND_TYPE_ARG3)(z), \ (SEND_TYPE_ARG3)(z), (SEND_TYPE_ARG4)(SEND_4TH_ARG))
(SEND_TYPE_ARG4)(SEND_4TH_ARG))
#else /* HAVE_SEND */ #else /* HAVE_SEND */
#ifndef swrite #ifndef swrite
#error "Missing definition of macro swrite!" #error "Missing definition of macro swrite!"
#endif #endif
#endif /* HAVE_SEND */ #endif /* HAVE_SEND */
/* /*
* Function-like macro definition used to close a socket. * Function-like macro definition used to close a socket.
*/ */
#if defined(HAVE_CLOSESOCKET) #if defined(HAVE_CLOSESOCKET)
# define sclose(x) closesocket((x)) #define sclose(x) closesocket((x))
#elif defined(HAVE_CLOSESOCKET_CAMEL) #elif defined(HAVE_CLOSESOCKET_CAMEL)
# define sclose(x) CloseSocket((x)) #define sclose(x) CloseSocket((x))
#elif defined(HAVE_CLOSE_S) #elif defined(HAVE_CLOSE_S)
# define sclose(x) close_s((x)) #define sclose(x) close_s((x))
#elif defined(USE_LWIPSOCK) #elif defined(USE_LWIPSOCK)
# define sclose(x) lwip_close((x)) #define sclose(x) lwip_close((x))
#else #else
# define sclose(x) close((x)) #define sclose(x) close((x))
#endif #endif
/* /*
* Stack-independent version of fcntl() on sockets: * Stack-independent version of fcntl() on sockets:
*/ */
#if defined(USE_LWIPSOCK) #if defined(USE_LWIPSOCK)
# define sfcntl lwip_fcntl #define sfcntl lwip_fcntl
#else #else
# define sfcntl fcntl #define sfcntl fcntl
#endif #endif
/* /*
@ -217,13 +212,12 @@ struct timeval {
*/ */
#if defined(__hpux) && !defined(HAVE_BOOL_T) #if defined(__hpux) && !defined(HAVE_BOOL_T)
typedef int bool; typedef int bool;
# define false 0 #define false 0
# define true 1 #define true 1
# define HAVE_BOOL_T #define HAVE_BOOL_T
#endif #endif
/* /*
* 'bool' exists on platforms with <stdbool.h>, i.e. C99 platforms. * 'bool' exists on platforms with <stdbool.h>, i.e. C99 platforms.
* On non-C99 platforms there's no bool, so define an enum for that. * On non-C99 platforms there's no bool, so define an enum for that.
@ -232,10 +226,7 @@ struct timeval {
*/ */
#ifndef HAVE_BOOL_T #ifndef HAVE_BOOL_T
typedef enum { typedef enum { bool_false = 0, bool_true = 1 } bool;
bool_false = 0,
bool_true = 1
} bool;
/* /*
* Use a define to let 'true' and 'false' use those enums. There * Use a define to let 'true' and 'false' use those enums. There
@ -243,9 +234,9 @@ struct timeval {
* there are some in the examples. This will cater for any later * there are some in the examples. This will cater for any later
* code happening to use true and false. * code happening to use true and false.
*/ */
# define false bool_false #define false bool_false
# define true bool_true #define true bool_true
# define HAVE_BOOL_T #define HAVE_BOOL_T
#endif #endif
/* the type we use for storing a single boolean bit */ /* the type we use for storing a single boolean bit */
@ -254,7 +245,7 @@ typedef bool bit;
#define BIT(x) bool x #define BIT(x) bool x
#else #else
typedef unsigned int bit; typedef unsigned int bit;
#define BIT(x) bit x:1 #define BIT(x) bit x : 1
#endif #endif
/* /*
@ -273,7 +264,6 @@ typedef unsigned int bit;
#include "curl_ctype.h" #include "curl_ctype.h"
/* /*
* Macro used to include code only in debug builds. * Macro used to include code only in debug builds.
*/ */
@ -281,10 +271,11 @@ typedef unsigned int bit;
#ifdef DEBUGBUILD #ifdef DEBUGBUILD
#define DEBUGF(x) x #define DEBUGF(x) x
#else #else
#define DEBUGF(x) do { } while(0) #define DEBUGF(x) \
do { \
} while (0)
#endif #endif
/* /*
* Macro used to include assertion code only in debug builds. * Macro used to include assertion code only in debug builds.
*/ */
@ -293,101 +284,101 @@ typedef unsigned int bit;
#if defined(DEBUGBUILD) #if defined(DEBUGBUILD)
#define DEBUGASSERT(x) assert(x) #define DEBUGASSERT(x) assert(x)
#else #else
#define DEBUGASSERT(x) do { } while(0) #define DEBUGASSERT(x) \
do { \
} while (0)
#endif #endif
/* /*
* Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno
* (or equivalent) on this platform to hide platform details to code using it. * (or equivalent) on this platform to hide platform details to code using it.
*/ */
#ifdef USE_WINSOCK #ifdef USE_WINSOCK
#define SOCKERRNO ((int)WSAGetLastError()) #define SOCKERRNO ((int)WSAGetLastError())
#define SET_SOCKERRNO(x) (WSASetLastError((int)(x))) #define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
#else #else
#define SOCKERRNO (errno) #define SOCKERRNO (errno)
#define SET_SOCKERRNO(x) (errno = (x)) #define SET_SOCKERRNO(x) (errno = (x))
#endif #endif
/* /*
* Portable error number symbolic names defined to Winsock error codes. * Portable error number symbolic names defined to Winsock error codes.
*/ */
#ifdef USE_WINSOCK #ifdef USE_WINSOCK
#undef EBADF /* override definition in errno.h */ #undef EBADF /* override definition in errno.h */
#define EBADF WSAEBADF #define EBADF WSAEBADF
#undef EINTR /* override definition in errno.h */ #undef EINTR /* override definition in errno.h */
#define EINTR WSAEINTR #define EINTR WSAEINTR
#undef EINVAL /* override definition in errno.h */ #undef EINVAL /* override definition in errno.h */
#define EINVAL WSAEINVAL #define EINVAL WSAEINVAL
#undef EWOULDBLOCK /* override definition in errno.h */ #undef EWOULDBLOCK /* override definition in errno.h */
#define EWOULDBLOCK WSAEWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK
#undef EINPROGRESS /* override definition in errno.h */ #undef EINPROGRESS /* override definition in errno.h */
#define EINPROGRESS WSAEINPROGRESS #define EINPROGRESS WSAEINPROGRESS
#undef EALREADY /* override definition in errno.h */ #undef EALREADY /* override definition in errno.h */
#define EALREADY WSAEALREADY #define EALREADY WSAEALREADY
#undef ENOTSOCK /* override definition in errno.h */ #undef ENOTSOCK /* override definition in errno.h */
#define ENOTSOCK WSAENOTSOCK #define ENOTSOCK WSAENOTSOCK
#undef EDESTADDRREQ /* override definition in errno.h */ #undef EDESTADDRREQ /* override definition in errno.h */
#define EDESTADDRREQ WSAEDESTADDRREQ #define EDESTADDRREQ WSAEDESTADDRREQ
#undef EMSGSIZE /* override definition in errno.h */ #undef EMSGSIZE /* override definition in errno.h */
#define EMSGSIZE WSAEMSGSIZE #define EMSGSIZE WSAEMSGSIZE
#undef EPROTOTYPE /* override definition in errno.h */ #undef EPROTOTYPE /* override definition in errno.h */
#define EPROTOTYPE WSAEPROTOTYPE #define EPROTOTYPE WSAEPROTOTYPE
#undef ENOPROTOOPT /* override definition in errno.h */ #undef ENOPROTOOPT /* override definition in errno.h */
#define ENOPROTOOPT WSAENOPROTOOPT #define ENOPROTOOPT WSAENOPROTOOPT
#undef EPROTONOSUPPORT /* override definition in errno.h */ #undef EPROTONOSUPPORT /* override definition in errno.h */
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
#undef EOPNOTSUPP /* override definition in errno.h */ #undef EOPNOTSUPP /* override definition in errno.h */
#define EOPNOTSUPP WSAEOPNOTSUPP #define EOPNOTSUPP WSAEOPNOTSUPP
#define EPFNOSUPPORT WSAEPFNOSUPPORT #define EPFNOSUPPORT WSAEPFNOSUPPORT
#undef EAFNOSUPPORT /* override definition in errno.h */ #undef EAFNOSUPPORT /* override definition in errno.h */
#define EAFNOSUPPORT WSAEAFNOSUPPORT #define EAFNOSUPPORT WSAEAFNOSUPPORT
#undef EADDRINUSE /* override definition in errno.h */ #undef EADDRINUSE /* override definition in errno.h */
#define EADDRINUSE WSAEADDRINUSE #define EADDRINUSE WSAEADDRINUSE
#undef EADDRNOTAVAIL /* override definition in errno.h */ #undef EADDRNOTAVAIL /* override definition in errno.h */
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
#undef ENETDOWN /* override definition in errno.h */ #undef ENETDOWN /* override definition in errno.h */
#define ENETDOWN WSAENETDOWN #define ENETDOWN WSAENETDOWN
#undef ENETUNREACH /* override definition in errno.h */ #undef ENETUNREACH /* override definition in errno.h */
#define ENETUNREACH WSAENETUNREACH #define ENETUNREACH WSAENETUNREACH
#undef ENETRESET /* override definition in errno.h */ #undef ENETRESET /* override definition in errno.h */
#define ENETRESET WSAENETRESET #define ENETRESET WSAENETRESET
#undef ECONNABORTED /* override definition in errno.h */ #undef ECONNABORTED /* override definition in errno.h */
#define ECONNABORTED WSAECONNABORTED #define ECONNABORTED WSAECONNABORTED
#undef ECONNRESET /* override definition in errno.h */ #undef ECONNRESET /* override definition in errno.h */
#define ECONNRESET WSAECONNRESET #define ECONNRESET WSAECONNRESET
#undef ENOBUFS /* override definition in errno.h */ #undef ENOBUFS /* override definition in errno.h */
#define ENOBUFS WSAENOBUFS #define ENOBUFS WSAENOBUFS
#undef EISCONN /* override definition in errno.h */ #undef EISCONN /* override definition in errno.h */
#define EISCONN WSAEISCONN #define EISCONN WSAEISCONN
#undef ENOTCONN /* override definition in errno.h */ #undef ENOTCONN /* override definition in errno.h */
#define ENOTCONN WSAENOTCONN #define ENOTCONN WSAENOTCONN
#define ESHUTDOWN WSAESHUTDOWN #define ESHUTDOWN WSAESHUTDOWN
#define ETOOMANYREFS WSAETOOMANYREFS #define ETOOMANYREFS WSAETOOMANYREFS
#undef ETIMEDOUT /* override definition in errno.h */ #undef ETIMEDOUT /* override definition in errno.h */
#define ETIMEDOUT WSAETIMEDOUT #define ETIMEDOUT WSAETIMEDOUT
#undef ECONNREFUSED /* override definition in errno.h */ #undef ECONNREFUSED /* override definition in errno.h */
#define ECONNREFUSED WSAECONNREFUSED #define ECONNREFUSED WSAECONNREFUSED
#undef ELOOP /* override definition in errno.h */ #undef ELOOP /* override definition in errno.h */
#define ELOOP WSAELOOP #define ELOOP WSAELOOP
#ifndef ENAMETOOLONG /* possible previous definition in errno.h */ #ifndef ENAMETOOLONG /* possible previous definition in errno.h */
#define ENAMETOOLONG WSAENAMETOOLONG #define ENAMETOOLONG WSAENAMETOOLONG
#endif #endif
#define EHOSTDOWN WSAEHOSTDOWN #define EHOSTDOWN WSAEHOSTDOWN
#undef EHOSTUNREACH /* override definition in errno.h */ #undef EHOSTUNREACH /* override definition in errno.h */
#define EHOSTUNREACH WSAEHOSTUNREACH #define EHOSTUNREACH WSAEHOSTUNREACH
#ifndef ENOTEMPTY /* possible previous definition in errno.h */ #ifndef ENOTEMPTY /* possible previous definition in errno.h */
#define ENOTEMPTY WSAENOTEMPTY #define ENOTEMPTY WSAENOTEMPTY
#endif #endif
#define EPROCLIM WSAEPROCLIM #define EPROCLIM WSAEPROCLIM
#define EUSERS WSAEUSERS #define EUSERS WSAEUSERS
#define EDQUOT WSAEDQUOT #define EDQUOT WSAEDQUOT
#define ESTALE WSAESTALE #define ESTALE WSAESTALE
#define EREMOTE WSAEREMOTE #define EREMOTE WSAEREMOTE
#endif #endif
/* /*
@ -395,14 +386,13 @@ typedef unsigned int bit;
*/ */
#ifdef __VMS #ifdef __VMS
#define argv_item_t __char_ptr32 #define argv_item_t __char_ptr32
#elif defined(_UNICODE) #elif defined(_UNICODE)
#define argv_item_t wchar_t * #define argv_item_t wchar_t *
#else #else
#define argv_item_t char * #define argv_item_t char *
#endif #endif
/* /*
* We use this ZERO_NULL to avoid picky compiler warnings, * We use this ZERO_NULL to avoid picky compiler warnings,
* when assigning a NULL pointer to a function pointer var. * when assigning a NULL pointer to a function pointer var.
@ -410,5 +400,4 @@ typedef unsigned int bit;
#define ZERO_NULL 0 #define ZERO_NULL 0
#endif /* HEADER_CURL_SETUP_ONCE_H */ #endif /* HEADER_CURL_SETUP_ONCE_H */