From: Ludovic Courtès Date: Tue, 17 Nov 2009 22:40:51 +0000 (+0100) Subject: Remove references to undefined macros. X-Git-Url: https://git.hcoop.net/bpt/guile.git/commitdiff_plain/56a3dcd4311d26ef2e9d14ef01021947562c5f17 Remove references to undefined macros. The intent is to allow compilation with `-Wundef', which in turn should make it easier to catch erroneous uses of nonexistent macros. * libguile/__scm.h: Don't assume `BUILDING_LIBGUILE' is defined. * libguile/conv-uinteger.i.c (SCM_TO_TYPE_PROTO): Remove unneeded CPP conditional on `TYPE_MIN == 0'. * libguile/fports.c: Check for the definition of `HAVE_CHSIZE' and `HAVE_FTRUNCATE', not for their value. * libguile/ports.c: Likewise. * libguile/numbers.c (guile_ieee_init): Likewise with `HAVE_DINFINITY' and `HAVE_DQNAN'. * test-suite/standalone/test-conversion.c (ieee_init): Likewise. * libguile/strings.c: Likewise with `SCM_STRING_LENGTH_HISTOGRAM'. * libguile/strings.h: Likewise. * libguile/tags.h: Likewise with `HAVE_INTTYPES_H' and `HAVE_STDINT_H'. * libguile/threads.c: Likewise with `HAVE_PTHREAD_GET_STACKADDR_NP'. * libguile/vm-engine.c (VM_NAME): Likewise with `VM_CHECK_IP'. * libguile/gen-scmconfig.c (main): Use "#ifdef HAVE_", not "#if HAVE_". * libguile/socket.c (scm_setsockopt): Likewise. --- diff --git a/libguile/__scm.h b/libguile/__scm.h index 8bb1b1a0e..c6cbe3fcb 100644 --- a/libguile/__scm.h +++ b/libguile/__scm.h @@ -175,9 +175,9 @@ /* SCM_API is a macro prepended to all function and data definitions which should be exported from libguile. */ -#if BUILDING_LIBGUILE && HAVE_VISIBILITY +#if defined BUILDING_LIBGUILE && defined HAVE_VISIBILITY # define SCM_API extern __attribute__((__visibility__("default"))) -#elif BUILDING_LIBGUILE && defined _MSC_VER +#elif defined BUILDING_LIBGUILE && defined _MSC_VER # define SCM_API __declspec(dllexport) extern #elif defined _MSC_VER # define SCM_API __declspec(dllimport) extern diff --git a/libguile/conv-uinteger.i.c b/libguile/conv-uinteger.i.c index 52f49f772..d6b969c20 100644 --- a/libguile/conv-uinteger.i.c +++ b/libguile/conv-uinteger.i.c @@ -54,13 +54,8 @@ SCM_TO_TYPE_PROTO (SCM val) return n; #else -#if TYPE_MIN == 0 - if (n <= TYPE_MAX) - return n; -#else /* TYPE_MIN != 0 */ if (n >= TYPE_MIN && n <= TYPE_MAX) return n; -#endif /* TYPE_MIN != 0 */ else goto out_of_range; @@ -83,13 +78,8 @@ SCM_TO_TYPE_PROTO (SCM val) mpz_export (&n, &count, 1, sizeof (TYPE), 0, 0, SCM_I_BIG_MPZ (val)); -#if TYPE_MIN == 0 - if (n <= TYPE_MAX) - return n; -#else /* TYPE_MIN != 0 */ if (n >= TYPE_MIN && n <= TYPE_MAX) return n; -#endif /* TYPE_MIN != 0 */ else goto out_of_range; diff --git a/libguile/fports.c b/libguile/fports.c index 12b791803..3e911f232 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -69,10 +69,10 @@ gnulib ftruncate.c has code using fcntl F_CHSIZE and F_FREESP, which might be possibilities if we've got other systems without ftruncate. */ -#if HAVE_CHSIZE && ! HAVE_FTRUNCATE +#if defined HAVE_CHSIZE && ! defined HAVE_FTRUNCATE # define ftruncate(fd, size) chsize (fd, size) -#undef HAVE_FTRUNCATE -#define HAVE_FTRUNCATE 1 +# undef HAVE_FTRUNCATE +# define HAVE_FTRUNCATE 1 #endif #if SIZEOF_OFF_T == SIZEOF_INT diff --git a/libguile/gen-scmconfig.c b/libguile/gen-scmconfig.c index bc0c2df20..f9fff6e3e 100644 --- a/libguile/gen-scmconfig.c +++ b/libguile/gen-scmconfig.c @@ -169,10 +169,10 @@ main (int argc, char *argv[]) #ifdef STDC_HEADERS pf ("#define SCM_HAVE_STDC_HEADERS 1 /* 0 or 1 */\n"); pf ("#include \n"); -# if HAVE_SYS_TYPES_H +# ifdef HAVE_SYS_TYPES_H pf ("#include \n"); # endif -# if HAVE_SYS_STDTYPES_H +# ifdef HAVE_SYS_STDTYPES_H pf ("#include \n"); # endif pf ("#include \n"); @@ -411,7 +411,7 @@ main (int argc, char *argv[]) else pf ("/* #undef SCM_HAVE_THREAD_STORAGE_CLASS */\n"); -#if USE_DLL_IMPORT +#ifdef USE_DLL_IMPORT pf ("\n"); pf ("/* Define some additional CPP macros on Win32 platforms. */\n"); pf ("# define __REGEX_IMPORT__ 1\n"); diff --git a/libguile/numbers.c b/libguile/numbers.c index 20fda02da..15c49c059 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -619,7 +619,7 @@ guile_ieee_init (void) before trying to use it. (But in practice we believe this is not a problem on any system guile is likely to target.) */ guile_Inf = INFINITY; -#elif HAVE_DINFINITY +#elif defined HAVE_DINFINITY /* OSF */ extern unsigned int DINFINITY[2]; guile_Inf = (*((double *) (DINFINITY))); @@ -642,7 +642,7 @@ guile_ieee_init (void) #ifdef NAN /* C99 NAN, when available */ guile_NaN = NAN; -#elif HAVE_DQNAN +#elif defined HAVE_DQNAN { /* OSF */ extern unsigned int DQNAN[2]; diff --git a/libguile/ports.c b/libguile/ports.c index e71ee0adc..1fd6f6350 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -80,7 +80,7 @@ gnulib ftruncate.c has code using fcntl F_CHSIZE and F_FREESP, which might be possibilities if we've got other systems without ftruncate. */ -#if HAVE_CHSIZE && ! HAVE_FTRUNCATE +#if defined HAVE_CHSIZE && ! defined HAVE_FTRUNCATE #define ftruncate(fd, size) chsize (fd, size) #undef HAVE_FTRUNCATE #define HAVE_FTRUNCATE 1 diff --git a/libguile/socket.c b/libguile/socket.c index cd313190e..092f6eb00 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -624,7 +624,7 @@ SCM_DEFINE (scm_setsockopt, "setsockopt", 4, 0, 0, struct linger opt_linger; #endif -#if HAVE_STRUCT_IP_MREQ +#ifdef HAVE_STRUCT_IP_MREQ struct ip_mreq opt_mreq; #endif @@ -678,7 +678,7 @@ SCM_DEFINE (scm_setsockopt, "setsockopt", 4, 0, 0, } } -#if HAVE_STRUCT_IP_MREQ +#ifdef HAVE_STRUCT_IP_MREQ if (ilevel == IPPROTO_IP && (ioptname == IP_ADD_MEMBERSHIP || ioptname == IP_DROP_MEMBERSHIP)) { @@ -760,7 +760,7 @@ scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg, *args = SCM_CDR (*args); soka = (struct sockaddr_in *) scm_malloc (sizeof (struct sockaddr_in)); -#if HAVE_STRUCT_SOCKADDR_SIN_LEN +#ifdef HAVE_STRUCT_SOCKADDR_SIN_LEN soka->sin_len = sizeof (struct sockaddr_in); #endif soka->sin_family = AF_INET; @@ -794,7 +794,7 @@ scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg, } soka = (struct sockaddr_in6 *) scm_malloc (sizeof (struct sockaddr_in6)); -#if HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN +#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN soka->sin6_len = sizeof (struct sockaddr_in6); #endif soka->sin6_family = AF_INET6; diff --git a/libguile/strings.c b/libguile/strings.c index 21295addf..1c74c6a1c 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -96,7 +96,7 @@ } \ while (0) -#if SCM_STRING_LENGTH_HISTOGRAM +#ifdef SCM_STRING_LENGTH_HISTOGRAM static size_t lenhist[1001]; #endif @@ -114,7 +114,7 @@ make_stringbuf (size_t len) SCM buf; -#if SCM_STRING_LENGTH_HISTOGRAM +#ifdef SCM_STRING_LENGTH_HISTOGRAM if (len < 1000) lenhist[len]++; else @@ -140,7 +140,7 @@ make_wide_stringbuf (size_t len) SCM buf; size_t raw_len; -#if SCM_STRING_LENGTH_HISTOGRAM +#ifdef SCM_STRING_LENGTH_HISTOGRAM if (len < 1000) lenhist[len]++; else @@ -972,7 +972,7 @@ SCM_DEFINE (scm_sys_symbol_dump, "%symbol-dump", 1, 0, 0, (SCM sym), } #undef FUNC_NAME -#if SCM_STRING_LENGTH_HISTOGRAM +#ifdef SCM_STRING_LENGTH_HISTOGRAM SCM_DEFINE (scm_sys_stringbuf_hist, "%stringbuf-hist", 0, 0, 0, (void), "") #define FUNC_NAME s_scm_sys_stringbuf_hist @@ -1040,9 +1040,11 @@ SCM_DEFINE (scm_string, "string", 0, 0, 1, if (wide == 0) { + char *buf; + result = scm_i_make_string (len, NULL); result = scm_i_string_start_writing (result); - char *buf = scm_i_string_writable_chars (result); + buf = scm_i_string_writable_chars (result); while (len > 0 && scm_is_pair (rest)) { SCM elt = SCM_CAR (rest); @@ -1055,9 +1057,11 @@ SCM_DEFINE (scm_string, "string", 0, 0, 1, } else { + scm_t_wchar *buf; + result = scm_i_make_wide_string (len, NULL); result = scm_i_string_start_writing (result); - scm_t_wchar *buf = scm_i_string_writable_wide_chars (result); + buf = scm_i_string_writable_wide_chars (result); while (len > 0 && scm_is_pair (rest)) { SCM elt = SCM_CAR (rest); diff --git a/libguile/strings.h b/libguile/strings.h index 4e5f70098..601bd9c6b 100644 --- a/libguile/strings.h +++ b/libguile/strings.h @@ -198,7 +198,7 @@ SCM_INTERNAL void scm_i_get_substring_spec (size_t len, SCM_API SCM scm_sys_string_dump (SCM); SCM_API SCM scm_sys_symbol_dump (SCM); -#if SCM_STRING_LENGTH_HISTOGRAM +#ifdef SCM_STRING_LENGTH_HISTOGRAM SCM_API SCM scm_sys_stringbuf_hist (void); #endif diff --git a/libguile/tags.h b/libguile/tags.h index 4a68f9c78..c8cd621d7 100644 --- a/libguile/tags.h +++ b/libguile/tags.h @@ -31,10 +31,13 @@ /* picks up scmconfig.h too */ #include "libguile/__scm.h" -#if HAVE_INTTYPES_H +/* FIXME: We shouldn't rely on `HAVE_*' macros here since it's a public + header. */ + +#ifdef HAVE_INTTYPES_H # include /* for INTPTR_MAX and friends */ #else -# if HAVE_STDINT_H +# ifdef HAVE_STDINT_H # include /* for INTPTR_MAX and friends */ # endif #endif diff --git a/libguile/threads.c b/libguile/threads.c index 82b39f82d..1527e01d1 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -661,7 +661,7 @@ get_thread_stack_base () } } -#elif HAVE_PTHREAD_GET_STACKADDR_NP +#elif defined HAVE_PTHREAD_GET_STACKADDR_NP /* This method for MacOS X. It'd be nice if there was some documentation on pthread_get_stackaddr_np, but as of 2006 there's nothing obvious at apple.com. */ diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index 5d8f65587..aaa8884fe 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -243,7 +243,7 @@ VM_NAME (struct scm_vm *vp, SCM program, SCM *argv, int nargs) err_msg = scm_from_locale_string ("VM: Bad wide string length: ~S"); goto vm_error; -#if VM_CHECK_IP +#ifdef VM_CHECK_IP vm_error_invalid_address: err_msg = scm_from_locale_string ("VM: Invalid program address"); finish_args = SCM_EOL; diff --git a/test-suite/standalone/test-conversion.c b/test-suite/standalone/test-conversion.c index 0dfa80a23..d20187465 100644 --- a/test-suite/standalone/test-conversion.c +++ b/test-suite/standalone/test-conversion.c @@ -834,7 +834,7 @@ ieee_init (void) before trying to use it. (But in practice we believe this is not a problem on any system guile is likely to target.) */ guile_Inf = INFINITY; -#elif HAVE_DINFINITY +#elif defined HAVE_DINFINITY /* OSF */ extern unsigned int DINFINITY[2]; guile_Inf = (*((double *) (DINFINITY))); @@ -853,7 +853,7 @@ ieee_init (void) #ifdef NAN /* C99 NAN, when available */ guile_NaN = NAN; -#elif HAVE_DQNAN +#elif defined HAVE_DQNAN { /* OSF */ extern unsigned int DQNAN[2];