/*
"gsdefines.h"
created by: grayspace aka J. Leveille
for: UbixOS Project
date: May 11, 2002
Purpose:
- I need/like to use simple defines for basic sized types which
aren't compiler dependant.
So here I define them and will use them, when we decide on some conventions
I will search and replace them out with the proper ones
- I need some kind of define for target architecture
NOTES:
- I will stick a 'g' on the end global defines I make for myself
- all my types are ending with g when unsigned, gs when signed
- for now, when I don't care about bit width and hwen I want
just an int for example, I will just use 'int' and assume
this will be the fastest type for doing math on the host CPU
$Id$
*/
#ifndef _GSDEFINES_H
#define _GSDEFINES_H
/* HACK: put somewhere better */
/* target CPU types (0) means unknown */
/* HACK: assume we're using IA32 architecture */
#define TCPU_UNKNOWN (0)
#define TCPU_IA32 (1)
/* host compiler types (0) means unknown */
/* HACK: assume we're using gcc 2.95.* comptible compiler */
#define HCMPLR_UNKNOWN (0)
#define HCMPLR_GCC_2_95_COMPAT (1)
#if (TCPU_IA32 & HCMPLR_GCC_2_95_COMPAT)
#define BYTEg unsigned char
#define BYTEgs signed char
#define WORDg unsigned short int
#define WORDgs signed short int
#define DWORDg unsigned int
#define DWORDgs signed int
#define QWORDg unsigned long long int
#define QWORDgs signed long long int
#else /* #if (TCPU_IA32 & HCMPLR_GCC_2_95_COMPAT) */
#error build environment unknown!!!
#endif /* #if (TCPU_??? & HCMPLR_???) */
/* handy macro for creating a bit mask */
#define MAKEMASK_GS( numbits, bitpos ) (((1<<(numbits)) - 1)<<(bitpos))
/* handy macro for extracting masked bits */
#define GETBITVAL_GS( bits, bitmask, bitpos ) (((bits)&(bitmask))>>(bitpos))
/* handy macro for setting masked bits
NOTE: *only* bits which fall into 'bitmask' once positioned will be set */
#define SETBITVAL_GS( bits_o, bitmask, bitpos, val )\
(bits_o) &= ~(bitmask);\
(bits_o) |= ((val)<<(bitpos)&bitmask)
/* handy macro for setting masked bits with the assumption
that 'val' once positioned will *only* contain bits in 'bitmask' */
#define SETBITVAL_FAST_GS( bits_o, bitmask, bitpos, val )\
(bits_o) &= ~(bitmask);\
(bits_o) |= ((val)<<(bitpos))
#endif /* _GSDEFINES_H */