1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

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.
This commit is contained in:
Ludovic Courtès 2009-11-17 23:40:51 +01:00
parent c32b39b9cb
commit 56a3dcd431
13 changed files with 35 additions and 38 deletions

View file

@ -175,9 +175,9 @@
/* SCM_API is a macro prepended to all function and data definitions /* SCM_API is a macro prepended to all function and data definitions
which should be exported from libguile. */ 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"))) # 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 # define SCM_API __declspec(dllexport) extern
#elif defined _MSC_VER #elif defined _MSC_VER
# define SCM_API __declspec(dllimport) extern # define SCM_API __declspec(dllimport) extern

View file

@ -54,13 +54,8 @@ SCM_TO_TYPE_PROTO (SCM val)
return n; return n;
#else #else
#if TYPE_MIN == 0
if (n <= TYPE_MAX)
return n;
#else /* TYPE_MIN != 0 */
if (n >= TYPE_MIN && n <= TYPE_MAX) if (n >= TYPE_MIN && n <= TYPE_MAX)
return n; return n;
#endif /* TYPE_MIN != 0 */
else else
goto out_of_range; 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)); 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) if (n >= TYPE_MIN && n <= TYPE_MAX)
return n; return n;
#endif /* TYPE_MIN != 0 */
else else
goto out_of_range; goto out_of_range;

View file

@ -69,10 +69,10 @@
gnulib ftruncate.c has code using fcntl F_CHSIZE and F_FREESP, which gnulib ftruncate.c has code using fcntl F_CHSIZE and F_FREESP, which
might be possibilities if we've got other systems without ftruncate. */ 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) # define ftruncate(fd, size) chsize (fd, size)
#undef HAVE_FTRUNCATE # undef HAVE_FTRUNCATE
#define HAVE_FTRUNCATE 1 # define HAVE_FTRUNCATE 1
#endif #endif
#if SIZEOF_OFF_T == SIZEOF_INT #if SIZEOF_OFF_T == SIZEOF_INT

View file

@ -169,10 +169,10 @@ main (int argc, char *argv[])
#ifdef STDC_HEADERS #ifdef STDC_HEADERS
pf ("#define SCM_HAVE_STDC_HEADERS 1 /* 0 or 1 */\n"); pf ("#define SCM_HAVE_STDC_HEADERS 1 /* 0 or 1 */\n");
pf ("#include <stdlib.h>\n"); pf ("#include <stdlib.h>\n");
# if HAVE_SYS_TYPES_H # ifdef HAVE_SYS_TYPES_H
pf ("#include <sys/types.h>\n"); pf ("#include <sys/types.h>\n");
# endif # endif
# if HAVE_SYS_STDTYPES_H # ifdef HAVE_SYS_STDTYPES_H
pf ("#include <sys/stdtypes.h>\n"); pf ("#include <sys/stdtypes.h>\n");
# endif # endif
pf ("#include <stddef.h>\n"); pf ("#include <stddef.h>\n");
@ -411,7 +411,7 @@ main (int argc, char *argv[])
else else
pf ("/* #undef SCM_HAVE_THREAD_STORAGE_CLASS */\n"); pf ("/* #undef SCM_HAVE_THREAD_STORAGE_CLASS */\n");
#if USE_DLL_IMPORT #ifdef USE_DLL_IMPORT
pf ("\n"); pf ("\n");
pf ("/* Define some additional CPP macros on Win32 platforms. */\n"); pf ("/* Define some additional CPP macros on Win32 platforms. */\n");
pf ("# define __REGEX_IMPORT__ 1\n"); pf ("# define __REGEX_IMPORT__ 1\n");

View file

@ -619,7 +619,7 @@ guile_ieee_init (void)
before trying to use it. (But in practice we believe this is not a before trying to use it. (But in practice we believe this is not a
problem on any system guile is likely to target.) */ problem on any system guile is likely to target.) */
guile_Inf = INFINITY; guile_Inf = INFINITY;
#elif HAVE_DINFINITY #elif defined HAVE_DINFINITY
/* OSF */ /* OSF */
extern unsigned int DINFINITY[2]; extern unsigned int DINFINITY[2];
guile_Inf = (*((double *) (DINFINITY))); guile_Inf = (*((double *) (DINFINITY)));
@ -642,7 +642,7 @@ guile_ieee_init (void)
#ifdef NAN #ifdef NAN
/* C99 NAN, when available */ /* C99 NAN, when available */
guile_NaN = NAN; guile_NaN = NAN;
#elif HAVE_DQNAN #elif defined HAVE_DQNAN
{ {
/* OSF */ /* OSF */
extern unsigned int DQNAN[2]; extern unsigned int DQNAN[2];

View file

@ -80,7 +80,7 @@
gnulib ftruncate.c has code using fcntl F_CHSIZE and F_FREESP, which gnulib ftruncate.c has code using fcntl F_CHSIZE and F_FREESP, which
might be possibilities if we've got other systems without ftruncate. */ 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) #define ftruncate(fd, size) chsize (fd, size)
#undef HAVE_FTRUNCATE #undef HAVE_FTRUNCATE
#define HAVE_FTRUNCATE 1 #define HAVE_FTRUNCATE 1

View file

@ -624,7 +624,7 @@ SCM_DEFINE (scm_setsockopt, "setsockopt", 4, 0, 0,
struct linger opt_linger; struct linger opt_linger;
#endif #endif
#if HAVE_STRUCT_IP_MREQ #ifdef HAVE_STRUCT_IP_MREQ
struct ip_mreq opt_mreq; struct ip_mreq opt_mreq;
#endif #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 && if (ilevel == IPPROTO_IP &&
(ioptname == IP_ADD_MEMBERSHIP || ioptname == IP_DROP_MEMBERSHIP)) (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); *args = SCM_CDR (*args);
soka = (struct sockaddr_in *) scm_malloc (sizeof (struct sockaddr_in)); 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); soka->sin_len = sizeof (struct sockaddr_in);
#endif #endif
soka->sin_family = AF_INET; 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)); 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); soka->sin6_len = sizeof (struct sockaddr_in6);
#endif #endif
soka->sin6_family = AF_INET6; soka->sin6_family = AF_INET6;

View file

@ -96,7 +96,7 @@
} \ } \
while (0) while (0)
#if SCM_STRING_LENGTH_HISTOGRAM #ifdef SCM_STRING_LENGTH_HISTOGRAM
static size_t lenhist[1001]; static size_t lenhist[1001];
#endif #endif
@ -114,7 +114,7 @@ make_stringbuf (size_t len)
SCM buf; SCM buf;
#if SCM_STRING_LENGTH_HISTOGRAM #ifdef SCM_STRING_LENGTH_HISTOGRAM
if (len < 1000) if (len < 1000)
lenhist[len]++; lenhist[len]++;
else else
@ -140,7 +140,7 @@ make_wide_stringbuf (size_t len)
SCM buf; SCM buf;
size_t raw_len; size_t raw_len;
#if SCM_STRING_LENGTH_HISTOGRAM #ifdef SCM_STRING_LENGTH_HISTOGRAM
if (len < 1000) if (len < 1000)
lenhist[len]++; lenhist[len]++;
else else
@ -972,7 +972,7 @@ SCM_DEFINE (scm_sys_symbol_dump, "%symbol-dump", 1, 0, 0, (SCM sym),
} }
#undef FUNC_NAME #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), "") SCM_DEFINE (scm_sys_stringbuf_hist, "%stringbuf-hist", 0, 0, 0, (void), "")
#define FUNC_NAME s_scm_sys_stringbuf_hist #define FUNC_NAME s_scm_sys_stringbuf_hist
@ -1040,9 +1040,11 @@ SCM_DEFINE (scm_string, "string", 0, 0, 1,
if (wide == 0) if (wide == 0)
{ {
char *buf;
result = scm_i_make_string (len, NULL); result = scm_i_make_string (len, NULL);
result = scm_i_string_start_writing (result); 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)) while (len > 0 && scm_is_pair (rest))
{ {
SCM elt = SCM_CAR (rest); SCM elt = SCM_CAR (rest);
@ -1055,9 +1057,11 @@ SCM_DEFINE (scm_string, "string", 0, 0, 1,
} }
else else
{ {
scm_t_wchar *buf;
result = scm_i_make_wide_string (len, NULL); result = scm_i_make_wide_string (len, NULL);
result = scm_i_string_start_writing (result); 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)) while (len > 0 && scm_is_pair (rest))
{ {
SCM elt = SCM_CAR (rest); SCM elt = SCM_CAR (rest);

View 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_string_dump (SCM);
SCM_API SCM scm_sys_symbol_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); SCM_API SCM scm_sys_stringbuf_hist (void);
#endif #endif

View file

@ -31,10 +31,13 @@
/* picks up scmconfig.h too */ /* picks up scmconfig.h too */
#include "libguile/__scm.h" #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 */ # include <inttypes.h> /* for INTPTR_MAX and friends */
#else #else
# if HAVE_STDINT_H # ifdef HAVE_STDINT_H
# include <stdint.h> /* for INTPTR_MAX and friends */ # include <stdint.h> /* for INTPTR_MAX and friends */
# endif # endif
#endif #endif

View 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. /* This method for MacOS X.
It'd be nice if there was some documentation on pthread_get_stackaddr_np, 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. */ but as of 2006 there's nothing obvious at apple.com. */

View 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"); err_msg = scm_from_locale_string ("VM: Bad wide string length: ~S");
goto vm_error; goto vm_error;
#if VM_CHECK_IP #ifdef VM_CHECK_IP
vm_error_invalid_address: vm_error_invalid_address:
err_msg = scm_from_locale_string ("VM: Invalid program address"); err_msg = scm_from_locale_string ("VM: Invalid program address");
finish_args = SCM_EOL; finish_args = SCM_EOL;

View file

@ -834,7 +834,7 @@ ieee_init (void)
before trying to use it. (But in practice we believe this is not a before trying to use it. (But in practice we believe this is not a
problem on any system guile is likely to target.) */ problem on any system guile is likely to target.) */
guile_Inf = INFINITY; guile_Inf = INFINITY;
#elif HAVE_DINFINITY #elif defined HAVE_DINFINITY
/* OSF */ /* OSF */
extern unsigned int DINFINITY[2]; extern unsigned int DINFINITY[2];
guile_Inf = (*((double *) (DINFINITY))); guile_Inf = (*((double *) (DINFINITY)));
@ -853,7 +853,7 @@ ieee_init (void)
#ifdef NAN #ifdef NAN
/* C99 NAN, when available */ /* C99 NAN, when available */
guile_NaN = NAN; guile_NaN = NAN;
#elif HAVE_DQNAN #elif defined HAVE_DQNAN
{ {
/* OSF */ /* OSF */
extern unsigned int DQNAN[2]; extern unsigned int DQNAN[2];