![]() |
Home | Libraries | Author | Links |
|
Macro and type definitions for inlining, endianness, abstract data types, scalar data types, alignment and flag handling. These definitions are used throughout the other SysToMath Base C Library modules.
Files | |
| file | basetype.h |
| Declaration of basic macro and type definitions depending on system specific settings. | |
8 Bit Data Types | |
| typedef unsigned char | StmByte |
| One unsigned byte of data. | |
| typedef unsigned char | StmUint8 |
| One unsigned byte of data. | |
| typedef signed char | StmInt8 |
| One signed byte of data. | |
| typedef StmByte * | StmAddr |
| Byte address. | |
16 Bit Data Types | |
| typedef unsigned short int | StmWord |
| Unsigned quantity consisting of two bytes of data. | |
| typedef unsigned short int | StmUint16 |
| Unsigned quantity consisting of two bytes of data. | |
| typedef short int | StmInt16 |
| Signed quantity consisting of two bytes of data. | |
32 Bit Data Types | |
| typedef unsigned int | StmDword |
| Unsigned quantity consisting of four bytes of data. | |
| typedef unsigned int | StmUint32 |
| Unsigned quantity consisting of four bytes of data. | |
| typedef int | StmInt32 |
| Signed quantity consisting of four bytes of data. | |
64 Bit Data Types | |
| typedef unsigned long long int | StmQword |
| Unsigned quantity consisting of eight bytes of data. | |
| typedef unsigned long long int | StmUint64 |
| Unsigned quantity consisting of eight bytes of data. | |
| typedef long long int | StmInt64 |
| Signed quantity consisting of eight bytes of data. | |
Boolean Data Type | |
| Definition of the boolean data type and its value constants. | |
| typedef int | StmBool |
| Boolean type. | |
| #define | StmFalse 0 |
| Value false for boolean type. | |
| #define | StmTrue 1 |
| Value true for boolean type. | |
Alignment | |
| Type definition and macros for alignment issues. | |
| typedef long | StmAlign |
| StmAlign shall satisfy the allignment requirements of every type. | |
| #define | StmAlignUnits(n) (((n) + sizeof (StmAlign) - 1) / sizeof (StmAlign)) |
| Number of StmAlign blocks for n bytes. | |
| #define | StmTypeAlignUnits(Type) (StmAlignUnits (sizeof (Type))) |
| Number of StmAlign blocks for one Type object. | |
Byte Order | |
| #define | __BIG_ENDIAN 4321 |
| Representation of the big endian byte order. | |
| #define | __LITTLE_ENDIAN 1234 |
| Representation of the little endian byte order. | |
| #define | __BYTE_ORDER __LITTLE_ENDIAN |
| Actual byte order. | |
Abstract Data Types | |
| Definition of abstract data types. | |
| #define | StmAbstractType(Type) |
| Definition of an abstract data type Type implemented by a structure. | |
| #define | StmAbstractTypeDefine(Type) |
| Definition of an abstract data type Type implemented by an arbitrary type. | |
Miscellanous Macros | |
| Definition of miscellaneous macros. | |
| #define | StmSizeofMember(agg, mem) (sizeof (((agg *) NULL) -> mem)) |
| Size of the member mem of an aggregat agg. | |
| #define | StmElements(vector) (sizeof (vector) / sizeof (vector [0])) |
| Element count of an array vector. | |
| #define | StmCharBits CHAR_BIT |
| Number of bits per character. | |
| #define | StmByteBits StmCharBits |
| Number of bits per byte. | |
| #define | StmUshortBits (sizeof (unsigned short int) * StmByteBits) |
| Number of bits per unsigned short int. | |
| #define | StmShortBits StmUshortBits |
| Number of bits per short int. | |
| #define | StmUintBits (sizeof (unsigned int) * StmByteBits) |
| Number of bits per unsigned int. | |
| #define | StmIntBits StmUintBits |
| Number of bits per int. | |
| #define | StmUlongIntBits (sizeof (unsigned long int) * StmByteBits) |
| Number of bits per unsigned long int. | |
| #define | StmLongIntBits StmUlongIntBits |
| Number of bits per long int. | |
| #define | StmBytesForBits(n) (((n) + StmByteBits - 1) / StmByteBits) |
| Number of bytes needed for a bit vector of n bits. | |
| #define | StmTwoToThe(nth) ((size_t) 1 << (nth)) |
| Represents 2 to the nth. | |
| #define | StmId(key) |
| Represents the unquoted string key as StmDword. | |
| #define | StmIdx(key) |
| Represents the quoted string key as StmDword. | |
Flag Field And Flag Macros | |
| Macros defining and handling flag fields and flags implemented as enumerators. The advantage of these macros over bit field declarations is that they are less implementation dependent regarding the placement of bits within a scalar type. Nevertheless beware of the dependency on the endianness of the architecture used. To neutralize that dependency use the endianness macros __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN.
| |
| #define | StmDeclareFlagField(name, beginBit, bitLength) |
| Declares enumerators for a flag field named name with begin bit beginBit and bit length bitLength. | |
| #define | StmGetFlagField(variable, name) (((variable) & name) >> name##Begin) |
| Gets the value of the flag field name of variable. | |
| #define | StmSetFlagField(variable, name, value) |
| Sets the the flag field name of variable to value. | |
| #define | StmDeclareFlag(name, beginBit) StmDeclareFlagField (name, beginBit, 1) |
| Declares enumerators for a flag named name with begin bit beginBit. | |
| #define | StmGetFlag(variable, name) (StmGetFlagField (variable, name)) |
| Gets the value of the flag name of variable. | |
| #define | StmSetFlag(variable, name, value) StmSetFlagField (variable, name, (value)) |
| Sets the the flag name of variable to value. | |
| #define __BIG_ENDIAN 4321 |
| #define __LITTLE_ENDIAN 1234 |
| #define __BYTE_ORDER __LITTLE_ENDIAN |
| #define StmFalse 0 |
Value false for boolean type.
Definition at line 212 of file basetype.h.
Referenced by commout(), gatherout(), main(), out(), pnlout(), pout(), and readline().
| #define StmTrue 1 |
Value true for boolean type.
Definition at line 216 of file basetype.h.
Referenced by bout(), cnlout(), commout(), main(), out(), pnlout(), pout(), readline(), and setclbeg().
| #define StmAbstractType | ( | Type | ) |
Value:
typedef struct Type##Impl_ Type##Impl_; \ typedef Type##Impl_ *Type; \ typedef const Type##Impl_ *Const##Type;
| [in] | Type | Name of the abstract data type to be defined. |
Definition at line 247 of file basetype.h.
| #define StmAbstractTypeDefine | ( | Type | ) |
Value:
typedef Type##Impl_ *Type; \ typedef const Type##Impl_ *Const##Type;
| [in] | Type | Name of the abstract data type to be defined. |
Definition at line 269 of file basetype.h.
Number of StmAlign blocks for n bytes.
The macro StmAlignUnits represents the least number of blocks of size sizeof (StmAlign) being able to contain a buffer of n bytes.
Definition at line 285 of file basetype.h.
| #define StmTypeAlignUnits | ( | Type | ) | (StmAlignUnits (sizeof (Type))) |
Number of StmAlign blocks for one Type object.
The macro StmTypeAlignUnits represents the least number of blocks of size sizeof (StmAlign) being able to contain one Type object.
Definition at line 291 of file basetype.h.
| #define StmSizeofMember | ( | agg, | |||
| mem | ) | (sizeof (((agg *) NULL) -> mem)) |
| #define StmElements | ( | vector | ) | (sizeof (vector) / sizeof (vector [0])) |
| #define StmCharBits CHAR_BIT |
| #define StmByteBits StmCharBits |
Number of bits per byte.
Definition at line 319 of file basetype.h.
Referenced by randomInt().
| #define StmUshortBits (sizeof (unsigned short int) * StmByteBits) |
| #define StmShortBits StmUshortBits |
| #define StmUintBits (sizeof (unsigned int) * StmByteBits) |
| #define StmIntBits StmUintBits |
| #define StmUlongIntBits (sizeof (unsigned long int) * StmByteBits) |
| #define StmLongIntBits StmUlongIntBits |
| #define StmBytesForBits | ( | n | ) | (((n) + StmByteBits - 1) / StmByteBits) |
| #define StmTwoToThe | ( | nth | ) | ((size_t) 1 << (nth)) |
| #define StmId | ( | key | ) |
Value:
(StmDword) (#key [0] ? \ #key [1] ? \ #key [2] ? \ #key [3] ? \ #key [3] + 256 * (#key [2] + 256 * (#key [1] + 256 * #key [0])) : \ #key [2] + 256 * (#key [1] + 256 * #key [0]) : \ #key [1] + 256 * #key [0] : \ #key [0] : \ 0)
Definition at line 355 of file basetype.h.
Referenced by main().
| #define StmIdx | ( | key | ) |
Value:
(StmDword) (key [0] ? \ key [1] ? \ key [2] ? \ key [3] ? \ key [3] + 256 * (key [2] + 256 * (key [1] + 256 * key [0])) : \ key [2] + 256 * (key [1] + 256 * key [0]) : \ key [1] + 256 * key [0] : \ key [0] : \ 0)
Definition at line 368 of file basetype.h.
| #define StmDeclareFlagField | ( | name, | |||
| beginBit, | |||||
| bitLength | ) |
Value:
name##Begin = (beginBit), \
name##Length = (bitLength), \
name##End = ((beginBit) + (bitLength)), \
name = ((((size_t) 1 << (bitLength)) - 1) << (beginBit))
Definition at line 421 of file basetype.h.
| #define StmGetFlagField | ( | variable, | |||
| name | ) | (((variable) & name) >> name##Begin) |
| #define StmSetFlagField | ( | variable, | |||
| name, | |||||
| value | ) |
Value:
do \ { \ (variable) &= ~name; (variable) |= ((value) << name##Begin) & name; \ } \ while (0)
Definition at line 434 of file basetype.h.
| #define StmDeclareFlag | ( | name, | |||
| beginBit | ) | StmDeclareFlagField (name, beginBit, 1) |
Declares enumerators for a flag named name with begin bit beginBit.
Definition at line 443 of file basetype.h.
| #define StmGetFlag | ( | variable, | |||
| name | ) | (StmGetFlagField (variable, name)) |
| #define StmSetFlag | ( | variable, | |||
| name, | |||||
| value | ) | StmSetFlagField (variable, name, (value)) |
| typedef unsigned char StmByte |
| typedef unsigned char StmUint8 |
| typedef signed char StmInt8 |
| typedef unsigned short int StmWord |
| typedef unsigned short int StmUint16 |
| typedef short int StmInt16 |
| typedef unsigned int StmDword |
| typedef unsigned int StmUint32 |
| typedef int StmInt32 |
| typedef unsigned long long int StmQword |
| typedef unsigned long long int StmUint64 |
| typedef long long int StmInt64 |
| typedef int StmBool |
| typedef long StmAlign |
StmAlign shall satisfy the allignment requirements of every type.
Definition at line 295 of file basetype.h.
© Copyright Tom Michaelis 2002-2007
Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).