1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3 * Copyright (c) 1999-2004 Carnegie Mellon University. All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
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
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.
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.
34 * ====================================================================
38 * prim_type.h -- Primitive types; more machine-independent.
40 * **********************************************
41 * CMU ARPA Speech Project
43 * Copyright (c) 1999 Carnegie Mellon University.
44 * ALL RIGHTS RESERVED.
45 * **********************************************
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).
55 * Revision 1.11 2005/06/22 03:10:23 arthchan2003
58 * Revision 1.3 2005/03/30 01:22:48 archan
59 * Fixed mistakes in last updates. Add
62 * 12-Mar-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
63 * Added arraysize_t, point_t, fpoint_t.
65 * 01-Feb-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
68 * 08-31-95 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
73 #ifndef _LIBUTIL_PRIM_TYPE_H_
74 #define _LIBUTIL_PRIM_TYPE_H_
78 * @brief Basic type definitions used in Sphinx.
85 } /* Fool Emacs into not indenting things. */
88 #include <sphinx_config.h>
90 /* Define some things for VisualDSP++ */
91 #if defined(__ADSPBLACKFIN__) && !defined(__GNUC__)
92 # ifndef HAVE_LONG_LONG
93 # define HAVE_LONG_LONG
96 typedef signed int ssize_t;
98 # define SIZEOF_LONG_LONG 8
99 # define __BIGSTACKVARIABLE__ static
100 #else /* Not VisualDSP++ */
101 # define __BIGSTACKVARIABLE__
105 * Union of basic types.
107 typedef union anytype_s {
115 * Assume P64 or LP64. If you need to port this to a DSP, let us know.
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 */
144 #define NULL (void *)0
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)
153 #define MAX_NEG_INT32 ((int32) 0x80000000)
154 #define MAX_NEG_INT16 ((int16) 0xffff8000)
155 #define MAX_NEG_INT8 ((int8) 0xffffff80)
157 #define MAX_UINT32 ((uint32) 0xffffffff)
158 #define MAX_UINT16 ((uint16) 0x0000ffff)
159 #define MAX_UINT8 ((uint8) 0x000000ff)
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
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
174 /* Will the following really work?? */
175 #define MAX_NEG_FLOAT32 ((float32) (-MAX_POS_FLOAT32))
176 #define MIN_NEG_FLOAT32 ((float32) (-MIN_POS_FLOAT32))
177 #define MAX_NEG_FLOAT64 ((float64) (-MAX_POS_FLOAT64))
178 #define MIN_NEG_FLOAT64 ((float64) (-MIN_POS_FLOAT64))