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