Browse code

use alignof( struct { type x};) everywhere now

Nat! authored on 04-07-2016 16:25:36
Showing 4 changed files
... ...
@@ -34,4 +34,4 @@ struct
34 34
 } _param;
35 35
 ```
36 36
 
37
-But accsessing those values, that's what mulle-vararg does for you.
37
+But accessing those values, that's what mulle-vararg does for you.
... ...
@@ -1,3 +1,8 @@
1
+## 0.4
2
+
3
+* i386 has some crazy alignment rules. So alignment has to be calculated
4
+  differnently now.
5
+
1 6
 ## 0.3
2 7
 
3 8
 * removed gnuisms to be C99 compliant
... ...
@@ -215,7 +215,7 @@
215 215
 			isa = XCBuildConfiguration;
216 216
 			baseConfigurationReference = 41998A331CB6693400D18DD8 /* Debug.xcconfig */;
217 217
 			buildSettings = {
218
-				CURRENT_PROJECT_VERSION = 0.2;
218
+				CURRENT_PROJECT_VERSION = 0.4;
219 219
 				GCC_C_LANGUAGE_STANDARD = c99;
220 220
 			};
221 221
 			name = Debug;
... ...
@@ -224,7 +224,7 @@
224 224
 			isa = XCBuildConfiguration;
225 225
 			baseConfigurationReference = 41998A3A1CB6693400D18DD8 /* Release.xcconfig */;
226 226
 			buildSettings = {
227
-				CURRENT_PROJECT_VERSION = 0.2;
227
+				CURRENT_PROJECT_VERSION = 0.4;
228 228
 				GCC_C_LANGUAGE_STANDARD = c99;
229 229
 			};
230 230
 			name = Release;
... ...
@@ -11,7 +11,7 @@
11 11
 
12 12
 #include "mulle_align.h"
13 13
 
14
-#define MULLE_VARARG_VERSION  ((0 << 20) | (3 << 8) | 0)
14
+#define MULLE_VARARG_VERSION  ((0 << 20) | (4 << 8) | 0)
15 15
 
16 16
 
17 17
 /*
... ...
@@ -82,10 +82,10 @@ static inline char  *_mulle_vararg_int_aligned_pointer( mulle_vararg_list *args,
82 82
 }
83 83
    
84 84
 
85
-#define mulle_vararg_next_integer( args, type)                                                   \
86
-   (sizeof( type) < sizeof( int)                                                                 \
87
-      ? (type) *(int *) _mulle_vararg_int_aligned_pointer( &args, sizeof( type), alignof( type)) \
88
-      : *(type *) _mulle_vararg_int_aligned_pointer( &args, sizeof( type), alignof( type)))
85
+#define mulle_vararg_next_integer( args, type)                                                                \
86
+   (sizeof( type) < sizeof( int)                                                                              \
87
+      ? (type) *(int *) _mulle_vararg_int_aligned_pointer( &args, sizeof( type), alignof( struct{ type x; })) \
88
+      : *(type *) _mulle_vararg_int_aligned_pointer( &args, sizeof( type), alignof( struct{ type x; })))
89 89
 
90 90
 
91 91
 static inline char  *_mulle_vararg_aligned_pointer( mulle_vararg_list *args, unsigned int align)
... ...
@@ -100,7 +100,7 @@ static inline char  *_mulle_vararg_aligned_pointer( mulle_vararg_list *args, uns
100 100
 
101 101
 // use this for all pointer and id types
102 102
 #define mulle_vararg_next_pointer( args, type)  \
103
-   (*(type *) _mulle_vararg_aligned_pointer( &args, alignof( type)))
103
+   (*(type *) _mulle_vararg_aligned_pointer( &args, alignof( struct{ type x; })))
104 104
 
105 105
 // use this for objects types
106 106
 #define mulle_vararg_next( args)                \
... ...
@@ -113,7 +113,7 @@ static inline char  *_mulle_vararg_aligned_pointer( mulle_vararg_list *args, uns
113 113
 
114 114
 // use this for all struct types
115 115
 #define mulle_vararg_next_struct( args, type)    \
116
-   (*(type *) _mulle_vararg_aligned_pointer( &args, alignof( type)))
116
+   (*(type *) _mulle_vararg_aligned_pointer( &args, alignof( struct{ type x; })))
117 117
 
118 118
 
119 119
 static inline char  *_mulle_vararg_double_aligned_pointer( mulle_vararg_list *args, size_t size, unsigned int align)
... ...
@@ -133,10 +133,10 @@ static inline char  *_mulle_vararg_double_aligned_pointer( mulle_vararg_list *ar
133 133
 
134 134
 
135 135
 // need separate routine for FP arguments, as float promotes to double
136
-#define mulle_vararg_next_fp( args, type)                                                              \
137
-   (sizeof( type) < sizeof( double)                                                                    \
138
-      ? (type) *(double *) _mulle_vararg_double_aligned_pointer( &args, sizeof( type), alignof( type)) \
139
-      : *(type *) _mulle_vararg_double_aligned_pointer( &args, sizeof( type), alignof( type)))
136
+#define mulle_vararg_next_fp( args, type)                                                                           \
137
+   (sizeof( type) < sizeof( double)                                                                                 \
138
+      ? (type) *(double *) _mulle_vararg_double_aligned_pointer( &args, sizeof( type), alignof( struct{ type x; })) \
139
+      : *(type *) _mulle_vararg_double_aligned_pointer( &args, sizeof( type), alignof( struct{ type x; })))
140 140
 
141 141
 
142 142