File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / libiconv / srcm4 / time_h.m4
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 13:38:46 2021 UTC (3 years, 4 months ago) by misho
Branches: libiconv, MAIN
CVS tags: v1_16p0, HEAD
libiconv 1.16

    1: # Configure a more-standard replacement for <time.h>.
    2: 
    3: # Copyright (C) 2000-2001, 2003-2007, 2009-2019 Free Software Foundation, Inc.
    4: 
    5: # serial 11
    6: 
    7: # This file is free software; the Free Software Foundation
    8: # gives unlimited permission to copy and/or distribute it,
    9: # with or without modifications, as long as this notice is preserved.
   10: 
   11: # Written by Paul Eggert and Jim Meyering.
   12: 
   13: AC_DEFUN([gl_HEADER_TIME_H],
   14: [
   15:   dnl Use AC_REQUIRE here, so that the default behavior below is expanded
   16:   dnl once only, before all statements that occur in other macros.
   17:   AC_REQUIRE([gl_HEADER_TIME_H_BODY])
   18: ])
   19: 
   20: AC_DEFUN([gl_HEADER_TIME_H_BODY],
   21: [
   22:   AC_REQUIRE([AC_C_RESTRICT])
   23:   AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
   24:   gl_NEXT_HEADERS([time.h])
   25:   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
   26: ])
   27: 
   28: dnl Check whether 'struct timespec' is declared
   29: dnl in time.h, sys/time.h, pthread.h, or unistd.h.
   30: 
   31: AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
   32: [
   33:   AC_CHECK_HEADERS_ONCE([sys/time.h])
   34:   AC_CACHE_CHECK([for struct timespec in <time.h>],
   35:     [gl_cv_sys_struct_timespec_in_time_h],
   36:     [AC_COMPILE_IFELSE(
   37:        [AC_LANG_PROGRAM(
   38:           [[#include <time.h>
   39:           ]],
   40:           [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
   41:        [gl_cv_sys_struct_timespec_in_time_h=yes],
   42:        [gl_cv_sys_struct_timespec_in_time_h=no])])
   43: 
   44:   TIME_H_DEFINES_STRUCT_TIMESPEC=0
   45:   SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
   46:   PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
   47:   UNISTD_H_DEFINES_STRUCT_TIMESPEC=0
   48:   if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
   49:     TIME_H_DEFINES_STRUCT_TIMESPEC=1
   50:   else
   51:     AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
   52:       [gl_cv_sys_struct_timespec_in_sys_time_h],
   53:       [AC_COMPILE_IFELSE(
   54:          [AC_LANG_PROGRAM(
   55:             [[#include <sys/time.h>
   56:             ]],
   57:             [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
   58:          [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
   59:          [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
   60:     if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
   61:       SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
   62:     else
   63:       AC_CACHE_CHECK([for struct timespec in <pthread.h>],
   64:         [gl_cv_sys_struct_timespec_in_pthread_h],
   65:         [AC_COMPILE_IFELSE(
   66:            [AC_LANG_PROGRAM(
   67:               [[#include <pthread.h>
   68:               ]],
   69:               [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
   70:            [gl_cv_sys_struct_timespec_in_pthread_h=yes],
   71:            [gl_cv_sys_struct_timespec_in_pthread_h=no])])
   72:       if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
   73:         PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
   74:       else
   75:         AC_CACHE_CHECK([for struct timespec in <unistd.h>],
   76:           [gl_cv_sys_struct_timespec_in_unistd_h],
   77:           [AC_COMPILE_IFELSE(
   78:              [AC_LANG_PROGRAM(
   79:                 [[#include <unistd.h>
   80:                 ]],
   81:                 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
   82:              [gl_cv_sys_struct_timespec_in_unistd_h=yes],
   83:              [gl_cv_sys_struct_timespec_in_unistd_h=no])])
   84:         if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then
   85:           UNISTD_H_DEFINES_STRUCT_TIMESPEC=1
   86:         fi
   87:       fi
   88:     fi
   89:   fi
   90:   AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
   91:   AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
   92:   AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
   93:   AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC])
   94: ])
   95: 
   96: AC_DEFUN([gl_TIME_MODULE_INDICATOR],
   97: [
   98:   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
   99:   AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
  100:   gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  101:   dnl Define it also as a C macro, for the benefit of the unit tests.
  102:   gl_MODULE_INDICATOR_FOR_TESTS([$1])
  103: ])
  104: 
  105: AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
  106: [
  107:   GNULIB_CTIME=0;                        AC_SUBST([GNULIB_CTIME])
  108:   GNULIB_MKTIME=0;                       AC_SUBST([GNULIB_MKTIME])
  109:   GNULIB_LOCALTIME=0;                    AC_SUBST([GNULIB_LOCALTIME])
  110:   GNULIB_NANOSLEEP=0;                    AC_SUBST([GNULIB_NANOSLEEP])
  111:   GNULIB_STRFTIME=0;                     AC_SUBST([GNULIB_STRFTIME])
  112:   GNULIB_STRPTIME=0;                     AC_SUBST([GNULIB_STRPTIME])
  113:   GNULIB_TIMEGM=0;                       AC_SUBST([GNULIB_TIMEGM])
  114:   GNULIB_TIME_R=0;                       AC_SUBST([GNULIB_TIME_R])
  115:   GNULIB_TIME_RZ=0;                      AC_SUBST([GNULIB_TIME_RZ])
  116:   GNULIB_TZSET=0;                        AC_SUBST([GNULIB_TZSET])
  117:   dnl Assume proper GNU behavior unless another module says otherwise.
  118:   HAVE_DECL_LOCALTIME_R=1;               AC_SUBST([HAVE_DECL_LOCALTIME_R])
  119:   HAVE_NANOSLEEP=1;                      AC_SUBST([HAVE_NANOSLEEP])
  120:   HAVE_STRPTIME=1;                       AC_SUBST([HAVE_STRPTIME])
  121:   HAVE_TIMEGM=1;                         AC_SUBST([HAVE_TIMEGM])
  122:   HAVE_TZSET=1;                          AC_SUBST([HAVE_TZSET])
  123:   dnl Even GNU libc does not have timezone_t yet.
  124:   HAVE_TIMEZONE_T=0;                     AC_SUBST([HAVE_TIMEZONE_T])
  125:   dnl If another module says to replace or to not replace, do that.
  126:   dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
  127:   dnl this lets maintainers check for portability.
  128:   REPLACE_CTIME=GNULIB_PORTCHECK;        AC_SUBST([REPLACE_CTIME])
  129:   REPLACE_LOCALTIME_R=GNULIB_PORTCHECK;  AC_SUBST([REPLACE_LOCALTIME_R])
  130:   REPLACE_MKTIME=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_MKTIME])
  131:   REPLACE_NANOSLEEP=GNULIB_PORTCHECK;    AC_SUBST([REPLACE_NANOSLEEP])
  132:   REPLACE_STRFTIME=GNULIB_PORTCHECK;     AC_SUBST([REPLACE_STRFTIME])
  133:   REPLACE_TIMEGM=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_TIMEGM])
  134:   REPLACE_TZSET=GNULIB_PORTCHECK;        AC_SUBST([REPLACE_TZSET])
  135: 
  136:   dnl Hack so that the time module doesn't depend on the sys_time module.
  137:   dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
  138:   : ${GNULIB_GETTIMEOFDAY=0};            AC_SUBST([GNULIB_GETTIMEOFDAY])
  139:   dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME
  140:   dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier
  141:   dnl is no longer a big deal.
  142:   REPLACE_GMTIME=0;                      AC_SUBST([REPLACE_GMTIME])
  143:   REPLACE_LOCALTIME=0;                   AC_SUBST([REPLACE_LOCALTIME])
  144: ])

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>