param.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* Compatibility header for old-style Unix parameters and limits.
  2. Copyright (C) 1995-2016 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_PARAM_H
  16. #define _SYS_PARAM_H 1
  17. #define __need_NULL
  18. #include <stddef.h>
  19. #include <sys/types.h>
  20. #include <limits.h>
  21. #include <endian.h> /* Define BYTE_ORDER et al. */
  22. #include <signal.h> /* Define NSIG. */
  23. /* This file defines some things in system-specific ways. */
  24. #include <bits/param.h>
  25. /* BSD names for some <limits.h> values. */
  26. #define NBBY CHAR_BIT
  27. #if !defined NGROUPS && defined NGROUPS_MAX
  28. # define NGROUPS NGROUPS_MAX
  29. #endif
  30. #if !defined MAXSYMLINKS && defined SYMLOOP_MAX
  31. # define MAXSYMLINKS SYMLOOP_MAX
  32. #endif
  33. #if !defined CANBSIZ && defined MAX_CANON
  34. # define CANBSIZ MAX_CANON
  35. #endif
  36. #if !defined MAXPATHLEN && defined PATH_MAX
  37. # define MAXPATHLEN PATH_MAX
  38. #endif
  39. #if !defined NOFILE && defined OPEN_MAX
  40. # define NOFILE OPEN_MAX
  41. #endif
  42. #if !defined MAXHOSTNAMELEN && defined HOST_NAME_MAX
  43. # define MAXHOSTNAMELEN HOST_NAME_MAX
  44. #endif
  45. #ifndef NCARGS
  46. # ifdef ARG_MAX
  47. # define NCARGS ARG_MAX
  48. # else
  49. /* ARG_MAX is unlimited, but we define NCARGS for BSD programs that want to
  50. compare against some fixed limit. */
  51. # define NCARGS INT_MAX
  52. # endif
  53. #endif
  54. /* Magical constants. */
  55. #ifndef NOGROUP
  56. # define NOGROUP 65535 /* Marker for empty group set member. */
  57. #endif
  58. #ifndef NODEV
  59. # define NODEV ((dev_t) -1) /* Non-existent device. */
  60. #endif
  61. /* Unit of `st_blocks'. */
  62. #ifndef DEV_BSIZE
  63. # define DEV_BSIZE 512
  64. #endif
  65. /* Bit map related macros. */
  66. #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
  67. #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
  68. #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
  69. #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
  70. /* Macros for counting and rounding. */
  71. #ifndef howmany
  72. # define howmany(x, y) (((x) + ((y) - 1)) / (y))
  73. #endif
  74. #ifdef __GNUC__
  75. # define roundup(x, y) (__builtin_constant_p (y) && powerof2 (y) \
  76. ? (((x) + (y) - 1) & ~((y) - 1)) \
  77. : ((((x) + ((y) - 1)) / (y)) * (y)))
  78. #else
  79. # define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
  80. #endif
  81. #define powerof2(x) ((((x) - 1) & (x)) == 0)
  82. /* Macros for min/max. */
  83. #define MIN(a,b) (((a)<(b))?(a):(b))
  84. #define MAX(a,b) (((a)>(b))?(a):(b))
  85. #endif /* sys/param.h */