SphinxBase  0.6
prim_type.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1999-2004 Carnegie Mellon University. All rights
4  * reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * This work was supported in part by funding from the Defense Advanced
19  * Research Projects Agency and the National Science Foundation of the
20  * United States of America, and the CMU Sphinx Speech Consortium.
21  *
22  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * ====================================================================
35  *
36  */
37 /*
38  * prim_type.h -- Primitive types; more machine-independent.
39  *
40  * **********************************************
41  * CMU ARPA Speech Project
42  *
43  * Copyright (c) 1999 Carnegie Mellon University.
44  * ALL RIGHTS RESERVED.
45  * **********************************************
46  *
47  * HISTORY
48  * $Log: prim_type.h,v $
49  * Revision 1.12 2005/10/05 00:31:14 dhdfu
50  * Make int8 be explicitly signed (signedness of 'char' is
51  * architecture-dependent). Then make a bunch of things use uint8 where
52  * signedness is unimportant, because on the architecture where 'char' is
53  * unsigned, it is that way for a reason (signed chars are slower).
54  *
55  * Revision 1.11 2005/06/22 03:10:23 arthchan2003
56  * Added keyword.
57  *
58  * Revision 1.3 2005/03/30 01:22:48 archan
59  * Fixed mistakes in last updates. Add
60  *
61  *
62  * 12-Mar-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
63  * Added arraysize_t, point_t, fpoint_t.
64  *
65  * 01-Feb-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
66  * Added anytype_t.
67  *
68  * 08-31-95 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
69  * Created.
70  */
71 
72 
73 #ifndef _LIBUTIL_PRIM_TYPE_H_
74 #define _LIBUTIL_PRIM_TYPE_H_
75 
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 #if 0
85 } /* Fool Emacs into not indenting things. */
86 #endif
87 
88 #include <sphinx_config.h>
89 
90 /* Define some things for VisualDSP++ */
91 #if defined(__ADSPBLACKFIN__) && !defined(__GNUC__)
92 # ifndef HAVE_LONG_LONG
93 # define HAVE_LONG_LONG
94 # endif
95 # ifndef ssize_t
96 typedef signed int ssize_t;
97 # endif
98 # define SIZEOF_LONG_LONG 8
99 # define __BIGSTACKVARIABLE__ static
100 #else /* Not VisualDSP++ */
101 # define __BIGSTACKVARIABLE__
102 #endif
103 
107 typedef union anytype_s {
108  void *ptr;
109  long i;
110  unsigned long ui;
111  double fl;
112 } anytype_t;
113 
114 /*
115  * Assume P64 or LP64. If you need to port this to a DSP, let us know.
116  */
117 typedef int int32;
118 typedef short int16;
119 typedef signed char int8;
120 typedef unsigned int uint32;
121 typedef unsigned short uint16;
122 typedef unsigned char uint8;
123 typedef float float32;
124 typedef double float64;
125 #if defined(_MSC_VER)
126 typedef __int64 int64;
127 typedef unsigned __int64 uint64;
128 #elif defined(HAVE_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
129 typedef long long int64;
130 typedef unsigned long long uint64;
131 #else /* !HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8 */
132 typedef double int64;
133 typedef double uint64;
134 #endif /* !HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8 */
135 #ifdef HAVE_FSEEKO
136 # define OFF_T off_t
137 # define FSEEK(stream, offset, whence) fseeko (stream, offset, whence)
138 # define FTELL(stream) ftello (stream)
139 # if SIZEOF_OFF_T == SIZEOF_INT
140 # define PRIdOFF_T "d"
141 # define PRIxOFF_T "x"
142 # elif SIZEOF_OFF_T == SIZEOF_LONG
143 # define PRIdOFF_T "ld"
144 # define PRIxOFF_T "lx"
145 # elif defined(HAVE_LONG_LONG) && SIZEOF_OFF_T == SIZEOF_LONG_LONG
146 # define PRIdOFF_T "lld"
147 # define PRIxOFF_T "llx"
148 # else
149 # error Cannot determine how to print an off_t
150 # endif
151 #else
152 # define OFF_T long
153 # define FSEEK(stream, offset, whence) fseek (stream, offset, whence)
154 # define FTELL(stream) ftell (stream)
155 # define PRIdOFF_T "ld"
156 # define PRIxOFF_T "lx"
157 #endif
158 
159 #ifndef TRUE
160 #define TRUE 1
161 #endif
162 #ifndef FALSE
163 #define FALSE 0
164 #endif
165 
166 #ifndef NULL
167 #define NULL (void *)0
168 #endif
169 
170 /* These really ought to come from <limits.h>, but not everybody has that. */
171 /* Useful constants */
172 #define MAX_INT32 ((int32) 0x7fffffff)
173 #define MAX_INT16 ((int16) 0x00007fff)
174 #define MAX_INT8 ((int8) 0x0000007f)
175 
176 #define MAX_NEG_INT32 ((int32) 0x80000000)
177 #define MAX_NEG_INT16 ((int16) 0xffff8000)
178 #define MAX_NEG_INT8 ((int8) 0xffffff80)
179 
180 #define MAX_UINT32 ((uint32) 0xffffffff)
181 #define MAX_UINT16 ((uint16) 0x0000ffff)
182 #define MAX_UINT8 ((uint8) 0x000000ff)
183 
184 /* The following are approximate; IEEE floating point standards might quibble! */
185 #define MAX_POS_FLOAT32 3.4e+38f
186 #define MIN_POS_FLOAT32 1.2e-38f /* But not 0 */
187 #define MAX_POS_FLOAT64 1.8e+307
188 #define MIN_POS_FLOAT64 2.2e-308
189 
190 #define MAX_IEEE_NORM_POS_FLOAT32 3.4e+38f
191 #define MIN_IEEE_NORM_POS_FLOAT32 1.2e-38f
192 #define MIN_IEEE_NORM_NEG_FLOAT32 -3.4e+38f
193 #define MAX_IEEE_NORM_POS_FLOAT64 1.8e+307
194 #define MIN_IEEE_NORM_POS_FLOAT64 2.2e-308
195 #define MIN_IEEE_NORM_NEG_FLOAT64 -1.8e+307
196 
197 /* Will the following really work?? */
198 #define MAX_NEG_FLOAT32 ((float32) (-MAX_POS_FLOAT32))
199 #define MIN_NEG_FLOAT32 ((float32) (-MIN_POS_FLOAT32))
200 #define MAX_NEG_FLOAT64 ((float64) (-MAX_POS_FLOAT64))
201 #define MIN_NEG_FLOAT64 ((float64) (-MIN_POS_FLOAT64))
202 
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 #endif
union anytype_s anytype_t
Union of basic types.
Union of basic types.
Definition: prim_type.h:107