revert between 56095 -> 55830 in arch
[AROS.git] / compiler / include / utility / tagitem.h
blob6b67c3f4331084d76e3a231e06772c41c0e357da
1 #ifndef UTILITY_TAGITEM_H
2 #define UTILITY_TAGITEM_H
4 /*
5 Copyright © 1995-2018, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Tag-lists
9 Lang: english
12 #ifndef EXEC_TYPES_H
13 # include <exec/types.h>
14 #endif
15 #include <stdarg.h>
17 typedef ULONG Tag;
19 struct TagItem
21 Tag ti_Tag __attribute__((aligned(sizeof(IPTR)))); /* Tag ID */
22 IPTR ti_Data __attribute__((aligned(sizeof(IPTR)))); /* Tag-specific data */
23 } __attribute__((packed));
25 #ifdef AROS_SLOWSTACKTAGS
26 __BEGIN_DECLS
27 struct TagItem * GetTagsFromStack (IPTR firstTag, va_list args);
28 void FreeTagsFromStack (struct TagItem * tags);
29 __END_DECLS
30 #endif
32 /* constants for Tag.ti_Tag, control tag values */
33 #define TAG_DONE (0UL) /* terminates array of TagItems. ti_Data unused */
34 #define TAG_END (0UL) /* synonym for TAG_DONE */
35 #define TAG_IGNORE (1UL) /* ignore this item, not end of array */
36 #define TAG_MORE (2UL) /* ti_Data is pointer to another array of TagItems
37 note that this tag terminates the current array */
38 #define TAG_SKIP (3UL) /* skip this and the next ti_Data items */
40 /* What separates user tags from system tags */
41 #define TAG_USER (1UL<<31)
42 #define TAG_OS (16UL) /* The first tag used by the OS */
44 /* Tag-Offsets for the OS */
45 #define DOS_TAGBASE (TAG_OS) /* Reserve 16k tags for DOS */
46 #define INTUITION_TAGBASE (TAG_OS | 0x2000) /* Reserve 16k tags for Intuition */
48 /* Tag filter for FilterTagItems() */
49 #define TAGFILTER_AND 0 /* exclude everything but filter hits */
50 #define TAGFILTER_NOT 1 /* exclude only filter hits */
52 /* Mapping types for MapTags() */
53 #define MAP_REMOVE_NOT_FOUND 0 /* remove tags that aren't in mapList */
54 #define MAP_KEEP_NOT_FOUND 1 /* keep tags that aren't in mapList */
56 /* Macro for syntactic sugar (and a little extra bug-resiliance) */
57 #define TAGLIST(args...) ((struct TagItem *)(IPTR []){ args, TAG_DONE })
60 Some macros to make it easier to write functions which operate on
61 stacktags on every CPU/compiler/hardware.
63 #ifndef AROS_TAGRETURNTYPE
64 # define AROS_TAGRETURNTYPE IPTR
65 #endif
67 #ifdef AROS_SLOWSTACKTAGS
68 # define AROS_NR_SLOWSTACKTAGS_PRE(arg) \
69 va_list args; \
70 struct TagItem * tags; \
72 va_start (args, arg); \
74 if ((tags = GetTagsFromStack (arg, args))) \
77 # define AROS_SLOWSTACKTAGS_PRE_AS(arg, rettype) \
78 rettype retval; \
79 va_list args; \
80 struct TagItem * tags; \
82 va_start (args, arg); \
84 if ((tags = GetTagsFromStack (arg, args))) \
87 # define AROS_SLOWSTACKTAGS_PRE(arg) \
88 AROS_SLOWSTACKTAGS_PRE_AS(arg, AROS_TAGRETURNTYPE)
90 # define AROS_SLOWSTACKTAGS_ARG(arg) tags
92 # define AROS_SLOWSTACKTAGS_POST \
93 FreeTagsFromStack (tags); \
94 } \
95 else \
96 retval = 0; \
98 va_end (args); \
100 return retval;
102 # define AROS_NR_SLOWSTACKTAGS_POST \
103 FreeTagsFromStack (tags); \
106 va_end (args);
107 #else
108 # define AROS_NR_SLOWSTACKTAGS_PRE(arg)
109 # define AROS_NR_SLOWSTACKTAGS_POST
110 # define AROS_SLOWSTACKTAGS_PRE(arg) AROS_TAGRETURNTYPE retval;
111 # define AROS_SLOWSTACKTAGS_PRE_AS(arg, rettype) rettype retval;
113 * In the following macro, we pretend to use a va_list, to stop GCC
114 * discarding varargs given to inlined functions. If this stops working
115 * in the future, we may have to enable slow stack tags for all archs.
117 # define AROS_SLOWSTACKTAGS_ARG(arg) \
118 ((struct TagItem *)({ \
119 va_list _dummy_args; \
120 va_start(_dummy_args, arg); \
121 va_end(_dummy_args); \
122 &(arg); \
124 # define AROS_SLOWSTACKTAGS_POST return retval;
125 #endif
127 #endif /* UTILITY_TAGITEM_H */