Changeset 7545


Ignore:
Timestamp:
08/01/18 21:54:49 (2 weeks ago)
Author:
baker
Message:

use <stdint.h> to define standard data types; use <math.h> round()

Location:
trunk/src/data_sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/data_sources/grf2ew/stdtypes.h

    r6803 r7545  
    1 /* $Id$ */ 
    21/* -------------------------------------------------------------------- 
    32   
     
    76 
    87----------------------------------------------------------------------- */ 
    9 #if !defined _STANDARD_TYPES_DEFINED_ 
    10 #define _STANDARD_TYPES_DEFINED_ 
    118 
    12 #if defined (X86_16BIT) 
     9#ifndef STD_TYPES_H 
     10#define STD_TYPES_H 
    1311 
    14 /* -------------------------------------------------------------------- */ 
    15 /* Standard types on x86 hardware with 16 bit compilers, i.e., Microsoft 
    16    Visual C++ 1.52 or Borland C++.  Also RTOS on 68k processors */ 
    17  
    18  /* Void type */ 
    19 typedef void VOID; 
    20  
    21  /* Characters */ 
    22 typedef char CHAR; 
    23  
    24  /* Boolean values (4 bytes) */ 
    25 typedef unsigned long BOOL; 
    26  
    27  /* Signed and unsigned 8 bit integers */ 
    28 typedef signed char INT8; 
    29 typedef unsigned char UINT8; 
    30  
    31  /* 16 bit integer values */ 
    32 typedef signed short INT16; 
    33 typedef unsigned short UINT16; 
    34  
    35  /* 32 bit integer values */ 
    36 typedef signed long INT32; 
    37 typedef unsigned long UINT32; 
    38  
    39  /* 32 bit IEEE 754 Real */ 
    40 typedef float REAL32; 
    41  
    42  /* 64 bit IEEE 754 Real */ 
    43 typedef double REAL64; 
    44  
    45  /* 80 bit IEEE 754 Real */ 
    46 typedef long double REAL80; 
    47  
    48 #elif defined (X86_WIN32) 
    49  
    50 /* -------------------------------------------------------------------- */ 
    51 /* Standard types on x86 hardware with Win32 compilers, i.e., Microsoft 
    52    Visual C++ 5.00 */ 
    53  
    54 #include <windows.h> 
    55  
    56  /* Void type */ 
    57  /* VOID is defined by the Win32 API in windows.h */ 
    58  
    59  /* Characters */ 
    60 typedef char CHAR; 
    61  
    62  /* Boolean values */ 
    63  /* BOOL is defined as unsigned 32 bits by the Win32 API in windows.h */ 
    64  
    65 #pragma warning(disable:4142) // Benign redefinition of type 
    66  
    67  /* Signed and unsigned 8 bit integers */ 
    68 typedef signed __int8 INT8; 
    69 typedef unsigned __int8 UINT8; 
    70  
    71  /* 16 bit integer values */ 
    72 typedef signed __int16 INT16; 
    73 typedef unsigned __int16 UINT16; 
    74  
    75  /* 32 bit integer values */ 
    76 #if _MSC_VER < 1200 
    77 typedef signed __int32 INT32; 
    78 typedef unsigned __int32 UINT32; 
    79 #endif 
    80  
    81  /* 64 bit integers */ 
    82 typedef signed __int64 INT64; 
    83 typedef unsigned __int64 UINT64; 
    84  
    85  /* 32 bit IEEE 754 Real */ 
    86 typedef float REAL32; 
    87  
    88  /* 64 bit IEEE 754 Real */ 
    89 typedef double REAL64; 
    90  
    91  /* 80 bit IEEE 754 Real */ 
    92 typedef long double REAL80; 
    93  
    94  
    95 #elif defined(__x86_64__) || defined(X86_UNIX64) 
    96  
    97 /* -------------------------------------------------------------------- */ 
    98 /* 64-bit UNIX -- assume that 'inttypes.h' is available and use it      */ 
    99 /* -------------------------------------------------------------------- */ 
    100  
    101 #include <inttypes.h> 
     12#include <stdint.h> 
    10213 
    10314/* Void type */ 
     
    13849typedef long double REAL80; 
    13950 
    140  /* Boolean values */ 
    141  /* We make it 32 bits because NT (currently) has BOOL that big and some 
    142   * code exists which looks for offsets using sizeof(BOOL) and that causes 
    143   * problems for data portability.  This will keep things happy until such 
    144   * time as NT changes the size of BOOL. 
    145   */ 
     51/* Boolean constants and variables ------------------------------------ */ 
     52 
     53#ifdef WIN32 
     54 
     55/* BOOL, TRUE, and FALSE are in windef.h 
     56 */ 
     57 
     58#include <windows.h> 
     59 
     60#else 
     61 
     62/* We make BOOL an int because NT (currently) has BOOL that big and some 
     63 * code exists which looks for offsets using sizeof(BOOL) and that causes 
     64 * problems for data portability.  This will keep things happy until such 
     65 * time as NT changes the size of BOOL. 
     66 */ 
     67 
    14668#if defined BOOL 
    14769#   undef BOOL 
    14870#endif 
    149 typedef UINT32 BOOL; 
    150  
    151  
    152 #elif defined(X86_UNIX32) || defined(SPARC_UNIX32) 
    153  
    154 /* -------------------------------------------------------------------- */ 
    155 /* Standard 32 bit UNIX types (both sparc and x86 hardware) */ 
    156  
    157 /* It turns out to be a real bitch to come up with names for the 
    158  * various size specific names that work for all flavors of Unix. 
    159  * Life was great with Solaris 2.6, as it provides <inttypes.h>, but 
    160  * not everybody else does (yet).   So, rather than define things in 
    161  * like INT8 in terms of something like int8_t, which we know will work 
    162  * instead I just do it in terms of things that I know work on the 
    163  * machines I'm currently using.  Not very pretty, and things will 
    164  * likely break in the future.  When they do, see if you've got 
    165  * <inttypes.h> and use it. 
    166  */ 
    167  
    168 /* Void type */ 
    169 #if defined VOID 
    170 #   undef VOID 
    171 #endif 
    172 typedef void VOID; 
    173  
    174  /* Characters */ 
    175 #if defined CHAR 
    176 #   undef CHAR 
    177 #endif 
    178 typedef char CHAR; 
    179  
    180  /* Signed and unsigned 8 bit integers */ 
    181 typedef signed char INT8; 
    182 typedef unsigned char UINT8; 
    183  
    184  /* 16 bit integer values */ 
    185 typedef signed short INT16; 
    186 typedef unsigned short UINT16; 
    187  
    188  /* 32 bit integer values */ 
    189 typedef signed int INT32; 
    190 typedef unsigned int UINT32; 
    191  
    192  /* 64 bit integers */ 
    193 typedef long long INT64; 
    194 typedef unsigned long long UINT64; 
    195  
    196  /* 32 bit IEEE 754 Real */ 
    197 typedef float REAL32; 
    198  
    199  /* 64 bit IEEE 754 Real */ 
    200 typedef double REAL64; 
    201  
    202  /* 80 bit IEEE 754 Real */ 
    203 typedef long double REAL80; 
    204  
    205  /* Boolean values */ 
    206  /* We make it 32 bits because NT (currently) has BOOL that big and some 
    207   * code exists which looks for offsets using sizeof(BOOL) and that causes 
    208   * problems for data portability.  This will keep things happy until such 
    209   * time as NT changes the size of BOOL. 
    210   */ 
    211 #if defined BOOL 
    212 #   undef BOOL 
    213 #endif 
    214 typedef UINT32 BOOL; 
    215  
    216 #else 
    217  
    218 #    error "can't determine platform!" 
    219  
    220 #endif 
    221  
    222 /* Boolean constants -------------------------------------------------- */ 
     71typedef int BOOL; 
    22372 
    22473#ifndef TRUE 
     
    23079#endif 
    23180 
    232 #endif 
     81#endif /* WIN32 */ 
     82 
     83#endif /* STD_TYPES_H */ 
  • trunk/src/data_sources/reftek2ew/samprate.c

    r3360 r7545  
    1 /* @(#)samprate.c       1.5 07/23/98 */ 
    21/*====================================================================== 
    32 * 
     
    87 *            calculate rate then round to integer unless is < 1.0 
    98 *====================================================================*/ 
     9 
    1010#include <math.h> 
     11 
    1112#include "import_rtp.h" 
    1213#include "stdtypes.h" 
     
    185186    newrate = (double) prev->chan[dt->chan].nsamp / 
    186187              (dt->tstamp - prev->chan[dt->chan].tstamp); 
    187     if (newrate >= 1.0) newrate = (REAL64)((INT)(newrate + .5));/* all rates are integers except .1 */ 
     188    if (newrate >= 1.0) newrate = round( newrate );/* all rates are integers except .1 */ 
    188189   store(prev, dt); 
    189190 
  • trunk/src/data_sources/reftek2ew/stdtypes.h

    r6114 r7545  
    1 #pragma ident "$Id$" 
    21/* -------------------------------------------------------------------- 
    3  Program  : Any 
    4  Task     : Standard types to enhance portability. 
    5  File     : archive.h 
    6  Purpose  : See task. 
    7  Host     : CC, GCC, Microsoft Visual C++ 5.x, MCC68K 3.1 
    8  Target   : Solaris (Sparc and x86), Linux, DOS, Win32, and RTOS 
    9  Author   : Robert Banfill (r.banfill@reftek.com) 
    10  Company  : Refraction Technology, Inc. 
    11             2626 Lombardy Lane, Suite 105 
    12             Dallas, Texas  75220  USA 
    13             (214) 353-0609 Voice, (214) 353-9659 Fax, info@reftek.com 
    14  Copyright: (c) 1997 Refraction Technology, Inc. - All Rights Reserved. 
    15  Notes    : 
    16  $Revision$ 
    17  $Logfile : R:/cpu68000/rt422/struct/version.h_v  $ 
    18  Revised  : 
    19       17Jan94  ---- (RLB) Initial code. 
    20       18May98  ---- (RLB) Cleaned up and added Win32 stuff. 
    21       18May98  ---- (DEC) Added unix stuff 
    22       23Jun98  ---- (RLB) Made all integer types sign specific 
     2   
     3  Standard explicit data type to enhance portability. 
     4 
     5  R. Banfill and D. Chavez 
    236 
    247----------------------------------------------------------------------- */ 
    258 
    26 #ifndef _STD_TYPES_ 
    27 #define _STD_TYPES_ 
     9#ifndef STD_TYPES_H 
     10#define STD_TYPES_H 
    2811 
    29 typedef int INT; 
     12#include <stdint.h> 
    3013 
    31 #if defined(X86_16BIT) || defined(M68K_32BIT) 
    32  
    33 /* -------------------------------------------------------------------- */ 
    34 /* Standard types on x86 hardware with 16 bit compilers, i.e., Microsoft 
    35    Visual C++ 1.52 or Borland C++.  Also RTOS on 68k processors */ 
    36  
    37  /* Void type */ 
     14/* Void type */ 
     15#if defined VOID 
     16#   undef VOID 
     17#endif 
    3818typedef void VOID; 
    3919 
    4020 /* Characters */ 
     21#if defined CHAR 
     22#   undef CHAR 
     23#endif 
    4124typedef char CHAR; 
    4225 
    43  /* Boolean values */ 
    44 typedef unsigned char BOOL; 
    45  
    4626 /* Signed and unsigned 8 bit integers */ 
    47 typedef char BYTE; 
    48 typedef signed char SBYTE; 
    49 typedef unsigned char UBYTE; 
     27typedef int8_t INT8; 
     28typedef uint8_t UINT8; 
    5029 
    5130 /* 16 bit integer values */ 
    52 typedef unsigned short WORD; 
    53 typedef short SWORD; 
    54 typedef unsigned short UWORD; 
     31typedef int16_t INT16; 
     32typedef uint16_t UINT16; 
    5533 
    5634 /* 32 bit integer values */ 
    57 typedef signed long LONG; 
    58 typedef unsigned long ULONG; 
    59 typedef signed long SLONG; 
    60  
    61  /* 32 bit IEEE 754 Real */ 
    62 typedef float FLOAT; 
    63  
    64  /* 64 bit IEEE 754 Real */ 
    65 typedef double DOUBLE; 
    66  
    67  /* 80 bit IEEE 754 Real */ 
    68 typedef double LDOUBLE; 
    69  
    70 #elif defined (X86_WIN32) 
    71  
    72 /* -------------------------------------------------------------------- */ 
    73 /* Standard types on x86 hardware with Win32 compilers, i.e., Microsoft 
    74    Visual C++ 5.00 */ 
    75  
    76 #include <windows.h> 
    77  
    78  /* Void type */ 
    79  /* VOID is defined by the Win32 API in windows.h */ 
    80  
    81  /* Characters */ 
    82 typedef char CHAR; 
    83  
    84  /* Boolean values */ 
    85  /* BOOL is defined by the Win32 API in windows.h */ 
    86  
    87  /* Signed and unsigned 8 bit integers */ 
    88 typedef signed __int8 INT8; 
    89 typedef unsigned __int8 UINT8; 
    90  
    91  /* 16 bit integer values */ 
    92 typedef signed __int16 INT16; 
    93 typedef unsigned __int16 UINT16; 
    94  
    95  /* 32 bit integer values */ 
    96 #if _MSC_VER < 1200 
    97 typedef signed __int32 INT32; 
    98 typedef unsigned __int32 UINT32; 
    99 #endif 
     35typedef int32_t INT32; 
     36typedef uint32_t UINT32; 
    10037 
    10138 /* 64 bit integers */ 
    102 typedef signed __int64 INT64; 
    103 typedef unsigned __int64 UINT64; 
     39typedef int64_t INT64; 
     40typedef uint64_t UINT64; 
    10441 
    10542 /* 32 bit IEEE 754 Real */ 
     
    11249typedef long double REAL80; 
    11350 
    114 #elif defined(X86_UNIX32) || defined(SPARC_UNIX32) 
     51/* Boolean constants and variables ------------------------------------ */ 
    11552 
    116 /* -------------------------------------------------------------------- */ 
    117 /* Standard 32 bit UNIX types (both sparc and x86 hardware) 
     53#ifdef WIN32 
    11854 
    119 /* It turns out to be a real bitch to come up with names for the 
    120  * various size specific names that work for all flavors of Unix. 
    121  * Life was great with Solaris 2.6, as it provides <inttypes.h>, but 
    122  * not everybody else does (yet).   So, rather than define things in 
    123  * like INT8 in terms of something like int8_t, which we know will work 
    124  * instead I just do it in terms of things that I know work on the 
    125  * machines I'm currently using.  Not very pretty, and things will 
    126  * likely break in the future.  When they do, see if you've got 
    127  * <inttypes.h> and use it. 
     55/* BOOL, TRUE, and FALSE are in windef.h 
    12856 */ 
    12957 
    130     /* Void type */ 
    131 typedef void VOID; 
    132  
    133  /* Characters */ 
    134 typedef char CHAR; 
    135  
    136  /* Signed and unsigned 8 bit integers */ 
    137 typedef signed char INT8; 
    138 typedef unsigned char UINT8; 
    139  
    140  /* 16 bit integer values */ 
    141 typedef signed short INT16; 
    142 typedef unsigned short UINT16; 
    143  
    144  /* 32 bit integer values */ 
    145 typedef signed long INT32; 
    146 typedef unsigned long UINT32; 
    147  
    148  /* 64 bit integers */ 
    149 typedef long long INT64; 
    150 typedef unsigned long long UINT64; 
    151  
    152  /* 32 bit IEEE 754 Real */ 
    153 typedef float REAL32; 
    154  
    155  /* 64 bit IEEE 754 Real */ 
    156 typedef double REAL64; 
    157  
    158  /* 80 bit IEEE 754 Real */ 
    159 typedef long double REAL80; 
    160  
    161  /* Boolean values */ 
    162  /* We make it 32 bits because NT (currently) has BOOL that big and some 
    163   * code exists which looks for offsets using sizeof(BOOL) and that causes 
    164   * problems for data portability.  This will keep things happy until such 
    165   * time as NT changes the size of BOOL. 
    166   */ 
    167 typedef INT32 BOOL; 
    168  
    169 #elif defined(X86_UNIX64) 
    170  
    171  /* Void type */ 
    172 typedef void VOID; 
    173  
    174  /* Characters */ 
    175 typedef char CHAR; 
    176  
    177  /* Signed and unsigned 8 bit integers */ 
    178 typedef signed char INT8; 
    179 typedef unsigned char UINT8; 
    180  
    181  /* 16 bit integer values */ 
    182 typedef signed short INT16; 
    183 typedef unsigned short UINT16; 
    184  
    185  /* 32 bit integer values */ 
    186 typedef signed int INT32; 
    187 typedef unsigned int UINT32; 
    188  
    189  /* 64 bit integers */ 
    190 typedef signed long INT64; 
    191 typedef unsigned long UINT64; 
    192  
    193  /* 32 bit IEEE 754 Real */ 
    194 typedef float REAL32; 
    195  
    196  /* 64 bit IEEE 754 Real */ 
    197 typedef double REAL64; 
    198  
    199  /* 80 bit IEEE 754 Real */ 
    200 typedef long double REAL80; 
    201  
    202  /* Boolean values */ 
    203  /* We make it 32 bits because NT (currently) has BOOL that big and some 
    204   * code exists which looks for offsets using sizeof(BOOL) and that causes 
    205   * problems for data portability.  This will keep things happy until such 
    206   * time as NT changes the size of BOOL. 
    207   */ 
    208 typedef INT32 BOOL; 
     58#include <windows.h> 
    20959 
    21060#else 
    21161 
    212 #    error "can't determine platform!" 
     62/* We make BOOL an int because NT (currently) has BOOL that big and some 
     63 * code exists which looks for offsets using sizeof(BOOL) and that causes 
     64 * problems for data portability.  This will keep things happy until such 
     65 * time as NT changes the size of BOOL. 
     66 */ 
    21367 
     68#if defined BOOL 
     69#   undef BOOL 
    21470#endif 
    215  
    216 /* Boolean constants -------------------------------------------------- */ 
     71typedef int BOOL; 
    21772 
    21873#ifndef TRUE 
     
    22479#endif 
    22580 
    226 #endif 
     81#endif /* WIN32 */ 
    22782 
    228 /* Revision History 
    229  * 
    230  * $Log$ 
    231  * Revision 1.6  2008/08/26 00:23:31  rwg 
    232  * fix build on x86_64...? 
    233  * 
    234  * Revision 1.5  2006/08/04 16:05:50  paulf 
    235  * 1.7 reftek2ew changes from Roberta Stavely of Reftek Inc 
    236  * 
    237  * Revision 1.4  2002/11/04 22:42:37  lombard 
    238  * Removed DOS end-of-line chars for use on unix. 
    239  * 
    240  * Revision 1.3  2002/11/04 21:40:53  alex 
    241  * *** empty log message *** 
    242  * 
    243  * Revision 1.1.1.1  2000/06/22 19:13:09  nobody 
    244  * Import existing sources into CVS 
    245  * 
    246  */ 
     83#endif /* STD_TYPES_H */ 
Note: See TracChangeset for help on using the changeset viewer.