File size: 6,054 Bytes
37a92a9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* ====================================================================
* Copyright (c) 1999-2004 Carnegie Mellon University. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* This work was supported in part by funding from the Defense Advanced
* Research Projects Agency and the National Science Foundation of the
* United States of America, and the CMU Sphinx Speech Consortium.
*
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
*
*/
/*
* prim_type.h -- Primitive types; more machine-independent.
*
* **********************************************
* CMU ARPA Speech Project
*
* Copyright (c) 1999 Carnegie Mellon University.
* ALL RIGHTS RESERVED.
* **********************************************
*
* HISTORY
* $Log: prim_type.h,v $
* Revision 1.12 2005/10/05 00:31:14 dhdfu
* Make int8 be explicitly signed (signedness of 'char' is
* architecture-dependent). Then make a bunch of things use uint8 where
* signedness is unimportant, because on the architecture where 'char' is
* unsigned, it is that way for a reason (signed chars are slower).
*
* Revision 1.11 2005/06/22 03:10:23 arthchan2003
* Added keyword.
*
* Revision 1.3 2005/03/30 01:22:48 archan
* Fixed mistakes in last updates. Add
*
*
* 12-Mar-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
* Added arraysize_t, point_t, fpoint_t.
*
* 01-Feb-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
* Added anytype_t.
*
* 08-31-95 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
* Created.
*/
#ifndef _LIBUTIL_PRIM_TYPE_H_
#define _LIBUTIL_PRIM_TYPE_H_
/**
* @file prim_type.h
* @brief Basic type definitions used in Sphinx.
*/
#ifdef __cplusplus
extern "C" {
#endif
#if 0
} /* Fool Emacs into not indenting things. */
#endif
#include <pocketsphinx/sphinx_config.h>
/* Define some things for VisualDSP++ */
#if defined(__ADSPBLACKFIN__) && !defined(__GNUC__)
# ifndef HAVE_LONG_LONG
# define HAVE_LONG_LONG
# endif
# ifndef ssize_t
typedef signed int ssize_t;
# endif
# define SIZEOF_LONG_LONG 8
# define __BIGSTACKVARIABLE__ static
#else /* Not VisualDSP++ */
# define __BIGSTACKVARIABLE__
#endif
/**
* @union anytype_t pocketsphinx/prim_type.h
* @brief Literally any type!
*
* (correction: not literally any type, but all the ones we use for configuration)
*/
typedef union anytype_s {
void *ptr;
long i;
unsigned long ui;
double fl;
} anytype_t;
/* Use C99 types if available */
#if defined(HAVE_STDINT_H) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
#include <stdint.h>
typedef int32_t int32;
typedef int16_t int16;
typedef int8_t int8;
typedef uint32_t uint32;
typedef uint16_t uint16;
typedef uint8_t uint8;
typedef int64_t int64;
typedef uint64_t uint64;
/* Take a wild guess otherwise */
#else
typedef int int32;
typedef short int16;
typedef signed char int8;
typedef unsigned int uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;
# if defined(_MSC_VER)
typedef __int64 int64;
typedef unsigned __int64 uint64;
# else
typedef long long int64;
typedef unsigned long long uint64;
# endif
#endif /* not C99 or POSIX */
/* We should maybe stop using these as there isn't any good way to
know their exact size, but it's 99% certain they are 32 and 64
bits. */
typedef float float32;
typedef double float64;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL (void *)0
#endif
/* These really ought to come from <limits.h>, but not everybody has that. */
/* Useful constants */
#define MAX_INT32 ((int32) 0x7fffffff)
#define MAX_INT16 ((int16) 0x00007fff)
#define MAX_INT8 ((int8) 0x0000007f)
#define MAX_NEG_INT32 ((int32) 0x80000000)
#define MAX_NEG_INT16 ((int16) 0xffff8000)
#define MAX_NEG_INT8 ((int8) 0xffffff80)
#define MAX_UINT32 ((uint32) 0xffffffff)
#define MAX_UINT16 ((uint16) 0x0000ffff)
#define MAX_UINT8 ((uint8) 0x000000ff)
/* The following are approximate; IEEE floating point standards might quibble! */
#define MAX_POS_FLOAT32 3.4e+38f
#define MIN_POS_FLOAT32 1.2e-38f /* But not 0 */
#define MAX_POS_FLOAT64 1.8e+307
#define MIN_POS_FLOAT64 2.2e-308
#define MAX_IEEE_NORM_POS_FLOAT32 3.4e+38f
#define MIN_IEEE_NORM_POS_FLOAT32 1.2e-38f
#define MIN_IEEE_NORM_NEG_FLOAT32 -3.4e+38f
#define MAX_IEEE_NORM_POS_FLOAT64 1.8e+307
#define MIN_IEEE_NORM_POS_FLOAT64 2.2e-308
#define MIN_IEEE_NORM_NEG_FLOAT64 -1.8e+307
/* Will the following really work?? */
#define MIN_NEG_FLOAT32 ((float32) (-MIN_POS_FLOAT32))
#define MIN_NEG_FLOAT64 ((float64) (-MIN_POS_FLOAT64))
#ifdef __cplusplus
}
#endif
#endif
|