Blame m4/stat-time.m4

Packit aea12f
# Checks for stat-related time functions.
Packit aea12f
Packit aea12f
# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2019 Free Software
Packit aea12f
# Foundation, Inc.
Packit aea12f
Packit aea12f
# This file is free software; the Free Software Foundation
Packit aea12f
# gives unlimited permission to copy and/or distribute it,
Packit aea12f
# with or without modifications, as long as this notice is preserved.
Packit aea12f
Packit aea12f
dnl From Paul Eggert.
Packit aea12f
Packit aea12f
# st_atim.tv_nsec - Linux, Solaris, Cygwin
Packit aea12f
# st_atimespec.tv_nsec - FreeBSD, NetBSD, if ! defined _POSIX_SOURCE
Packit aea12f
# st_atimensec - FreeBSD, NetBSD, if defined _POSIX_SOURCE
Packit aea12f
# st_atim.st__tim.tv_nsec - UnixWare (at least 2.1.2 through 7.1)
Packit aea12f
Packit aea12f
# st_birthtimespec - FreeBSD, NetBSD (hidden on OpenBSD 3.9, anyway)
Packit aea12f
# st_birthtim - Cygwin 1.7.0+
Packit aea12f
Packit aea12f
AC_DEFUN([gl_STAT_TIME],
Packit aea12f
[
Packit aea12f
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
Packit aea12f
  AC_CHECK_HEADERS_ONCE([sys/time.h])
Packit aea12f
Packit aea12f
  AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec],
Packit aea12f
    [AC_CACHE_CHECK([whether struct stat.st_atim is of type struct timespec],
Packit aea12f
       [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec],
Packit aea12f
       [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Packit aea12f
          [[
Packit aea12f
            #include <sys/types.h>
Packit aea12f
            #include <sys/stat.h>
Packit aea12f
            #if HAVE_SYS_TIME_H
Packit aea12f
            # include <sys/time.h>
Packit aea12f
            #endif
Packit aea12f
            #include <time.h>
Packit aea12f
            struct timespec ts;
Packit aea12f
            struct stat st;
Packit aea12f
          ]],
Packit aea12f
          [[
Packit aea12f
            st.st_atim = ts;
Packit aea12f
          ]])],
Packit aea12f
          [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=yes],
Packit aea12f
          [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no])])
Packit aea12f
     if test $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec = yes; then
Packit aea12f
       AC_DEFINE([TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC], [1],
Packit aea12f
         [Define to 1 if the type of the st_atim member of a struct stat is
Packit aea12f
          struct timespec.])
Packit aea12f
     fi],
Packit aea12f
    [AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec], [],
Packit aea12f
       [AC_CHECK_MEMBERS([struct stat.st_atimensec], [],
Packit aea12f
          [AC_CHECK_MEMBERS([struct stat.st_atim.st__tim.tv_nsec], [], [],
Packit aea12f
             [#include <sys/types.h>
Packit aea12f
              #include <sys/stat.h>])],
Packit aea12f
          [#include <sys/types.h>
Packit aea12f
           #include <sys/stat.h>])],
Packit aea12f
       [#include <sys/types.h>
Packit aea12f
        #include <sys/stat.h>])],
Packit aea12f
    [#include <sys/types.h>
Packit aea12f
     #include <sys/stat.h>])
Packit aea12f
])
Packit aea12f
Packit aea12f
# Check for st_birthtime, a feature from UFS2 (FreeBSD, NetBSD, OpenBSD, etc.)
Packit aea12f
# and NTFS (Cygwin).
Packit aea12f
# There was a time when this field was named st_createtime (21 June
Packit aea12f
# 2002 to 16 July 2002) But that window is very small and applied only
Packit aea12f
# to development code, so systems still using that configuration are
Packit aea12f
# not supported.  See revisions 1.10 and 1.11 of FreeBSD's
Packit aea12f
# src/sys/ufs/ufs/dinode.h.
Packit aea12f
#
Packit aea12f
AC_DEFUN([gl_STAT_BIRTHTIME],
Packit aea12f
[
Packit aea12f
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
Packit aea12f
  AC_CHECK_HEADERS_ONCE([sys/time.h])
Packit aea12f
  AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec], [],
Packit aea12f
    [AC_CHECK_MEMBERS([struct stat.st_birthtimensec], [],
Packit aea12f
      [AC_CHECK_MEMBERS([struct stat.st_birthtim.tv_nsec], [], [],
Packit aea12f
         [#include <sys/types.h>
Packit aea12f
          #include <sys/stat.h>])],
Packit aea12f
       [#include <sys/types.h>
Packit aea12f
        #include <sys/stat.h>])],
Packit aea12f
    [#include <sys/types.h>
Packit aea12f
     #include <sys/stat.h>])
Packit aea12f
])