Test initialisation of MUIA_List_AdjustWidth and MUIA_List_AdjustHeight, and
[AROS.git] / compiler / include / utility / tagitem.h
blob9e0e84f1a64f7cd519d01c1543fa5c14d16e1987
1 #ifndef UTILITY_TAGITEM_H
2 #define UTILITY_TAGITEM_H
4 /*
5 Copyright © 1995-2010, 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 #ifdef AROS_SLOWSTACKTAGS
16 # include <stdarg.h>
17 #endif
19 typedef ULONG Tag;
21 struct TagItem
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
28 __BEGIN_DECLS
29 struct TagItem * GetTagsFromStack (IPTR firstTag, va_list args);
30 void FreeTagsFromStack (struct TagItem * tags);
31 __END_DECLS
32 #endif
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
67 #endif
69 #ifdef AROS_SLOWSTACKTAGS
70 # define AROS_NR_SLOWSTACKTAGS_PRE(arg) \
71 va_list args; \
72 struct TagItem * tags; \
74 va_start (args, arg); \
76 if ((tags = GetTagsFromStack (arg, args))) \
79 # define AROS_SLOWSTACKTAGS_PRE_AS(arg, rettype) \
80 rettype retval; \
81 va_list args; \
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); \
96 } \
97 else \
98 retval = 0; \
100 va_end (args); \
102 return retval;
104 # define AROS_NR_SLOWSTACKTAGS_POST \
105 FreeTagsFromStack (tags); \
108 va_end (args);
109 #else
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;
116 #endif
118 #endif /* UTILITY_TAGITEM_H */