1 /* Substitute for and wrapper around <utime.h>.
2 Copyright (C) 2017-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 #ifndef _@GUARD_PREFIX@_UTIME_H
20 @PRAGMA_SYSTEM_HEADER@
24 /* This file uses #include_next of a system file that defines time_t.
25 For the 'year2038' module to work right, <config.h> needs to have been
27 #if !_GL_CONFIG_H_INCLUDED
28 #error "Please include config.h first."
31 /* The include_next requires a split double-inclusion guard. */
33 # @INCLUDE_NEXT@ @NEXT_UTIME_H@
36 #ifndef _@GUARD_PREFIX@_UTIME_H
37 #define _@GUARD_PREFIX@_UTIME_H
39 /* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
40 #if !_GL_CONFIG_H_INCLUDED
41 #error "Please include config.h first."
45 # include <sys/utime.h>
49 /* Get struct timespec. */
53 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
55 /* The definition of _GL_ARG_NONNULL is copied here. */
57 /* The definition of _GL_WARN_ON_USE is copied here. */
60 #if defined _WIN32 && ! defined __CYGWIN__
62 /* Define 'struct utimbuf' as an alias of 'struct _utimbuf'
63 (or possibly, if present, 'struct __utimbuf64'). */
64 # define utimbuf _utimbuf
71 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
72 # define utime rpl_utime
74 _GL_FUNCDECL_RPL (utime
, int, (const char *filename
, const struct utimbuf
*ts
),
75 _GL_ARG_NONNULL ((1)));
76 _GL_CXXALIAS_RPL (utime
, int, (const char *filename
, const struct utimbuf
*ts
));
77 # elif defined _WIN32 && !defined __CYGWIN__
78 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
82 _GL_CXXALIAS_MDA (utime
, int, (const char *filename
, const struct utimbuf
*ts
));
85 _GL_FUNCDECL_SYS (utime
, int, (const char *filename
, const struct utimbuf
*ts
),
86 _GL_ARG_NONNULL ((1)));
88 _GL_CXXALIAS_SYS (utime
, int, (const char *filename
, const struct utimbuf
*ts
));
91 _GL_CXXALIASWARN (utime
);
93 #elif defined GNULIB_POSIXCHECK
95 # if HAVE_RAW_DECL_UTIME
96 _GL_WARN_ON_USE (utime
,
97 "utime is unportable - "
98 "use gnulib module canonicalize-lgpl for portability");
100 #elif @GNULIB_MDA_UTIME@
101 /* On native Windows, map 'utime' to '_utime', so that -loldnames is not
102 required. In C++ with GNULIB_NAMESPACE, avoid differences between
103 platforms by defining GNULIB_NAMESPACE::utime always. */
104 # if defined _WIN32 && !defined __CYGWIN__
105 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
107 # define utime _utime
109 _GL_CXXALIAS_MDA (utime
, int, (const char *filename
, const struct utimbuf
*ts
));
111 _GL_CXXALIAS_SYS (utime
, int, (const char *filename
, const struct utimbuf
*ts
));
114 _GL_CXXALIASWARN (utime
);
119 _GL_EXTERN_C
int _gl_utimens_windows (const char *filename
, struct timespec ts
[2]);
123 #endif /* _@GUARD_PREFIX@_UTIME_H */
124 #endif /* _@GUARD_PREFIX@_UTIME_H */