1 /* @(#)values.h	1.1 18/12/30 Copyright 2018 J. Schilling */
2 /*
3  *	Abstraction code for values.h
4  *
5  *	Copyright (c) 2018 J. Schilling
6  */
7 /*
8  * The contents of this file are subject to the terms of the
9  * Common Development and Distribution License, Version 1.0 only
10  * (the "License").  You may not use this file except in compliance
11  * with the License.
12  *
13  * See the file CDDL.Schily.txt in this distribution for details.
14  * A copy of the CDDL is also available via the Internet at
15  * http://www.opensource.org/licenses/cddl1.txt
16  *
17  * When distributing Covered Code, include this CDDL HEADER in each
18  * file and include the License file CDDL.Schily.txt from this distribution.
19  */
20 
21 #ifndef	_SCHILY_VALUES_H
22 #define	_SCHILY_VALUES_H
23 
24 #ifdef	__cplusplus
25 extern "C" {
26 #endif
27 
28 #ifndef _SCHILY_MCONFIG_H
29 #include <schily/mconfig.h>
30 #endif
31 
32 #ifdef	HAVE_FLOAT_H
33 #ifndef	_INCL_FLOAT_H
34 #define	_INCL_FLOAT_H
35 #include <float.h>
36 #endif
37 #endif
38 
39 #ifdef	HAVE_VALUES_H
40 #ifndef	_INCL_VALUES_H
41 #define	_INCL_VALUES_H
42 #include <values.h>
43 #endif
44 #endif
45 
46 #ifndef	BITSPERBYTE
47 #define	BITSPERBYTE	8
48 #endif
49 
50 #ifndef	BITS
51 #define	BITS(type)	(BITSPERBYTE * (long)sizeof (type))
52 #endif
53 
54 #ifndef	HIBITS
55 #define	HIBITS		((short)(1 << (BITS(short) - 1)))
56 #endif
57 
58 #if defined(__STDC__)
59 #ifndef	HIBITI
60 #define	HIBITI		(1U << (BITS(int) - 1))
61 #endif
62 #ifndef	HIBITL
63 #define	HIBITL		(1UL << (BITS(long) - 1))
64 #endif
65 #else
66 #ifndef	HIBITI
67 #define	HIBITI		((unsigned)1 << (BITS(int) - 1))
68 #endif
69 #ifndef	HIBITL
70 #define	HIBITL		(1L << (BITS(long) - 1))
71 #endif
72 #endif
73 
74 #ifndef	MAXSHORT
75 #define	MAXSHORT	((short)~HIBITS)
76 #endif
77 #ifndef	MAXINT
78 #define	MAXINT		((int)(~HIBITI))
79 #endif
80 #ifndef	MAXLONG
81 #define	MAXLONG		((long)(~HIBITL))
82 #endif
83 
84 #ifdef	__cplusplus
85 }
86 #endif
87 
88 #endif	/* _SCHILY_VALUES_H */
89