1 #ifndef UTILITY_TAGITEM_H
2 #define UTILITY_TAGITEM_H
5 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
13 # include <exec/types.h>
15 #ifdef AROS_SLOWSTACKTAGS
23 Tag ti_Tag
__attribute__((aligned(sizeof(IPTR
)))); /* Tag ID */
24 IPTR ti_Data
__attribute__((aligned(sizeof(IPTR
)))); /* Tag-specific data */
25 } __attribute__((packed
));
27 #ifdef AROS_SLOWSTACKTAGS
29 struct TagItem
* GetTagsFromStack (IPTR firstTag
, va_list args
);
30 void FreeTagsFromStack (struct TagItem
* tags
);
34 /* constants for Tag.ti_Tag, control tag values */
35 #define TAG_DONE (0UL) /* terminates array of TagItems. ti_Data unused */
36 #define TAG_END (0UL) /* synonym for TAG_DONE */
37 #define TAG_IGNORE (1UL) /* ignore this item, not end of array */
38 #define TAG_MORE (2UL) /* ti_Data is pointer to another array of TagItems
39 note that this tag terminates the current array */
40 #define TAG_SKIP (3UL) /* skip this and the next ti_Data items */
42 /* What separates user tags from system tags */
43 #define TAG_USER ((STACKULONG)(1UL<<31))
44 #define TAG_OS (16UL) /* The first tag used by the OS */
46 /* Tag-Offsets for the OS */
47 #define DOS_TAGBASE (TAG_OS) /* Reserve 16k tags for DOS */
48 #define INTUITION_TAGBASE (TAG_OS | 0x2000) /* Reserve 16k tags for Intuition */
50 /* Tag filter for FilterTagItems() */
51 #define TAGFILTER_AND 0 /* exclude everything but filter hits */
52 #define TAGFILTER_NOT 1 /* exclude only filter hits */
54 /* Mapping types for MapTags() */
55 #define MAP_REMOVE_NOT_FOUND 0 /* remove tags that aren't in mapList */
56 #define MAP_KEEP_NOT_FOUND 1 /* keep tags that aren't in mapList */
58 /* Macro for syntactic sugar (and a little extra bug-resiliance) */
59 #define TAGLIST(args...) ((struct TagItem *)(IPTR []){ args, TAG_DONE })
62 Some macros to make it easier to write functions which operate on
63 stacktags on every CPU/compiler/hardware.
65 #ifndef AROS_TAGRETURNTYPE
66 # define AROS_TAGRETURNTYPE IPTR
69 #ifdef AROS_SLOWSTACKTAGS
70 # define AROS_NR_SLOWSTACKTAGS_PRE(arg) \
72 struct TagItem * tags; \
74 va_start (args, arg); \
76 if ((tags = GetTagsFromStack (arg, args))) \
79 # define AROS_SLOWSTACKTAGS_PRE_AS(arg, rettype) \
82 struct TagItem * tags; \
84 va_start (args, arg); \
86 if ((tags = GetTagsFromStack (arg, args))) \
89 # define AROS_SLOWSTACKTAGS_PRE(arg) \
90 AROS_SLOWSTACKTAGS_PRE_AS(arg, AROS_TAGRETURNTYPE)
92 # define AROS_SLOWSTACKTAGS_ARG(arg) tags
94 # define AROS_SLOWSTACKTAGS_POST \
95 FreeTagsFromStack (tags); \
104 # define AROS_NR_SLOWSTACKTAGS_POST \
105 FreeTagsFromStack (tags); \
110 # define AROS_NR_SLOWSTACKTAGS_PRE(arg)
111 # define AROS_NR_SLOWSTACKTAGS_POST
112 # define AROS_SLOWSTACKTAGS_PRE(arg) AROS_TAGRETURNTYPE retval;
113 # define AROS_SLOWSTACKTAGS_PRE_AS(arg, rettype) rettype retval;
114 # define AROS_SLOWSTACKTAGS_ARG(arg) ((struct TagItem *)&(arg))
115 # define AROS_SLOWSTACKTAGS_POST return retval;
118 #endif /* UTILITY_TAGITEM_H */