vegastrike  0.5.1.r1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
posh.h File Reference

Portable Open Source Harness header file. More...

Go to the source code of this file.

Macros

#define POSH_OS_EMBEDDED
 
#define POSH_OS_STRING   "Embedded/Unknown"
 
#define POSH_CDECL
 
#define POSH_STDCALL
 
#define POSH_FASTCALL
 
#define POSH_IMPORTEXPORT
 
#define POSH_PUBLIC_API(rtype)   extern POSH_IMPORTEXPORT rtype
 
#define POSH_BIG_ENDIAN   1
 
#define POSH_ENDIAN_STRING   "big"
 
#define POSH_COMPILE_TIME_ASSERT(name, x)   typedef int _POSH_dummy_##name[(x) ? 1 : -1]
 
#define POSH_BigU16(x)   (x)
 
#define POSH_BigU32(x)   (x)
 
#define POSH_BigS16(x)   (x)
 
#define POSH_BigS32(x)   (x)
 
#define POSH_LittleU16(x)   POSH_SwapU16( x )
 
#define POSH_LittleU32(x)   POSH_SwapU32( x )
 
#define POSH_LittleS16(x)   POSH_SwapS16( x )
 
#define POSH_LittleS32(x)   POSH_SwapS32( x )
 

Typedefs

typedef unsigned char posh_byte_t
 
typedef unsigned char posh_u8_t
 
typedef signed char posh_i8_t
 
typedef signed char posh_s8_t
 
typedef unsigned short posh_u16_t
 
typedef short posh_i16_t
 
typedef short posh_s16_t
 
typedef unsigned posh_u32_t
 
typedef int posh_i32_t
 
typedef int posh_s32_t
 

Functions

 POSH_COMPILE_TIME_ASSERT (posh_byte_t, sizeof(posh_byte_t)==1)
 
 POSH_COMPILE_TIME_ASSERT (posh_i8_t, sizeof(posh_i8_t)==1)
 
 POSH_COMPILE_TIME_ASSERT (posh_u16_t, sizeof(posh_u16_t)==2)
 
 POSH_COMPILE_TIME_ASSERT (posh_s16_t, sizeof(posh_s16_t)==2)
 
 POSH_COMPILE_TIME_ASSERT (posh_u32_t, sizeof(posh_u32_t)==4)
 
 POSH_COMPILE_TIME_ASSERT (posh_s32_t, sizeof(posh_s32_t)==4)
 
 POSH_COMPILE_TIME_ASSERT (posh_testfloat_t, sizeof(float)==4)
 
 POSH_COMPILE_TIME_ASSERT (posh_testdouble_t, sizeof(double)==8)
 
 POSH_COMPILE_TIME_ASSERT (posh_32bit_pointer, sizeof(void *)==4)
 
const char * POSH_GetArchString (void)
 
posh_u32_t POSH_LittleFloatBits (float f)
 
posh_u32_t POSH_BigFloatBits (float f)
 
float POSH_FloatFromLittleBits (posh_u32_t bits)
 
float POSH_FloatFromBigBits (posh_u32_t bits)
 
void POSH_DoubleBits (double d, posh_byte_t dst[8])
 
double POSH_DoubleFromBits (const posh_byte_t src[8])
 
float * POSH_WriteFloatToLittle (void *dst, float f)
 
float * POSH_WriteFloatToBig (void *dst, float f)
 
float POSH_ReadFloatFromLittle (const void *src)
 
float POSH_ReadFloatFromBig (const void *src)
 
double * POSH_WriteDoubleToLittle (void *dst, double d)
 
double * POSH_WriteDoubleToBig (void *dst, double d)
 
double POSH_ReadDoubleFromLittle (const void *src)
 
double POSH_ReadDoubleFromBig (const void *src)
 
posh_u16_t POSH_SwapU16 (posh_u16_t u)
 
posh_s16_t POSH_SwapS16 (posh_s16_t u)
 
posh_u32_t POSH_SwapU32 (posh_u32_t u)
 
posh_s32_t POSH_SwapS32 (posh_s32_t u)
 
posh_u16_tPOSH_WriteU16ToLittle (void *dst, posh_u16_t value)
 
posh_s16_tPOSH_WriteS16ToLittle (void *dst, posh_s16_t value)
 
posh_u32_tPOSH_WriteU32ToLittle (void *dst, posh_u32_t value)
 
posh_s32_tPOSH_WriteS32ToLittle (void *dst, posh_s32_t value)
 
posh_u16_tPOSH_WriteU16ToBig (void *dst, posh_u16_t value)
 
posh_s16_tPOSH_WriteS16ToBig (void *dst, posh_s16_t value)
 
posh_u32_tPOSH_WriteU32ToBig (void *dst, posh_u32_t value)
 
posh_s32_tPOSH_WriteS32ToBig (void *dst, posh_s32_t value)
 
posh_u16_t POSH_ReadU16FromLittle (const void *src)
 
posh_s16_t POSH_ReadS16FromLittle (const void *src)
 
posh_u32_t POSH_ReadU32FromLittle (const void *src)
 
posh_s32_t POSH_ReadS32FromLittle (const void *src)
 
posh_u16_t POSH_ReadU16FromBig (const void *src)
 
posh_s16_t POSH_ReadS16FromBig (const void *src)
 
posh_u32_t POSH_ReadU32FromBig (const void *src)
 
posh_s32_t POSH_ReadS32FromBig (const void *src)
 

Detailed Description

Portable Open Source Harness header file.

Author
Brian Hook, poshl.nosp@m.ib@p.nosp@m.oshli.nosp@m.b.or.nosp@m.g
Version
0.0 Header file for POSH, the Portable Open Source Harness project.

NOTE: Unlike most header files, this one is designed to be included multiple times, which is why it does not have the #ifndef/#define preamble.

POSH relies on environment specified preprocessor symbols in order to infer as much as possible about the target OS/architecture and the host compiler capabilities.

NOTE: POSH is simple and focused. It attempts to provide basic functionality and information, but it does NOT attempt to emulate missing functionality. I am also not willing to make POSH dirty and hackish to support truly ancient and/or outmoded and/or bizarre technologies such as non-ANSI compilers, systems with non-IEEE floating point formats, 16-bit operating systems, etc.

Please refer to the accompanying HTML documentation or visit http://www.poshlib.org for more information on how to use POSH.

Definition in file posh.h.

Macro Definition Documentation

#define POSH_CDECL

Specifies that a function should use the C calling convention. The cdecl convention passes parameters on the stack, with the caller responsible for cleaning up the stack (which in turn allows for variable argument lists). It's marginally slower than the other calling conventions, and is the default calling convention for the C language.

*  extern void POSH_CDECL someFunction( const char *, ... );
*  

Todo:
need to get a comprehensive list of how cdecl, et. al. are specified

Definition at line 640 of file posh.h.

#define POSH_COMPILE_TIME_ASSERT (   name,
 
)    typedef int _POSH_dummy_##name[(x) ? 1 : -1]

Cross-platform compile time assertion macro that will cause a syntax error at compile time if the assertion 'x' is not true.

#define POSH_FASTCALL

Specifies that a function should use the register/"fastcall" calling convention. The fastcall convention passes as many parameters as possible via registers. If there is an overflow, the remaining parameters are passed on the stack. It is the called function's responsibility to remove clean up the stack.

*  extern void POSH_FASTCALL someFunction( int x, int y, int z );
*  

Definition at line 642 of file posh.h.

#define POSH_IMPORTEXPORT

Definition at line 745 of file posh.h.

#define POSH_OS_STRING   "Embedded/Unknown"

Definition at line 577 of file posh.h.

#define POSH_PUBLIC_API (   rtype)    extern POSH_IMPORTEXPORT rtype
use as a wrapper for all publicly exported functions and data

<code><b>POSH_PUBLIC_API</code></b> should be used as a wrapper
around any data or function return type values that are exported
from a DLL.  This macro ensures proper linkage irrespective of
compiler.

Example usage:
<pre><code>
*   POSH_PUBLIC_API(int) functionThatReturnsInt( void );
*   POSH_PUBLIC_API(int) globalIntVariable;
*   
#define POSH_STDCALL

Specifies that a function should use the PASCAL/"stdcall" calling convention. The stdcall convention passes parameters on the stack, however the called function is responsible for stack cleanup. This is slightly faster than cdecl, but without the ability to handle variable argument lists. It is also the default calling convention for the Pascal language.

*  extern void POSH_STDCALL someFunction( void );
*  

Definition at line 641 of file posh.h.

Function Documentation

POSH_COMPILE_TIME_ASSERT ( posh_byte_t  ,
sizeof(posh_byte_t = =1 
)
POSH_COMPILE_TIME_ASSERT ( posh_i8_t  ,
sizeof(posh_i8_t = =1 
)
POSH_COMPILE_TIME_ASSERT ( posh_u16_t  ,
sizeof(posh_u16_t = =2 
)
POSH_COMPILE_TIME_ASSERT ( posh_s16_t  ,
sizeof(posh_s16_t = =2 
)
POSH_COMPILE_TIME_ASSERT ( posh_u32_t  ,
sizeof(posh_u32_t = =4 
)
POSH_COMPILE_TIME_ASSERT ( posh_s32_t  ,
sizeof(posh_s32_t = =4 
)
POSH_COMPILE_TIME_ASSERT ( posh_testfloat_t  ,
sizeof(float)  = =4 
)
POSH_COMPILE_TIME_ASSERT ( posh_testdouble_t  ,
sizeof(double)  = =8 
)
POSH_COMPILE_TIME_ASSERT ( posh_32bit_pointer  ,
sizeof(void *)  = =4 
)