param.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Compatibility header for old-style Unix parameters and limits.
  17. Copyright (C) 1995-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _SYS_PARAM_H
  31. #define _SYS_PARAM_H 1
  32. #define __need_NULL
  33. #include <stddef.h>
  34. #include <sys/types.h>
  35. #include <limits.h>
  36. #include <endian.h> /* Define BYTE_ORDER et al. */
  37. #include <signal.h> /* Define NSIG. */
  38. /* This file defines some things in system-specific ways. */
  39. #include <bits/param.h>
  40. /* BSD names for some <limits.h> values. */
  41. #define NBBY CHAR_BIT
  42. #if !defined NGROUPS && defined NGROUPS_MAX
  43. # define NGROUPS NGROUPS_MAX
  44. #endif
  45. #if !defined MAXSYMLINKS && defined SYMLOOP_MAX
  46. # define MAXSYMLINKS SYMLOOP_MAX
  47. #endif
  48. #if !defined CANBSIZ && defined MAX_CANON
  49. # define CANBSIZ MAX_CANON
  50. #endif
  51. #if !defined MAXPATHLEN && defined PATH_MAX
  52. # define MAXPATHLEN PATH_MAX
  53. #endif
  54. #if !defined NOFILE && defined OPEN_MAX
  55. # define NOFILE OPEN_MAX
  56. #endif
  57. #if !defined MAXHOSTNAMELEN && defined HOST_NAME_MAX
  58. # define MAXHOSTNAMELEN HOST_NAME_MAX
  59. #endif
  60. #ifndef NCARGS
  61. # ifdef ARG_MAX
  62. # define NCARGS ARG_MAX
  63. # else
  64. /* ARG_MAX is unlimited, but we define NCARGS for BSD programs that want to
  65. compare against some fixed limit. */
  66. # define NCARGS INT_MAX
  67. # endif
  68. #endif
  69. /* Magical constants. */
  70. #ifndef NOGROUP
  71. # define NOGROUP 65535 /* Marker for empty group set member. */
  72. #endif
  73. #ifndef NODEV
  74. # define NODEV ((dev_t) -1) /* Non-existent device. */
  75. #endif
  76. /* Unit of `st_blocks'. */
  77. #ifndef DEV_BSIZE
  78. # define DEV_BSIZE 512
  79. #endif
  80. /* Bit map related macros. */
  81. #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
  82. #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
  83. #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
  84. #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
  85. /* Macros for counting and rounding. */
  86. #ifndef howmany
  87. # define howmany(x, y) (((x) + ((y) - 1)) / (y))
  88. #endif
  89. #ifdef __GNUC__
  90. # define roundup(x, y) (__builtin_constant_p (y) && powerof2 (y) \
  91. ? (((x) + (y) - 1) & ~((y) - 1)) \
  92. : ((((x) + ((y) - 1)) / (y)) * (y)))
  93. #else
  94. # define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
  95. #endif
  96. #define powerof2(x) ((((x) - 1) & (x)) == 0)
  97. /* Macros for min/max. */
  98. #define MIN(a,b) (((a)<(b))?(a):(b))
  99. #define MAX(a,b) (((a)>(b))?(a):(b))
  100. #endif /* sys/param.h */