diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-04-28 16:11:47 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-04-28 16:11:47 +0200 |
commit | 47364430f0ec21e2e4a8923a2fc6320ddbf42887 (patch) | |
tree | 396438725edab170904b478eb4615c71792ba8e3 /lib | |
parent | f1d294f3a7f043966571e4c04297d3688070aefa (diff) | |
download | libtasn1-47364430f0ec21e2e4a8923a2fc6320ddbf42887.tar.gz libtasn1-47364430f0ec21e2e4a8923a2fc6320ddbf42887.tar.bz2 libtasn1-47364430f0ec21e2e4a8923a2fc6320ddbf42887.zip |
Added minmax gnulib module.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gllib/Makefile.am | 8 | ||||
-rw-r--r-- | lib/gllib/minmax.h | 60 | ||||
-rw-r--r-- | lib/glm4/gnulib-cache.m4 | 3 | ||||
-rw-r--r-- | lib/glm4/gnulib-comp.m4 | 4 | ||||
-rw-r--r-- | lib/glm4/minmax.m4 | 44 |
5 files changed, 117 insertions, 2 deletions
diff --git a/lib/gllib/Makefile.am b/lib/gllib/Makefile.am index 19e9881..96932d1 100644 --- a/lib/gllib/Makefile.am +++ b/lib/gllib/Makefile.am @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=lgl --no-vc-files hash-pjw-bare intprops lib-symbol-versions lib-symbol-visibility stdint strverscmp +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=lgl --no-vc-files hash-pjw-bare intprops lib-symbol-versions lib-symbol-visibility minmax stdint strverscmp AUTOMAKE_OPTIONS = 1.9.6 gnits @@ -82,6 +82,12 @@ AM_CFLAGS += $(CFLAG_VISIBILITY) ## end gnulib module lib-symbol-visibility +## begin gnulib module minmax + +libgnu_la_SOURCES += minmax.h + +## end gnulib module minmax + ## begin gnulib module snippet/arg-nonnull # The BUILT_SOURCES created by this Makefile snippet are not used via #include diff --git a/lib/gllib/minmax.h b/lib/gllib/minmax.h new file mode 100644 index 0000000..5a763f8 --- /dev/null +++ b/lib/gllib/minmax.h @@ -0,0 +1,60 @@ +/* MIN, MAX macros. + Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2014 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. */ + +#ifndef _MINMAX_H +#define _MINMAX_H + +/* Note: MIN, MAX are also defined in <sys/param.h> on some systems + (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about + MIN, MAX macro redefinitions on some systems; the workaround is to + #include this file as the last one among the #include list. */ + +/* Before we define the following symbols we get the <limits.h> file + since otherwise we get redefinitions on some systems if <limits.h> is + included after this file. Likewise for <sys/param.h>. + If more than one of these system headers define MIN and MAX, pick just + one of the headers (because the definitions most likely are the same). */ +#if HAVE_MINMAX_IN_LIMITS_H +# include <limits.h> +#elif HAVE_MINMAX_IN_SYS_PARAM_H +# include <sys/param.h> +#endif + +/* Note: MIN and MAX should be used with two arguments of the + same type. They might not return the minimum and maximum of their two + arguments, if the arguments have different types or have unusual + floating-point values. For example, on a typical host with 32-bit 'int', + 64-bit 'long long', and 64-bit IEEE 754 'double' types: + + MAX (-1, 2147483648) returns 4294967295. + MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0. + MAX (NaN, 0.0) returns 0.0. + MAX (+0.0, -0.0) returns -0.0. + + and in each case the answer is in some sense bogus. */ + +/* MAX(a,b) returns the maximum of A and B. */ +#ifndef MAX +# define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif + +/* MIN(a,b) returns the minimum of A and B. */ +#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + +#endif /* _MINMAX_H */ diff --git a/lib/glm4/gnulib-cache.m4 b/lib/glm4/gnulib-cache.m4 index 76ab890..052a4e5 100644 --- a/lib/glm4/gnulib-cache.m4 +++ b/lib/glm4/gnulib-cache.m4 @@ -27,7 +27,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=lgl --no-vc-files hash-pjw-bare intprops lib-symbol-versions lib-symbol-visibility stdint strverscmp +# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=lgl --no-vc-files hash-pjw-bare intprops lib-symbol-versions lib-symbol-visibility minmax stdint strverscmp # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) @@ -36,6 +36,7 @@ gl_MODULES([ intprops lib-symbol-versions lib-symbol-visibility + minmax stdint strverscmp ]) diff --git a/lib/glm4/gnulib-comp.m4 b/lib/glm4/gnulib-comp.m4 index 8cbba4d..3af169f 100644 --- a/lib/glm4/gnulib-comp.m4 +++ b/lib/glm4/gnulib-comp.m4 @@ -47,6 +47,7 @@ AC_DEFUN([lgl_EARLY], # Code from module intprops: # Code from module lib-symbol-versions: # Code from module lib-symbol-visibility: + # Code from module minmax: # Code from module multiarch: # Code from module snippet/arg-nonnull: # Code from module snippet/c++defs: @@ -76,6 +77,7 @@ AC_DEFUN([lgl_INIT], AC_REQUIRE([gl_EXTERN_INLINE]) gl_LD_VERSION_SCRIPT gl_VISIBILITY + gl_MINMAX gl_MULTIARCH gt_TYPE_SSIZE_T gl_STDDEF_H @@ -231,6 +233,7 @@ AC_DEFUN([lgl_FILE_LIST], [ lib/hash-pjw-bare.c lib/hash-pjw-bare.h lib/intprops.h + lib/minmax.h lib/stddef.in.h lib/stdint.in.h lib/string.in.h @@ -244,6 +247,7 @@ AC_DEFUN([lgl_FILE_LIST], [ m4/include_next.m4 m4/ld-version-script.m4 m4/longlong.m4 + m4/minmax.m4 m4/multiarch.m4 m4/off_t.m4 m4/ssize_t.m4 diff --git a/lib/glm4/minmax.m4 b/lib/glm4/minmax.m4 new file mode 100644 index 0000000..edbeb43 --- /dev/null +++ b/lib/glm4/minmax.m4 @@ -0,0 +1,44 @@ +# minmax.m4 serial 4 +dnl Copyright (C) 2005, 2009-2014 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_PREREQ([2.53]) + +AC_DEFUN([gl_MINMAX], +[ + AC_REQUIRE([gl_PREREQ_MINMAX]) +]) + +# Prerequisites of lib/minmax.h. +AC_DEFUN([gl_PREREQ_MINMAX], +[ + gl_MINMAX_IN_HEADER([limits.h]) + gl_MINMAX_IN_HEADER([sys/param.h]) +]) + +dnl gl_MINMAX_IN_HEADER(HEADER) +dnl The parameter has to be a literal header name; it cannot be macro, +dnl nor a shell variable. (Because autoheader collects only AC_DEFINE +dnl invocations with a literal macro name.) +AC_DEFUN([gl_MINMAX_IN_HEADER], +[ + m4_pushdef([header], AS_TR_SH([$1])) + m4_pushdef([HEADER], AS_TR_CPP([$1])) + AC_CACHE_CHECK([whether <$1> defines MIN and MAX], + [gl_cv_minmax_in_]header, + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <$1> + int x = MIN (42, 17);]], + [[]])], + [gl_cv_minmax_in_]header[=yes], + [gl_cv_minmax_in_]header[=no])]) + if test $gl_cv_minmax_in_[]header = yes; then + AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1, + [Define to 1 if <$1> defines the MIN and MAX macros.]) + fi + m4_popdef([HEADER]) + m4_popdef([header]) +]) |