Home | History | Annotate | Line # | Download | only in include
int_limits.h revision 1.10
      1  1.10    simonb /*	$NetBSD: int_limits.h,v 1.10 2020/07/26 08:08:41 simonb Exp $	*/
      2   1.1    kleink 
      3   1.1    kleink /*-
      4   1.1    kleink  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5   1.1    kleink  * All rights reserved.
      6   1.1    kleink  *
      7   1.1    kleink  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1    kleink  * by Klaus Klein.
      9   1.1    kleink  *
     10   1.1    kleink  * Redistribution and use in source and binary forms, with or without
     11   1.1    kleink  * modification, are permitted provided that the following conditions
     12   1.1    kleink  * are met:
     13   1.1    kleink  * 1. Redistributions of source code must retain the above copyright
     14   1.1    kleink  *    notice, this list of conditions and the following disclaimer.
     15   1.1    kleink  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1    kleink  *    notice, this list of conditions and the following disclaimer in the
     17   1.1    kleink  *    documentation and/or other materials provided with the distribution.
     18   1.1    kleink  *
     19   1.1    kleink  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.1    kleink  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.1    kleink  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.1    kleink  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.1    kleink  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.1    kleink  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.1    kleink  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.1    kleink  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.1    kleink  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.1    kleink  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.1    kleink  * POSSIBILITY OF SUCH DAMAGE.
     30   1.1    kleink  */
     31   1.1    kleink 
     32   1.1    kleink #ifndef _MIPS_INT_LIMITS_H_
     33  1.10    simonb #define	_MIPS_INT_LIMITS_H_
     34   1.1    kleink 
     35   1.9      matt #ifdef __SIG_ATOMIC_MAX__
     36   1.9      matt #include <sys/common_int_limits.h>
     37   1.9      matt #else
     38   1.1    kleink /*
     39   1.1    kleink  * 7.18.2 Limits of specified-width integer types
     40   1.1    kleink  */
     41   1.1    kleink 
     42   1.1    kleink /* 7.18.2.1 Limits of exact-width integer types */
     43   1.1    kleink 
     44   1.1    kleink /* minimum values of exact-width signed integer types */
     45   1.1    kleink #define	INT8_MIN	(-0x7f-1)			/* int8_t	  */
     46   1.1    kleink #define	INT16_MIN	(-0x7fff-1)			/* int16_t	  */
     47   1.1    kleink #define	INT32_MIN	(-0x7fffffff-1)			/* int32_t	  */
     48   1.3   thorpej #ifdef _LP64
     49   1.3   thorpej #define	INT64_MIN	(-0x7fffffffffffffffL-1)	/* int64_t	  */
     50   1.3   thorpej #else
     51   1.1    kleink #define	INT64_MIN	(-0x7fffffffffffffffLL-1)	/* int64_t	  */
     52   1.3   thorpej #endif
     53   1.1    kleink 
     54   1.1    kleink /* maximum values of exact-width signed integer types */
     55   1.1    kleink #define	INT8_MAX	0x7f				/* int8_t	  */
     56   1.1    kleink #define	INT16_MAX	0x7fff				/* int16_t	  */
     57   1.1    kleink #define	INT32_MAX	0x7fffffff			/* int32_t	  */
     58   1.3   thorpej #ifdef _LP64
     59   1.3   thorpej #define	INT64_MAX	0x7fffffffffffffffL		/* int64_t	  */
     60   1.3   thorpej #else
     61   1.1    kleink #define	INT64_MAX	0x7fffffffffffffffLL		/* int64_t	  */
     62   1.3   thorpej #endif
     63   1.1    kleink 
     64   1.1    kleink /* maximum values of exact-width unsigned integer types */
     65   1.6  drochner #define	UINT8_MAX	0xff				/* uint8_t	  */
     66   1.6  drochner #define	UINT16_MAX	0xffff				/* uint16_t	  */
     67   1.1    kleink #define	UINT32_MAX	0xffffffffU			/* uint32_t	  */
     68   1.3   thorpej #ifdef _LP64
     69   1.3   thorpej #define	UINT64_MAX	0xffffffffffffffffUL		/* uint64_t	  */
     70   1.3   thorpej #else
     71   1.1    kleink #define	UINT64_MAX	0xffffffffffffffffULL		/* uint64_t	  */
     72   1.3   thorpej #endif
     73   1.1    kleink 
     74   1.1    kleink /* 7.18.2.2 Limits of minimum-width integer types */
     75   1.1    kleink 
     76   1.1    kleink /* minimum values of minimum-width signed integer types */
     77   1.1    kleink #define	INT_LEAST8_MIN	(-0x7f-1)			/* int_least8_t	  */
     78   1.1    kleink #define	INT_LEAST16_MIN	(-0x7fff-1)			/* int_least16_t  */
     79   1.1    kleink #define	INT_LEAST32_MIN	(-0x7fffffff-1)			/* int_least32_t  */
     80   1.3   thorpej #ifdef _LP64
     81   1.3   thorpej #define	INT_LEAST64_MIN	(-0x7fffffffffffffffL-1)	/* int_least64_t  */
     82   1.3   thorpej #else
     83   1.1    kleink #define	INT_LEAST64_MIN	(-0x7fffffffffffffffLL-1)	/* int_least64_t  */
     84   1.3   thorpej #endif
     85   1.1    kleink 
     86   1.1    kleink /* maximum values of minimum-width signed integer types */
     87   1.1    kleink #define	INT_LEAST8_MAX	0x7f				/* int_least8_t	  */
     88   1.1    kleink #define	INT_LEAST16_MAX	0x7fff				/* int_least16_t  */
     89   1.1    kleink #define	INT_LEAST32_MAX	0x7fffffff			/* int_least32_t  */
     90   1.3   thorpej #ifdef _LP64
     91   1.3   thorpej #define	INT_LEAST64_MAX	0x7fffffffffffffffL		/* int_least64_t  */
     92   1.3   thorpej #else
     93   1.1    kleink #define	INT_LEAST64_MAX	0x7fffffffffffffffLL		/* int_least64_t  */
     94   1.3   thorpej #endif
     95   1.1    kleink 
     96   1.1    kleink /* maximum values of minimum-width unsigned integer types */
     97   1.6  drochner #define	UINT_LEAST8_MAX	 0xff				/* uint_least8_t  */
     98   1.6  drochner #define	UINT_LEAST16_MAX 0xffff				/* uint_least16_t */
     99   1.1    kleink #define	UINT_LEAST32_MAX 0xffffffffU			/* uint_least32_t */
    100   1.3   thorpej #ifdef _LP64
    101   1.3   thorpej #define	UINT_LEAST64_MAX 0xffffffffffffffffUL		/* uint_least64_t */
    102   1.3   thorpej #else
    103   1.1    kleink #define	UINT_LEAST64_MAX 0xffffffffffffffffULL		/* uint_least64_t */
    104   1.3   thorpej #endif
    105   1.1    kleink 
    106   1.2    kleink /* 7.18.2.3 Limits of fastest minimum-width integer types */
    107  1.10    simonb 
    108   1.2    kleink /* minimum values of fastest minimum-width signed integer types */
    109   1.2    kleink #define	INT_FAST8_MIN	(-0x7fffffff-1)			/* int_fast8_t	  */
    110   1.2    kleink #define	INT_FAST16_MIN	(-0x7fffffff-1)			/* int_fast16_t	  */
    111   1.2    kleink #define	INT_FAST32_MIN	(-0x7fffffff-1)			/* int_fast32_t	  */
    112   1.3   thorpej #ifdef _LP64
    113   1.3   thorpej #define	INT_FAST64_MIN	(-0x7fffffffffffffffL-1)	/* int_fast64_t	  */
    114   1.3   thorpej #else
    115   1.2    kleink #define	INT_FAST64_MIN	(-0x7fffffffffffffffLL-1)	/* int_fast64_t	  */
    116   1.3   thorpej #endif
    117   1.2    kleink 
    118   1.2    kleink /* maximum values of fastest minimum-width signed integer types */
    119   1.2    kleink #define	INT_FAST8_MAX	0x7fffffff			/* int_fast8_t	  */
    120   1.2    kleink #define	INT_FAST16_MAX	0x7fffffff			/* int_fast16_t	  */
    121   1.2    kleink #define	INT_FAST32_MAX	0x7fffffff			/* int_fast32_t	  */
    122   1.3   thorpej #ifdef _LP64
    123   1.3   thorpej #define	INT_FAST64_MAX	0x7fffffffffffffffL		/* int_fast64_t	  */
    124   1.3   thorpej #else
    125   1.2    kleink #define	INT_FAST64_MAX	0x7fffffffffffffffLL		/* int_fast64_t	  */
    126   1.3   thorpej #endif
    127   1.2    kleink 
    128   1.2    kleink /* maximum values of fastest minimum-width unsigned integer types */
    129   1.2    kleink #define	UINT_FAST8_MAX	0xffffffffU			/* uint_fast8_t	  */
    130   1.2    kleink #define	UINT_FAST16_MAX	0xffffffffU			/* uint_fast16_t  */
    131   1.2    kleink #define	UINT_FAST32_MAX	0xffffffffU			/* uint_fast32_t  */
    132   1.3   thorpej #ifdef _LP64
    133   1.3   thorpej #define	UINT_FAST64_MAX	0xffffffffffffffffUL		/* uint_fast64_t  */
    134   1.3   thorpej #else
    135   1.2    kleink #define	UINT_FAST64_MAX	0xffffffffffffffffULL		/* uint_fast64_t  */
    136   1.3   thorpej #endif
    137   1.1    kleink 
    138   1.1    kleink /* 7.18.2.4 Limits of integer types capable of holding object pointers */
    139   1.1    kleink 
    140   1.3   thorpej #ifdef _LP64
    141   1.3   thorpej #define	INTPTR_MIN	(-0x7fffffffffffffffL-1)	/* intptr_t	  */
    142   1.3   thorpej #define	INTPTR_MAX	0x7fffffffffffffffL		/* intptr_t	  */
    143   1.3   thorpej #define	UINTPTR_MAX	0xffffffffffffffffUL		/* uintptr_t	  */
    144   1.3   thorpej #else
    145   1.1    kleink #define	INTPTR_MIN	(-0x7fffffff-1)			/* intptr_t	  */
    146   1.1    kleink #define	INTPTR_MAX	0x7fffffff			/* intptr_t	  */
    147   1.1    kleink #define	UINTPTR_MAX	0xffffffffU			/* uintptr_t	  */
    148   1.3   thorpej #endif
    149   1.1    kleink 
    150   1.1    kleink /* 7.18.2.5 Limits of greatest-width integer types */
    151   1.1    kleink 
    152   1.3   thorpej #ifdef _LP64
    153   1.3   thorpej #define	INTMAX_MIN	(-0x7fffffffffffffffL-1)	/* intmax_t	  */
    154   1.3   thorpej #define	INTMAX_MAX	0x7fffffffffffffffL		/* intmax_t	  */
    155   1.3   thorpej #define	UINTMAX_MAX	0xffffffffffffffffUL		/* uintmax_t	  */
    156   1.3   thorpej #else
    157   1.1    kleink #define	INTMAX_MIN	(-0x7fffffffffffffffLL-1)	/* intmax_t	  */
    158   1.1    kleink #define	INTMAX_MAX	0x7fffffffffffffffLL		/* intmax_t	  */
    159   1.1    kleink #define	UINTMAX_MAX	0xffffffffffffffffULL		/* uintmax_t	  */
    160   1.3   thorpej #endif
    161   1.1    kleink 
    162   1.1    kleink 
    163   1.1    kleink /*
    164   1.1    kleink  * 7.18.3 Limits of other integer types
    165   1.1    kleink  */
    166   1.1    kleink 
    167   1.1    kleink /* limits of ptrdiff_t */
    168   1.3   thorpej #ifdef _LP64
    169   1.3   thorpej #define	PTRDIFF_MIN	(-0x7fffffffffffffffL-1)	/* ptrdiff_t	  */
    170   1.3   thorpej #define	PTRDIFF_MAX	0x7fffffffffffffffL		/* ptrdiff_t	  */
    171   1.3   thorpej #else
    172   1.1    kleink #define	PTRDIFF_MIN	(-0x7fffffff-1)			/* ptrdiff_t	  */
    173   1.1    kleink #define	PTRDIFF_MAX	0x7fffffff			/* ptrdiff_t	  */
    174   1.3   thorpej #endif
    175   1.1    kleink 
    176   1.1    kleink /* limits of sig_atomic_t */
    177   1.1    kleink #define	SIG_ATOMIC_MIN	(-0x7fffffff-1)			/* sig_atomic_t	  */
    178   1.1    kleink #define	SIG_ATOMIC_MAX	0x7fffffff			/* sig_atomic_t	  */
    179   1.1    kleink 
    180   1.1    kleink /* limit of size_t */
    181   1.3   thorpej #ifdef _LP64
    182   1.3   thorpej #define	SIZE_MAX	0xffffffffffffffffUL		/* size_t	  */
    183   1.3   thorpej #else
    184   1.1    kleink #define	SIZE_MAX	0xffffffffU			/* size_t	  */
    185   1.3   thorpej #endif
    186   1.1    kleink 
    187   1.9      matt #endif /* !__SIG_ATOMIC_MAX__ */
    188   1.9      matt 
    189   1.1    kleink #endif /* !_MIPS_INT_LIMITS_H_ */
    190