limits.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * limits.h
  3. *
  4. * Defines constants for the sizes of integral types.
  5. *
  6. * NOTE: GCC should supply a version of this header and it should be safe to
  7. * use that version instead of this one (maybe safer).
  8. *
  9. * This file is part of the Mingw32 package.
  10. *
  11. * Contributors:
  12. * Created by Colin Peters <[email protected]>
  13. *
  14. * THIS SOFTWARE IS NOT COPYRIGHTED
  15. *
  16. * This source code is offered for use in the public domain. You may
  17. * use, modify or distribute it freely.
  18. *
  19. * This code is distributed in the hope that it will be useful but
  20. * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  21. * DISCLAIMED. This includes but is not limited to warranties of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  23. *
  24. * $Revision: 1.2 $
  25. * $Author: bellard $
  26. * $Date: 2005/04/17 13:14:29 $
  27. *
  28. */
  29. #ifndef _LIMITS_H_
  30. #define _LIMITS_H_
  31. /* All the headers include this file. */
  32. #include <_mingw.h>
  33. /*
  34. * File system limits
  35. *
  36. * TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the
  37. * same as FILENAME_MAX and FOPEN_MAX from stdio.h?
  38. * NOTE: Apparently the actual size of PATH_MAX is 260, but a space is
  39. * required for the NUL. TODO: Test?
  40. */
  41. #define PATH_MAX (259)
  42. /*
  43. * Characteristics of the char data type.
  44. *
  45. * TODO: Is MB_LEN_MAX correct?
  46. */
  47. #define CHAR_BIT 8
  48. #define MB_LEN_MAX 2
  49. #define SCHAR_MIN (-128)
  50. #define SCHAR_MAX 127
  51. #define UCHAR_MAX 255
  52. /* TODO: Is this safe? I think it might just be testing the preprocessor,
  53. * not the compiler itself... */
  54. #if ('\x80' < 0)
  55. #define CHAR_MIN SCHAR_MIN
  56. #define CHAR_MAX SCHAR_MAX
  57. #else
  58. #define CHAR_MIN 0
  59. #define CHAR_MAX UCHAR_MAX
  60. #endif
  61. /*
  62. * Maximum and minimum values for ints.
  63. */
  64. #define INT_MAX 2147483647
  65. #define INT_MIN (-INT_MAX-1)
  66. #define UINT_MAX 0xffffffff
  67. /*
  68. * Maximum and minimum values for shorts.
  69. */
  70. #define SHRT_MAX 32767
  71. #define SHRT_MIN (-SHRT_MAX-1)
  72. #define USHRT_MAX 0xffff
  73. /*
  74. * Maximum and minimum values for longs and unsigned longs.
  75. *
  76. * TODO: This is not correct for Alphas, which have 64 bit longs.
  77. */
  78. #define LONG_MAX 2147483647L
  79. #define LONG_MIN (-LONG_MAX-1)
  80. #define ULONG_MAX 0xffffffffUL
  81. /*
  82. * The GNU C compiler also allows 'long long int'
  83. */
  84. #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
  85. #define LONG_LONG_MAX 9223372036854775807LL
  86. #define LONG_LONG_MIN (-LONG_LONG_MAX-1)
  87. #define ULONG_LONG_MAX (2ULL * LONG_LONG_MAX + 1)
  88. /* ISO C9x macro names */
  89. #define LLONG_MAX LONG_LONG_MAX
  90. #define LLONG_MIN LONG_LONG_MIN
  91. #define ULLONG_MAX ULONG_LONG_MAX
  92. #endif /* Not Strict ANSI and GNU C compiler */
  93. #endif /* not _LIMITS_H_ */