11.11Sriastrad/*	$NetBSD: limits.h,v 1.11 2024/10/30 15:56:11 riastradh Exp $	*/
21.1Scherry
31.1Scherry/*
41.1Scherry * Copyright (c) 1988 The Regents of the University of California.
51.1Scherry * All rights reserved.
61.1Scherry *
71.1Scherry * Redistribution and use in source and binary forms, with or without
81.1Scherry * modification, are permitted provided that the following conditions
91.1Scherry * are met:
101.1Scherry * 1. Redistributions of source code must retain the above copyright
111.1Scherry *    notice, this list of conditions and the following disclaimer.
121.1Scherry * 2. Redistributions in binary form must reproduce the above copyright
131.1Scherry *    notice, this list of conditions and the following disclaimer in the
141.1Scherry *    documentation and/or other materials provided with the distribution.
151.1Scherry * 3. Neither the name of the University nor the names of its contributors
161.1Scherry *    may be used to endorse or promote products derived from this software
171.1Scherry *    without specific prior written permission.
181.1Scherry *
191.1Scherry * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
201.1Scherry * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
211.1Scherry * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
221.1Scherry * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
231.1Scherry * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
241.1Scherry * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
251.1Scherry * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
261.1Scherry * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
271.1Scherry * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
281.1Scherry * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
291.1Scherry * SUCH DAMAGE.
301.1Scherry *
311.1Scherry *	@(#)limits.h	7.2 (Berkeley) 6/28/90
321.1Scherry */
331.1Scherry
341.1Scherry#ifndef	_MACHINE_LIMITS_H_
351.1Scherry#define	_MACHINE_LIMITS_H_
361.1Scherry
371.11Sriastrad#include <sys/featuretest.h>
381.11Sriastrad
391.1Scherry#define	CHAR_BIT	8		/* number of bits in a char */
401.1Scherry
411.3Sdrochner#define	UCHAR_MAX	0xff		/* max value for an unsigned char */
421.6Schristos#define	SCHAR_MAX	0x7f		/* max value for a signed char */
431.6Schristos#define	SCHAR_MIN	(-0x7f-1)	/* min value for a signed char */
441.1Scherry
451.3Sdrochner#define	USHRT_MAX	0xffff		/* max value for an unsigned short */
461.1Scherry#define	SHRT_MAX	0x7fff		/* max value for a short */
471.1Scherry#define	SHRT_MIN	(-0x7fff-1)	/* min value for a short */
481.1Scherry
491.1Scherry#define	UINT_MAX	0xffffffffU	/* max value for an unsigned int */
501.1Scherry#define	INT_MAX		0x7fffffff	/* max value for an int */
511.1Scherry#define	INT_MIN	        (-0x7fffffff-1)	/* min value for an int */
521.1Scherry
531.1Scherry#define	ULONG_MAX	0xffffffffffffffffUL	/* max value for an unsigned long */
541.1Scherry#define	LONG_MAX	0x7fffffffffffffffL	/* max value for a long */
551.1Scherry#define	LONG_MIN	(-0x7fffffffffffffffL-1)	/* min value for a long */
561.1Scherry
571.1Scherry
581.1Scherry#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \
591.1Scherry    defined(_NETBSD_SOURCE)
601.1Scherry#define	ULLONG_MAX	0xffffffffffffffffULL	/* max unsigned long long */
611.1Scherry#define	LLONG_MAX	0x7fffffffffffffffLL	/* max signed long long */
621.1Scherry#define	LLONG_MIN	(-0x7fffffffffffffffLL-1) /* min signed long long */
631.1Scherry#endif
641.1Scherry
651.9Sdholland#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
661.9Sdholland    defined(_NETBSD_SOURCE)
671.9Sdholland#define	SSIZE_MAX	LONG_MAX	/* max value for a ssize_t */
681.9Sdholland
691.1Scherry#if defined(_NETBSD_SOURCE)
701.7Schristos#define	SSIZE_MIN	LONG_MIN	/* min value for a ssize_t */
711.1Scherry#define	SIZE_T_MAX	ULONG_MAX	/* max value for a size_t */
721.1Scherry
731.10Schristos#define	UQUAD_MAX	0xffffffffffffffffULL		/* max unsigned quad */
741.10Schristos#define	QUAD_MAX	0x7fffffffffffffffLL		/* max signed quad */
751.10Schristos#define	QUAD_MIN	(-0x7fffffffffffffffLL-1)	/* min signed quad */
761.1Scherry
771.1Scherry#endif /* _NETBSD_SOURCE */
781.1Scherry#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */
791.1Scherry
801.1Scherry#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
811.1Scherry#define LONG_BIT	64
821.1Scherry#define WORD_BIT	32
831.1Scherry
841.8Smatt#define DBL_DIG		__DBL_DIG__
851.8Smatt#define DBL_MAX		__DBL_MAX__
861.8Smatt#define DBL_MIN		__DBL_MIN__
871.8Smatt
881.8Smatt#define FLT_DIG		__FLT_DIG__
891.8Smatt#define FLT_MAX		__FLT_MAX__
901.8Smatt#define FLT_MIN		__FLT_MIN__
911.1Scherry#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
921.1Scherry
931.1Scherry#endif /* _MACHINE_LIMITS_H_ */
94