1/* Definitions of macros to access `dev_t' values.
2 Copyright (C) 1996-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SYSMACROS_H_OUTER
20
21#ifndef __SYSMACROS_DEPRECATED_INCLUSION
22# define _SYS_SYSMACROS_H_OUTER 1
23#endif
24
25/* If <sys/sysmacros.h> is included after <sys/types.h>, these macros
26 will already be defined, and we need to redefine them without the
27 deprecation warnings. (If they are included in the opposite order,
28 the outer #ifndef will suppress this entire file and the macros
29 will be usable without warnings.) */
30#undef major
31#undef minor
32#undef makedev
33
34/* This is the macro that must be defined to satisfy the misuse check
35 in bits/sysmacros.h. */
36#ifndef _SYS_SYSMACROS_H
37#define _SYS_SYSMACROS_H 1
38
39#include <features.h>
40#include <bits/types.h>
41#include <bits/sysmacros.h>
42
43/* Caution: The text of this deprecation message is unquoted, so that
44 #symbol can be substituted. (It is converted to a string by
45 __SYSMACROS_DM1.) This means the message must be a sequence of
46 complete pp-tokens; in particular, English contractions (it's,
47 can't) cannot be used.
48
49 The message has been manually word-wrapped to fit in 80 columns
50 when output by GCC 5 and 6. The first line is shorter to leave
51 some room for the "foo.c:23: warning:" annotation. */
52#define __SYSMACROS_DM(symbol) __SYSMACROS_DM1 \
53 (In the GNU C Library, #symbol is defined\n\
54 by <sys/sysmacros.h>. For historical compatibility, it is\n\
55 currently defined by <sys/types.h> as well, but we plan to\n\
56 remove this soon. To use #symbol, include <sys/sysmacros.h>\n\
57 directly. If you did not intend to use a system-defined macro\n\
58 #symbol, you should undefine it after including <sys/types.h>.)
59
60/* This macro is variadic because the deprecation message above
61 contains commas. */
62#define __SYSMACROS_DM1(...) __glibc_macro_warning (#__VA_ARGS__)
63
64#define __SYSMACROS_DECL_TEMPL(rtype, name, proto) \
65 extern rtype gnu_dev_##name proto __THROW __attribute_const__;
66
67#define __SYSMACROS_IMPL_TEMPL(rtype, name, proto) \
68 __extension__ __extern_inline __attribute_const__ rtype \
69 __NTH (gnu_dev_##name proto)
70
71__BEGIN_DECLS
72
73__SYSMACROS_DECLARE_MAJOR (__SYSMACROS_DECL_TEMPL)
74__SYSMACROS_DECLARE_MINOR (__SYSMACROS_DECL_TEMPL)
75__SYSMACROS_DECLARE_MAKEDEV (__SYSMACROS_DECL_TEMPL)
76
77#ifdef __USE_EXTERN_INLINES
78
79__SYSMACROS_DEFINE_MAJOR (__SYSMACROS_IMPL_TEMPL)
80__SYSMACROS_DEFINE_MINOR (__SYSMACROS_IMPL_TEMPL)
81__SYSMACROS_DEFINE_MAKEDEV (__SYSMACROS_IMPL_TEMPL)
82
83#endif
84
85__END_DECLS
86
87#endif /* _SYS_SYSMACROS_H */
88
89#ifndef __SYSMACROS_NEED_IMPLEMENTATION
90# undef __SYSMACROS_DECL_TEMPL
91# undef __SYSMACROS_IMPL_TEMPL
92# undef __SYSMACROS_DECLARE_MAJOR
93# undef __SYSMACROS_DECLARE_MINOR
94# undef __SYSMACROS_DECLARE_MAKEDEV
95# undef __SYSMACROS_DEFINE_MAJOR
96# undef __SYSMACROS_DEFINE_MINOR
97# undef __SYSMACROS_DEFINE_MAKEDEV
98#endif
99
100#ifdef __SYSMACROS_DEPRECATED_INCLUSION
101# define major(dev) __SYSMACROS_DM (major) gnu_dev_major (dev)
102# define minor(dev) __SYSMACROS_DM (minor) gnu_dev_minor (dev)
103# define makedev(maj, min) __SYSMACROS_DM (makedev) gnu_dev_makedev (maj, min)
104#else
105# define major(dev) gnu_dev_major (dev)
106# define minor(dev) gnu_dev_minor (dev)
107# define makedev(maj, min) gnu_dev_makedev (maj, min)
108#endif
109
110#endif /* sys/sysmacros.h */
111