crete an idle task to run when theres ... umm. .. nothing to do ..
[AROS.git] / compiler / include / utility / pack.h
blobe51d669b42d13b501997e4aa95d7fa72fc4c4f7a
1 #ifndef UTILITY_PACK_H
2 #define UTILITY_PACK_H
4 /*
5 Copyright © 1995-2011, 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 /* Full IPTR (or SIPTR) value. Makes difference on 64 bits. */
51 #if __WORDSIZE > 32
52 #define PKCTRL_IPTR (PKCTRL_ULONG | 0x00002000)
53 #define PKCTRL_SIPTR (PKCTRL_LONG | 0x00002000)
54 #else
55 #define PKCTRL_IPTR PKCTRL_ULONG
56 #define PKCTRL_SIPTR PKCTRL_LONG
57 #endif
59 #define PK_CALCOFFSET(type,field) ((IPTR)(&((struct type *)0)->field))
60 #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)
61 #define PK_BITNUM2(flag) ((flag) < 0x0100 ? PK_BITNUM1(flag) : 8 + PK_BITNUM1((flag)>>8))
62 #define PK_BITNUM(flag) ((flag) < 0x010000 ? PK_BITNUM2(flag) : 16 + PK_BITNUM2((flag)>>16))
64 /* Macros to create pack tables */
65 #define PACK_STARTTABLE(tagbase) (tagbase)
66 #define PACK_NEWOFFSET(tagbase) (-1L),(tagbase)
67 #define PACK_ENDTABLE 0
68 #define PACK_ENTRY(tagbase,tag,type,field,control) (control | ((tag - tagbase)<<16L) | PK_CALCOFFSET(type,field))
69 #define PACK_BYTEBIT(tagbase,tag,type,field,control,flags) (control | ((tag - tagbase)<<16L) | PK_CALCOFFSET(type,field) | (PK_BITNUM(flags) <<13L))
70 #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))
71 #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))
73 #endif /* UTILITY_PACK_H */