Debian Codegraph @

m4/stat-time.m4

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