2010-01-11 Eric Blake <ebb9@byu.net>
+ math: add portability warnings for classification macros
+ * modules/math (Depends-on): Add warn-on-use.
+ (Makefile.am): Provide new substitutions.
+ * m4/math_h.m4 (gl_MATH_H): Require inline.
+ * lib/math.in.h (_GL_WARN_REAL_FLOATING_DECL)
+ (_GL_WARN_REAL_FLOATING_IMPL): New helper macros.
+ (isfinite, isinf, isnan, signbit) [GNULIB_POSIXCHECK]: Use them to
+ implement warnings.
+
unistd: warn on use of environ without module
* modules/unistd (Depends-on): Add warn-on-use.
(Makefile.am): Provide new substitutions.
/* The definition of _GL_ARG_NONNULL is copied here. */
+/* Helper macros to define a portability warning for the
+ classification macro FUNC called with VALUE. POSIX declares the
+ classification macros with an argument of real-floating (that is,
+ one of float, double, or long double). */
+#define _GL_WARN_REAL_FLOATING_DECL(func) \
+static inline int \
+rpl_ ## func ## f (float f) \
+{ \
+ return func (f); \
+} \
+static inline int \
+rpl_ ## func ## d (double d) \
+{ \
+ return func (d); \
+} \
+static inline int \
+rpl_ ## func ## l (long double l) \
+{ \
+ return func (l); \
+} \
+_GL_WARN_ON_USE (rpl_ ## func ## f, #func " is unportable - " \
+ "use gnulib module " #func " for portability"); \
+_GL_WARN_ON_USE (rpl_ ## func ## d, #func " is unportable - " \
+ "use gnulib module " #func " for portability"); \
+_GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \
+ "use gnulib module " #func " for portability")
+#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \
+ (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \
+ : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \
+ : rpl_ ## func ## l (value))
+
#ifdef __cplusplus
extern "C" {
gl_isfinitef (x))
# endif
#elif defined GNULIB_POSIXCHECK
- /* How to override a macro? */
+# if defined isfinite
+_GL_WARN_REAL_FLOATING_DECL (isfinite);
+# undef isfinite
+# define isfinite(x) _GL_WARN_REAL_FLOATING_IMPL (isfinite, x)
+# endif
#endif
gl_isinff (x))
# endif
#elif defined GNULIB_POSIXCHECK
- /* How to override a macro? */
+# if defined isinf
+_GL_WARN_REAL_FLOATING_DECL (isinf);
+# undef isinf
+# define isinf(x) _GL_WARN_REAL_FLOATING_IMPL (isinf, x)
+# endif
#endif
gl_isnan_f (x))
# endif
#elif defined GNULIB_POSIXCHECK
- /* How to override a macro? */
+# if defined isnan
+_GL_WARN_REAL_FLOATING_DECL (isnan);
+# undef isnan
+# define isnan(x) _GL_WARN_REAL_FLOATING_IMPL (isnan, x)
+# endif
#endif
gl_signbitf (x))
# endif
#elif defined GNULIB_POSIXCHECK
- /* How to override a macro? */
+# if defined signbit
+_GL_WARN_REAL_FLOATING_DECL (signbit);
+# undef signbit
+# define signbit(x) _GL_WARN_REAL_FLOATING_IMPL (signbit, x)
+# endif
#endif
-# math_h.m4 serial 14
+# math_h.m4 serial 15
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
[
AC_REQUIRE([gl_MATH_H_DEFAULTS])
gl_CHECK_NEXT_HEADERS([math.h])
+ AC_REQUIRE([AC_C_INLINE])
+
AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]],
[[/* Solaris 10 has a broken definition of NAN. Other platforms
m4/math_h.m4
Depends-on:
+arg-nonnull
include_next
link-warning
-arg-nonnull
+warn-on-use
configure.ac:
gl_MATH_H
# We need the following in order to create <math.h> when the system
# doesn't have one that works with the given compiler.
-math.h: math.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+math.h: math.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
-e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/math.in.h; \
} > $@-t && \
mv $@-t $@