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 
76 /**
77  * @file prim_type.h
78  * @brief Basic type definitions used in Sphinx.
79  */
80 
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 
104 /**
105  * Union of basic types.
106  */
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 
136 #ifndef TRUE
137 #define TRUE 1
138 #endif
139 #ifndef FALSE
140 #define FALSE 0
141 #endif
142 
143 #ifndef NULL
144 #define NULL (void *)0
145 #endif
146 
147 /* These really ought to come from <limits.h>, but not everybody has that. */
148 /* Useful constants */
149 #define MAX_INT32		((int32) 0x7fffffff)
150 #define MAX_INT16		((int16) 0x00007fff)
151 #define MAX_INT8		((int8)  0x0000007f)
152 
153 #define MAX_NEG_INT32		((int32) 0x80000000)
154 #define MAX_NEG_INT16		((int16) 0xffff8000)
155 #define MAX_NEG_INT8		((int8)  0xffffff80)
156 
157 #define MAX_UINT32		((uint32) 0xffffffff)
158 #define MAX_UINT16		((uint16) 0x0000ffff)
159 #define MAX_UINT8		((uint8)  0x000000ff)
160 
161 /* The following are approximate; IEEE floating point standards might quibble! */
162 #define MAX_POS_FLOAT32		3.4e+38f
163 #define MIN_POS_FLOAT32		1.2e-38f	/* But not 0 */
164 #define MAX_POS_FLOAT64		1.8e+307
165 #define MIN_POS_FLOAT64		2.2e-308
166 
167 #define MAX_IEEE_NORM_POS_FLOAT32        3.4e+38f
168 #define MIN_IEEE_NORM_POS_FLOAT32        1.2e-38f
169 #define MIN_IEEE_NORM_NEG_FLOAT32       -3.4e+38f
170 #define MAX_IEEE_NORM_POS_FLOAT64        1.8e+307
171 #define MIN_IEEE_NORM_POS_FLOAT64        2.2e-308
172 #define MIN_IEEE_NORM_NEG_FLOAT64       -1.8e+307
173 
174 /* Will the following really work?? */
175 #define MIN_NEG_FLOAT32		((float32) (-MIN_POS_FLOAT32))
176 #define MIN_NEG_FLOAT64		((float64) (-MIN_POS_FLOAT64))
177 
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif
184