chiark / gitweb /
work around broken solaris gcc
authorstevenj <stevenj@alum.mit.edu>
Sat, 22 Nov 2008 22:29:58 +0000 (17:29 -0500)
committerstevenj <stevenj@alum.mit.edu>
Sat, 22 Nov 2008 22:29:58 +0000 (17:29 -0500)
darcs-hash:20081122222958-c8de0-e8509a08196f53a05ba2c77513bd297c01f47637.gz

18 files changed:
NEWS
api/f77api.c
api/nlopt.c
cdirect/cdirect.c
cdirect/hybrid.c
configure.ac
direct/Makefile.am
direct/direct-internal.h
mma/mma.c
octave/Makefile.am
octave/dummy.c [new file with mode: 0644]
octave/nlopt_minimize_constrained-mex.c
util/mt19937ar.c
util/nlopt-util.h
util/qsort_r.c
util/redblack_test.c
util/sobolseq.c
util/timer.c

diff --git a/NEWS b/NEWS
index ea14eb6f6a273a677adaaad56f0d93e5e0bc6b26..9acbdcfae08cc2d56d7a57bafb96007c5e34d7df 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+* Workaround for gcc 3.4.x conflict with HUGE_VAL definition in Solaris
+  (gcc bug 19933).
+
+* Better identification of Matlab-plugin installation directory.
+
 NLopt 1.0.1 (13 Nov. 2008)
 
 * Allow user to override Matlab-plugin installation directory with
index 1adf45c33786b14b7c671782ac4500cb00662725..2a52f2a7e557d675cd60f88b4c5b77cee08b48b0 100644 (file)
@@ -23,7 +23,7 @@
 #include <stdlib.h>
 
 #include "nlopt.h"
-#include "config.h"
+#include "nlopt-util.h"
 
 /*-----------------------------------------------------------------------*/
 /* wrappers around f77 procedures */
index 3e497532a31a2cf1743cf161e36c3ea3bc4ca752..056165f95bbdf6aaf25d1f369977b1b381addf76 100644 (file)
 
 #include "nlopt.h"
 #include "nlopt-util.h"
-#include "config.h"
 
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 
 /*************************************************************************/
 
-#ifdef INFINITY
-#  define MY_INF INFINITY
-#else
-#  define MY_INF HUGE_VAL
-#endif
-
 int nlopt_isinf(double x) {
      return fabs(x) >= HUGE_VAL * 0.99
 #ifdef HAVE_ISINF
@@ -182,10 +175,10 @@ static double f_bound(int n, const double *x, void *data_)
        discontinuous objectives so we can just return Inf for invalid x */
      for (i = 0; i < n; ++i)
          if (x[i] < data->lb[i] || x[i] > data->ub[i])
-              return MY_INF;
+              return HUGE_VAL;
 
      f = data->f(n, x, NULL, data->f_data);
-     return (isnan(f) || nlopt_isinf(f) ? MY_INF : f);
+     return (isnan(f) || nlopt_isinf(f) ? HUGE_VAL : f);
 }
 
 static double f_noderiv(int n, const double *x, void *data_)
@@ -306,7 +299,7 @@ static nlopt_result nlopt_minimize_(
      stop.n = n;
      stop.minf_max = (isnan(minf_max) 
                      || (nlopt_isinf(minf_max) && minf_max < 0))
-         ? -MY_INF : minf_max;
+         ? -HUGE_VAL : minf_max;
      stop.ftol_rel = ftol_rel;
      stop.ftol_abs = ftol_abs;
      stop.xtol_rel = xtol_rel;
index 49d4836173c11b0101ccc4873fb835e0ba9bfafb..f61df07f6f370946200f4fe742f85be80aa888ac 100644 (file)
@@ -28,7 +28,6 @@
 #include "nlopt.h"
 #include "cdirect.h"
 #include "redblack.h"
-#include "config.h"
 
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
index 3e683ea09b6ba345e5eda9830162ebe38ea17834..72776999938b8a8fbb6dc3eebc95c89fece1a14e 100644 (file)
@@ -28,7 +28,6 @@
 #include "nlopt.h"
 #include "cdirect.h"
 #include "redblack.h"
-#include "config.h"
 
 /* Hybrid algorithm, inspired by DIRECT, that uses another local
  * optimization algorithm within each rectangle, and then looks
index d83922697678c17506d0fcce3c4652fb4069fc6a..992732d154d698705e59b47e38e7a620d5f003b2 100644 (file)
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(nlopt, 1.0.1, stevenj@alum.mit.edu)
+AC_INIT(nlopt, 1.0.2, stevenj@alum.mit.edu)
 AC_CONFIG_SRCDIR(api/nlopt.h)
-SHARED_VERSION_INFO="0:1:0" # CURRENT:REVISION:AGE
+SHARED_VERSION_INFO="0:2:0" # CURRENT:REVISION:AGE
 
 AM_INIT_AUTOMAKE(1.7)
 AM_CONFIG_HEADER(config.h)
@@ -165,6 +165,23 @@ AC_SUBST(MEX_INSTALL_DIR)
 AC_SUBST(MEX)
 AC_SUBST(MEXSUFF)
 
+dnl -----------------------------------------------------------------------
+dnl Check for broken Solaris HUGE_VAL macro under gcc 3.4.x and similar
+
+AC_MSG_CHECKING([for working HUGE_VAL])
+AC_TRY_COMPILE([#include <math.h>], [double x = -HUGE_VAL;], 
+[AC_MSG_RESULT([ok])],
+[AC_TRY_COMPILE([#include <math.h>
+#ifdef __GNUC__
+#undef HUGE_VAL
+#define HUGE_VAL __builtin_huge_val()
+#endif], [double x = -HUGE_VAL;], 
+[AC_MSG_RESULT([__builtin_huge_val()])
+AC_DEFINE(REPLACEMENT_HUGE_VAL,[__builtin_huge_val()],
+          [replacement for broken HUGE_VAL macro, if needed])],
+[AC_MSG_RESULT([unknown])
+AC_MSG_ERROR([broken HUGE_VAL macro with this compiler, unknown workaround])])])
+
 dnl -----------------------------------------------------------------------
 dnl Debugging
 
index 4fae9bc37e0cb0dfc32ed8fc46f053a5049e135e..161dded987746fb75d6de4f3263687ede4b0383c 100644 (file)
@@ -1,3 +1,5 @@
+AM_CPPFLAGS = -I$(top_srcdir)/util -I$(top_srcdir)/api
+
 noinst_LTLIBRARIES = libdirect.la
 libdirect_la_SOURCES = DIRect.c direct_wrap.c DIRserial.c DIRsubrout.c \
 direct-internal.h direct.h
index c9cb6858c0e56bae3845b66164280a8f3b10d4ba..d937832dcfc741c719e5e2eb0df456470df7a803 100644 (file)
@@ -6,6 +6,7 @@
 #include <math.h>
 
 #include "direct.h"
+#include "nlopt-util.h"
 
 #ifdef __cplusplus
 extern "C"
index 31d6089bf0a766f1b8634b5f1597d563809e000b..ab12dc14ee43a8580411a9f5658888eabf9ffe18 100644 (file)
--- a/mma/mma.c
+++ b/mma/mma.c
@@ -26,7 +26,7 @@
 #include <stdio.h>
 
 #include "mma.h"
-#include "config.h"
+#include "nlopt-util.h"
 
 int mma_verbose = 0; /* > 0 for verbose output */
 
index d06a143da07d7ce50f6df8a2f7bc86682b74d576..c03ffedb97b075c5b3f99dd3995df6a7ebf18e3e 100644 (file)
@@ -1,7 +1,13 @@
-AM_CPPFLAGS = -I$(top_srcdir)/api 
+AM_CPPFLAGS = -I$(top_srcdir)/api -I$(top_srcdir)/util
 
 MFILES = NLOPT_GN_DIRECT.m NLOPT_GN_DIRECT_L.m NLOPT_GN_DIRECT_L_RAND.m NLOPT_GN_DIRECT_NOSCAL.m NLOPT_GN_DIRECT_L_NOSCAL.m NLOPT_GN_DIRECT_L_RAND_NOSCAL.m NLOPT_GN_ORIG_DIRECT.m NLOPT_GN_ORIG_DIRECT_L.m NLOPT_GD_STOGO.m NLOPT_GD_STOGO_RAND.m NLOPT_LD_LBFGS_NOCEDAL.m NLOPT_LD_LBFGS.m NLOPT_LN_PRAXIS.m NLOPT_LD_VAR1.m NLOPT_LD_VAR2.m NLOPT_LD_TNEWTON.m NLOPT_LD_TNEWTON_RESTART.m NLOPT_LD_TNEWTON_PRECOND.m NLOPT_LD_TNEWTON_PRECOND_RESTART.m NLOPT_GN_CRS2_LM.m NLOPT_GN_MLSL.m NLOPT_GD_MLSL.m NLOPT_GN_MLSL_LDS.m NLOPT_GD_MLSL_LDS.m NLOPT_LD_MMA.m NLOPT_LN_COBYLA.m NLOPT_LN_NEWUOA.m NLOPT_LN_NEWUOA_BOUND.m NLOPT_LN_NELDERMEAD.m NLOPT_LN_SBPLX.m 
 
+#######################################################################
+# dummy C program to fool automake into making sure that CPPFLAGS etc.
+# are all defined
+noinst_PROGRAMS = dummy
+dummy_SOURCES = dummy.c
+
 #######################################################################
 octdir = $(OCT_INSTALL_DIR)
 mdir = $(M_INSTALL_DIR)
diff --git a/octave/dummy.c b/octave/dummy.c
new file mode 100644 (file)
index 0000000..dc34341
--- /dev/null
@@ -0,0 +1,2 @@
+#include <stdio.h>
+int main(void) { printf("Hello world.\n"); return 0; }
index 92620f387b31617879d66625b9344b77f073d8fd..538bcb16d651e636a6c657fdcba00859faab45aa 100644 (file)
@@ -29,6 +29,7 @@
 #include <mex.h>
 
 #include "nlopt.h"
+#include "nlopt-util.h"
 
 #define xSTRIZE(x) #x
 #define STRIZE(x) xSTRIZE(x)
index 03ae83e2c7b8596e2dac1df3956642fe1179a24e..2e82376b98e0a29d5e51f89264193046c1b815cb 100644 (file)
@@ -46,7 +46,6 @@
 */
 
 #include "nlopt-util.h"
-#include "config.h"
 
 #if defined(HAVE_STDINT_H)
 #  include <stdint.h>
index 46e2ca6a16bab123074182b8eb30ec25fc842568..586f35e0c19bc9c1b28df0a9082b12007730bc06 100644 (file)
 #define NLOPT_UTIL_H
 
 #include <stdlib.h>
+#include <math.h>
+#include "config.h"
+
+/* workaround for Solaris + gcc 3.4.x bug (see configure.ac) */
+#if defined(__GNUC__) && defined(REPLACEMENT_HUGE_VAL)
+#  undef HUGE_VAL
+#  define HUGE_VAL REPLACEMENT_HUGE_VAL
+#endif
 
 #ifdef __cplusplus
 extern "C"
index 583cdc57872b94184f71a2e721fbf88dbea0156a..ebbc649d4a2eef45c9c99f8a5685996421057bba 100644 (file)
@@ -20,8 +20,7 @@
  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
  */
 
-#include <nlopt-util.h>
-#include "config.h"
+#include "nlopt-util.h"
 
 /* Simple replacement for the BSD qsort_r function (re-entrant sorting),
    if it is not available.  (It looks like glibc 2.8 will include qsort_r
index 467c755a360e3904aeaa783471974fac26a83212..3ee8cc829f9a04a9e6f392b3b723443a54d27c8d 100644 (file)
 #include <time.h>
 #include "redblack.h"
 
+#include "config.h"
+/* workaround for Solaris + gcc 3.4.x bug (see configure.ac) */
+#if defined(__GNUC__) && defined(REPLACEMENT_HUGE_VAL)
+#  undef HUGE_VAL
+#  define HUGE_VAL REPLACEMENT_HUGE_VAL
+#endif
+
 static int comp(rb_key k1, rb_key k2)
 {
      if (*k1 < *k2) return -1;
index 42120fc7d21c73f7bce2f282f2f7b885d24a3345..b3bee05f9f8da363c09312588dd5bd36b64b78ba 100644 (file)
    a free/open-source implementation. */
 
 #include <stdlib.h>
+#include <math.h>
 
 #include "nlopt-util.h"
 
-#include "config.h"
-
 #if defined(HAVE_STDINT_H)
 #  include <stdint.h>
 #endif
@@ -250,7 +249,6 @@ void nlopt_sobol_skip(nlopt_sobol s, unsigned n, double *x)
 /* compile with -DSOBOLSEQ_TEST for test program */
 #ifdef SOBOLSEQ_TEST
 #include <stdio.h>
-#include <math.h>
 #include <time.h>
 
 /* test integrand from Joe and Kuo paper ... integrates to 1 */
index ed06b4291d2fbec1f4ea85e7ad9abf6357846f28..d8e053f3efc15ed817a02b40aed289a7ebce7f3e 100644 (file)
@@ -21,7 +21,6 @@
  */
 
 #include "nlopt-util.h"
-#include "config.h"
 
 #if TIME_WITH_SYS_TIME
 # include <sys/time.h>