loader: VTOC partition size is one sector too large
[unleashed.git] / include / values.h
blob94ccdb4718b29f5733718cab46cd66031b507e7e
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
22 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
29 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
30 * Use is subject to license terms.
33 #ifndef _VALUES_H
34 #define _VALUES_H
36 #include <sys/isa_defs.h>
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
43 * These values work with any binary representation of integers
44 * where the high-order bit contains the sign.
47 /* a number used normally for size of a shift */
48 #define BITSPERBYTE 8
50 #define BITS(type) (BITSPERBYTE * (long)sizeof (type))
52 /* short, regular and long ints with only the high-order bit turned on */
53 #define HIBITS ((short)(1 << (BITS(short) - 1)))
55 #define HIBITI (1U << (BITS(int) - 1))
56 #define HIBITL (1UL << (BITS(long) - 1))
58 /* largest short, regular and long int */
59 #define MAXSHORT ((short)~HIBITS)
60 #define MAXINT ((int)(~HIBITI))
61 #define MAXLONG ((long)(~HIBITL))
64 * various values that describe the binary floating-point representation
65 * _EXPBASE - the exponent base
66 * DMAXEXP - the maximum exponent of a double (as returned by frexp())
67 * FMAXEXP - the maximum exponent of a float (as returned by frexp())
68 * DMINEXP - the minimum exponent of a double (as returned by frexp())
69 * FMINEXP - the minimum exponent of a float (as returned by frexp())
70 * MAXDOUBLE - the largest double
71 * ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
72 * MAXFLOAT - the largest float
73 * ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
74 * MINDOUBLE - the smallest double (_EXPBASE ** (DMINEXP - 1))
75 * MINFLOAT - the smallest float (_EXPBASE ** (FMINEXP - 1))
76 * DSIGNIF - the number of significant bits in a double
77 * FSIGNIF - the number of significant bits in a float
78 * DMAXPOWTWO - the largest power of two exactly representable as a double
79 * FMAXPOWTWO - the largest power of two exactly representable as a float
80 * _IEEE - 1 if IEEE standard representation is used
81 * _DEXPLEN - the number of bits for the exponent of a double
82 * _FEXPLEN - the number of bits for the exponent of a float
83 * _HIDDENBIT - 1 if high-significance bit of mantissa is implicit
84 * LN_MAXDOUBLE - the natural log of the largest double -- log(MAXDOUBLE)
85 * LN_MINDOUBLE - the natural log of the smallest double -- log(MINDOUBLE)
86 * LN_MAXFLOAT - the natural log of the largest float -- log(MAXFLOAT)
87 * LN_MINFLOAT - the natural log of the smallest float -- log(MINFLOAT)
91 * Currently, only IEEE-754 format is supported.
93 #if defined(_IEEE_754)
94 #define MAXDOUBLE 1.79769313486231570e+308
95 #define MAXFLOAT ((float)3.40282346638528860e+38)
96 #define MINDOUBLE 4.94065645841246544e-324
97 #define MINFLOAT ((float)1.40129846432481707e-45)
98 #define _IEEE 1
99 #define _DEXPLEN 11
100 #define _HIDDENBIT 1
101 #define _LENBASE 1
102 #define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
103 #define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
104 #else
105 /* #error is strictly ansi-C, but works as well as anything for K&R systems. */
106 #error "ISA not supported"
107 #endif
109 #define _EXPBASE (1 << _LENBASE)
110 #define _FEXPLEN 8
111 #define DSIGNIF (BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
112 #define FSIGNIF (BITS(float) - _FEXPLEN + _HIDDENBIT - 1)
113 #define DMAXPOWTWO ((double)(1 << (BITS(int) - 2)) * \
114 (1 << (DSIGNIF - BITS(int) + 1)))
115 #define FMAXPOWTWO ((float)(1 << (FSIGNIF - 1)))
116 #define DMAXEXP ((1 << (_DEXPLEN - 1)) - 1 + _IEEE)
117 #define FMAXEXP ((1 << (_FEXPLEN - 1)) - 1 + _IEEE)
118 #define LN_MAXDOUBLE (M_LN2 * DMAXEXP)
119 #define LN_MAXFLOAT (float)(M_LN2 * FMAXEXP)
120 #define LN_MINDOUBLE (M_LN2 * (DMINEXP - 1))
121 #define LN_MINFLOAT (float)(M_LN2 * (FMINEXP - 1))
122 #define H_PREC (DSIGNIF % 2 ? (1 << DSIGNIF/2) * M_SQRT2 : 1 << DSIGNIF/2)
123 #define FH_PREC \
124 (float)(FSIGNIF % 2 ? (1 << FSIGNIF/2) * M_SQRT2 : 1 << FSIGNIF/2)
125 #define X_EPS (1.0/H_PREC)
126 #define FX_EPS (float)((float)1.0/FH_PREC)
127 #define X_PLOSS ((double)(int)(M_PI * H_PREC))
128 #define FX_PLOSS ((float)(int)(M_PI * FH_PREC))
129 #define X_TLOSS (M_PI * DMAXPOWTWO)
130 #define FX_TLOSS (float)(M_PI * FMAXPOWTWO)
131 #define M_LN2 0.69314718055994530942
132 #define M_PI 3.14159265358979323846
133 #define M_SQRT2 1.41421356237309504880
134 #define MAXBEXP DMAXEXP /* for backward compatibility */
135 #define MINBEXP DMINEXP /* for backward compatibility */
136 #define MAXPOWTWO DMAXPOWTWO /* for backward compatibility */
138 #ifdef __cplusplus
140 #endif
142 #endif /* _VALUES_H */