Updated PCI IDs to latest snapshot.
[tangerine.git] / compiler / include / utility / pack.h
blob268667e157f4906d7e623ec6fd7026051e6430de
1 #ifndef UTILITY_PACK_H
2 #define UTILITY_PACK_H
4 /*
5 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Used for (Un)PackTagItems()
9 Lang: english
12 #ifndef EXEC_TYPES_H
13 # include <exec/types.h>
14 #endif
15 #ifndef UTILITY_TAGITEM_H
16 # include <utility/tagitem.h>
17 #endif
19 #define PSTB_EXISTS 26
20 #define PSTF_EXISTS (1L<<26)
21 #define PSTB_PACK 29
22 #define PSTF_PACK (1L<<29)
23 #define PSTB_UNPACK 30
24 #define PSTF_UNPACK (1L<<30)
25 #define PSTB_SIGNED 31
26 #define PSTF_SIGNED (1L<<31)
28 #define PKCTRL_UBYTE 0x00000000
29 #define PKCTRL_BYTE 0x80000000
30 #define PKCTRL_UWORD 0x08000000
31 #define PKCTRL_WORD 0x88000000
32 #define PKCTRL_ULONG 0x10000000
33 #define PKCTRL_LONG 0x90000000
34 #define PKCTRL_PACKUNPACK 0x00000000
35 #define PKCTRL_UNPACKONLY 0x20000000
36 #define PKCTRL_PACKONLY 0x40000000
37 #define PKCTRL_BIT 0x18000000
38 #define PKCTRL_FLIPBIT 0x98000000
40 /* Macros (don't use!) */
42 #if AROS_BIG_ENDIAN
43 #define PK_WORDOFFSET(flag) ((flag) < 0x0100 ? 1 : 0)
44 #define PK_LONGOFFSET(flag) ((flag) < 0x0100 ? 3 : (flag) < 0x010000 ? 2 : (flag) < 0x01000000 ? 1 : 0)
45 #else
46 #define PK_WORDOFFSET(flag) ((flag) < 0x0100 ? 0 : 1)
47 #define PK_LONGOFFSET(flag) ((flag) < 0x0100 ? 0 : (flag) < 0x010000 ? 1 : (flag) < 0x01000000 ? 2 : 3)
48 #endif
50 #define PK_CALCOFFSET(type,field) ((IPTR)(&((struct type *)0)->field))
51 #define PK_BITNUM1(flag) ((flag) == 0x01 ? 0 : (flag) == 0x02 ? 1 : (flag) == 0x04 ? 2 : (flag) == 0x08 ? 3 : (flag) == 0x10 ? 4 : (flag) == 0x20 ? 5 : (flag) == 0x40 ? 6 : 7)
52 #define PK_BITNUM2(flag) ((flag) < 0x0100 ? PK_BITNUM1(flag) : 8 + PK_BITNUM1((flag)>>8))
53 #define PK_BITNUM(flag) ((flag) < 0x010000 ? PK_BITNUM2(flag) : 16 + PK_BITNUM2((flag)>>16))
55 /* Macros to create pack tables */
56 #define PACK_STARTTABLE(tagbase) (tagbase)
57 #define PACK_NEWOFFSET(tagbase) (-1L),(tagbase)
58 #define PACK_ENDTABLE 0
59 #define PACK_ENTRY(tagbase,tag,type,field,control) (control | ((tag - tagbase)<<16L) | PK_CALCOFFSET(type,field))
60 #define PACK_BYTEBIT(tagbase,tag,type,field,control,flags) (control | ((tag - tagbase)<<16L) | PK_CALCOFFSET(type,field) | (PK_BITNUM(flags) <<13L))
61 #define PACK_WORDBIT(tagbase,tag,type,field,control,flags) (control | ((tag - tagbase)<<16L) | (PK_CALCOFFSET(type,field) + PK_WORDOFFSET(flags)) | ((PK_BITNUM(flags) & 7)<<13L))
62 #define PACK_LONGBIT(tagbase,tag,type,field,control,flags) (control | ((tag - tagbase)<<16L) | (PK_CALCOFFSET(type,field) + PK_LONGOFFSET(flags)) | ((PK_BITNUM(flags) & 7)<<13L))
64 #endif /* UTILITY_PACK_H */