summaryrefslogtreecommitdiff
path: root/ext/date/lib/timelib.m4
blob: 99bf9fad20bc44fc6593b2d0e09898b090a6ce72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
dnl
dnl $Id$
dnl
dnl
dnl TL_DEF_HAVE(what [, why])
dnl
dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [WHY])'
dnl
AC_DEFUN([TL_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___),1,[ $2 ])])dnl

dnl
dnl TL_CHECK_INT_TYPE(type)
dnl
AC_DEFUN([TL_CHECK_INT_TYPE],[
AC_CACHE_CHECK([for $1], ac_cv_int_type_$1, [
AC_TRY_COMPILE([
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#elif HAVE_STDINT_H   
# include <stdint.h>  
#endif],
[if (($1 *) 0)
  return 0;   
if (sizeof ($1))
  return 0;
], [ac_cv_int_type_$1=yes], [ac_cv_int_type_$1=no])
])
if test "$ac_cv_int_type_$1" = "yes"; then
  TL_DEF_HAVE($1, [Define if $1 type is present.])
fi
])dnl

dnl
dnl AC_TIMELIB_C_BIGENDIAN
dnl Replacement macro for AC_C_BIGENDIAN
dnl
AC_DEFUN([AC_TIMELIB_C_BIGENDIAN],
[AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php,
 [
  ac_cv_c_bigendian_php=unknown
  AC_TRY_RUN(
  [
int main(void)
{
        short one = 1;
        char *cp = (char *)&one;

        if (*cp == 0) {
                return(0);
        } else {
                return(1);
        }
} 
  ], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown])
 ])
 if test $ac_cv_c_bigendian_php = yes; then
   AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word])
 fi
])dnl

dnl Check for types, sizes, etc. needed by timelib
AC_CHECK_SIZEOF(long, 8)
AC_CHECK_SIZEOF(int, 4)
TL_CHECK_INT_TYPE(int32_t)
TL_CHECK_INT_TYPE(uint32_t)

dnl Check for headers needed by timelib
AC_CHECK_HEADERS([ \
sys/types.h \
inttypes.h \
stdint.h \
string.h \
stdlib.h
])

dnl Check for strtoll, atoll
AC_CHECK_FUNCS(strtoll atoll strftime gettimeofday)