Defines and TypesSetup Data Types and Predefined Strings Macros Required DefinesDescriptionThe required defines are: CPU type, CPU bitness, CPU word sizes, and the OS type. You will find a TEMPLATE file in the make/ directory of the source. Unless you are porting the libraries to a new platform, these will already be set and usable with the `build...` script. CPU_64BIT or CPU_32BIT - CPU bitness The CPU type is set by defining either CPU_32BIT or CPU_64BIT. CPU_WORD_SIZES - CPU word sizes The CPU word sizes is set by defining CPU_WORD_SIZES to be sizeof(long, int, short), and must be one of:
CPU_TYPE - CPU type The CPU type is set by defining CPU_TYPE to be one of the following. Note that valid values of CPU_TYPE are from 0 to V3_CPU_TYPE_MAX inclusive. The array V3_CPU_TYPES of CPU names will also be of use to programmers, see below.
OS_TYPE - OS type The OS is set by defining OS_TYPE to be one of the following. Note that valid values of OS_TYPE are from 0 to V3_OS_TYPE_MAX inclusive. The array V3_OS_TYPES of OS names will also be of use to programmers, see below.
Optional Defines
Data TypesDescriptionCosm defines the following portable data types: Note that the 32, 16, and 8-bit types can be used normally, however the 64-bit and 128-bit types must use special functions (cosmmath) for math, and special macros (_V3_SET and _V3_EQ) for setting constants to maintain portability. Integer Types u8 Unsigned 8-bit integer. s8 Signed 8-bit integer. u16 Unsigned 16-bit integer. s16 Signed 16-bit integer. u32 Unsigned 32-bit integer. s32 Signed 32-bit integer. u64 Unsigned 64-bit integer. s64 Signed 64-bit integer. u128 Unsigned 128-bit integer. s128 Signed 128-bit integer. Floating Point Types f32 32-bit IEEE floating point value. f64 64-bit IEEE floating point value. Text Types ascii Holds one ascii character. unicode Holds one unicode character. Time Type v3_time Time value. Times are signed s128's of type v3_time, 64b.64b format based 0 = 00:00:00 UTC, Jan 1, 2000 AD. This gives a Range of +/- 2.923E11 years and a resolution of 5.421E-20 seconds. This allows times from bang to crunch - assuming a closed universe (if it's not closed, we have bigger problems). It's also useful for timing the half lives of particles like neutral sigma baryons. Defined Strings and ThingsStringscputypes.h defines the string arrays V3_CPU_TYPES and V3_OS_TYPES. These are mostly for debugging output, since the CPU and OS are not relivant in most cases. Example const ascii * cpu_types[] = V3_CPU_TYPES; const ascii * os_types[] = V3_OS_TYPES; v3PrintA( (ascii *) "CPU = %.20s, OS = %.20s\n", cpu_types[( CPU_TYPE > V3_CPU_TYPE_MAX ) ? 0 : CPU_TYPE], os_types[( OS_TYPE > V3_OS_TYPE_MAX ) ? 0 : OS_TYPE] ); EndianV3_ENDIAN_CURRENT, V3_ENDIAN_BIG, and V3_ENDIAN_LITTLE are defined. V3_ENDIAN_CURRENT is whichever one the machine is running in at the time. Some systems can be run in either. Example if ( V3_ENDIAN_CURRENT == V3_ENDIAN_BIG ) { /* do the big thing */ } else { /* do the little thing */ } MiscV3_PASS, V3_FAIL, and NULL are defined. For those working in the CPU/OS layer, if the system has a non-struct u64 type then V3_HAVE_U64 is defined. On a CPU_32BIT system this only happens when the compiler directly provides a fake 64-bit type. This fake type will generally be faster then using C code for 64-bit operations. This define should never be used outside of CPU/OS. _V3_SETDescriptionSets or initializes a 64-bit or 128-bit integer (signed or unsigned) to a constant value. 64-bit Types The first argument is the variable to be set, followed by the value in hex (without the '0x' prefix), in groups of 32 bits, 2 groups total. Exampleu64 a; s64 b; _V3_SET64( a, 4FF46423, 12345678 ); /* a is now 0x4FF4642312345678 */ _V3_SET64( b, 49FDC238, 87654321 ); /* b is now 0x49FDC23887654321 */ 128-bit Types The first argument is the variable to be set, followed by the value in hex (without the '0x' prefix), in groups of 32 bits, 4 groups total. Exampleu128 a; s128 b; _V3_SET128( a, 01234567, 89ABCDEF, FEDCBA98, 76543210 ); /* a is now 0x0123456789ABCDEFFEDCBA9876543210 */ _V3_SET128( b, 32507DFF, DAF85A34, 7AF51C34, 45A54391 ); /* b is now 0x32507DFFDAF85A347AF51C3445A54391 */ _V3_EQDescriptionCompares a 64-bit or 128-bit integer (signed or unsigned) variable to a constant. Returns non-zero if equal, and 0 if unequal. 64-bit Types The first argument is the variable to be compared to a constant, followed by the constant to compare it to in hex (without the '0x' prefix), in groups of 32 bits, 2 groups total. Exampleu64 a; s64 b; _V3_SET64( a, 4FF46423, 12345678 ); if ( _V3_EQ64( a, 4FF46423, 12345678 ) ) { /* equal */ } _V3_SET64( b, 49FDC238, 87654321 ); if ( _V3_EQ64( b, 49FDC238, 87654321 ) ) { /* equal */ } 128-bit Types The first argument is the variable to be compared to a constant, followed by the constant to compare it to in hex (without the '0x' prefix), in groups of 32 bits, 4 groups total. Exampleu128 a; s128 b; _V3_SET128( a, 01234567, 89ABCDEF, FEDCBA98, 76543210 ); if ( _V3_EQ128( a, 01234567, 89ABCDEF, FEDCBA98, 76543210 ) ) { /* equal */ } _V3_SET128( b, 32507DFF, DAF85A34, 7AF51C34, 45A54391 ); if ( _V3_EQ128( a, 32507DFF, DAF85A34, 7AF51C34, 45A54391 ) ) { /* equal */ }
© Copyright Mithral Communications & Design Inc.
1995-2003.
All rights reserved.
Mithral® and Cosm® are trademarks of
Mithral Communications & Design Inc.
|