added strftime %z check into configure.ac

This commit is contained in:
hyunghwan.chung 2017-04-28 23:25:21 +00:00
parent 3a072e9d7c
commit e2a7646b75
5 changed files with 80 additions and 13 deletions

46
moo/configure vendored
View File

@ -19110,6 +19110,52 @@ fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strftime %z" >&5
$as_echo_n "checking for strftime %z... " >&6; }
if test "$cross_compiling" = yes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown" >&5
$as_echo "unknown" >&6; }
$as_echo "#define HAVE_STRFTIME_SMALL_Z 1" >>confdefs.h
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <string.h>
#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif
#if defined(HAVE_TIME_H)
#include <time.h>
#endif
int main ()
{
char buf[100];
time_t t = 0;
strftime (buf, sizeof(buf), "%z", gmtime(&t));
return strcmp(buf, "%z") == 0? 1: 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_STRFTIME_SMALL_Z 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
# The cast to long int works around a bug in the HP C Compiler # The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.

View File

@ -213,6 +213,34 @@ AC_TRY_LINK(
[AC_MSG_RESULT(no)] [AC_MSG_RESULT(no)]
) )
AC_MSG_CHECKING([for strftime %z])
AC_TRY_RUN(
[#include <string.h>
#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif
#if defined(HAVE_TIME_H)
#include <time.h>
#endif
int main ()
{
char buf[100];
time_t t = 0;
strftime (buf, sizeof(buf), "%z", gmtime(&t));
return strcmp(buf, "%z") == 0? 1: 0;
}],
[
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_STRFTIME_SMALL_Z], [1], [strftime supports %z])
],
[AC_MSG_RESULT(no)],
[
dnl cross-compiling, assume yes
AC_MSG_RESULT(unknown)
AC_DEFINE([HAVE_STRFTIME_SMALL_Z], [1], [strftime supports %z])
]
)
dnl check the size of primitive data types dnl check the size of primitive data types
AC_CHECK_SIZEOF(char,,[[]]) AC_CHECK_SIZEOF(char,,[[]])
AC_CHECK_SIZEOF(short,,[[]]) AC_CHECK_SIZEOF(short,,[[]])

View File

@ -85,16 +85,6 @@ class MyObject(Object)
] on: Exception do: [:ex | ('Exception caught - ' & ex asString) dump ].*) ] on: Exception do: [:ex | ('Exception caught - ' & ex asString) dump ].*)
ffi := FFI new: '/lib64/libc.so.6'. ffi := FFI new: '/lib64/libc.so.6'.
(*
(ffi isError)
ifTrue: [System logNl: 'cannot open libc.so' ]
ifFalse: [
(ffi call: #getpid signature: ')i' arguments: nil) dump.
(ffi call: #printf signature: 's|iis)i' arguments: #(S'A=>%d B=>%d Hello, world %s\n' 1 2 'fly away')) dump.
(ffi call: #printf signature: 's|iis)i' arguments: #(S'A=>%d B=>%d Hello, world %s\n' 1 2 'jump down')) dump.
ffi close.
].
*)
if (ffi isError) if (ffi isError)
{ {
System logNl: 'cannot open libc.so' System logNl: 'cannot open libc.so'

View File

@ -660,10 +660,10 @@ if (mask & MOO_LOG_GC) return; /* don't show gc logs */
} }
#else #else
tmp = localtime_r (&now, &tm); tmp = localtime_r (&now, &tm);
#if defined(__sun) && defined(__SVR4) /* TODO: better check on support of %z */ #if defined(HAVE_STRFTIME_SMALL_Z)
tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
#else
tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp); tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
#else
tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
#endif #endif
if (tslen == 0) if (tslen == 0)
{ {

View File

@ -217,6 +217,9 @@
/* Define to 1 if you have the <stdlib.h> header file. */ /* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H #undef HAVE_STDLIB_H
/* strftime supports %z */
#undef HAVE_STRFTIME_SMALL_Z
/* Define to 1 if you have the <strings.h> header file. */ /* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H #undef HAVE_STRINGS_H