realloc: more improvements for realloc (p, 0)
[gnulib.git] / m4 / minus-zero.m4
blob4837287b24edda57412045280f2d57ce970733a8
1 # minus-zero.m4
2 # serial 2
3 dnl Copyright (C) 2010-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
9 # Macros for floating-point negative zero.
10 # Keep in sync with tests/minus-zero.h!
12 # Expands to code that defines a variable or macro minus_zerof.
13 AC_DEFUN([gl_FLOAT_MINUS_ZERO_CODE],
15 #include <float.h>
16 /* minus_zerof represents the value -0.0f.  */
17 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
18    ICC 10.0 has a bug when optimizing the expression -zero.
19    The expression -FLT_MIN * FLT_MIN does not work when cross-compiling
20    to PowerPC on Mac OS X 10.5.  */
21 #if defined __hpux || defined __sgi || defined __ICC
22 static float
23 compute_minus_zerof (void)
25   return -FLT_MIN * FLT_MIN;
27 # define minus_zerof compute_minus_zerof ()
28 #else
29 float minus_zerof = -0.0f;
30 #endif
31 ]])
33 # Expands to code that defines a variable or macro minus_zerod.
34 AC_DEFUN([gl_DOUBLE_MINUS_ZERO_CODE],
36 #include <float.h>
37 /* minus_zerod represents the value -0.0.  */
38 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
39    ICC 10.0 has a bug when optimizing the expression -zero.
40    The expression -DBL_MIN * DBL_MIN does not work when cross-compiling
41    to PowerPC on Mac OS X 10.5.  */
42 #if defined __hpux || defined __sgi || defined __ICC
43 static double
44 compute_minus_zerod (void)
46   return -DBL_MIN * DBL_MIN;
48 # define minus_zerod compute_minus_zerod ()
49 #else
50 double minus_zerod = -0.0;
51 #endif
52 ]])
54 # Expands to code that defines a variable or macro minus_zerol.
55 AC_DEFUN([gl_LONG_DOUBLE_MINUS_ZERO_CODE],
57 #include <float.h>
58 #if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
59 # undef LDBL_MIN
60 # define LDBL_MIN        3.3621031431120935063E-4932L
61 #endif
62 /* minus_zerol represents the value -0.0L.  */
63 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
64    IRIX cc can't put -0.0L into .data, but can compute at runtime.
65    ICC 10.0 has a bug when optimizing the expression -zero.
66    The expression -LDBL_MIN * LDBL_MIN does not work when cross-compiling
67    to PowerPC on Mac OS X 10.5.  */
68 #if defined __hpux || defined __sgi || defined __ICC
69 static long double
70 compute_minus_zerol (void)
72   return -LDBL_MIN * LDBL_MIN;
74 # define minus_zerol compute_minus_zerol ()
75 #else
76 long double minus_zerol = -0.0L;
77 #endif
78 ]])