From 77b3bc239daf75d9fb7702ee34c8e5871c47d387 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 28 Jul 2006 14:19:02 +0000 Subject: First step trying to avoid the multiple header inclusion and recursion nightmare. Reintroduce checking for HAVE_MSG_NOSIGNAL in configure script, so that we don't depend on header inclusion order for a valid check. --- lib/setup_once.h | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 lib/setup_once.h (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h new file mode 100644 index 000000000..a570a6a4e --- /dev/null +++ b/lib/setup_once.h @@ -0,0 +1,106 @@ +#ifndef __SETUP_ONCE_H +#define __SETUP_ONCE_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2006, 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 http://curl.haxx.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. + * + * $Id$ + ***************************************************************************/ + + +/* + * If we have the MSG_NOSIGNAL define, make sure we use + * it as the fourth argument of send() and recv() + */ + +#ifdef HAVE_MSG_NOSIGNAL +#define SEND_4TH_ARG MSG_NOSIGNAL +#else +#define SEND_4TH_ARG 0 +#endif + + +/* + * The definitions for the return type and arguments types + * of functions recv() and send() belong and come from the + * configuration file. Do not define them in any other place. + * + * HAVE_RECV is defined if you have a function named recv() + * which is used to read incoming data from sockets. If your + * function has another name then don't define HAVE_RECV. + * + * If HAVE_RECV is defined then RECV_TYPE_ARG1, RECV_TYPE_ARG2, + * RECV_TYPE_ARG3, RECV_TYPE_ARG4 and RECV_TYPE_RETV must also + * be defined. + * + * HAVE_SEND is defined if you have a function named send() + * which is used to write outgoing data on a connected socket. + * If yours has another name then don't define HAVE_SEND. + * + * If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2, + * SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and + * SEND_TYPE_RETV must also be defined. + */ + +#ifdef HAVE_RECV +#if !defined(RECV_TYPE_ARG1) || \ + !defined(RECV_TYPE_ARG2) || \ + !defined(RECV_TYPE_ARG3) || \ + !defined(RECV_TYPE_ARG4) || \ + !defined(RECV_TYPE_RETV) + /* */ + Error Missing_definition_of_return_and_arguments_types_of_recv + /* */ +#else +#define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \ + (RECV_TYPE_ARG2)(y), \ + (RECV_TYPE_ARG3)(z), \ + (RECV_TYPE_ARG4)(SEND_4TH_ARG)) +#endif +#else /* HAVE_RECV */ +#ifdef DJGPP +#define sread(x,y,z) (ssize_t)read_s((int)(x), (char *)(y), (int)(z)) +#endif +#endif /* HAVE_RECV */ + +#ifdef HAVE_SEND +#if !defined(SEND_TYPE_ARG1) || \ + !defined(SEND_QUAL_ARG2) || \ + !defined(SEND_TYPE_ARG2) || \ + !defined(SEND_TYPE_ARG3) || \ + !defined(SEND_TYPE_ARG4) || \ + !defined(SEND_TYPE_RETV) + /* */ + Error Missing_definition_of_return_and_arguments_types_of_send + /* */ +#else +#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \ + (SEND_TYPE_ARG2)(y), \ + (SEND_TYPE_ARG3)(z), \ + (SEND_TYPE_ARG4)(SEND_4TH_ARG)) +#endif +#else /* HAVE_SEND */ +#ifdef DJGPP +#define swrite(x,y,z) (ssize_t)write_s((int)(x), (char *)(y), (int)(z)) +#endif +#endif /* HAVE_SEND */ + + +#endif /* __SETUP_ONCE_H */ + -- cgit v1.2.1 From f1343b2f55fe9c9c64de116252fadbc0a6105bd6 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 31 Jul 2006 17:12:24 +0000 Subject: Force compilation failure in case macros sread() or swrite() are not defined. --- lib/setup_once.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index a570a6a4e..2e3dcc1f4 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -77,6 +77,11 @@ #ifdef DJGPP #define sread(x,y,z) (ssize_t)read_s((int)(x), (char *)(y), (int)(z)) #endif +#ifndef sread + /* */ + Error Missing_definition_of_macro_sread + /* */ +#endif #endif /* HAVE_RECV */ #ifdef HAVE_SEND @@ -99,6 +104,11 @@ #ifdef DJGPP #define swrite(x,y,z) (ssize_t)write_s((int)(x), (char *)(y), (int)(z)) #endif +#ifndef swrite + /* */ + Error Missing_definition_of_macro_swrite + /* */ +#endif #endif /* HAVE_SEND */ -- cgit v1.2.1 From 9691a78f6baa9ac38a37ff60ea58b3f7d4021781 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Tue, 29 Aug 2006 16:26:41 +0000 Subject: Support other MS-DOS compilers (MSDOS is a djgpp built-in define). --- lib/setup_once.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 2e3dcc1f4..d3a4cc0a1 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -33,7 +33,7 @@ #define SEND_4TH_ARG MSG_NOSIGNAL #else #define SEND_4TH_ARG 0 -#endif +#endif /* @@ -74,7 +74,7 @@ (RECV_TYPE_ARG4)(SEND_4TH_ARG)) #endif #else /* HAVE_RECV */ -#ifdef DJGPP +#ifdef MSDOS #define sread(x,y,z) (ssize_t)read_s((int)(x), (char *)(y), (int)(z)) #endif #ifndef sread @@ -101,7 +101,7 @@ (SEND_TYPE_ARG4)(SEND_4TH_ARG)) #endif #else /* HAVE_SEND */ -#ifdef DJGPP +#ifdef MSDOS #define swrite(x,y,z) (ssize_t)write_s((int)(x), (char *)(y), (int)(z)) #endif #ifndef swrite -- cgit v1.2.1 From 71c6335293e4945262ab25b867d59be17ce12819 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 18 Oct 2006 03:41:19 +0000 Subject: Move definition of IS*() macros to setup_once.h --- lib/setup_once.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index d3a4cc0a1..9c00fd637 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -24,6 +24,16 @@ ***************************************************************************/ +/******************************************************************** + * NOTICE * + * ======== * + * * + * Content of header files lib/setup_once.h and ares/setup_once.h * + * must be kept in sync. Modify the other one if you change this. * + * * + ********************************************************************/ + + /* * If we have the MSG_NOSIGNAL define, make sure we use * it as the fourth argument of send() and recv() @@ -112,5 +122,18 @@ #endif /* HAVE_SEND */ +/* + * Uppercase macro versions of ANSI/ISO is*() functions/macros which + * avoid negative number inputs whith argument byte codes > 127. + */ + +#define ISSPACE(x) (isspace((int) ((unsigned char)x))) +#define ISDIGIT(x) (isdigit((int) ((unsigned char)x))) +#define ISALNUM(x) (isalnum((int) ((unsigned char)x))) +#define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x))) +#define ISGRAPH(x) (isgraph((int) ((unsigned char)x))) +#define ISALPHA(x) (isalpha((int) ((unsigned char)x))) + + #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From 1cddd744ade9bbd9779b7320a1cd24696b722e2f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 18 Oct 2006 12:59:02 +0000 Subject: Tor's spell fixes --- lib/setup_once.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 9c00fd637..52e12a5be 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -124,7 +124,7 @@ /* * Uppercase macro versions of ANSI/ISO is*() functions/macros which - * avoid negative number inputs whith argument byte codes > 127. + * avoid negative number inputs with argument byte codes > 127. */ #define ISSPACE(x) (isspace((int) ((unsigned char)x))) -- cgit v1.2.1 From 94095c61d8cb93be46e248eb7f8d7cd07da27396 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Wed, 18 Oct 2006 13:50:23 +0000 Subject: Added ISPRINT() required for src/main.c. --- lib/setup_once.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 52e12a5be..5573cbcb2 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -123,7 +123,7 @@ /* - * Uppercase macro versions of ANSI/ISO is*() functions/macros which + * Uppercase macro versions of ANSI/ISO is*() functions/macros which * avoid negative number inputs with argument byte codes > 127. */ @@ -133,6 +133,7 @@ #define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x))) #define ISGRAPH(x) (isgraph((int) ((unsigned char)x))) #define ISALPHA(x) (isalpha((int) ((unsigned char)x))) +#define ISPRINT(x) (isprint((int) ((unsigned char)x))) #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From 812ce0d93ff087da2b776600f37928e4a10c5509 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Fri, 27 Oct 2006 14:07:32 +0000 Subject: Get rid of the special sread()+swrite() for MSDOS. Use recv() and send(). Added needed HAVE_x defines. --- lib/setup_once.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 5573cbcb2..04640707c 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -84,9 +84,6 @@ (RECV_TYPE_ARG4)(SEND_4TH_ARG)) #endif #else /* HAVE_RECV */ -#ifdef MSDOS -#define sread(x,y,z) (ssize_t)read_s((int)(x), (char *)(y), (int)(z)) -#endif #ifndef sread /* */ Error Missing_definition_of_macro_sread @@ -111,9 +108,6 @@ (SEND_TYPE_ARG4)(SEND_4TH_ARG)) #endif #else /* HAVE_SEND */ -#ifdef MSDOS -#define swrite(x,y,z) (ssize_t)write_s((int)(x), (char *)(y), (int)(z)) -#endif #ifndef swrite /* */ Error Missing_definition_of_macro_swrite -- cgit v1.2.1 From 73226415fc51cdfbfa730eae80119411d65dd124 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 22 Nov 2006 18:41:34 +0000 Subject: Added a check in configure that verifies if is available, defining HAVE_SIGNAL_H if the header is available. Added a check in configure that tests if the sig_atomic_t type is available, defining HAVE_SIG_ATOMIC_T if it is available. Providing a suitable default in setup_once.h if not available. Added a check in configure that tests if the sig_atomic_t type is already defined as volatile, defining HAVE_SIG_ATOMIC_T_VOLATILE if it is available and already defined as volatile. --- lib/setup_once.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 04640707c..07909475c 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -130,5 +130,15 @@ #define ISPRINT(x) (isprint((int) ((unsigned char)x))) +/* + * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type. + */ + +#ifndef HAVE_SIG_ATOMIC_T +typedef int sig_atomic_t; +#define HAVE_SIG_ATOMIC_T +#endif + + #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From a46f55b9de423b4084982467d6f28f69a64ab8f3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 25 Nov 2006 01:02:52 +0000 Subject: Make sure RETSIGTYPE is properly defined --- lib/setup_once.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 07909475c..9f36995eb 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -140,5 +140,14 @@ typedef int sig_atomic_t; #endif +/* + * Default return type for signal handlers. + */ + +#ifndef RETSIGTYPE +#define RETSIGTYPE void +#endif + + #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From 8d11767048349f60361760e57e27e11644759b3b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 16 Dec 2006 22:28:08 +0000 Subject: recv() doesn't take MSG_NOSIGNAL in its forth argument so let's not pass it. Brendan Jurd pointed out. --- lib/setup_once.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 9f36995eb..a1e9f098f 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -81,7 +81,7 @@ #define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \ (RECV_TYPE_ARG2)(y), \ (RECV_TYPE_ARG3)(z), \ - (RECV_TYPE_ARG4)(SEND_4TH_ARG)) + (RECV_TYPE_ARG4)(0)) #endif #else /* HAVE_RECV */ #ifndef sread -- cgit v1.2.1 From f1918aa3430c7cb3cb941a58d8d52b3798a53247 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 27 Jan 2007 01:56:20 +0000 Subject: sync comment with reality --- lib/setup_once.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index a1e9f098f..ee6864158 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2007, 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 @@ -36,7 +36,7 @@ /* * If we have the MSG_NOSIGNAL define, make sure we use - * it as the fourth argument of send() and recv() + * it as the fourth argument of function send() */ #ifdef HAVE_MSG_NOSIGNAL -- cgit v1.2.1 From ef6f24a7ce99674262ee51e6cba2fcf798dd19f2 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 2 Feb 2007 15:31:32 +0000 Subject: move DEBUGF macro definition to setup_once.h --- lib/setup_once.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index ee6864158..3d3235ede 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -149,5 +149,16 @@ typedef int sig_atomic_t; #endif +/* + * Macro used to include code only in debug builds. + */ + +#ifdef CURLDEBUG +#define DEBUGF(X) X +#else +#define DEBUGF(X) do { } while (0) +#endif + + #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From 6d05a33ed92b76a1166bca069382f5d03302153c Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 13 Feb 2007 17:47:27 +0000 Subject: use our own ISBLANK macro --- lib/setup_once.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 3d3235ede..445bb970b 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -122,6 +122,7 @@ */ #define ISSPACE(x) (isspace((int) ((unsigned char)x))) +#define ISBLANK(x) (isblank((int) ((unsigned char)x))) #define ISDIGIT(x) (isdigit((int) ((unsigned char)x))) #define ISALNUM(x) (isalnum((int) ((unsigned char)x))) #define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x))) -- cgit v1.2.1 From 0db485a44836903c2854fc8c559e7874e5b9e4f0 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 13 Feb 2007 18:02:20 +0000 Subject: use our own ISUPPER and ISLOWER macros --- lib/setup_once.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 445bb970b..1c4d6c99c 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -129,6 +129,8 @@ #define ISGRAPH(x) (isgraph((int) ((unsigned char)x))) #define ISALPHA(x) (isalpha((int) ((unsigned char)x))) #define ISPRINT(x) (isprint((int) ((unsigned char)x))) +#define ISUPPER(x) (isupper((int) ((unsigned char)x))) +#define ISLOWER(x) (islower((int) ((unsigned char)x))) /* -- cgit v1.2.1 From be71ccbce3a0e9c9ca13665b0c6b8dd7b7febe7b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 13 Feb 2007 19:01:03 +0000 Subject: check for isblank() at configuration stage. If not available provide a suitable replacement for use in our ISBLANK macro --- lib/setup_once.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 1c4d6c99c..827a6901e 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -122,7 +122,6 @@ */ #define ISSPACE(x) (isspace((int) ((unsigned char)x))) -#define ISBLANK(x) (isblank((int) ((unsigned char)x))) #define ISDIGIT(x) (isdigit((int) ((unsigned char)x))) #define ISALNUM(x) (isalnum((int) ((unsigned char)x))) #define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x))) @@ -132,6 +131,13 @@ #define ISUPPER(x) (isupper((int) ((unsigned char)x))) #define ISLOWER(x) (islower((int) ((unsigned char)x))) +#ifdef HAVE_ISBLANK +#define ISBLANK(x) (isblank((int) ((unsigned char)x))) +#else +#define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \ + (((unsigned char)x) == '\t')) +#endif + /* * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type. -- cgit v1.2.1 From fbcf86b83ee2a49b5627cc45545777f2a3fc488a Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 14 Feb 2007 13:31:37 +0000 Subject: avoid using funtion isblank() and just use our ISBLANK macro to provide this functionality on all platforms --- lib/setup_once.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 827a6901e..e5a1117ac 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -131,12 +131,8 @@ #define ISUPPER(x) (isupper((int) ((unsigned char)x))) #define ISLOWER(x) (islower((int) ((unsigned char)x))) -#ifdef HAVE_ISBLANK -#define ISBLANK(x) (isblank((int) ((unsigned char)x))) -#else #define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \ (((unsigned char)x) == '\t')) -#endif /* -- cgit v1.2.1 From d21e4eb8ae10d704a01cfd0278f4efd636842457 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 15 Feb 2007 16:23:24 +0000 Subject: introduce uppercase macros SOCKERRNO, SET_SOCKERRNO(), ERRNO and SET_ERRNO() making them available to any source code file which includes "setup.h". Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno (or equivalent) on this platform to hide platform details to code using it. Macro ERRNO / SET_ERRNO() returns / sets the NOT *socket-related* errno (or equivalent) on this platform to hide platform details to code using it. --- lib/setup_once.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index e5a1117ac..38d86db6f 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -165,5 +165,33 @@ typedef int sig_atomic_t; #endif +/* + * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno + * (or equivalent) on this platform to hide platform details to code using it. + */ + +#ifdef USE_WINSOCK +#define SOCKERRNO ((int)WSAGetLastError()) +#define SET_SOCKERRNO(x) (WSASetLastError((int)(x))) +#else +#define SOCKERRNO (errno) +#define SET_SOCKERRNO(x) (errno = (x)) +#endif + + +/* + * Macro ERRNO / SET_ERRNO() returns / sets the NOT *socket-related* errno + * (or equivalent) on this platform to hide platform details to code using it. + */ + +#ifdef WIN32 +#define ERRNO ((int)GetLastError()) +#define SET_ERRNO(x) (SetLastError((DWORD)(x))) +#else +#define ERRNO (errno) +#define SET_ERRNO(x) (errno = (x)) +#endif + + #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From d9bf55570b4abbe9ed0058091d567e99ebff0973 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 17 Feb 2007 13:51:24 +0000 Subject: Move portable error number symbolic name definitions to setup_once.h --- lib/setup_once.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 38d86db6f..630cd05e3 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -193,5 +193,50 @@ typedef int sig_atomic_t; #endif +/* + * Portable error number symbolic names defined to Winsock error codes. + */ + +#ifdef USE_WINSOCK +#define EWOULDBLOCK WSAEWOULDBLOCK +#define EINPROGRESS WSAEINPROGRESS +#define EALREADY WSAEALREADY +#define ENOTSOCK WSAENOTSOCK +#define EDESTADDRREQ WSAEDESTADDRREQ +#define EMSGSIZE WSAEMSGSIZE +#define EPROTOTYPE WSAEPROTOTYPE +#define ENOPROTOOPT WSAENOPROTOOPT +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT +#define EOPNOTSUPP WSAEOPNOTSUPP +#define EPFNOSUPPORT WSAEPFNOSUPPORT +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#define EADDRINUSE WSAEADDRINUSE +#define EADDRNOTAVAIL WSAEADDRNOTAVAIL +#define ENETDOWN WSAENETDOWN +#define ENETUNREACH WSAENETUNREACH +#define ENETRESET WSAENETRESET +#define ECONNABORTED WSAECONNABORTED +#define ECONNRESET WSAECONNRESET +#define ENOBUFS WSAENOBUFS +#define EISCONN WSAEISCONN +#define ENOTCONN WSAENOTCONN +#define ESHUTDOWN WSAESHUTDOWN +#define ETOOMANYREFS WSAETOOMANYREFS +#define ETIMEDOUT WSAETIMEDOUT +#define ECONNREFUSED WSAECONNREFUSED +#define ELOOP WSAELOOP +#define ENAMETOOLONG WSAENAMETOOLONG +#define EHOSTDOWN WSAEHOSTDOWN +#define EHOSTUNREACH WSAEHOSTUNREACH +#define ENOTEMPTY WSAENOTEMPTY +#define EPROCLIM WSAEPROCLIM +#define EUSERS WSAEUSERS +#define EDQUOT WSAEDQUOT +#define ESTALE WSAESTALE +#define EREMOTE WSAEREMOTE +#endif + + #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From ec9e399668ee04d8c184375f4948662e9e324144 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 18 Feb 2007 00:34:37 +0000 Subject: fix ENAMETOOLONG and ENOTEMPTY may already be defined in errno.h --- lib/setup_once.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 630cd05e3..2cf4ebea4 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -34,6 +34,13 @@ ********************************************************************/ +/* + * Inclusion of common header files. + */ + +#include + + /* * If we have the MSG_NOSIGNAL define, make sure we use * it as the fourth argument of function send() @@ -226,10 +233,14 @@ typedef int sig_atomic_t; #define ETIMEDOUT WSAETIMEDOUT #define ECONNREFUSED WSAECONNREFUSED #define ELOOP WSAELOOP +#ifndef ENAMETOOLONG /* possible previous definition in errno.h */ #define ENAMETOOLONG WSAENAMETOOLONG +#endif #define EHOSTDOWN WSAEHOSTDOWN #define EHOSTUNREACH WSAEHOSTUNREACH +#ifndef ENOTEMPTY /* possible previous definition in errno.h */ #define ENOTEMPTY WSAENOTEMPTY +#endif #define EPROCLIM WSAEPROCLIM #define EUSERS WSAEUSERS #define EDQUOT WSAEDQUOT -- cgit v1.2.1 From 29bb6f65f1ac786b189ca6e860b463c5142bc486 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 20 Feb 2007 12:12:27 +0000 Subject: Move header file inclusion logic and definition of timeval struct for platforms that don't have it to setup_once.h --- lib/setup_once.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 2cf4ebea4..190b69ed7 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -38,8 +38,49 @@ * Inclusion of common header files. */ +#include +#include +#include +#include +#include #include +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SYS_STAT_H +#include +#endif + +#ifdef HAVE_SYS_TIME_H +#include +#ifdef TIME_WITH_SYS_TIME +#include +#endif +#else +#ifdef HAVE_TIME_H +#include +#endif +#endif + +#ifdef WIN32 +#include +#include +#endif + + +/* + * Definition of timeval struct for platforms that don't have it. + */ + +#ifndef HAVE_STRUCT_TIMEVAL +struct timeval { + long tv_sec; + long tv_usec; +}; +#endif + /* * If we have the MSG_NOSIGNAL define, make sure we use -- cgit v1.2.1 From 3a634a273a7bff3d219883f572db786e2c1004b1 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 21 Feb 2007 19:03:20 +0000 Subject: curlassert macro replaced with DEBUGASSERT macro defined in setup_once.h --- lib/setup_once.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 190b69ed7..7af68bf3f 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -207,9 +207,20 @@ typedef int sig_atomic_t; */ #ifdef CURLDEBUG -#define DEBUGF(X) X +#define DEBUGF(x) x #else -#define DEBUGF(X) do { } while (0) +#define DEBUGF(x) do { } while (0) +#endif + + +/* + * Macro used to include assertion code only in debug builds. + */ + +#if defined(CURLDEBUG) && defined(HAVE_ASSERT_H) +#define DEBUGASSERT(x) assert(x) +#else +#define DEBUGASSERT(x) do { } while (0) #endif -- cgit v1.2.1 From 69565afab0be081211df57a245a222cbd3e43ed3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 22 Feb 2007 02:51:54 +0000 Subject: Check for stdbool.h at configuration stage, and include it if available. Check for lowercase 'bool' type at configuration stage. If not available provide a suitable replacement with a type definition of 'unsigned char' in setup_once.h Move definitions of TRUE and FALSE to setup_once.h --- lib/setup_once.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 7af68bf3f..79324d40f 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -69,6 +69,10 @@ #include #endif +#ifdef HAVE_STDBOOL_H +#include +#endif + /* * Definition of timeval struct for platforms that don't have it. @@ -183,6 +187,28 @@ struct timeval { (((unsigned char)x) == '\t')) +/* + * Typedef to 'unsigned char' if bool is not an available 'typedefed' type. + */ + +#ifndef HAVE_BOOL_T +typedef unsigned char bool; +#define HAVE_BOOL_T +#endif + + +/* + * Default definition of uppercase TRUE and FALSE. + */ + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + + /* * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type. */ -- cgit v1.2.1 From 8fe9376d542ef4f11b2049190de363f7b79436ec Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 4 Apr 2007 06:06:36 +0000 Subject: move WinSock definitions of EBADF, EINTR, EINVAL and EAFNOSUPPORT to setup_once.h --- lib/setup_once.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 79324d40f..03141a4ff 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -283,6 +283,12 @@ typedef int sig_atomic_t; */ #ifdef USE_WINSOCK +#undef EBADF /* override definition in errno.h */ +#define EBADF WSAEBADF +#undef EINTR /* override definition in errno.h */ +#define EINTR WSAEINTR +#undef EINVAL /* override definition in errno.h */ +#define EINVAL WSAEINVAL #define EWOULDBLOCK WSAEWOULDBLOCK #define EINPROGRESS WSAEINPROGRESS #define EALREADY WSAEALREADY -- cgit v1.2.1 From 84c5e846b335f6dc760afb139be31b67aa708687 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 11 Apr 2007 11:02:13 +0000 Subject: convenience SIG_ATOMIC_T macro definition --- lib/setup_once.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 03141a4ff..4bbde0ec8 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -219,6 +219,17 @@ typedef int sig_atomic_t; #endif +/* + * Convenience SIG_ATOMIC_T definition + */ + +#ifdef HAVE_SIG_ATOMIC_T_VOLATILE +#define SIG_ATOMIC_T static sig_atomic_t +#else +#define SIG_ATOMIC_T static volatile sig_atomic_t +#endif + + /* * Default return type for signal handlers. */ -- cgit v1.2.1 From 94b253fde793a7419f0eafe16b24f440d344a1c9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 25 Apr 2007 03:00:10 +0000 Subject: Steve Little's fixes to allow compilation on VMS 64-bit mode --- lib/setup_once.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 4bbde0ec8..585faed8d 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -344,5 +344,26 @@ typedef int sig_atomic_t; #endif +/* + * Actually use __32_getpwuid() on 64-bit VMS builds for getpwuid() + */ + +#if defined(VMS) && \ + defined(__INITIAL_POINTER_SIZE) && (__INITIAL_POINTER_SIZE == 64) +#define getpwuid __32_getpwuid +#endif + + +/* + * Macro argv_item_t hides platform details to code using it. + */ + +#ifdef VMS +#define argv_item_t __char_ptr32 +#else +#define argv_item_t char * +#endif + + #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From 375cdf89adaf11a14a7717c39245ac997d0da699 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 12 Jun 2007 21:39:21 +0000 Subject: With lots of help from Rich Rauenza(?) in bug #1733119, we introduce a fairly complicated work-around for 64bit HPUX compiles. We do the fix using inline static functions to make them follow the header file properly and thus get used fine in the test suite too etc. --- lib/setup_once.h | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 585faed8d..08ead5eb2 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -365,5 +365,87 @@ typedef int sig_atomic_t; #endif +#if defined (__LP64__) && defined(__hpux) && !defined(_XOPEN_SOURCE_EXTENDED) +#include +/* HP-UX has this oddity where it features a few functions that don't work + with socklen_t so we need to convert to ints + + This is due to socklen_t being a 64bit int under 64bit ABI, but the + pre-xopen (default) interfaces require an int, which is 32bits. + + Therefore, Anytime socklen_t is passed by pointer, the libc function + truncates the 64bit socklen_t value by treating it as a 32bit value. + + + Note that some socket calls are allowed to have a NULL pointer for + the socklen arg. +*/ + +inline static int Curl_hp_getsockname(int s, struct sockaddr *name, + socklen_t *namelen) +{ + int rc; + if(namelen) { + int len = *namelen; + rc = getsockname(s, name, &len); + *namelen = len; + } + else + rc = getsockname(s, name, 0); + return rc; +} + +inline static int Curl_hp_getsockopt(int s, int level, int optname, + void *optval, socklen_t *optlen) +{ + int rc; + if(optlen) { + int len = *optlen; + rc = getsockopt(s, level, optname, optval, &len); + *optlen = len; + } + else + rc = getsockopt(s, level, optname, optval, 0); + return rc; +} + +inline static int Curl_hp_accept(int sockfd, struct sockaddr *addr, + socklen_t *addrlen) +{ + int rc; + if(addrlen) { + int len = *addrlen; + rc = accept(sockfd, addr, &len); + *addrlen = len; + } + else + rc = accept(sockfd, addr, 0); + return rc; +} + + +inline static ssize_t Curl_hp_recvfrom(int s, void *buf, size_t len, int flags, + struct sockaddr *from, + socklen_t *fromlen) +{ + ssize_t rc; + if(fromlen) { + int fromlen32 = *fromlen; + rc = recvfrom(s, buf, len, flags, from, &fromlen32); + *fromlen = fromlen32; + } + else { + rc = recvfrom(s, buf, len, flags, from, 0); + } + return rc; +} + +#define getsockname(a,b,c) Curl_hp_getsockname((a),(b),(c)) +#define getsockopt(a,b,c,d,e) Curl_hp_getsockopt((a),(b),(c),(d),(e)) +#define accept(a,b,c) Curl_hp_accept((a),(b),(c)) +#define recvfrom(a,b,c,d,e,f) Curl_hp_recvfrom((a),(b),(c),(d),(e),(f)) + +#endif /* HPUX work-around */ + #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From 8147c3659d427110fe7febccaa2f60d4ab1a5cc7 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 5 Sep 2007 22:01:57 +0000 Subject: Minix doesn't support getsockopt on UDP sockets or send/recv on TCP sockets. --- lib/setup_once.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 08ead5eb2..1622f0cc8 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -98,6 +98,13 @@ struct timeval { #endif +#if defined(__minix) +/* Minix doesn't support recv on TCP sockets */ +#define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \ + (RECV_TYPE_ARG2)(y), \ + (RECV_TYPE_ARG3)(z)) + +#elif defined(HAVE_RECV) /* * The definitions for the return type and arguments types * of functions recv() and send() belong and come from the @@ -120,7 +127,6 @@ struct timeval { * SEND_TYPE_RETV must also be defined. */ -#ifdef HAVE_RECV #if !defined(RECV_TYPE_ARG1) || \ !defined(RECV_TYPE_ARG2) || \ !defined(RECV_TYPE_ARG3) || \ @@ -143,7 +149,14 @@ struct timeval { #endif #endif /* HAVE_RECV */ -#ifdef HAVE_SEND + +#if defined(__minix) +/* Minix doesn't support send on TCP sockets */ +#define swrite(x,y,z) (ssize_t)write((SEND_TYPE_ARG1)(x), \ + (SEND_TYPE_ARG2)(y), \ + (SEND_TYPE_ARG3)(z)) + +#elif defined(HAVE_SEND) #if !defined(SEND_TYPE_ARG1) || \ !defined(SEND_QUAL_ARG2) || \ !defined(SEND_TYPE_ARG2) || \ -- cgit v1.2.1 From 92433e596b7fbfa5c75926705dcfef0080ebf012 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 17 Oct 2007 16:58:32 +0000 Subject: We use this ZERO_NULL to avoid picky compiler warnings, when assigning a NULL pointer to a function pointer var. --- lib/setup_once.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 1622f0cc8..ba564120a 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -378,6 +378,14 @@ typedef int sig_atomic_t; #endif +/* + * We use this ZERO_NULL to avoid picky compiler warnings, + * when assigning a NULL pointer to a function pointer var. + */ + +#define ZERO_NULL 0 + + #if defined (__LP64__) && defined(__hpux) && !defined(_XOPEN_SOURCE_EXTENDED) #include /* HP-UX has this oddity where it features a few functions that don't work @@ -460,5 +468,6 @@ inline static ssize_t Curl_hp_recvfrom(int s, void *buf, size_t len, int flags, #endif /* HPUX work-around */ + #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From 08c5e2a194876be4db31536ac0211695c12aa266 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 24 Oct 2007 14:39:07 +0000 Subject: Windows build targets have socklen_t definition in ws2tcpip.h but some versions of ws2tcpip.h do not have the definition. It seems that when the socklen_t definition is missing from ws2tcpip.h the definition for INET_ADDRSTRLEN is also missing, and that when one definition is present the other one also is available. --- lib/setup_once.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index ba564120a..83ee95cf4 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -98,6 +98,24 @@ struct timeval { #endif +/* + * Windows build targets have socklen_t definition in + * ws2tcpip.h but some versions of ws2tcpip.h do not + * have the definition. It seems that when the socklen_t + * definition is missing from ws2tcpip.h the definition + * for INET_ADDRSTRLEN is also missing, and that when one + * definition is present the other one also is available. + */ + +#if defined(WIN32) && !defined(HAVE_SOCKLEN_T) +# if ( defined(_MSC_VER) && !defined(INET_ADDRSTRLEN) ) || \ + (!defined(_MSC_VER) && !defined(HAVE_WS2TCPIP_H) ) +# define socklen_t int +# define HAVE_SOCKLEN_T +# endif +#endif + + #if defined(__minix) /* Minix doesn't support recv on TCP sockets */ #define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \ -- cgit v1.2.1 From d8efc9921766c72a7da1c878c4cb05cde2f0e6f6 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 21 May 2008 14:04:14 +0000 Subject: fix: remove need and definition of HAVE_SOCKLEN_T symbol --- lib/setup_once.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 83ee95cf4..b0355e289 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -107,11 +107,10 @@ struct timeval { * definition is present the other one also is available. */ -#if defined(WIN32) && !defined(HAVE_SOCKLEN_T) +#if defined(WIN32) && !defined(HAVE_CONFIG_H) # if ( defined(_MSC_VER) && !defined(INET_ADDRSTRLEN) ) || \ (!defined(_MSC_VER) && !defined(HAVE_WS2TCPIP_H) ) # define socklen_t int -# define HAVE_SOCKLEN_T # endif #endif -- cgit v1.2.1 From a9dc900515a28dcf55b2901a8609072430087693 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 16 Jul 2008 19:16:41 +0000 Subject: Configure process now checks availability of recvfrom() socket function and finds out its return type and the types of its arguments. Added definitions for non-configure systems config files, and introduced macro sreadfrom which will be used on udp sockets as a recvfrom() wrapper. --- lib/setup_once.h | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index b0355e289..77b253588 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2008, 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 @@ -198,6 +198,37 @@ struct timeval { #endif /* HAVE_SEND */ +#if defined(HAVE_RECVFROM) +/* + * Currently recvfrom is only used on udp sockets. + */ +#if !defined(RECVFROM_TYPE_ARG1) || \ + !defined(RECVFROM_TYPE_ARG2) || \ + !defined(RECVFROM_TYPE_ARG3) || \ + !defined(RECVFROM_TYPE_ARG4) || \ + !defined(RECVFROM_TYPE_ARG5) || \ + !defined(RECVFROM_TYPE_ARG6) || \ + !defined(RECVFROM_TYPE_RETV) + /* */ + Error Missing_definition_of_return_and_arguments_types_of_recvfrom + /* */ +#else +#define sreadfrom(s,b,bl,f,fl) (ssize_t)recvfrom((RECVFROM_TYPE_ARG1)(s), \ + (RECVFROM_TYPE_ARG2)(b), \ + (RECVFROM_TYPE_ARG3)(bl), \ + (RECVFROM_TYPE_ARG4)(0), \ + (RECVFROM_TYPE_ARG5)(f), \ + (RECVFROM_TYPE_ARG6)(fl)) +#endif +#else /* HAVE_RECVFROM */ +#ifndef sreadfrom + /* */ + Error Missing_definition_of_macro_sreadfrom + /* */ +#endif +#endif /* HAVE_RECVFROM */ + + /* * Uppercase macro versions of ANSI/ISO is*() functions/macros which * avoid negative number inputs with argument byte codes > 127. -- cgit v1.2.1 From 39f23aec6b3cd5e7e5dd9077d96f8eff37ff2b19 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 17 Jul 2008 03:07:54 +0000 Subject: RECVFROM_TYPE_ARG2, RECVFROM_TYPE_ARG5 and RECVFROM_TYPE_ARG6 are now defined to the data type pointed by its respective argument and not the pointer type. --- lib/setup_once.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 77b253588..0e2d8bc12 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -213,12 +213,12 @@ struct timeval { Error Missing_definition_of_return_and_arguments_types_of_recvfrom /* */ #else -#define sreadfrom(s,b,bl,f,fl) (ssize_t)recvfrom((RECVFROM_TYPE_ARG1)(s), \ - (RECVFROM_TYPE_ARG2)(b), \ - (RECVFROM_TYPE_ARG3)(bl), \ - (RECVFROM_TYPE_ARG4)(0), \ - (RECVFROM_TYPE_ARG5)(f), \ - (RECVFROM_TYPE_ARG6)(fl)) +#define sreadfrom(s,b,bl,f,fl) (ssize_t)recvfrom((RECVFROM_TYPE_ARG1) (s), \ + (RECVFROM_TYPE_ARG2 *)(b), \ + (RECVFROM_TYPE_ARG3) (bl), \ + (RECVFROM_TYPE_ARG4) (0), \ + (RECVFROM_TYPE_ARG5 *)(f), \ + (RECVFROM_TYPE_ARG6 *)(fl)) #endif #else /* HAVE_RECVFROM */ #ifndef sreadfrom -- cgit v1.2.1 From 1b37baf6568e37d52601231c45e6394a3d0ff55b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 21 Jul 2008 03:06:07 +0000 Subject: Use the sreadfrom() wrapper to replace recvfrom() in our code. --- lib/setup_once.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 0e2d8bc12..e96f6984a 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -229,6 +229,13 @@ struct timeval { #endif /* HAVE_RECVFROM */ +#ifdef RECVFROM_TYPE_ARG6_IS_VOID +# define RECVFROM_ARG6_T unsigned int +#else +# define RECVFROM_ARG6_T RECVFROM_TYPE_ARG6 +#endif + + /* * Uppercase macro versions of ANSI/ISO is*() functions/macros which * avoid negative number inputs with argument byte codes > 127. -- cgit v1.2.1 From 0919de451188b2aca609e0c7952b58a62a02ca9b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 21 Jul 2008 18:24:32 +0000 Subject: Change recvfrom's sixth argument data type to the 'historically standard' 'int' data type for systems where this sixth argument is prototyped as a void pointer. Start of thread: http://curl.haxx.se/mail/lib-2008-07/0153.html --- lib/setup_once.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index e96f6984a..82d74e72f 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -230,7 +230,7 @@ struct timeval { #ifdef RECVFROM_TYPE_ARG6_IS_VOID -# define RECVFROM_ARG6_T unsigned int +# define RECVFROM_ARG6_T int #else # define RECVFROM_ARG6_T RECVFROM_TYPE_ARG6 #endif -- cgit v1.2.1 From f9894f4ebcbe863c5075d411585dbca75311d427 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 27 Aug 2008 00:25:02 +0000 Subject: Don't abort configuration if recvfrom() is not available. --- lib/setup_once.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 82d74e72f..90c5de14f 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -198,6 +198,7 @@ struct timeval { #endif /* HAVE_SEND */ +#if 0 #if defined(HAVE_RECVFROM) /* * Currently recvfrom is only used on udp sockets. @@ -234,6 +235,7 @@ struct timeval { #else # define RECVFROM_ARG6_T RECVFROM_TYPE_ARG6 #endif +#endif /* if 0 */ /* -- cgit v1.2.1 From 9770899a4bfb27ea73d0b0ee4be857ea1e47c4fd Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 21 Apr 2009 10:26:58 +0000 Subject: Moved potential inclusion of system's malloc.h and memory.h header files to setup_once.h. Inclusion of each header file is based on the definition of NEED_MALLOC_H and NEED_MEMORY_H respectively. --- lib/setup_once.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 90c5de14f..c1c899631 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2009, 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 @@ -49,6 +49,14 @@ #include #endif +#ifdef NEED_MALLOC_H +#include +#endif + +#ifdef NEED_MEMORY_H +#include +#endif + #ifdef HAVE_SYS_STAT_H #include #endif -- cgit v1.2.1 From 9137e717b04644592b9b527839470337fdd9f44d Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 2 May 2009 02:37:32 +0000 Subject: Use build-time configured curl_socklen_t instead of socklen_t --- lib/setup_once.h | 100 ------------------------------------------------------- 1 file changed, 100 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index c1c899631..933d95abb 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -106,23 +106,6 @@ struct timeval { #endif -/* - * Windows build targets have socklen_t definition in - * ws2tcpip.h but some versions of ws2tcpip.h do not - * have the definition. It seems that when the socklen_t - * definition is missing from ws2tcpip.h the definition - * for INET_ADDRSTRLEN is also missing, and that when one - * definition is present the other one also is available. - */ - -#if defined(WIN32) && !defined(HAVE_CONFIG_H) -# if ( defined(_MSC_VER) && !defined(INET_ADDRSTRLEN) ) || \ - (!defined(_MSC_VER) && !defined(HAVE_WS2TCPIP_H) ) -# define socklen_t int -# endif -#endif - - #if defined(__minix) /* Minix doesn't support recv on TCP sockets */ #define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \ @@ -451,88 +434,5 @@ typedef int sig_atomic_t; #define ZERO_NULL 0 -#if defined (__LP64__) && defined(__hpux) && !defined(_XOPEN_SOURCE_EXTENDED) -#include -/* HP-UX has this oddity where it features a few functions that don't work - with socklen_t so we need to convert to ints - - This is due to socklen_t being a 64bit int under 64bit ABI, but the - pre-xopen (default) interfaces require an int, which is 32bits. - - Therefore, Anytime socklen_t is passed by pointer, the libc function - truncates the 64bit socklen_t value by treating it as a 32bit value. - - - Note that some socket calls are allowed to have a NULL pointer for - the socklen arg. -*/ - -inline static int Curl_hp_getsockname(int s, struct sockaddr *name, - socklen_t *namelen) -{ - int rc; - if(namelen) { - int len = *namelen; - rc = getsockname(s, name, &len); - *namelen = len; - } - else - rc = getsockname(s, name, 0); - return rc; -} - -inline static int Curl_hp_getsockopt(int s, int level, int optname, - void *optval, socklen_t *optlen) -{ - int rc; - if(optlen) { - int len = *optlen; - rc = getsockopt(s, level, optname, optval, &len); - *optlen = len; - } - else - rc = getsockopt(s, level, optname, optval, 0); - return rc; -} - -inline static int Curl_hp_accept(int sockfd, struct sockaddr *addr, - socklen_t *addrlen) -{ - int rc; - if(addrlen) { - int len = *addrlen; - rc = accept(sockfd, addr, &len); - *addrlen = len; - } - else - rc = accept(sockfd, addr, 0); - return rc; -} - - -inline static ssize_t Curl_hp_recvfrom(int s, void *buf, size_t len, int flags, - struct sockaddr *from, - socklen_t *fromlen) -{ - ssize_t rc; - if(fromlen) { - int fromlen32 = *fromlen; - rc = recvfrom(s, buf, len, flags, from, &fromlen32); - *fromlen = fromlen32; - } - else { - rc = recvfrom(s, buf, len, flags, from, 0); - } - return rc; -} - -#define getsockname(a,b,c) Curl_hp_getsockname((a),(b),(c)) -#define getsockopt(a,b,c,d,e) Curl_hp_getsockopt((a),(b),(c),(d),(e)) -#define accept(a,b,c) Curl_hp_accept((a),(b),(c)) -#define recvfrom(a,b,c,d,e,f) Curl_hp_recvfrom((a),(b),(c),(d),(e),(f)) - -#endif /* HPUX work-around */ - - #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From 2c166812253c28cdfbffdd4de069f5c11db3c7a8 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 10 Jun 2009 02:49:42 +0000 Subject: Adjusted to take in account that... With the curl memory tracking feature decoupled from the debug build feature, CURLDEBUG and DEBUGBUILD preprocessor symbol definitions are used as follows: CURLDEBUG used for curl debug memory tracking specific code (--enable-curldebug) DEBUGBUILD used for debug enabled specific code (--enable-debug) --- lib/setup_once.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 933d95abb..4c4d3f599 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -304,7 +304,7 @@ typedef int sig_atomic_t; * Macro used to include code only in debug builds. */ -#ifdef CURLDEBUG +#ifdef DEBUGBUILD #define DEBUGF(x) x #else #define DEBUGF(x) do { } while (0) @@ -315,7 +315,7 @@ typedef int sig_atomic_t; * Macro used to include assertion code only in debug builds. */ -#if defined(CURLDEBUG) && defined(HAVE_ASSERT_H) +#if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H) #define DEBUGASSERT(x) assert(x) #else #define DEBUGASSERT(x) do { } while (0) -- cgit v1.2.1 From 2c0c05e96d8b611e1f5eedea518fa1a7857804c9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 19 Jun 2009 00:41:03 +0000 Subject: sclose() function-like macro definition used to close a socket, now solely based on HAVE_CLOSESOCKET and HAVE_CLOSESOCKET_CAMEL config file preprocessor definitions. --- lib/setup_once.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 4c4d3f599..9ad69e58d 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -229,6 +229,19 @@ struct timeval { #endif /* if 0 */ +/* + * Function-like macro definition used to close a socket. + */ + +#if defined(HAVE_CLOSESOCKET) +# define sclose(x) closesocket((x)) +#elif defined(HAVE_CLOSESOCKET_CAMEL) +# define sclose(x) CloseSocket((x)) +#else +# define sclose(x) close((x)) +#endif + + /* * Uppercase macro versions of ANSI/ISO is*() functions/macros which * avoid negative number inputs with argument byte codes > 127. -- cgit v1.2.1 From 3184a91ec86b2f35f16a8e11e2daa03fac8e91b6 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 30 Dec 2009 17:59:56 +0000 Subject: VMS specific preprocessor symbol checking adjustments --- lib/setup_once.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 9ad69e58d..5c49165f0 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -422,7 +422,7 @@ typedef int sig_atomic_t; * Actually use __32_getpwuid() on 64-bit VMS builds for getpwuid() */ -#if defined(VMS) && \ +#if defined(__VMS) && \ defined(__INITIAL_POINTER_SIZE) && (__INITIAL_POINTER_SIZE == 64) #define getpwuid __32_getpwuid #endif @@ -432,7 +432,7 @@ typedef int sig_atomic_t; * Macro argv_item_t hides platform details to code using it. */ -#ifdef VMS +#ifdef __VMS #define argv_item_t __char_ptr32 #else #define argv_item_t char * -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- lib/setup_once.h | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 5c49165f0..473eef2b7 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -20,7 +20,6 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * $Id$ ***************************************************************************/ -- cgit v1.2.1 From 81239edb89add9327d2b03105c9981d092e16ace Mon Sep 17 00:00:00 2001 From: Tanguy Fautre Date: Thu, 20 May 2010 22:40:48 +0200 Subject: build: allow curl to build with Microsoft VC10 By undefing a bunch of E* defines that VC10 has started to define but that we redefine internally to their WSA* alternatives when building for Windows. --- lib/setup_once.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 473eef2b7..cdc0ecf64 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -373,38 +373,63 @@ typedef int sig_atomic_t; #define EINTR WSAEINTR #undef EINVAL /* override definition in errno.h */ #define EINVAL WSAEINVAL +#undef EWOULDBLOCK /* override definition in errno.h */ #define EWOULDBLOCK WSAEWOULDBLOCK +#undef EINPROGRESS /* override definition in errno.h */ #define EINPROGRESS WSAEINPROGRESS +#undef EALREADY /* override definition in errno.h */ #define EALREADY WSAEALREADY +#undef ENOTSOCK /* override definition in errno.h */ #define ENOTSOCK WSAENOTSOCK +#undef EDESTADDRREQ /* override definition in errno.h */ #define EDESTADDRREQ WSAEDESTADDRREQ +#undef EMSGSIZE /* override definition in errno.h */ #define EMSGSIZE WSAEMSGSIZE +#undef EPROTOTYPE /* override definition in errno.h */ #define EPROTOTYPE WSAEPROTOTYPE +#undef ENOPROTOOPT /* override definition in errno.h */ #define ENOPROTOOPT WSAENOPROTOOPT +#undef EPROTONOSUPPORT /* override definition in errno.h */ #define EPROTONOSUPPORT WSAEPROTONOSUPPORT #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT +#undef EOPNOTSUPP /* override definition in errno.h */ #define EOPNOTSUPP WSAEOPNOTSUPP #define EPFNOSUPPORT WSAEPFNOSUPPORT +#undef EAFNOSUPPORT /* override definition in errno.h */ #define EAFNOSUPPORT WSAEAFNOSUPPORT +#undef EADDRINUSE /* override definition in errno.h */ #define EADDRINUSE WSAEADDRINUSE +#undef EADDRNOTAVAIL /* override definition in errno.h */ #define EADDRNOTAVAIL WSAEADDRNOTAVAIL +#undef ENETDOWN /* override definition in errno.h */ #define ENETDOWN WSAENETDOWN +#undef ENETUNREACH /* override definition in errno.h */ #define ENETUNREACH WSAENETUNREACH +#undef ENETRESET /* override definition in errno.h */ #define ENETRESET WSAENETRESET +#undef ECONNABORTED /* override definition in errno.h */ #define ECONNABORTED WSAECONNABORTED +#undef ECONNRESET /* override definition in errno.h */ #define ECONNRESET WSAECONNRESET +#undef ENOBUFS /* override definition in errno.h */ #define ENOBUFS WSAENOBUFS +#undef EISCONN /* override definition in errno.h */ #define EISCONN WSAEISCONN +#undef ENOTCONN /* override definition in errno.h */ #define ENOTCONN WSAENOTCONN #define ESHUTDOWN WSAESHUTDOWN #define ETOOMANYREFS WSAETOOMANYREFS +#undef ETIMEDOUT /* override definition in errno.h */ #define ETIMEDOUT WSAETIMEDOUT +#undef ECONNREFUSED /* override definition in errno.h */ #define ECONNREFUSED WSAECONNREFUSED +#undef ELOOP /* override definition in errno.h */ #define ELOOP WSAELOOP #ifndef ENAMETOOLONG /* possible previous definition in errno.h */ #define ENAMETOOLONG WSAENAMETOOLONG #endif #define EHOSTDOWN WSAEHOSTDOWN +#undef EHOSTUNREACH /* override definition in errno.h */ #define EHOSTUNREACH WSAEHOSTUNREACH #ifndef ENOTEMPTY /* possible previous definition in errno.h */ #define ENOTEMPTY WSAENOTEMPTY -- cgit v1.2.1 From b4f0e1291f2095d4d2be0842ddfcd57895c750a6 Mon Sep 17 00:00:00 2001 From: Tor Arntsen Date: Thu, 27 May 2010 16:58:15 +0200 Subject: setup_once: use enum type for 'bool' on non-C99 platforms An enum will catch non-bool assignments to bool on platforms with a strict compiler, e.g MIPSPro. Signed-off-by: Kamil Dudka --- lib/setup_once.h | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index cdc0ecf64..fff115b8f 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -261,24 +261,42 @@ struct timeval { /* - * Typedef to 'unsigned char' if bool is not an available 'typedefed' type. + * 'bool' exists on platforms with , i.e. C99 platforms. + * On non-C99 platforms there's no bool, so define an enum for that. + * On C99 platforms 'false' and 'true' also exist. Enum uses a + * global namespace though, so use bool_false and bool_true. */ #ifndef HAVE_BOOL_T -typedef unsigned char bool; -#define HAVE_BOOL_T + typedef enum { + bool_false = 0, + bool_true = 1 + } bool; + +/* + * Use a define to let 'true' and 'false' use those enums. There + * are currently no use of true and false in libcurl proper, but + * there are some in the examples. This will cater for any later + * code happening to use true and false. + */ +# define false bool_false +# define true bool_true +# define HAVE_BOOL_T #endif /* - * Default definition of uppercase TRUE and FALSE. + * Redefine TRUE and FALSE too, to catch current use. With this + * change, 'bool found = 1' will give a warning on MIPSPro, but + * 'bool found = TRUE' will not. Change tested on IRIX/MIPSPro, + * AIX 5.1/Xlc, Tru64 5.1/cc, w/make test too. */ #ifndef TRUE -#define TRUE 1 +#define TRUE true #endif #ifndef FALSE -#define FALSE 0 +#define FALSE false #endif -- cgit v1.2.1 From 374f48675b193290757d48e7c5f6af8129bc8a1d Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 31 May 2010 13:51:29 +0200 Subject: update year in copyright notice --- lib/setup_once.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index fff115b8f..85e78e8d8 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2010, 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 -- cgit v1.2.1 From 0696260122f1ebdf43bcc926b03bfd58bff318e3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 7 Feb 2011 15:09:24 +0100 Subject: Curl_gmtime: avoid future mistakes Document Curl_gmtime() and define away the old functions so that they won't be used internally again by mistake. --- lib/setup_once.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 85e78e8d8..e817b6dea 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2011, 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 @@ -488,6 +488,8 @@ typedef int sig_atomic_t; #define ZERO_NULL 0 +#define gmtime(x) do_not_use_gmtime_use_Curl_gmtime() +#define gmtime_r(x,y) do_not_use_gmtime_r_use_Curl_gmtime() #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From f19ace8d33e468969d3329e6bb17d6c032147e91 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 14 Feb 2011 13:42:01 +0100 Subject: gmtime: remove define It turns out some systems rely on the gmtime or gmtime_r to be defined already in the system headers and thus my "precaution" redefining of them only caused trouble. They are now removed. --- lib/setup_once.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index e817b6dea..1b6fde527 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -488,8 +488,5 @@ typedef int sig_atomic_t; #define ZERO_NULL 0 -#define gmtime(x) do_not_use_gmtime_use_Curl_gmtime() -#define gmtime_r(x,y) do_not_use_gmtime_r_use_Curl_gmtime() - #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From b5d170b55110bacc61a4aa8bf99df1afc303c5dc Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 16 May 2011 23:46:43 +0200 Subject: CLOSESOCKETFUNCTION: added Introduced the initial setup to allow closesocket callbacks by making sure sclose() is only ever called from one place in the libcurl source and still run all test cases fine. --- lib/setup_once.h | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 1b6fde527..b449807db 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -240,7 +240,6 @@ struct timeval { # define sclose(x) close((x)) #endif - /* * Uppercase macro versions of ANSI/ISO is*() functions/macros which * avoid negative number inputs with argument byte codes > 127. -- cgit v1.2.1 From ef2176109fca302ed89193716b62c3a7113552a3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 24 Jul 2011 04:39:43 +0200 Subject: errno.h inclusion conditionally done in setup_once.h --- lib/setup_once.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index b449807db..751102bed 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -42,7 +42,10 @@ #include #include #include + +#ifdef HAVE_ERRNO_H #include +#endif #ifdef HAVE_SYS_TYPES_H #include -- cgit v1.2.1 From f6272dd9b8ae8d188068aeb0df2af496a964e407 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 5 Aug 2011 15:42:05 +0200 Subject: BSD-style lwIP TCP/IP stack support - followup --- lib/setup_once.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 751102bed..4f7d0d791 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -490,5 +490,21 @@ typedef int sig_atomic_t; #define ZERO_NULL 0 + +/* + * Ensure that Winsock and lwIP TCP/IP stacks are not mixed. + */ + +#if defined(__LWIP_OPT_H__) +# if defined(SOCKET) || \ + defined(USE_WINSOCK) || \ + defined(HAVE_ERRNO_H) || \ + defined(HAVE_WINSOCK_H) || \ + defined(HAVE_WINSOCK2_H) || \ + defined(HAVE_WS2TCPIP_H) +# error "Winsock and lwIP TCP/IP stack definitions shall not coexist!" +# endif +#endif + #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From 9194e1700312f27c6e2abdfb1f604e130497e887 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 2 Sep 2011 19:40:53 +0200 Subject: MemoryTracking: fix logging of free() calls done where Curl_safefree is called Just internal stuff... Curl_safefree is now a macro defined in memdebug.h instead of a function prototyped in url.h and implemented in url.c, so inclusion of url.h is no longer required in order to simply use Curl_safefree. Provide definition of macro WHILE_FALSE in setup_once.h in order to allow other macros such as DEBUGF and DEBUGASSERT, and code using it, to compile without 'conditional expression is constant' warnings. The WHILE_FALSE stuff fixes 150+ MSVC compiler warnings. --- lib/setup_once.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 4f7d0d791..63a3698de 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -302,6 +302,27 @@ struct timeval { #endif +/* + * Macro WHILE_FALSE may be used to build single-iteration do-while loops, + * avoiding compiler warnings. Mostly intended for other macro definitions. + */ + +#define WHILE_FALSE while(0) + +#if defined(_MSC_VER) && !defined(__POCC__) +# undef WHILE_FALSE +# if (_MSC_VER < 1500) +# define WHILE_FALSE while(1, 0) +# else +# define WHILE_FALSE \ +__pragma(warning(push)) \ +__pragma(warning(disable:4127)) \ +while(0) \ +__pragma(warning(pop)) +# endif +#endif + + /* * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type. */ @@ -339,7 +360,7 @@ typedef int sig_atomic_t; #ifdef DEBUGBUILD #define DEBUGF(x) x #else -#define DEBUGF(x) do { } while (0) +#define DEBUGF(x) do { } WHILE_FALSE #endif @@ -350,7 +371,7 @@ typedef int sig_atomic_t; #if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H) #define DEBUGASSERT(x) assert(x) #else -#define DEBUGASSERT(x) do { } while (0) +#define DEBUGASSERT(x) do { } WHILE_FALSE #endif -- cgit v1.2.1 From 6b75d2c2df7209919a70a29a4479625b62fb3c28 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 3 Sep 2011 16:06:10 +0200 Subject: fix a bunch of MSVC compiler warnings --- lib/setup_once.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 63a3698de..64cfeeaac 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -1,5 +1,5 @@ -#ifndef __SETUP_ONCE_H -#define __SETUP_ONCE_H +#ifndef HEADER_CURL_SETUP_ONCE_H +#define HEADER_CURL_SETUP_ONCE_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -323,6 +323,13 @@ __pragma(warning(pop)) #endif +/* + * Definition of our NOP statement Object-like macro + */ + +#define Curl_nop_stmt do { } WHILE_FALSE + + /* * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type. */ @@ -360,7 +367,7 @@ typedef int sig_atomic_t; #ifdef DEBUGBUILD #define DEBUGF(x) x #else -#define DEBUGF(x) do { } WHILE_FALSE +#define DEBUGF(x) Curl_nop_stmt #endif @@ -371,7 +378,7 @@ typedef int sig_atomic_t; #if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H) #define DEBUGASSERT(x) assert(x) #else -#define DEBUGASSERT(x) do { } WHILE_FALSE +#define DEBUGASSERT(x) Curl_nop_stmt #endif @@ -527,5 +534,4 @@ typedef int sig_atomic_t; # endif #endif -#endif /* __SETUP_ONCE_H */ - +#endif /* HEADER_CURL_SETUP_ONCE_H */ -- cgit v1.2.1 From a405a8976d9732dac4cf92f6718b7b4fec5c6375 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 3 Sep 2011 18:26:21 +0200 Subject: revert changes not intended to be pushed with commit 6b75d2c2 --- lib/setup_once.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 64cfeeaac..fad6f3213 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -1,5 +1,5 @@ -#ifndef HEADER_CURL_SETUP_ONCE_H -#define HEADER_CURL_SETUP_ONCE_H +#ifndef __SETUP_ONCE_H +#define __SETUP_ONCE_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -534,4 +534,4 @@ typedef int sig_atomic_t; # endif #endif -#endif /* HEADER_CURL_SETUP_ONCE_H */ +#endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From 196e0d699f70bf6f519d6f5e670989fd581c1686 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 4 Sep 2011 17:09:22 +0200 Subject: setup_once.h cleanup and sync --- lib/setup_once.h | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index fad6f3213..8bdb472df 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -257,10 +257,13 @@ struct timeval { #define ISPRINT(x) (isprint((int) ((unsigned char)x))) #define ISUPPER(x) (isupper((int) ((unsigned char)x))) #define ISLOWER(x) (islower((int) ((unsigned char)x))) +#define ISASCII(x) (isascii((int) ((unsigned char)x))) #define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \ (((unsigned char)x) == '\t')) +#define TOLOWER(x) (tolower((int) ((unsigned char)x))) + /* * 'bool' exists on platforms with , i.e. C99 platforms. @@ -323,13 +326,6 @@ __pragma(warning(pop)) #endif -/* - * Definition of our NOP statement Object-like macro - */ - -#define Curl_nop_stmt do { } WHILE_FALSE - - /* * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type. */ @@ -367,7 +363,7 @@ typedef int sig_atomic_t; #ifdef DEBUGBUILD #define DEBUGF(x) x #else -#define DEBUGF(x) Curl_nop_stmt +#define DEBUGF(x) do { } WHILE_FALSE #endif @@ -378,7 +374,7 @@ typedef int sig_atomic_t; #if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H) #define DEBUGASSERT(x) assert(x) #else -#define DEBUGASSERT(x) Curl_nop_stmt +#define DEBUGASSERT(x) do { } WHILE_FALSE #endif @@ -519,19 +515,4 @@ typedef int sig_atomic_t; #define ZERO_NULL 0 -/* - * Ensure that Winsock and lwIP TCP/IP stacks are not mixed. - */ - -#if defined(__LWIP_OPT_H__) -# if defined(SOCKET) || \ - defined(USE_WINSOCK) || \ - defined(HAVE_ERRNO_H) || \ - defined(HAVE_WINSOCK_H) || \ - defined(HAVE_WINSOCK2_H) || \ - defined(HAVE_WS2TCPIP_H) -# error "Winsock and lwIP TCP/IP stack definitions shall not coexist!" -# endif -#endif - #endif /* __SETUP_ONCE_H */ -- cgit v1.2.1 From ad77420ac761b8a1ab20792ae4dc2f88208776a2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 17 Mar 2012 23:02:21 +0100 Subject: lwip: basic checks and macros for compatiblity --- lib/setup_once.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 8bdb472df..4137f374c 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, 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 @@ -239,10 +239,21 @@ struct timeval { # define sclose(x) closesocket((x)) #elif defined(HAVE_CLOSESOCKET_CAMEL) # define sclose(x) CloseSocket((x)) +#elif defined(USE_LWIPSOCK) +# define sclose(x) lwip_close((x)) #else # define sclose(x) close((x)) #endif +/* + * Stack-independent version of fcntl() on sockets: + */ +#if defined(USE_LWIPSOCK) +# define sfcntl lwip_fcntl +#else +# define sfcntl fcntl +#endif + /* * Uppercase macro versions of ANSI/ISO is*() functions/macros which * avoid negative number inputs with argument byte codes > 127. -- cgit v1.2.1 From 7d4ed0b10e66f5a4bf8d215be50acfa81f02a3dd Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 14 Apr 2012 15:41:38 +0200 Subject: setup_once.h: tighten requirements for stdbool.h header inclusion Include stdbool.h only when it is available and configure is capable of detecting a proper 'bool' data type when the header is included. Compilation fix for old or unpatched versions of XL C compiler. Report: http://curl.haxx.se/mail/archive-2012-04/0022.html --- lib/setup_once.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/setup_once.h') diff --git a/lib/setup_once.h b/lib/setup_once.h index 4137f374c..eb14e5886 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -79,7 +79,7 @@ #include #endif -#ifdef HAVE_STDBOOL_H +#if defined(HAVE_STDBOOL_H) && defined(HAVE_BOOL_T) #include #endif -- cgit v1.2.1