SphinxBase  0.6
include/sphinxbase/prim_type.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
00002 /* ====================================================================
00003  * Copyright (c) 1999-2004 Carnegie Mellon University.  All rights
00004  * reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer. 
00012  *
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in
00015  *    the documentation and/or other materials provided with the
00016  *    distribution.
00017  *
00018  * This work was supported in part by funding from the Defense Advanced 
00019  * Research Projects Agency and the National Science Foundation of the 
00020  * United States of America, and the CMU Sphinx Speech Consortium.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
00023  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
00024  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00025  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
00026  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00027  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00028  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00029  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
00030  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00031  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00032  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * ====================================================================
00035  *
00036  */
00037 /*
00038  * prim_type.h -- Primitive types; more machine-independent.
00039  *
00040  * **********************************************
00041  * CMU ARPA Speech Project
00042  *
00043  * Copyright (c) 1999 Carnegie Mellon University.
00044  * ALL RIGHTS RESERVED.
00045  * **********************************************
00046  * 
00047  * HISTORY
00048  * $Log: prim_type.h,v $
00049  * Revision 1.12  2005/10/05 00:31:14  dhdfu
00050  * Make int8 be explicitly signed (signedness of 'char' is
00051  * architecture-dependent).  Then make a bunch of things use uint8 where
00052  * signedness is unimportant, because on the architecture where 'char' is
00053  * unsigned, it is that way for a reason (signed chars are slower).
00054  *
00055  * Revision 1.11  2005/06/22 03:10:23  arthchan2003
00056  * Added  keyword.
00057  *
00058  * Revision 1.3  2005/03/30 01:22:48  archan
00059  * Fixed mistakes in last updates. Add
00060  *
00061  * 
00062  * 12-Mar-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
00063  *              Added arraysize_t, point_t, fpoint_t.
00064  * 
00065  * 01-Feb-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
00066  *              Added anytype_t.
00067  * 
00068  * 08-31-95     M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
00069  *              Created.
00070  */
00071 
00072 
00073 #ifndef _LIBUTIL_PRIM_TYPE_H_
00074 #define _LIBUTIL_PRIM_TYPE_H_
00075 
00081 #ifdef __cplusplus
00082 extern "C" {
00083 #endif
00084 #if 0
00085 } /* Fool Emacs into not indenting things. */
00086 #endif
00087 
00088 #include <sphinx_config.h>
00089 
00090 /* Define some things for VisualDSP++ */
00091 #if defined(__ADSPBLACKFIN__) && !defined(__GNUC__)
00092 # ifndef HAVE_LONG_LONG
00093 #  define HAVE_LONG_LONG
00094 # endif
00095 # ifndef ssize_t
00096 typedef signed int ssize_t;
00097 # endif
00098 # define SIZEOF_LONG_LONG 8
00099 # define __BIGSTACKVARIABLE__ static
00100 #else /* Not VisualDSP++ */
00101 # define __BIGSTACKVARIABLE__
00102 #endif
00103 
00107 typedef union anytype_s {
00108     void *ptr;
00109     long i;
00110     unsigned long ui;
00111     double fl;
00112 } anytype_t;
00113 
00114 /*
00115  * Assume P64 or LP64.  If you need to port this to a DSP, let us know.
00116  */
00117 typedef int             int32;
00118 typedef short           int16;
00119 typedef signed char     int8;
00120 typedef unsigned int    uint32;
00121 typedef unsigned short  uint16;
00122 typedef unsigned char   uint8;
00123 typedef float           float32;
00124 typedef double          float64;
00125 #if defined(_MSC_VER)
00126 typedef __int64          int64;
00127 typedef unsigned __int64 uint64;
00128 #elif defined(HAVE_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
00129 typedef long long          int64;
00130 typedef unsigned long long uint64;
00131 #else /* !HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8 */
00132 typedef double          int64;
00133 typedef double          uint64;
00134 #endif /* !HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8 */
00135 
00136 #ifndef TRUE
00137 #define TRUE 1
00138 #endif
00139 #ifndef FALSE
00140 #define FALSE 0
00141 #endif
00142 
00143 #ifndef NULL
00144 #define NULL (void *)0
00145 #endif
00146 
00147 /* These really ought to come from <limits.h>, but not everybody has that. */
00148 /* Useful constants */
00149 #define MAX_INT32               ((int32) 0x7fffffff)
00150 #define MAX_INT16               ((int16) 0x00007fff)
00151 #define MAX_INT8                ((int8)  0x0000007f)
00152 
00153 #define MAX_NEG_INT32           ((int32) 0x80000000)
00154 #define MAX_NEG_INT16           ((int16) 0xffff8000)
00155 #define MAX_NEG_INT8            ((int8)  0xffffff80)
00156 
00157 #define MAX_UINT32              ((uint32) 0xffffffff)
00158 #define MAX_UINT16              ((uint16) 0x0000ffff)
00159 #define MAX_UINT8               ((uint8)  0x000000ff)
00160 
00161 /* The following are approximate; IEEE floating point standards might quibble! */
00162 #define MAX_POS_FLOAT32         3.4e+38f
00163 #define MIN_POS_FLOAT32         1.2e-38f        /* But not 0 */
00164 #define MAX_POS_FLOAT64         1.8e+307
00165 #define MIN_POS_FLOAT64         2.2e-308
00166 
00167 #define MAX_IEEE_NORM_POS_FLOAT32        3.4e+38f
00168 #define MIN_IEEE_NORM_POS_FLOAT32        1.2e-38f
00169 #define MIN_IEEE_NORM_NEG_FLOAT32       -3.4e+38f
00170 #define MAX_IEEE_NORM_POS_FLOAT64        1.8e+307
00171 #define MIN_IEEE_NORM_POS_FLOAT64        2.2e-308
00172 #define MIN_IEEE_NORM_NEG_FLOAT64       -1.8e+307
00173 
00174 /* Will the following really work?? */
00175 #define MAX_NEG_FLOAT32         ((float32) (-MAX_POS_FLOAT32))
00176 #define MIN_NEG_FLOAT32         ((float32) (-MIN_POS_FLOAT32))
00177 #define MAX_NEG_FLOAT64         ((float64) (-MAX_POS_FLOAT64))
00178 #define MIN_NEG_FLOAT64         ((float64) (-MIN_POS_FLOAT64))
00179 
00180 
00181 #ifdef __cplusplus
00182 }
00183 #endif
00184 
00185 #endif