|
28 | 28 |
|
29 | 29 | #include <msgpack.h> |
30 | 30 |
|
| 31 | +/* Note: |
| 32 | + * 64 bit Windows : |
| 33 | + * All of the size_t casts have been replaced with |
| 34 | + * size_t pointer casts because there is an issue |
| 35 | + * with msvc where it doesn't honor the type promotion |
| 36 | + * when a small constant integer is hard-coded. |
| 37 | + * |
| 38 | + * This should not be a problem because according to |
| 39 | + * the standard a size_t should be as large as the |
| 40 | + * native register size just like pointers. |
| 41 | + * |
| 42 | + * 32 bit Windows : |
| 43 | + * 64 bit integers are still defined as their specific |
| 44 | + * types because the compiler handles them properly. |
| 45 | + * |
| 46 | + * Additionally, even though it would be preferrable to be |
| 47 | + * able to use the optimize pragma to selectively disable |
| 48 | + * the problematic optimizations it doesn't seem to work |
| 49 | + * as expected. |
| 50 | + */ |
| 51 | + |
| 52 | +#ifdef FLB_SYSTEM_WINDOWS |
| 53 | +#ifdef _WIN64 |
| 54 | +typedef size_t * flb_log_event_encoder_size_t; |
| 55 | +typedef size_t * flb_log_event_encoder_int64_t; |
| 56 | +typedef size_t * flb_log_event_encoder_uint64_t; |
| 57 | +#else |
| 58 | +typedef size_t * flb_log_event_encoder_size_t; |
| 59 | +typedef int64_t flb_log_event_encoder_int64_t; |
| 60 | +typedef uint64_t flb_log_event_encoder_uint64_t; |
| 61 | +#endif |
| 62 | +#else |
| 63 | +typedef size_t flb_log_event_encoder_size_t; |
| 64 | +typedef int64_t flb_log_event_encoder_int64_t; |
| 65 | +typedef uint64_t flb_log_event_encoder_uint64_t; |
| 66 | +#endif |
| 67 | + |
31 | 68 | #define FLB_EVENT_ENCODER_SUCCESS 0 |
32 | 69 | #define FLB_EVENT_ENCODER_ERROR_UNSPECIFIED -1 |
33 | 70 | #define FLB_EVENT_ENCODER_ERROR_ALLOCATION_ERROR -2 |
|
75 | 112 |
|
76 | 113 | #define FLB_LOG_EVENT_APPEND_UNTIL_TERMINATOR -1 |
77 | 114 |
|
78 | | -/* Note: all of the size_t casts have been replaced with |
79 | | - * size_t pointer casts because there is an issue |
80 | | - * with msvc where it doesn't honor the type promotion |
81 | | - * when a small constant integer is hard-coded. |
82 | | - * |
83 | | - * This should not be a problem because according to |
84 | | - * the standard a size_t should be as large as the |
85 | | - * native register size just like pointers. |
86 | | - */ |
87 | | - |
88 | 115 | #define FLB_LOG_EVENT_VALUE_LIST_TERMINATOR() \ |
89 | 116 | (int) FLB_LOG_EVENT_APPEND_TERMINATOR_VALUE_TYPE |
90 | 117 |
|
91 | 118 | #define FLB_LOG_EVENT_STRING_LENGTH_VALUE(length) \ |
92 | 119 | (int) FLB_LOG_EVENT_STRING_LENGTH_VALUE_TYPE, \ |
93 | | - (size_t *) length |
| 120 | + (flb_log_event_encoder_size_t) length |
94 | 121 |
|
95 | 122 | #define FLB_LOG_EVENT_STRING_BODY_VALUE(buffer, length) \ |
96 | 123 | (int) FLB_LOG_EVENT_STRING_BODY_VALUE_TYPE, \ |
97 | 124 | (char *) buffer, \ |
98 | | - (size_t *) length |
| 125 | + (flb_log_event_encoder_size_t) length |
99 | 126 |
|
100 | 127 | #define FLB_LOG_EVENT_BINARY_LENGTH_VALUE(length) \ |
101 | 128 | (int) FLB_LOG_EVENT_BINARY_LENGTH_VALUE_TYPE, \ |
102 | | - (size_t *) length |
| 129 | + (flb_log_event_encoder_size_t) length |
103 | 130 |
|
104 | 131 | #define FLB_LOG_EVENT_BINARY_BODY_VALUE(buffer, length) \ |
105 | 132 | (int) FLB_LOG_EVENT_BINARY_BODY_VALUE_TYPE, \ |
106 | 133 | (char *) buffer, \ |
107 | | - (size_t *) length |
| 134 | + (flb_log_event_encoder_size_t) length |
108 | 135 |
|
109 | 136 | #define FLB_LOG_EVENT_EXT_LENGTH_VALUE(type_, length) \ |
110 | 137 | (int) FLB_LOG_EVENT_EXT_LENGTH_VALUE_TYPE, \ |
111 | 138 | (int) type_, \ |
112 | | - (size_t *) length |
| 139 | + (flb_log_event_encoder_size_t) length |
113 | 140 |
|
114 | 141 | #define FLB_LOG_EVENT_EXT_BODY_VALUE(buffer, length) \ |
115 | 142 | (int) FLB_LOG_EVENT_EXT_BODY_VALUE_TYPE, \ |
116 | 143 | (char *) buffer, \ |
117 | | - (size_t *) length |
| 144 | + (flb_log_event_encoder_size_t) length |
118 | 145 |
|
119 | 146 | #define FLB_LOG_EVENT_TIMESTAMP_VALUE(value) \ |
120 | 147 | (int) FLB_LOG_EVENT_TIMESTAMP_VALUE_TYPE, \ |
|
153 | 180 |
|
154 | 181 | #define FLB_LOG_EVENT_INT64_VALUE(value) \ |
155 | 182 | (int) FLB_LOG_EVENT_INT64_VALUE_TYPE, \ |
156 | | - (int64_t *) value |
| 183 | + (flb_log_event_encoder_int64_t) value |
157 | 184 |
|
158 | 185 | #define FLB_LOG_EVENT_UINT8_VALUE(value) \ |
159 | 186 | (int) FLB_LOG_EVENT_UINT8_VALUE_TYPE, \ |
|
169 | 196 |
|
170 | 197 | #define FLB_LOG_EVENT_UINT64_VALUE(value) \ |
171 | 198 | (int) FLB_LOG_EVENT_UINT64_VALUE_TYPE, \ |
172 | | - (uint64_t *) value |
| 199 | + (flb_log_event_encoder_uint64_t) value |
173 | 200 |
|
174 | 201 | #define FLB_LOG_EVENT_DOUBLE_VALUE(value) \ |
175 | 202 | (int) FLB_LOG_EVENT_DOUBLE_VALUE_TYPE, \ |
|
186 | 213 | #define FLB_LOG_EVENT_MSGPACK_RAW_VALUE(buffer, length) \ |
187 | 214 | (int) FLB_LOG_EVENT_MSGPACK_RAW_VALUE_TYPE, \ |
188 | 215 | (char *) buffer, \ |
189 | | - (size_t *) length |
| 216 | + (flb_log_event_encoder_size_t) length |
190 | 217 |
|
191 | 218 | #define FLB_LOG_EVENT_STRING_VALUE(buffer, length) \ |
192 | 219 | FLB_LOG_EVENT_STRING_LENGTH_VALUE(length), \ |
|
0 commit comments