GL Studio SCECpp Runtime Library
gls_types.h
Go to the documentation of this file.
1 /*! \file gls_types.h
2 
3 \brief This header defines the basic types used by
4  the GL Studio DO-178B Runtime Library.
5 
6 \par Copyright Information
7 Copyright (C) 1999-2012 The DiSTI Corporation<br>
8 Orlando, FL USA<br>
9 All rights reserved.<br>
10 
11  This file is copyrighted software and contains proprietary trade secrets of
12 DiSTI, and embodies substantial creative efforts as well as confidential
13 information, ideas, and expressions.
14 
15  Permission to use, and copy this software and its documentation for any
16 purpose is hereby granted per the Distribution Agreement and/or the Licensing
17 Agreement signed with DiSTI. This permission is granted provided that:
18  1. The above copyright notice appears in all copies.
19  2. That both the copyright notice and this permission notice appear in
20  the supporting documentation.
21  3. That the names DiSTI and GL Studio not be used in advertising or
22  publicity pertaining to distribution of the software without specific,
23  written prior permission of DiSTI.
24 
25  Permission to modify the software is granted, but not the right to
26 distribute the source code whether modified, or non-modified. Modifying the
27 software might invalidate the DO-178B certification package.
28 
29  Permission to distribute binaries produced by compiling source code, or
30 modified source code is granted, provided you:
31  1. Provide your name and address as the primary contact for the support
32  of your modified version.
33  2. Retain our contact information in regard to use of the base software.
34 
35  DiSTI does not provide warranty for this software or guarantee that it
36 satisfies any specification or requirement unless otherwise stated in a
37 specific contractual arrangement between the customer and DiSTI.
38 
39 */
40 #ifndef _GLS_TYPES_H
41 #define _GLS_TYPES_H
42 
43 #include "gls_include.h"
44 #include <limits.h>
45 #include <float.h>
46 #include <math.h>
47 #include "gls_gl.h"
48 #include "gls_assert.h"
49 
50 /** define GLS_NULL pointer value */
51 #define GLS_NULL ( 0 )
52 
53 /** 8-bit character */
54 typedef char GlsChar;
55 /** largest value that can fit in a GlsChar */
56 #define GLSCHAR_MAX ( CHAR_MAX )
57 /** smallest value that can fit in a GlsChar */
58 #define GLSCHAR_MIN ( CHAR_MIN )
59 
60 /** 8-bit unsigned character */
61 typedef unsigned char GlsUChar;
62 /** largest value that can be stored in a GlsUChar */
63 #define GLSUCHAR_MAX ( UCHAR_MAX )
64 
65 /** 32-bit signed integer */
66 typedef int GlsInt32;
67 /** largest value that can be stored in a GlsInt32 */
68 #define GLSINT32_MAX ( INT_MAX )
69 /** smallest value that can be stored in a GlsInt32 */
70 #define GLSINT32_MIN ( INT_MIN )
71 
72 /** 32-bit unsigned integer */
73 typedef unsigned int GlsUInt32;
74 /** largest value that can be stored in a GlsUInt32 */
75 #define GLSUINT32_MAX ( UINT_MAX )
76 
77 /** 32-bit single precision floating point */
78 typedef float GlsFloat32;
79 /** largest value that can be stored in a GlsFloat32 */
80 #define GLSFLOAT32_MAX ( FLT_MAX )
81 /** smallest value that can be stored in a GlsFloat32 */
82 #define GLSFLOAT32_MIN ( FLT_MIN )
83 /** smallest GlsFloat32 value such that ( 1.0 + GLSFLOAT32_EPSILON != 1.0 ) */
84 #define GLSFLOAT32_EPSILON ( FLT_EPSILON )
85 
86 /** 64-bit double precision floating point */
87 typedef double GlsFloat64;
88 /** largest value that can be stored in a GlsFloat64 */
89 #define GLSFLOAT64_MAX ( DBL_MAX )
90 /** smallest value that can be stored in a GlsFloat64 */
91 #define GLSFLOAT64_MIN ( DBL_MIN )
92 /** smallest GlsFloat64 value such that ( 1.0 + GLSFLOAT64_EPSILON != 1.0 ) */
93 #define GLSFLOAT64_EPSILON ( DBL_EPSILON )
94 
95 /** boolean value */
96 typedef bool GlsBool;
97 
98 /** true value for a GlsBool */
99 #define GLS_TRUE ( true )
100 /** false value for a GlsBool */
101 #define GLS_FALSE ( false )
102 
103 #if defined( GLS_DEBUG )
104 #pragma BullseyeCoverage save off
105 /** Determine if the given floating point value is valid ( GLS_DEBUG only )
106  * \param f floating point value in question
107  * \return GLS_TRUE if float is valid else GLS_FALSE
108  * \pre none
109  * \post none
110  */
111 inline GlsBool GlsFloatIsValid( const GlsFloat64 f )
112 {
113  #if defined( GLS_LINUX_TEST )
114  return( !isnan( f ) && isfinite( f ) );
115  #else
116  #if !defined( GLS_VXWORKS )
117  return( _finite( f ) != 0 );
118  #else
119  return GLS_TRUE;
120  #endif
121  #endif
122 }
123 #pragma BullseyeCoverage restore
124 #endif // GLS_DEBUG
125 
126 #if defined( GLS_DEBUG )
127 #pragma BullseyeCoverage save off
128 /** Assert that the basic library types have the proper sizes and values at runtime ( GLS_DEBUG only )
129  * \pre none
130  * \post none
131  */
132 inline void GlsTypesAssertValid( void )
133 {
134  // check sizes
135  GlsAssert( sizeof( GlsChar ) == 1u );
136  GlsAssert( sizeof( GlsUChar ) == 1u );
137  GlsAssert( sizeof( GlsInt32 ) == 4u );
138  GlsAssert( sizeof( GlsUInt32 ) == 4u );
139  GlsAssert( sizeof( GlsFloat32 ) == 4u );
140  GlsAssert( sizeof( GlsFloat64 ) == 8u );
141 
142  // assumes that GLS_TRUE is always "true" and GLS_FALSE is always "false"
143  GlsAssert( GLS_TRUE == true );
144  GlsAssert( GLS_FALSE == false );
145 
146  // ensure that floats line up with GL floats
147  GlsAssert( sizeof( GlsFloat32 ) == sizeof( GLfloat ) );
148  GlsAssert( sizeof( GlsFloat64 ) == sizeof( GLdouble ) );
149 }
150 #pragma BullseyeCoverage restore
151 #endif // GLS_DEBUG
152 
153 #endif // _GLS_TYPES_H
int GlsInt32
Definition: gls_types.h:66
unsigned char GlsUChar
Definition: gls_types.h:61
bool GlsBool
Definition: gls_types.h:96
#define GlsAssert(_exp)
Definition: gls_assert.h:108
char GlsChar
Definition: gls_types.h:54
This header defines the runtime assert checking macros for the GL Studio DO-178B Runtime Library...
unsigned int GlsUInt32
Definition: gls_types.h:73
This header defines any preprocessor defines needed to configure the GL Studio DO-178B Runtime Librar...
float GlsFloat32
Definition: gls_types.h:78
#define GLS_TRUE
Definition: gls_types.h:99
double GlsFloat64
Definition: gls_types.h:87
#define GLS_FALSE
Definition: gls_types.h:101
This header includes the API for the OpenGL provider used in the GL Studio DO-178B Runtime Library...