sysmacros.h 3.9 KB

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