[Cosm Logo]

Defines and Types

Setup

Data Types and Predefined Strings

Macros


Required Defines

Description

The 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:

  • 422
  • 442
  • 842

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.

  • CPU_UNKNOWN
  • CPU_X86
  • CPU_POWERPC
  • CPU_MIPS
  • CPU_MIPS64
  • CPU_ALPHA
  • CPU_PA_RISC
  • CPU_68K
  • CPU_SPARC
  • CPU_SPARC64
  • CPU_POWER
  • CPU_VAX
  • CPU_ARM
  • CPU_88K
  • CPU_S390
  • CPU_SH4

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.

  • OS_UNKNOWN
  • OS_WIN32
  • OS_MACOS
  • OS_MACOSX
  • OS_LINUX
  • OS_BSDI
  • OS_NETBSD
  • OS_FREEBSD
  • OS_OPENBSD
  • OS_NEXTSTEP
  • OS_BEOS
  • OS_IRIX
  • OS_IRIX64
  • OS_SUNOS
  • OS_SOLARIS
  • OS_SCO
  • OS_QNX
  • OS_TRU64
  • OS_VMS
  • OS_OS2
  • OS_UNIXWARE
  • OS_HPUX
  • OS_MACH
  • OS_AIX
  • OS_AUX
  • OS_AMIGAOS
  • OS_NETWARE
  • OS_MVS
  • OS_ULTRIX
  • OS_DGUX
  • OS_SINIX
  • OS_DYNIX
  • OS_OS390
  • OS_RISCOS
  • OS_OS9
  • OS_NUTC

Optional Defines

WITH_GUI
Compile Cosm libraries with GUI support.
NO_THREADS
Compile Cosm libraries without threads support.
NO_NETWORKING
Compile Cosm libraries without networking support.
NO_IEEE_FLOAT
Compile Cosm libraries without IEEE floating point support.
NO_CRYPTO
Compile Cosm libraries without support for non-hash cryptographic functions, this allows for worldwide product export from the US. Products with crypto should involve one or more people outside the US.
NONPORTABLE_CODE
cosm.h will redefine dangerous or replaced functions from the standard C library. To use the replaced functions you must use this define. If you do use these functions, your code will NOT be portable.

Data Types

Description

Cosm 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 Strings

Description

cputypes.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.

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], os_types[OS_TYPE] );

_V3_SET

Description

Sets 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.

Example

  u64 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.

Example

  u128 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_EQ

Description

Compares 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.

Example

  u64 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.

Example

  u128 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.
Document last modified: