1*56bb7041Schristos# Checks for stat-related time functions. 2*56bb7041Schristos 3*56bb7041Schristos# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2020 Free Software 4*56bb7041Schristos# Foundation, Inc. 5*56bb7041Schristos 6*56bb7041Schristos# This file is free software; the Free Software Foundation 7*56bb7041Schristos# gives unlimited permission to copy and/or distribute it, 8*56bb7041Schristos# with or without modifications, as long as this notice is preserved. 9*56bb7041Schristos 10*56bb7041Schristosdnl From Paul Eggert. 11*56bb7041Schristos 12*56bb7041Schristos# st_atim.tv_nsec - Linux, Solaris, Cygwin 13*56bb7041Schristos# st_atimespec.tv_nsec - FreeBSD, NetBSD, if ! defined _POSIX_SOURCE 14*56bb7041Schristos# st_atimensec - FreeBSD, NetBSD, if defined _POSIX_SOURCE 15*56bb7041Schristos# st_atim.st__tim.tv_nsec - UnixWare (at least 2.1.2 through 7.1) 16*56bb7041Schristos 17*56bb7041Schristos# st_birthtimespec - FreeBSD, NetBSD (hidden on OpenBSD 3.9, anyway) 18*56bb7041Schristos# st_birthtim - Cygwin 1.7.0+ 19*56bb7041Schristos 20*56bb7041SchristosAC_DEFUN([gl_STAT_TIME], 21*56bb7041Schristos[ 22*56bb7041Schristos AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 23*56bb7041Schristos AC_CHECK_HEADERS_ONCE([sys/time.h]) 24*56bb7041Schristos 25*56bb7041Schristos AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec], 26*56bb7041Schristos [AC_CACHE_CHECK([whether struct stat.st_atim is of type struct timespec], 27*56bb7041Schristos [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec], 28*56bb7041Schristos [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 29*56bb7041Schristos [[ 30*56bb7041Schristos #include <sys/types.h> 31*56bb7041Schristos #include <sys/stat.h> 32*56bb7041Schristos #if HAVE_SYS_TIME_H 33*56bb7041Schristos # include <sys/time.h> 34*56bb7041Schristos #endif 35*56bb7041Schristos #include <time.h> 36*56bb7041Schristos struct timespec ts; 37*56bb7041Schristos struct stat st; 38*56bb7041Schristos ]], 39*56bb7041Schristos [[ 40*56bb7041Schristos st.st_atim = ts; 41*56bb7041Schristos ]])], 42*56bb7041Schristos [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=yes], 43*56bb7041Schristos [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no])]) 44*56bb7041Schristos if test $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec = yes; then 45*56bb7041Schristos AC_DEFINE([TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC], [1], 46*56bb7041Schristos [Define to 1 if the type of the st_atim member of a struct stat is 47*56bb7041Schristos struct timespec.]) 48*56bb7041Schristos fi], 49*56bb7041Schristos [AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec], [], 50*56bb7041Schristos [AC_CHECK_MEMBERS([struct stat.st_atimensec], [], 51*56bb7041Schristos [AC_CHECK_MEMBERS([struct stat.st_atim.st__tim.tv_nsec], [], [], 52*56bb7041Schristos [#include <sys/types.h> 53*56bb7041Schristos #include <sys/stat.h>])], 54*56bb7041Schristos [#include <sys/types.h> 55*56bb7041Schristos #include <sys/stat.h>])], 56*56bb7041Schristos [#include <sys/types.h> 57*56bb7041Schristos #include <sys/stat.h>])], 58*56bb7041Schristos [#include <sys/types.h> 59*56bb7041Schristos #include <sys/stat.h>]) 60*56bb7041Schristos]) 61*56bb7041Schristos 62*56bb7041Schristos# Check for st_birthtime, a feature from UFS2 (FreeBSD, NetBSD, OpenBSD, etc.) 63*56bb7041Schristos# and NTFS (Cygwin). 64*56bb7041Schristos# There was a time when this field was named st_createtime (21 June 65*56bb7041Schristos# 2002 to 16 July 2002) But that window is very small and applied only 66*56bb7041Schristos# to development code, so systems still using that configuration are 67*56bb7041Schristos# not supported. See revisions 1.10 and 1.11 of FreeBSD's 68*56bb7041Schristos# src/sys/ufs/ufs/dinode.h. 69*56bb7041Schristos# 70*56bb7041SchristosAC_DEFUN([gl_STAT_BIRTHTIME], 71*56bb7041Schristos[ 72*56bb7041Schristos AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 73*56bb7041Schristos AC_CHECK_HEADERS_ONCE([sys/time.h]) 74*56bb7041Schristos AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec], [], 75*56bb7041Schristos [AC_CHECK_MEMBERS([struct stat.st_birthtimensec], [], 76*56bb7041Schristos [AC_CHECK_MEMBERS([struct stat.st_birthtim.tv_nsec], [], [], 77*56bb7041Schristos [#include <sys/types.h> 78*56bb7041Schristos #include <sys/stat.h>])], 79*56bb7041Schristos [#include <sys/types.h> 80*56bb7041Schristos #include <sys/stat.h>])], 81*56bb7041Schristos [#include <sys/types.h> 82*56bb7041Schristos #include <sys/stat.h>]) 83*56bb7041Schristos]) 84