From 278003ca94cf3d3e5f9619e6b2fd08ab590c0899 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 12 Dec 2013 17:40:58 +1000 Subject: [PATCH] Don't unconditionally define _GNU_SOURCE Also, fix build if JIM_OPTIMIZATION is disabled Signed-off-by: Steve Bennett --- Makefile.in | 4 ++-- auto.def | 2 +- jim-aio.c | 1 + jim-exec.c | 1 + jim.c | 13 ++++++++++--- make-bootstrap-jim | 8 +++++++- regtest.tcl | 8 +++++++- 7 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Makefile.in b/Makefile.in index aa38da3..c43c6e9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -27,8 +27,8 @@ exec_prefix ?= @exec_prefix@ prefix ?= @prefix@ docdir = @docdir@ -CC += -D_GNU_SOURCE -Wall $(OPTIM) -I. -CXX += -D_GNU_SOURCE -Wall $(OPTIM) -I. +CC += -Wall $(OPTIM) -I. +CXX += -Wall $(OPTIM) -I. @if srcdir != . CFLAGS += -I@srcdir@ CXXFLAGS += -I@srcdir@ diff --git a/auto.def b/auto.def index 18d8a9f..fcf4a80 100644 --- a/auto.def +++ b/auto.def @@ -144,7 +144,7 @@ define tclsh [info nameofexecutable] if {![cc-check-functions _NSGetEnviron]} { msg-checking "Checking environ declared in unistd.h..." - if {[cctest -cflags -D_GNU_SOURCE -includes unistd.h -code {char **ep = environ;}]} { + if {[cctest -cflags {-D_GNU_SOURCE -D_POSIX_SOURCE} -includes unistd.h -code {char **ep = environ;}]} { define NO_ENVIRON_EXTERN msg-result "yes" } else { diff --git a/jim-aio.c b/jim-aio.c index 8a96f27..4663afb 100644 --- a/jim-aio.c +++ b/jim-aio.c @@ -39,6 +39,7 @@ #include "jimautoconf.h" +#define _GNU_SOURCE #include #include #include diff --git a/jim-exec.c b/jim-exec.c index e25eb2e..985a588 100644 --- a/jim-exec.c +++ b/jim-exec.c @@ -20,6 +20,7 @@ * express or implied warranty. */ +#define _GNU_SOURCE #include #include diff --git a/jim.c b/jim.c index 1532c1c..d7d5f0e 100644 --- a/jim.c +++ b/jim.c @@ -41,6 +41,7 @@ * official policies, either expressed or implied, of the Jim Tcl Project. **/ #define JIM_OPTIMIZATION /* comment to avoid optimizations and reduce size */ +#define _GNU_SOURCE /* Mostly just for environ */ #include #include @@ -115,6 +116,12 @@ static void JimPanicDump(int fail_condition, const char *fmt, ...); #define JimPanic(X) #endif +#ifdef JIM_OPTIMIZATION +#define JIM_IF_OPTIM(X) X +#else +#define JIM_IF_OPTIM(X) +#endif + /* ----------------------------------------------------------------------------- * Global variables * ---------------------------------------------------------------------------*/ @@ -11907,16 +11914,16 @@ static int Jim_ForCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv if (retval == JIM_OK || retval == JIM_CONTINUE) { /* increment */ - evalnext: +JIM_IF_OPTIM(evalnext:) retval = Jim_EvalObj(interp, argv[3]); if (retval == JIM_OK || retval == JIM_CONTINUE) { /* test */ - testcond: +JIM_IF_OPTIM(testcond:) retval = Jim_GetBoolFromExpr(interp, argv[2], &boolean); } } } - out: +JIM_IF_OPTIM(out:) if (stopVarNamePtr) { Jim_DecrRefCount(interp, stopVarNamePtr); } diff --git a/make-bootstrap-jim b/make-bootstrap-jim index ba3b2f8..d69380b 100755 --- a/make-bootstrap-jim +++ b/make-bootstrap-jim @@ -49,7 +49,7 @@ allexts="bootstrap aio readdir regexp file glob exec clock array stdlib tclcompa echo "/* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */" # define some core features -for i in _GNU_SOURCE JIM_TCL_COMPAT JIM_REFERENCES JIM_ANSIC JIM_REGEXP HAVE_NO_AUTOCONF _JIMAUTOCONF_H; do +for i in JIM_TCL_COMPAT JIM_REFERENCES JIM_ANSIC JIM_REGEXP HAVE_NO_AUTOCONF _JIMAUTOCONF_H; do echo "#define $i" done echo '#define TCL_LIBRARY "."' @@ -78,6 +78,12 @@ cat <