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/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.
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.
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) and special macros (_V3_SET and _V3_EQ) 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 floating point value. f64 64-bit 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. Predefined StringsDescriptioncputypes.h also 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. Exampleconst ascii * cpu_types[] = V3_CPU_TYPES; const ascii * os_types[] = V3_OS_TYPES; v3PrintA( (ascii *) "CPU = %.20s, OS = %.20s\n", cpu_types[CPU_TYPE], os_types[OS_TYPE] ); _V3_SETDescriptionSets or initializes a 64-bit or 128-bit integer (signed and unsigned) variable. 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 are 64-bit or 128-bit integer (signed or unsigned) variable to a constant. 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. 1999.
All rights reserved.
Mithral(tm) and Cosm(tm) are trademarks of
Mithral Communications & Design, Inc.
|