diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-23 23:31:33 +0200 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-23 23:31:33 +0200 |
commit | 157f5234c463abe1b23a2f86dd182f40f99020fe (patch) | |
tree | 8428dbbb979942caa68dc181452c2354c1b7e120 | |
parent | 08c066cac2efdfcf569e47609e9e1b0a947ce129 (diff) | |
download | xine-lib-157f5234c463abe1b23a2f86dd182f40f99020fe.tar.gz xine-lib-157f5234c463abe1b23a2f86dd182f40f99020fe.tar.bz2 |
Check for MIN/MAX macro and include the header for them if found.
The MIN/MAX macro are quite often used on the source code to find the
minimum or maximum value between two, instead of defining it per-unit,
check if the system provides them include the right header, otherwise
define them during configure run.
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | lib/os_internal.h | 4 | ||||
-rw-r--r-- | m4/Makefile.am | 1 | ||||
-rw-r--r-- | m4/misc.m4 | 58 |
4 files changed, 67 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 79c93f448..6490374c7 100644 --- a/configure.ac +++ b/configure.ac @@ -2177,6 +2177,10 @@ AC_CHECK_FUNC(opendir, AC_MSG_ERROR([dirent is needed (opendir, readdir, ...)]) fi]) +XINE_CHECK_MINMAX([], [ + AC_DEFINE([MIN(x, y)], [(x > y) ? y : x], [Get the minimum value between two]) + AC_DEFINE([MAX(x, y)], [(x > y) ? x : y], [Get the maximum value between two]) + ]) dnl --------------------------------------------- dnl cflags and debug cflags diff --git a/lib/os_internal.h b/lib/os_internal.h index 11601bbdf..6e6e14a3d 100644 --- a/lib/os_internal.h +++ b/lib/os_internal.h @@ -4,6 +4,10 @@ #include <stddef.h> #include <stdarg.h> +#ifdef HAVE_SYS_PARAM_H +# include <sys/param.h> +#endif + #ifdef HOST_OS_DARWIN /* Darwin (Mac OS X) needs __STDC_LIBRARY_SUPPORTED__ for SCNx64 and * SCNxMAX macros */ diff --git a/m4/Makefile.am b/m4/Makefile.am index ddf3a9425..bcaa78a49 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -24,6 +24,7 @@ EXTRA_DIST = glibc2.m4 intdiv0.m4 intmax.m4 inttypes.m4 inttypes_h.m4 inttypes-p lcmessage.m4 \ libFLAC.m4 \ libfame.m4 \ + misc.m4 \ opengl.m4 \ optimizations.m4 \ pkg.m4 \ diff --git a/m4/misc.m4 b/m4/misc.m4 new file mode 100644 index 000000000..ab0d55510 --- /dev/null +++ b/m4/misc.m4 @@ -0,0 +1,58 @@ +dnl Miscellaneous M4 macros for configure +dnl Copyright (c) 2008 Diego Pettenò <flameeyes@gmail.com> +dnl Copyright (c) 2008 xine project +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2, or (at your option) +dnl any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. +dnl +dnl As a special exception, the copyright owners of the +dnl macro gives unlimited permission to copy, distribute and modify the +dnl configure scripts that are the output of Autoconf when processing the +dnl Macro. You need not follow the terms of the GNU General Public +dnl License when using or distributing such scripts, even though portions +dnl of the text of the Macro appear in them. The GNU General Public +dnl License (GPL) does govern all other use of the material that +dnl constitutes the Autoconf Macro. +dnl +dnl This special exception to the GPL applies to versions of the +dnl Autoconf Macro released by this project. When you make and +dnl distribute a modified version of the Autoconf Macro, you may extend +dnl this special exception to the GPL to apply to your modified version as +dnl well. + +AC_DEFUN([XINE_CHECK_MINMAX], [ + AC_CHECK_HEADERS([sys/param.h]) + AC_CACHE_CHECK([for MIN()/MAX() macros], + xine_cv_minmax, + [ + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + #ifdef HAVE_SYS_PARAM_H + # include <sys/param.h> + #endif + ], [ + int a = MIN(1, 3); + int b = MAX(2, 3); + ])], + [xine_cv_minmax=yes], + [xine_cv_minmax=no]) + ]) + + if test x$xine_cv_minmax = xyes; then + ifelse([$1], , [:], [$1]) + else + ifelse([$2], , [:], [$2]) + fi +]) |