param.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*++
  2. Copyright (c) 2015 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. param.h
  9. Abstract:
  10. This header contains old system parameter definitions. This header is
  11. included only for application compatibility. New applications should use
  12. alternate methods to get at the information defined here.
  13. Author:
  14. Evan Green 12-Jan-2015
  15. --*/
  16. #ifndef _SYS_PARAM_H
  17. #define _SYS_PARAM_H
  18. //
  19. // ------------------------------------------------------------------- Includes
  20. //
  21. #include <libcbase.h>
  22. #include <endian.h>
  23. #include <limits.h>
  24. //
  25. // --------------------------------------------------------------------- Macros
  26. //
  27. //
  28. // Define macros for manipulating bitmaps.
  29. //
  30. #define setbit(_Array, _Bit) \
  31. (((unsigned char *)(_Array))[(_Bit) / NBBY] |= 1 << ((_Bit) % NBBY))
  32. #define clrbit(_Array, _Bit) \
  33. (((unsigned char *)(_Array))[(_Bit) / NBBY] &= ~(1 << ((_Bit) % NBBY)))
  34. #define isset(_Array, _Bit) \
  35. (((const unsigned char *)(_Array))[(_Bit) / NBBY] & (1 << ((_Bit) % NBBY)))
  36. #define isclr(_Array, _Bit) (!isset(_Array, _Bit))
  37. //
  38. // Define macros for counting and rounding.
  39. //
  40. #define howmany(_Value, _Divisor) (((_Value) + ((_Divisor) - 1)) / (_Divisor))
  41. #define nitems(_Array) (sizeof((_Array)) / sizeof((_Array)[0])
  42. #define rounddown(_Value, _Round) (((_Value) / (_Round)) * (_Round))
  43. #define roundup(_Value, _Round) \
  44. ((((_Value) + ((_Round) - 1)) / (_Round)) * (_Round))
  45. //
  46. // Round down or up if the rounding value is a power of two.
  47. //
  48. #define rounddown2(_Value, _Round) ((_Value) & (~((_Round) - 1)))
  49. #define roundup2(_Value, _Round) \
  50. (((_Value) + ((_Round) - 1)) & (~((_Round) - 1)))
  51. #define powerof2(_Value) ((((_Value) - 1) & (_Value)) == 0)
  52. //
  53. // Define macros for MIN and MAX.
  54. //
  55. #define MIN(_Value1, _Value2) (((_Value1) < (_Value2)) ? (_Value1) : (_Value2))
  56. #define MAX(_Value1, _Value2) (((_Value1) > (_Value2)) ? (_Value1) : (_Value2))
  57. //
  58. // ---------------------------------------------------------------- Definitions
  59. //
  60. //
  61. // Define the number of bits in a byte.
  62. //
  63. #define NBBY CHAR_BIT
  64. //
  65. // Define the maximum number of user groups.
  66. //
  67. #define NGROUPS NGROUPS_MAX
  68. //
  69. // Define the maximum number of symbolic links that can be expanded in a path.
  70. //
  71. #define MAXSYMLINKS 8
  72. //
  73. // Define the maximum number of argument bytes when calling an exec function.
  74. //
  75. #define NCARGS _POSIX_ARG_MAX
  76. //
  77. // Define the default maximum number of files that can be open per process. The
  78. // actual number is much greater than this, but this value is included for
  79. // compatibility with older applications only.
  80. //
  81. #define NOFILE 256
  82. //
  83. // Define the value for an empty group set.
  84. //
  85. #define NOGROUP 65535
  86. //
  87. // Define the maximum host name size.
  88. //
  89. #define MAXHOSTNAMELEN 256
  90. //
  91. // Define the maximum domain name size.
  92. //
  93. #define MAXDOMNAMELEN 256
  94. //
  95. // Define the maximum size of a path after symlink expansion.
  96. //
  97. #define MAXPATHLEN PATH_MAX
  98. //
  99. // Define the unit of st_blocks in the stat structure.
  100. //
  101. #define DEV_BSIZE 512
  102. //
  103. // ------------------------------------------------------ Data Type Definitions
  104. //
  105. //
  106. // -------------------------------------------------------------------- Globals
  107. //
  108. //
  109. // -------------------------------------------------------- Function Prototypes
  110. //
  111. #endif