Browse Source

Add an option to use localtime_r if available.

mingodad 9 years ago
parent
commit
2cfa19a2bd
2 changed files with 18 additions and 8 deletions
  1. 10 1
      SquiLu/sqstdlib/sqstdsystem.cpp
  2. 8 7
      SquiLu/squilu.cbp

+ 10 - 1
SquiLu/sqstdlib/sqstdsystem.cpp

@@ -233,12 +233,21 @@ static SQRESULT _system_date(HSQUIRRELVM v)
 	time_t t = (time_t)arg_time;
 
     struct tm *stm;
+#ifdef SQ_USE_LOCALTIME_R
+    struct tm ltm_r;
+#endif // SQ_USE_LOCALTIME_R
     if (*arg_format == _SC('!')) {  /* UTC? */
         stm = gmtime(&t);
         arg_format++;  /* skip `!' */
     }
     else
+    {
+#ifdef SQ_USE_LOCALTIME_R
+        stm = localtime_r(&t, &ltm_r);
+#else
         stm = localtime(&t);
+#endif // SQ_USE_LOCALTIME_R
+    }
     if (stm == NULL)  /* invalid date? */
         sq_pushnull(v);
     else if (scstrcmp(arg_format, _SC("*t")) == 0) {
@@ -292,7 +301,7 @@ static SQRESULT _system_exit (HSQUIRRELVM v) {
   exit(status);
 }
 
-#if defined(SC_USE_MKSTEMP)
+#if defined(SQ_USE_MKSTEMP)
 #include <unistd.h>
 #define SQ_TMPNAMBUFSIZE	32
 #define sq_tmpnam(b,e)	{ \

+ 8 - 7
SquiLu/squilu.cbp

@@ -466,7 +466,7 @@
 					<Add library="pthread" />
 					<Add library="rt" />
 					<Add library="dl" />
-					<Add library="axtls" />
+					<Add library="axtls-dbg" />
 					<Add library="mpdecimal" />
 					<Add library="discount" />
 					<Add library="fltk_z" />
@@ -526,8 +526,8 @@
 				</Linker>
 			</Target>
 			<Target title="Release FLTK 64bits Computed Gotos">
-				<Option output="bin/squilu" prefix_auto="1" extension_auto="1" />
-				<Option object_output="obj/Release/" />
+				<Option output="bin/squilu-cg" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Release-cg/" />
 				<Option type="1" />
 				<Option compiler="gcc" />
 				<Compiler>
@@ -651,7 +651,7 @@
 					<Add library="discount" />
 					<Add library="X11" />
 					<Add library="fontconfig" />
-					<Add library="axtls" />
+					<Add library="axtls-dbg" />
 					<Add library="Xcursor" />
 					<Add library="Xfixes" />
 					<Add directory="../../zeromq-3.2.2" />
@@ -708,7 +708,7 @@
 					<Add library="discount" />
 					<Add library="X11" />
 					<Add library="fontconfig" />
-					<Add library="axtls" />
+					<Add library="axtls-dbg" />
 					<Add library="Xcursor" />
 					<Add library="Xfixes" />
 					<Add directory="../../zeromq-3.2.2" />
@@ -739,7 +739,7 @@
 					<Add library="pthread" />
 					<Add library="rt" />
 					<Add library="dl" />
-					<Add library="axtls" />
+					<Add library="axtls-dbg" />
 					<Add library="mpdecimal" />
 					<Add library="discount" />
 					<Add library="fltk_z" />
@@ -862,7 +862,8 @@
 			<Add option="-std=c++11" />
 			<Add option="-Wall" />
 			<Add option="-fno-strict-aliasing" />
-			<Add option="-DSC_USE_MKSTEMP=1" />
+			<Add option="-DSQ_USE_MKSTEMP=1" />
+			<Add option="-DSQ_USE_LOCALTIME_R=1" />
 			<Add option="-DONLY_ASCII=1" />
 			<Add option="-DPROFILE_SQVM0=1" />
 			<Add option="-DSQ_JIT_LLVM44=1" />