Remove references to undefined macros.
authorLudovic Courtès <ludo@gnu.org>
Tue, 17 Nov 2009 22:40:51 +0000 (23:40 +0100)
committerLudovic Courtès <ludo@gnu.org>
Tue, 17 Nov 2009 22:42:22 +0000 (23:42 +0100)
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.

13 files changed:
libguile/__scm.h
libguile/conv-uinteger.i.c
libguile/fports.c
libguile/gen-scmconfig.c
libguile/numbers.c
libguile/ports.c
libguile/socket.c
libguile/strings.c
libguile/strings.h
libguile/tags.h
libguile/threads.c
libguile/vm-engine.c
test-suite/standalone/test-conversion.c

index 8bb1b1a..c6cbe3f 100644 (file)
 /* 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
index 52f49f7..d6b969c 100644 (file)
@@ -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;
 
index 12b7918..3e911f2 100644 (file)
    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
index bc0c2df..f9fff6e 100644 (file)
@@ -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 <stdlib.h>\n");
-# if HAVE_SYS_TYPES_H
+# ifdef HAVE_SYS_TYPES_H
   pf ("#include <sys/types.h>\n");
 # endif
-# if HAVE_SYS_STDTYPES_H
+# ifdef HAVE_SYS_STDTYPES_H
   pf ("#include <sys/stdtypes.h>\n");
 # endif
   pf ("#include <stddef.h>\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");
index 20fda02..15c49c0 100644 (file)
@@ -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];
index e71ee0a..1fd6f63 100644 (file)
@@ -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
index cd31319..092f6eb 100644 (file)
@@ -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;
index 21295ad..1c74c6a 100644 (file)
@@ -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);
index 4e5f700..601bd9c 100644 (file)
@@ -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
 
index 4a68f9c..c8cd621 100644 (file)
 /* 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 <inttypes.h>  /* for INTPTR_MAX and friends */
 #else
-# if HAVE_STDINT_H
+# ifdef HAVE_STDINT_H
 #  include <stdint.h>   /* for INTPTR_MAX and friends */
 # endif
 #endif
index 82b39f8..1527e01 100644 (file)
@@ -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.  */
index 5d8f655..aaa8884 100644 (file)
@@ -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;
index 0dfa80a..d201874 100644 (file)
@@ -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];