limits.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* $OpenBSD: limits.h,v 1.8 2009/11/27 19:54:35 guenther Exp $ */
  2. /*
  3. * Copyright (c) 2002 Marc Espie.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
  15. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
  18. * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  20. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  21. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  22. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #ifndef _SYS_LIMITS_H_
  27. #define _SYS_LIMITS_H_
  28. #include <sys/cdefs.h>
  29. /* Common definitions for limits.h. */
  30. #define CHAR_BIT 8 /* number of bits in a char */
  31. #define SCHAR_MAX 0x7f /* max value for a signed char */
  32. #define SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
  33. #define UCHAR_MAX 0xff /* max value for an unsigned char */
  34. #ifdef __CHAR_UNSIGNED__
  35. # define CHAR_MIN 0 /* min value for a char */
  36. # define CHAR_MAX 0xff /* max value for a char */
  37. #else
  38. # define CHAR_MAX 0x7f
  39. # define CHAR_MIN (-0x7f-1)
  40. #endif
  41. #define MB_LEN_MAX 1 /* Allow UTF-8 (RFC 3629) */
  42. #define USHRT_MAX 0xffff /* max value for an unsigned short */
  43. #define SHRT_MAX 0x7fff /* max value for a short */
  44. #define SHRT_MIN (-0x7fff-1) /* min value for a short */
  45. #define UINT_MAX 0xffffffffU /* max value for an unsigned int */
  46. #define INT_MAX 0x7fffffff /* max value for an int */
  47. #define INT_MIN (-0x7fffffff-1) /* min value for an int */
  48. #ifdef __x86_64__
  49. # define ULONG_MAX 0xffffffffffffffffUL /* max value for unsigned long */
  50. # define LONG_MAX 0x7fffffffffffffffL /* max value for a signed long */
  51. # define LONG_MIN (-0x7fffffffffffffffL-1) /* min value for a signed long */
  52. #else
  53. # define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
  54. # define LONG_MAX 0x7fffffffL /* max value for a long */
  55. # define LONG_MIN (-0x7fffffffL-1) /* min value for a long */
  56. #endif
  57. #define ULLONG_MAX 0xffffffffffffffffULL /* max value for unsigned long long */
  58. #define LLONG_MAX 0x7fffffffffffffffLL /* max value for a signed long long */
  59. #define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min value for a signed long long */
  60. #ifdef __x86_64__
  61. # define LONG_BIT 64
  62. #else
  63. # define LONG_BIT 32
  64. #endif
  65. #endif /* !_SYS_LIMITS_H_ */