PocketSphinx  5.0.0rc5
A small speech recognizer
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 <pocketsphinx/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 /* Use C99 types if available */
115 #if defined(HAVE_STDINT_H) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
116 #include <stdint.h>
117 typedef int32_t int32;
118 typedef int16_t int16;
119 typedef int8_t int8;
120 typedef uint32_t uint32;
121 typedef uint16_t uint16;
122 typedef uint8_t uint8;
123 typedef int64_t int64;
124 typedef uint64_t uint64;
125 /* Take a wild guess otherwise */
126 #else
127 typedef int int32;
128 typedef short int16;
129 typedef signed char int8;
130 typedef unsigned int uint32;
131 typedef unsigned short uint16;
132 typedef unsigned char uint8;
133 # if defined(_MSC_VER)
134 typedef __int64 int64;
135 typedef unsigned __int64 uint64;
136 # else
137 typedef long long int64;
138 typedef unsigned long long uint64;
139 # endif
140 #endif /* not C99 or POSIX */
141 
142 /* We should maybe stop using these as there isn't any good way to
143  know their exact size, but it's 99% certain they are 32 and 64
144  bits. */
145 typedef float float32;
146 typedef double float64;
147 
148 #ifndef TRUE
149 #define TRUE 1
150 #endif
151 #ifndef FALSE
152 #define FALSE 0
153 #endif
154 
155 #ifndef NULL
156 #define NULL (void *)0
157 #endif
158 
159 /* These really ought to come from <limits.h>, but not everybody has that. */
160 /* Useful constants */
161 #define MAX_INT32 ((int32) 0x7fffffff)
162 #define MAX_INT16 ((int16) 0x00007fff)
163 #define MAX_INT8 ((int8) 0x0000007f)
164 
165 #define MAX_NEG_INT32 ((int32) 0x80000000)
166 #define MAX_NEG_INT16 ((int16) 0xffff8000)
167 #define MAX_NEG_INT8 ((int8) 0xffffff80)
168 
169 #define MAX_UINT32 ((uint32) 0xffffffff)
170 #define MAX_UINT16 ((uint16) 0x0000ffff)
171 #define MAX_UINT8 ((uint8) 0x000000ff)
172 
173 /* The following are approximate; IEEE floating point standards might quibble! */
174 #define MAX_POS_FLOAT32 3.4e+38f
175 #define MIN_POS_FLOAT32 1.2e-38f /* But not 0 */
176 #define MAX_POS_FLOAT64 1.8e+307
177 #define MIN_POS_FLOAT64 2.2e-308
178 
179 #define MAX_IEEE_NORM_POS_FLOAT32 3.4e+38f
180 #define MIN_IEEE_NORM_POS_FLOAT32 1.2e-38f
181 #define MIN_IEEE_NORM_NEG_FLOAT32 -3.4e+38f
182 #define MAX_IEEE_NORM_POS_FLOAT64 1.8e+307
183 #define MIN_IEEE_NORM_POS_FLOAT64 2.2e-308
184 #define MIN_IEEE_NORM_NEG_FLOAT64 -1.8e+307
185 
186 /* Will the following really work?? */
187 #define MIN_NEG_FLOAT32 ((float32) (-MIN_POS_FLOAT32))
188 #define MIN_NEG_FLOAT64 ((float64) (-MIN_POS_FLOAT64))
189 
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 
195 #endif
anytype_t
union anytype_s anytype_t
anytype_s
Definition: prim_type.h:107