annotate lib/minmax.h @ 40231:9b3c79fdfe0b

strtod: fix clash with strtold Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817). * lib/strtod.c (compute_minus_zero, minus_zero): Simplify by remving the macro / external variable, and having just a function. User changed. This avoids the need for an external variable that might clash.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 11 Mar 2019 16:40:29 -0700
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4207
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* MIN, MAX macros.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2019 Free Software
12559
c2cbabec01dd update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents: 12518
diff changeset
3 Foundation, Inc.
4207
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 any later version.
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 GNU General Public License for more details.
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
16 along with this program; if not, see <https://www.gnu.org/licenses/>. */
4207
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 #ifndef _MINMAX_H
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #define _MINMAX_H
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
4211
086eea465aaa Comments.
Bruno Haible <bruno@clisp.org>
parents: 4207
diff changeset
21 /* Note: MIN, MAX are also defined in <sys/param.h> on some systems
086eea465aaa Comments.
Bruno Haible <bruno@clisp.org>
parents: 4207
diff changeset
22 (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about
086eea465aaa Comments.
Bruno Haible <bruno@clisp.org>
parents: 4207
diff changeset
23 MIN, MAX macro redefinitions on some systems; the workaround is to
086eea465aaa Comments.
Bruno Haible <bruno@clisp.org>
parents: 4207
diff changeset
24 #include this file as the last one among the #include list. */
086eea465aaa Comments.
Bruno Haible <bruno@clisp.org>
parents: 4207
diff changeset
25
4207
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 /* Before we define the following symbols we get the <limits.h> file
5882
4166e2857787 Add autoconf tests for the 'minmax' module.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
27 since otherwise we get redefinitions on some systems if <limits.h> is
4166e2857787 Add autoconf tests for the 'minmax' module.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
28 included after this file. Likewise for <sys/param.h>.
4166e2857787 Add autoconf tests for the 'minmax' module.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
29 If more than one of these system headers define MIN and MAX, pick just
4166e2857787 Add autoconf tests for the 'minmax' module.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
30 one of the headers (because the definitions most likely are the same). */
4166e2857787 Add autoconf tests for the 'minmax' module.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
31 #if HAVE_MINMAX_IN_LIMITS_H
4166e2857787 Add autoconf tests for the 'minmax' module.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
32 # include <limits.h>
4166e2857787 Add autoconf tests for the 'minmax' module.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
33 #elif HAVE_MINMAX_IN_SYS_PARAM_H
4166e2857787 Add autoconf tests for the 'minmax' module.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
34 # include <sys/param.h>
4166e2857787 Add autoconf tests for the 'minmax' module.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
35 #endif
4207
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36
4754
c6f70c2457d2 Omit the special code that used __typeof__ for MIN and MAX,
Paul Eggert <eggert@cs.ucla.edu>
parents: 4211
diff changeset
37 /* Note: MIN and MAX should be used with two arguments of the
4207
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 same type. They might not return the minimum and maximum of their two
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 arguments, if the arguments have different types or have unusual
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 floating-point values. For example, on a typical host with 32-bit 'int',
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 64-bit 'long long', and 64-bit IEEE 754 'double' types:
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 MAX (-1, 2147483648) returns 4294967295.
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 MAX (NaN, 0.0) returns 0.0.
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 MAX (+0.0, -0.0) returns -0.0.
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 and in each case the answer is in some sense bogus. */
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 /* MAX(a,b) returns the maximum of A and B. */
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 #ifndef MAX
4754
c6f70c2457d2 Omit the special code that used __typeof__ for MIN and MAX,
Paul Eggert <eggert@cs.ucla.edu>
parents: 4211
diff changeset
52 # define MAX(a,b) ((a) > (b) ? (a) : (b))
4207
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 #endif
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 /* MIN(a,b) returns the minimum of A and B. */
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 #ifndef MIN
4754
c6f70c2457d2 Omit the special code that used __typeof__ for MIN and MAX,
Paul Eggert <eggert@cs.ucla.edu>
parents: 4211
diff changeset
57 # define MIN(a,b) ((a) < (b) ? (a) : (b))
4207
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 #endif
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59
b9f1372430fa New module minmax.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 #endif /* _MINMAX_H */