typedefs_shadow.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2013, Shadow Robot Company, All rights reserved.
00003  * 
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 3.0 of the License, or (at your option) any later version.
00008  * 
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012  * Lesser General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library.
00016  */
00017 
00018 #ifndef TYPEDEFS_SHADOW_H_INCLUDED
00019 #define TYPEDEFS_SHADOW_H_INCLUDED
00020 
00021 #include <limits.h>
00022 #include <stdint.h>
00023 
00024 /*
00025 typedef enum _BOOL { FALSE = 0, TRUE } BOOL;  // Undefined size
00026 
00027 #ifndef NULL
00028     #define NULL    ((void *)0)
00029 #endif
00030 */
00031 /*
00032 #define PUBLIC                                  // Function attributes
00033 #define PROTECTED
00034 #define PRIVATE   static
00035 */
00036 
00037 // Processor & Compiler independent, size specific definitions
00038 // To Do:  We need to verify the sizes on each compiler.  These
00039 //         may be compiler specific, we should either move them
00040 //         to "compiler.h" or #ifdef them for compiler type.
00041 typedef int8_t    int8s;
00042 typedef int16_t   int16s;
00043 typedef int32_t   int32s;
00044 //typedef signed long long    int64s;
00045 
00046 typedef uint8_t   int8u;
00047 typedef uint16_t  int16u;
00048 typedef uint32_t  int32u;  // other name for 32-bit integer
00049 //typedef unsigned long long  int64u;
00050 
00051 
00052 // Check that an int8 is 8 bits
00053 //
00054 /*
00055 #if UCHAR_MAX !=  0xFF
00056     #error UCHAR_MAX wrong
00057 #endif
00058 
00059 #if UCHAR_MIN != 0
00060     #error CHAR_MIN wrong
00061 #endif
00062 
00063 
00064 // Check that an int16 is 16 bits
00065 //
00066 #if USHRT_MAX !=  0xFFFF
00067     #error UINT_MAX wrong
00068 #endif
00069 
00070 #if USHRT_MIN != 0
00071     #error UINT_MIN wrong
00072 #endif
00073 
00074 
00075 // Check that an int32 is 32 bits
00076 //
00077 #if UINT_MAX !=  0xFFFFFFFF
00078     #error UINT_MAX wrong
00079 #endif
00080 
00081 #if UINT_MIN != 0
00082     #error UINT_MIN wrong
00083 #endif
00084 */
00085 
00090 #ifdef UNUSED
00091 #elif defined(__GNUC__)
00092     #define UNUSED(x) UNUSED_ ## x __attribute__((unused))
00093 #elif defined(__LCLINT__)
00094     #define UNUSED(x) /*@unused@*/ x
00095 #else
00096     #define UNUSED(x) x
00097 #endif
00098 
00099 
00100 typedef union
00101 {
00102     int16u U16;
00103     int16s S16;
00104     int8u  U8[2];
00105     int8s  S8[2];
00106 }union16;
00107 
00108 typedef union
00109 {
00110     int32u U32;
00111     int32s S32;
00112     int16u U16[2];
00113     int16s S16[2];
00114     int8u  U8[4];
00115     int8s  S8[4];
00116 }union32;
00117 
00118 //#define SWAP_BYTES(u)   {u.U8[0]^=u.U8[1]; u.U8[1]^=u.U8[0]; u.U8[0]^=u.U8[1];}
00119 #define SWAP_BYTES(u)   {int8u t; t=u.U8[0]; u.U8[0]=u.U8[1]; u.U8[1]=t;}
00120 #define SWAP_ENDIANNESS(x)  (((x&0x000000FF)<<24) | ((x&0x0000FF00)<<8) | ((x&0xFF000000)>>24) | ((x&0x00FF0000)>>8))
00121 
00122 
00123 int32u  bit_count_32(int32u n);
00124 void    safe_string_copy(char* source, char* dest, int max_chars);
00125 int32u  atoiu_safe(char *s, int32u max_chars);
00126 void    swap_bytes(int16u *i);
00127 int     typedef_tests(void);
00128 
00129 //#define max(a, b) (((a)>(b)) ? (a) : (b))
00130 //#define min(a, b) (((a)<(b)) ? (a) : (b))
00131 
00132 #endif


sr_ronex_external_protocol
Author(s): Ugo Cupcic, Toni Oliver, Mark Pitchless
autogenerated on Thu Jun 6 2019 21:21:43