diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-19 21:27:12 (GMT) |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-19 21:27:12 (GMT) |
commit | 26fbe7f1e68bb0c96da32491efcf3696fe6c299b (patch) | |
tree | c4d95289187a64e9c7517bf73d8208026c3d2fb3 /gl/m4/exponentd.m4 | |
parent | 5f79e3e9f62ca5487d9881973149136ba1d19d3e (diff) | |
download | monitoring-plugins-26fbe7f1e68bb0c96da32491efcf3696fe6c299b.tar.gz |
Sync with the latest Gnulib code (6f2d632)
Diffstat (limited to 'gl/m4/exponentd.m4')
-rw-r--r-- | gl/m4/exponentd.m4 | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/gl/m4/exponentd.m4 b/gl/m4/exponentd.m4 new file mode 100644 index 0000000..09df468 --- /dev/null +++ b/gl/m4/exponentd.m4 | |||
@@ -0,0 +1,116 @@ | |||
1 | # exponentd.m4 serial 3 | ||
2 | dnl Copyright (C) 2007-2008, 2010-2013 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | AC_DEFUN([gl_DOUBLE_EXPONENT_LOCATION], | ||
7 | [ | ||
8 | AC_CACHE_CHECK([where to find the exponent in a 'double'], | ||
9 | [gl_cv_cc_double_expbit0], | ||
10 | [ | ||
11 | AC_RUN_IFELSE( | ||
12 | [AC_LANG_SOURCE([[ | ||
13 | #include <float.h> | ||
14 | #include <stddef.h> | ||
15 | #include <stdio.h> | ||
16 | #include <string.h> | ||
17 | #define NWORDS \ | ||
18 | ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) | ||
19 | typedef union { double value; unsigned int word[NWORDS]; } memory_double; | ||
20 | static unsigned int ored_words[NWORDS]; | ||
21 | static unsigned int anded_words[NWORDS]; | ||
22 | static void add_to_ored_words (double x) | ||
23 | { | ||
24 | memory_double m; | ||
25 | size_t i; | ||
26 | /* Clear it first, in case sizeof (double) < sizeof (memory_double). */ | ||
27 | memset (&m, 0, sizeof (memory_double)); | ||
28 | m.value = x; | ||
29 | for (i = 0; i < NWORDS; i++) | ||
30 | { | ||
31 | ored_words[i] |= m.word[i]; | ||
32 | anded_words[i] &= m.word[i]; | ||
33 | } | ||
34 | } | ||
35 | int main () | ||
36 | { | ||
37 | size_t j; | ||
38 | FILE *fp = fopen ("conftest.out", "w"); | ||
39 | if (fp == NULL) | ||
40 | return 1; | ||
41 | for (j = 0; j < NWORDS; j++) | ||
42 | anded_words[j] = ~ (unsigned int) 0; | ||
43 | add_to_ored_words (0.25); | ||
44 | add_to_ored_words (0.5); | ||
45 | add_to_ored_words (1.0); | ||
46 | add_to_ored_words (2.0); | ||
47 | add_to_ored_words (4.0); | ||
48 | /* Remove bits that are common (e.g. if representation of the first mantissa | ||
49 | bit is explicit). */ | ||
50 | for (j = 0; j < NWORDS; j++) | ||
51 | ored_words[j] &= ~anded_words[j]; | ||
52 | /* Now find the nonzero word. */ | ||
53 | for (j = 0; j < NWORDS; j++) | ||
54 | if (ored_words[j] != 0) | ||
55 | break; | ||
56 | if (j < NWORDS) | ||
57 | { | ||
58 | size_t i; | ||
59 | for (i = j + 1; i < NWORDS; i++) | ||
60 | if (ored_words[i] != 0) | ||
61 | { | ||
62 | fprintf (fp, "unknown"); | ||
63 | return (fclose (fp) != 0); | ||
64 | } | ||
65 | for (i = 0; ; i++) | ||
66 | if ((ored_words[j] >> i) & 1) | ||
67 | { | ||
68 | fprintf (fp, "word %d bit %d", (int) j, (int) i); | ||
69 | return (fclose (fp) != 0); | ||
70 | } | ||
71 | } | ||
72 | fprintf (fp, "unknown"); | ||
73 | return (fclose (fp) != 0); | ||
74 | } | ||
75 | ]])], | ||
76 | [gl_cv_cc_double_expbit0=`cat conftest.out`], | ||
77 | [gl_cv_cc_double_expbit0="unknown"], | ||
78 | [ | ||
79 | dnl On ARM, there are two 'double' floating-point formats, used by | ||
80 | dnl different sets of instructions: The older FPA instructions assume | ||
81 | dnl that they are stored in big-endian word order, while the words | ||
82 | dnl (like integer types) are stored in little-endian byte order. | ||
83 | dnl The newer VFP instructions assume little-endian order | ||
84 | dnl consistently. | ||
85 | AC_EGREP_CPP([mixed_endianness], [ | ||
86 | #if defined arm || defined __arm || defined __arm__ | ||
87 | mixed_endianness | ||
88 | #endif | ||
89 | ], | ||
90 | [gl_cv_cc_double_expbit0="unknown"], | ||
91 | [ | ||
92 | pushdef([AC_MSG_CHECKING],[:])dnl | ||
93 | pushdef([AC_MSG_RESULT],[:])dnl | ||
94 | pushdef([AC_MSG_RESULT_UNQUOTED],[:])dnl | ||
95 | AC_C_BIGENDIAN( | ||
96 | [gl_cv_cc_double_expbit0="word 0 bit 20"], | ||
97 | [gl_cv_cc_double_expbit0="word 1 bit 20"], | ||
98 | [gl_cv_cc_double_expbit0="unknown"]) | ||
99 | popdef([AC_MSG_RESULT_UNQUOTED])dnl | ||
100 | popdef([AC_MSG_RESULT])dnl | ||
101 | popdef([AC_MSG_CHECKING])dnl | ||
102 | ]) | ||
103 | ]) | ||
104 | rm -f conftest.out | ||
105 | ]) | ||
106 | case "$gl_cv_cc_double_expbit0" in | ||
107 | word*bit*) | ||
108 | word=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word //' -e 's/ bit.*//'` | ||
109 | bit=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word.*bit //'` | ||
110 | AC_DEFINE_UNQUOTED([DBL_EXPBIT0_WORD], [$word], | ||
111 | [Define as the word index where to find the exponent of 'double'.]) | ||
112 | AC_DEFINE_UNQUOTED([DBL_EXPBIT0_BIT], [$bit], | ||
113 | [Define as the bit index in the word where to find bit 0 of the exponent of 'double'.]) | ||
114 | ;; | ||
115 | esac | ||
116 | ]) | ||