changeset 15453:4d960b078272

build: Remove unnecessary AC_CHECK_FUNCS calls. * configure.ac: Remove unnecessary AC_CHECK_FUNCS calls. Segregate some AC_CHECK_FUNCS calls to only be tested when building GUI. Segregate some AC_CHECK_FUNCS calls to only be tested on certain platforms. * __magick_read__.cc: Shorten comment to less than 80 characters. * ov-ch-mat.cc: Add workaround for toascii if function is not available. * lo-mappers.cc: Use log2f and exp2f if they are available. Otherwise, fall back to double versions log2 and exp2 or other workaround.
author Rik <rik@octave.org>
date Sat, 29 Sep 2012 11:57:44 -0700
parents 219479b461b8
children 2d7bdbdd9f5d
files configure.ac libinterp/dldfcn/__magick_read__.cc libinterp/octave-value/ov-ch-mat.cc liboctave/numeric/lo-mappers.cc
diffstat 4 files changed, 52 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac
+++ b/configure.ac
@@ -878,6 +878,9 @@
   AC_LANG_POP(C++)
   CPPFLAGS="$save_CPPFLAGS"
   LIBS="$save_LIBS"
+
+  AC_CHECK_FUNCS([setlocale], [],
+                 [warn_magick="$magick++ requires setlocale function.  The imread function for reading image files will not be fully functional."])
 ])
 
 if test -z "$warn_magick"; then
@@ -1913,18 +1916,24 @@
 
 ### Checks for functions and variables.
 
+dnl These checks define/undefine HAVE_FUNCNAME in config.h.
+dnl Code tests HAVE_FUNCNAME and either uses function or provides workaround.
 dnl Use multiple AC_CHECKs to avoid line continuations '\' in list
-AC_CHECK_FUNCS([basename canonicalize_file_name chmod dup2])
+AC_CHECK_FUNCS([canonicalize_file_name dup2])
 AC_CHECK_FUNCS([endgrent endpwent execvp expm1 expm1f fork])
 AC_CHECK_FUNCS([getegid geteuid getgid getgrent getgrgid getgrnam])
-AC_CHECK_FUNCS([getpgrp getpid getppid getpwent getpwuid getuid getwd])
-AC_CHECK_FUNCS([isascii kill lgamma lgammaf lgamma_r lgammaf_r])
-AC_CHECK_FUNCS([localtime_r log1p log1pf mkstemp modf pipe pow putenv])
-AC_CHECK_FUNCS([realpath resolvepath rindex roundl select setgrent])
-AC_CHECK_FUNCS([setlocale setpwent setvbuf siglongjmp])
-AC_CHECK_FUNCS([sqrt strsignal tempnam tgammaf umask])
-AC_CHECK_FUNCS([uname utime x_utime waitpid])
-AC_CHECK_FUNCS([_chmod _kbhit _utime32])
+AC_CHECK_FUNCS([getpgrp getpid getppid getpwent getpwuid getuid])
+AC_CHECK_FUNCS([kill lgamma lgammaf lgamma_r lgammaf_r])
+AC_CHECK_FUNCS([log1p log1pf pipe])
+AC_CHECK_FUNCS([realpath resolvepath roundl])
+AC_CHECK_FUNCS([select setgrent setpwent siglongjmp strsignal])
+AC_CHECK_FUNCS([tempnam tgammaf toascii])
+AC_CHECK_FUNCS([umask uname waitpid])
+AC_CHECK_FUNCS([_kbhit])
+
+dnl There are no workarounds in the code for missing these functions.
+AC_CHECK_FUNCS([modf pow putenv sqrt sqrtf], [],
+               [AC_MSG_ERROR([Missing function required to build Octave])])
 
 ## exp2, round, tgamma function checks
 AC_LANG_PUSH(C++)
@@ -2037,6 +2046,14 @@
   ;;
 esac
 
+## Windows-specific use of functions
+case $canonical_host_type in
+  *-*-mingw* | *-*-msdosmsvc*)
+    AC_CHECK_FUNCS([setvbuf], [],
+                   [AC_MSG_ERROR([Missing function required to build Octave])])
+    ;;
+esac
+
 ## Cygwin kluge for getrusage.
 AC_CHECK_FUNCS([getrusage])
 case $canonical_host_type in
@@ -2270,16 +2287,21 @@
   OCTAVE_CHECK_FUNC_FINDFIRST_MODERN
   OCTAVE_CHECK_FUNC_SETPLACEHOLDERTEXT
 
+  AC_CHECK_FUNCS([setlocale], [],
+                 [AC_MSG_ERROR([Missing function required to build GUI])])
+
   case $canonical_host_type in
     *-*-mingw* | *-*-msdosmsvc*)
       win32_terminal=yes
+      AC_CHECK_FUNCS([setvbuf], [],
+                     [AC_MSG_ERROR([Missing function required to build GUI])])
       ;;
     *)
       AC_CHECK_HEADERS([pty.h libutil.h util.h])
       AC_SEARCH_LIBS([openpty], [util],
         [AC_DEFINE(HAVE_OPENPTY, [], [Define whether openpty exists])])
-      AC_CHECK_FUNCS([chown ftruncate mmap munmap], [],
-                     [AC_MSG_ERROR([Missing function required by GUI])])
+      AC_CHECK_FUNCS([chmod chown ftruncate mmap munmap], [],
+                     [AC_MSG_ERROR([Missing function required to build GUI])])
       ;;
   esac
 else
--- a/libinterp/dldfcn/__magick_read__.cc
+++ b/libinterp/dldfcn/__magick_read__.cc
@@ -381,7 +381,7 @@
 
   if (! initialized)
     {
-      // Save the locale as GraphicsMagick might change this (depending on version)
+      // Save locale as GraphicsMagick might change this (depending on version)
       const char *static_locale = setlocale (LC_ALL, NULL);
       const std::string locale (static_locale);
 
--- a/libinterp/octave-value/ov-ch-mat.cc
+++ b/libinterp/octave-value/ov-ch-mat.cc
@@ -152,17 +152,23 @@
   return retval;
 }
 
-// The C++ standard guarantees cctype defines functions, not macros (and hence macros *CAN'T*
-// be defined if only cctype is included)
-// so there's no need to f*ck around. The exceptions are isascii and toascii,
-// which are not C++.
+// The C++ standard guarantees cctype defines functions, not macros
+// (and hence macros *CAN'T* be defined if only cctype is included)
+// so there's no need to f*ck around.
+// The exceptions are isascii and toascii, which are not C++.
 // Oddly enough, all those character functions are int (*) (int), even
-// in C++. Wicked!
+// in C++.  Wicked!
 static inline int xisascii (int c)
 { return isascii (c); }
 
 static inline int xtoascii (int c)
-{ return toascii (c); }
+{
+#ifdef HAVE_TOASCII
+  return toascii (c);
+#else
+  return (c & 0x7F);
+#endif
+}
 
 octave_value
 octave_char_matrix::map (unary_mapper_t umap) const
--- a/liboctave/numeric/lo-mappers.cc
+++ b/liboctave/numeric/lo-mappers.cc
@@ -317,7 +317,9 @@
 float
 xlog2 (float x)
 {
-#if defined (HAVE_LOG2)
+#if defined (HAVE_LOG2F)
+  return log2f (x);
+#elif defined (HAVE_LOG2)
   return log2 (x);
 #else
 #if defined (M_LN2)
@@ -345,7 +347,9 @@
 float
 xexp2 (float x)
 {
-#if defined (HAVE_EXP2)
+#if defined (HAVE_EXP2F)
+  return exp2f (x);
+#elif defined (HAVE_EXP2)
   return exp2 (x);
 #else
 #if defined (M_LN2)