doc/SHA256SUMS: Add the list of SHA-256 hashes of release files
[xz.git] / lib / getopt-cdefs.h
blob576428c1c42d1dc766dffcc6fa6a0c76ff7529af
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 /* getopt-on-non-glibc compatibility macros.
4 Copyright (C) 1989-2023 Free Software Foundation, Inc.
5 This file is part of gnulib.
6 Unlike most of the getopt implementation, it is NOT shared
7 with the GNU C Library.
9 This file is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation; either version 2.1 of the
12 License, or (at your option) any later version.
14 This file is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with this program. If not, see <https://www.gnu.org/licenses/>. */
22 #ifndef _GETOPT_CDEFS_H
23 #define _GETOPT_CDEFS_H 1
25 /* This header should not be used directly; include getopt.h or
26 unistd.h instead. It does not have a protective #error, because
27 the guard macro for getopt.h in gnulib is not fixed. */
29 /* getopt-core.h and getopt-ext.h are shared with GNU libc, and expect
30 a number of the internal macros supplied to GNU libc's headers by
31 sys/cdefs.h. Provide fallback definitions for all of them. */
32 #ifdef HAVE_SYS_CDEFS_H
33 # include <sys/cdefs.h>
34 #endif
36 #ifndef __BEGIN_DECLS
37 # ifdef __cplusplus
38 # define __BEGIN_DECLS extern "C" {
39 # else
40 # define __BEGIN_DECLS /* nothing */
41 # endif
42 #endif
43 #ifndef __END_DECLS
44 # ifdef __cplusplus
45 # define __END_DECLS }
46 # else
47 # define __END_DECLS /* nothing */
48 # endif
49 #endif
51 #ifndef __GNUC_PREREQ
52 # if defined __GNUC__ && defined __GNUC_VERSION__
53 # define __GNUC_PREREQ(maj, min) \
54 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
55 # else
56 # define __GNUC_PREREQ(maj, min) 0
57 # endif
58 #endif
60 #ifndef __THROW
61 # if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
62 # if __cplusplus >= 201103L
63 # define __THROW noexcept (true)
64 # else
65 # define __THROW throw ()
66 # endif
67 # else
68 # define __THROW
69 # endif
70 #endif
72 #endif /* _GETOPT_CDEFS_H */