1
0

param.h 3.4 KB

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