Browse code

* add missing file

Nat! authored on 18-12-2018 23:57:12
Showing 4 changed files
... ...
@@ -13,7 +13,7 @@ stacktrace/
13 13
 malloc-error/
14 14
 
15 15
 
16
-environment-os-*.sh
16
+environment-user-*.sh
17 17
 environment-host-*.sh
18 18
 
19 19
 # ### > generated by mulle-sde (extensions/mulle-sde/sde/init)
... ...
@@ -1,3 +1,7 @@
1
+### 1.0.8
2
+
3
+* add missing file
4
+
1 5
 ### 1.0.7
2 6
 
3 7
 * upgrade to newest mulle-sde
4 8
new file mode 100644
... ...
@@ -0,0 +1,133 @@
1
+
2
+#ifndef mulle_vararg_h__
3
+#define mulle_vararg_h__
4
+
5
+#include "mulle-align.h"
6
+
7
+
8
+// sketched out idea for a vararg builder
9
+// returns the address to push next argument unto.
10
+// it's the callers responsiblity to
11
+// * remember the start of the vararg buffer
12
+// * ensure that the buffer is large enough (tricky!)
13
+// * use the returne value as the first argument next time
14
+//
15
+// Intended use:
16
+//
17
+// mulle_vararg_builderbuffer_t  buf[ mulle_vararg_builderbuffer_n( sizeof( int) + sizeof( long)]
18
+// mulle_vararg_list             p = mulle_vararg_builderbuffer_get_list( buf);
19
+// mulle_vararg_list             q;
20
+//
21
+// q = mulle_vararg_push_integer( p, 18);
22
+// q = mulle_vararg_push_integer( q, 48L);
23
+// mulle_mvsprintf( buffer, "%d %ld", p);
24
+
25
+// use double for alignment
26
+typedef double   mulle_vararg_builderbuffer_t;
27
+typedef void     *mulle_vararg_builder_t;
28
+
29
+#define mulle_vararg_builderbuffer_n( size_t n)  \
30
+   (((n) + sizeof( mulle_vararg_builderbuffer_t) - 1)/ sizeof( mulle_vararg_builderbuffer_t))
31
+
32
+
33
+static inline void   mulle_vararg_push_longdouble( mulle_vararg_list *ap, long double value)
34
+{
35
+   long double   *q;
36
+
37
+   q     = mulle_pointer_align( ap->p, alignof( long double));
38
+   *q++  = value;
39
+   ap->p = q;
40
+}
41
+
42
+
43
+static inline void   mulle_vararg_push_double( mulle_vararg_list *ap, double value)
44
+{
45
+   double   *q;
46
+
47
+   q     = mulle_pointer_align( ap->p, alignof( double));
48
+   *q++  = value;
49
+   ap->p = q;
50
+}
51
+
52
+
53
+static inline void   mulle_vararg_push_longlong( mulle_vararg_list *ap, long long value)
54
+{
55
+   long long   *q;
56
+
57
+   q    = mulle_pointer_align( p, alignof( long long));
58
+   *q++ = value;
59
+   ap->p = q;
60
+}
61
+
62
+
63
+static inline void   mulle_vararg_push_int( mulle_vararg_list *ap, int value)
64
+{
65
+   int   *q;
66
+
67
+   q    = mulle_pointer_align( p, alignof( int));
68
+   *q++ = value;
69
+   ap->p = q;
70
+}
71
+
72
+
73
+static inline void   mulle_vararg_push_long( mulle_vararg_list *ap, long value)
74
+{
75
+   long   *q;
76
+
77
+   q    = mulle_pointer_align( p, alignof( long));
78
+   *q++ = value;
79
+   ap->p = q;
80
+}
81
+
82
+
83
+static inline void   mulle_vararg_push_pointer( mulle_vararg_list *ap, void *value)
84
+{
85
+   void   **q;
86
+
87
+   q    = mulle_pointer_align( p, alignof( void *));
88
+   *q++ = value;
89
+   ap->p = q;
90
+}
91
+
92
+
93
+typedef void  (*mulle_vararg_void_functionpointer)( void);
94
+
95
+static inline void *
96
+   mulle_vararg_push_functionpointer( void *ap,
97
+                                      mulle_vararg_void_functionpointer value)
98
+{
99
+   mulle_vararg_void_functionpointer   *q;
100
+
101
+   q    = mulle_pointer_align( p, alignof( mulle_vararg_void_functionpointer));
102
+   *q++ = value;
103
+   ap->p = q;
104
+}
105
+
106
+
107
+#define mulle_vararg_push_integer( p , x)                      \
108
+   (                                                           \
109
+      sizeof( x) <= sizeof( int)                               \
110
+         ? mulle_vararg_push_int( p, (int) x)                  \
111
+         : (sizeof( x) <= sizeof( long))                       \
112
+            ? mulle_vararg_push_long( p, (long) x)             \
113
+            : mulle_vararg_push_longlong( p, (long long) x)    \
114
+   )
115
+
116
+#define mulle_vararg_push_fp( p , x)                           \
117
+   (                                                           \
118
+      sizeof( x) <= sizeof( double)                            \
119
+         ? mulle_vararg_push_double( p, (double) x)            \
120
+         : mulle_vararg_push_longdouble( p, (long double) x)   \
121
+   )
122
+
123
+
124
+#define mulle_vararg_push_struct( ap , x)                                     \
125
+   (                                                                          \
126
+      memcpy( mulle_pointer_align( ap->p, alignof( x)), &x, sizeof( x)),      \
127
+      ap->p = &((char *) mulle_pointer_align( p, alignof( x)))[ sizeof( x)]   \
128
+   )
129
+
130
+#define mulle_vararg_push_union( ap , x)    mulle_vararg_push_struct( p, x)
131
+
132
+#endif
133
+
... ...
@@ -14,7 +14,7 @@
14 14
 //
15 15
 // community version is always even
16 16
 //
17
-#define MULLE_VARARG_VERSION  ((1 << 20) | (0 << 8) | 7)
17
+#define MULLE_VARARG_VERSION  ((1 << 20) | (0 << 8) | 8)
18 18
 
19 19
 
20 20
 /*