openat: don’t close (-1)
[gnulib.git] / lib / utime.in.h
blob55b7ee8c943a0fb87f90f440774f3e37318776e9
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
19 #if __GNUC__ >= 3
20 @PRAGMA_SYSTEM_HEADER@
21 #endif
22 @PRAGMA_COLUMNS@
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
26 included before. */
27 #if !_GL_CONFIG_H_INCLUDED
28 #error "Please include config.h first."
29 #endif
31 /* The include_next requires a split double-inclusion guard. */
32 #if @HAVE_UTIME_H@
33 # @INCLUDE_NEXT@ @NEXT_UTIME_H@
34 #endif
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."
42 #endif
44 #if !@HAVE_UTIME_H@
45 # include <sys/utime.h>
46 #endif
48 #if @GNULIB_UTIME@
49 /* Get struct timespec. */
50 # include <time.h>
51 #endif
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
66 #endif
69 #if @GNULIB_UTIME@
70 # if @REPLACE_UTIME@
71 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
72 # define utime rpl_utime
73 # endif
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)
79 # undef utime
80 # define utime _utime
81 # endif
82 _GL_CXXALIAS_MDA (utime, int, (const char *filename, const struct utimbuf *ts));
83 # else
84 # if !@HAVE_UTIME@
85 _GL_FUNCDECL_SYS (utime, int, (const char *filename, const struct utimbuf *ts),
86 _GL_ARG_NONNULL ((1)));
87 # endif
88 _GL_CXXALIAS_SYS (utime, int, (const char *filename, const struct utimbuf *ts));
89 # endif
90 # if __GLIBC__ >= 2
91 _GL_CXXALIASWARN (utime);
92 # endif
93 #elif defined GNULIB_POSIXCHECK
94 # undef utime
95 # if HAVE_RAW_DECL_UTIME
96 _GL_WARN_ON_USE (utime,
97 "utime is unportable - "
98 "use gnulib module canonicalize-lgpl for portability");
99 # endif
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)
106 # undef utime
107 # define utime _utime
108 # endif
109 _GL_CXXALIAS_MDA (utime, int, (const char *filename, const struct utimbuf *ts));
110 # else
111 _GL_CXXALIAS_SYS (utime, int, (const char *filename, const struct utimbuf *ts));
112 # endif
113 # if __GLIBC__ >= 2
114 _GL_CXXALIASWARN (utime);
115 # endif
116 #endif
118 #if @GNULIB_UTIME@
119 _GL_EXTERN_C int _gl_utimens_windows (const char *filename, struct timespec ts[2]);
120 #endif
123 #endif /* _@GUARD_PREFIX@_UTIME_H */
124 #endif /* _@GUARD_PREFIX@_UTIME_H */