1 #ifndef UTILITY_PACK_H 2 #define UTILITY_PACK_H 3 4 /* 5 utility.library pack attributes and macros 6 7 Copyright © 2002 The MorphOS Development Team, All Rights Reserved. 8 */ 9 10 #ifndef EXEC_TYPES_H 11 # include <exec/types.h> 12 #endif 13 14 #ifndef UTILITY_TAGITEM_H 15 # include <utility/tagitem.h> 16 #endif 17 18 19 #define PSTB_SIGNED 31 20 #define PSTB_UNPACK 30 21 #define PSTB_PACK 29 22 #define PSTB_EXISTS 26 23 24 #define PSTF_SIGNED (1<<PSTB_SIGNED) 25 #define PSTF_UNPACK (1<<PSTB_UNPACK) 26 #define PSTF_PACK (1<<PSTB_PACK) 27 #define PSTF_EXISTS (1<<PSTB_EXISTS) 28 29 30 #define PKCTRL_PACKUNPACK 0x00000000 31 #define PKCTRL_PACKONLY 0x40000000 32 #define PKCTRL_UNPACKONLY 0x20000000 33 34 #define PKCTRL_BYTE 0x80000000 35 #define PKCTRL_WORD 0x88000000 36 #define PKCTRL_LONG 0x90000000 37 38 #define PKCTRL_UBYTE 0x00000000 39 #define PKCTRL_UWORD 0x08000000 40 #define PKCTRL_ULONG 0x10000000 41 42 #define PKCTRL_BIT 0x18000000 43 #define PKCTRL_FLIPBIT 0x98000000 44 45 46 #define PK_BITNUM1(flg) ((flg) == 0x01 ? 0 : (flg) == 0x02 ? 1 : (flg) == 0x04 ? 2 : (flg) == 0x08 ? 3 : (flg) == 0x10 ? 4 : (flg) == 0x20 ? 5 : (flg) == 0x40 ? 6 : 7) 47 #define PK_BITNUM2(flg) ((flg < 0x100 ? PK_BITNUM1(flg) : 8 + PK_BITNUM1(flg >> 8))) 48 #define PK_BITNUM(flg) ((flg < 0x10000 ? PK_BITNUM2(flg) : 16 + PK_BITNUM2(flg >> 16))) 49 #define PK_WORDOFFSET(flg) ((flg) < 0x100 ? 1 : 0) 50 #define PK_LONGOFFSET(flg) ((flg) < 0x100 ? 3 : (flg) < 0x10000 ? 2 : (flg) < 0x1000000 ? 1 : 0) 51 #define PK_CALCOFFSET(type,field) ((ULONG)(&((struct type *)0)->field)) 52 53 54 #define PACK_STARTTABLE(tagbase) (tagbase) 55 #define PACK_NEWOFFSET(tagbase) (-1L),(tagbase) 56 #define PACK_ENDTABLE 0 57 #define PACK_ENTRY(tagbase,tag,type,field,control) (control | ((tag-tagbase) << 16L) | PK_CALCOFFSET(type,field)) 58 #define PACK_BYTEBIT(tagbase,tag,type,field,control,flags) (control | ((tag-tagbase) << 16L) | PK_CALCOFFSET(type,field) | (PK_BITNUM(flags) << 13L)) 59 #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)) 60 #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)) 61 62 63 #endif /* UTILITY_PACK_H */