Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / sys / common_limits.h @ 14

History | View | Annotate | Download (3.74 KB)

1
/*        $NetBSD: common_limits.h,v 1.2 2014/08/19 15:46:46 matt Exp $        */
2

    
3
/*-
4
 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5
 * All rights reserved.
6
 *
7
 * This code is derived from software contributed to The NetBSD Foundation
8
 * by Matt Thomas of 3am Software Foundry.
9
 *
10
 * Redistribution and use in source and binary forms, with or without
11
 * modification, are permitted provided that the following conditions
12
 * are met:
13
 * 1. Redistributions of source code must retain the above copyright
14
 *    notice, this list of conditions and the following disclaimer.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice, this list of conditions and the following disclaimer in the
17
 *    documentation and/or other materials provided with the distribution.
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
 * POSSIBILITY OF SUCH DAMAGE.
30
 */
31

    
32
#ifndef _SYS_COMMON_LIMITS_H_
33
#define _SYS_COMMON_LIMITS_H_
34

    
35
#define        CHAR_BIT        __CHAR_BIT__        /* number of bits in a char */
36

    
37
#define SCHAR_MIN        (-__SCHAR_MAX__-1) /* min value for a signed char */
38
#define        SCHAR_MAX        __SCHAR_MAX__        /* max value for a signed char */
39
#define        UCHAR_MAX        (2*SCHAR_MAX+1)        /* max value for an unsigned char */
40

    
41
#define        SHRT_MIN        (-__SHRT_MAX__-1) /* min value for a short */
42
#define        SHRT_MAX        __SHRT_MAX__        /* max value for a short */
43
#define        USHRT_MAX        (2*SHRT_MAX+1)        /* max value for an unsigned short */
44

    
45
#define        INT_MIN                (-__INT_MAX__-1) /* min value for an int */
46
#define        INT_MAX                __INT_MAX__        /* max value for an int */
47
#define        UINT_MAX        (2U*INT_MAX+1U)        /* max value for an unsigned int */
48

    
49
#define        LONG_MIN        (-__LONG_MAX__-1L)        /* min value for a long */
50
#define        LONG_MAX        __LONG_MAX__                /* max value for a long */
51
#define        ULONG_MAX        (2UL*LONG_MAX+1UL)        /* max unsigned long */
52

    
53
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
54
    defined(_NETBSD_SOURCE)
55
#define        SSIZE_MAX        LONG_MAX        /* max value for a ssize_t */
56

    
57
#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \
58
    defined(_NETBSD_SOURCE)
59
#define        LLONG_MIN        (-__LONG_LONG_MAX__-1LL) /* min signed long long */
60
#define        LLONG_MAX        __LONG_LONG_MAX__        /* max signed long long */
61
#define        ULLONG_MAX        (2ULL*LLONG_MAX+1ULL)        /* max unsigned long long */
62
#endif
63

    
64
#if defined(_NETBSD_SOURCE)
65
#define        SSIZE_MIN        LONG_MIN        /* min value for a ssize_t */
66
#define        SIZE_T_MAX        ULONG_MAX        /* max value for a size_t */
67

    
68
#define        UQUAD_MAX        ULLONG_MAX        /* max unsigned quad */
69
#define        QUAD_MAX        LLONG_MAX        /* max signed quad */
70
#define        QUAD_MIN        LLONG_MIN        /* min signed quad */
71

    
72
#endif /* _NETBSD_SOURCE */
73
#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */
74

    
75
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
76
#define LONG_BIT        (__SIZEOF_LONG__ * 8)
77
#define WORD_BIT        (__SIZEOF_INT__ * 8)
78

    
79
#define DBL_DIG                __DBL_DIG__
80
#define DBL_MAX                __DBL_MAX__
81
#define DBL_MIN                __DBL_MIN__
82

    
83
#define FLT_DIG                __FLT_DIG__
84
#define FLT_MAX                __FLT_MAX__
85
#define FLT_MIN                __FLT_MIN__
86

    
87
#ifdef __LDBL_DIG__
88
#define LDBL_DIG        __LDBL_DIG__
89
#define LDBL_MAX        __LDBL_MAX__
90
#define LDBL_MIN        __LDBL_MIN__
91
#endif
92

    
93
#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
94

    
95
#endif /* _SYS_COMMON_LIMITS_H_ */