@@ -216,7 +216,6 @@ typedef signed long int zig_c_long;
216216typedef unsigned long int zig_c_ulong ;
217217typedef signed long long int zig_c_longlong ;
218218typedef unsigned long long int zig_c_ulonglong ;
219- typedef long double zig_c_longdouble ;
220219
221220typedef uint8_t zig_u8 ;
222221typedef int8_t zig_i8 ;
@@ -255,120 +254,111 @@ typedef int64_t zig_i64;
255254#define zig_minInt_i64 INT64_MIN
256255#define zig_maxInt_i64 INT64_MAX
257256
257+ #define zig_builtin_f16 (name ) __##name##h
258+ #define zig_builtin_constant_f16 (name ) zig_suffix_f16(__builtin_##name)
258259#if FLT_MANT_DIG == 11
259260typedef float zig_f16 ;
260261#define zig_suffix_f16 (x ) x##f
261- #define zig_builtin_f16 (name ) __builtin_##name##f
262262#elif DBL_MANT_DIG == 11
263263typedef double zig_f16 ;
264264#define zig_suffix_f16 (x ) x
265- #define zig_builtin_f16 (name ) __builtin_##name
266265#elif LDBL_MANT_DIG == 11
267266typedef long double zig_f16 ;
268267#define zig_suffix_f16 (x ) x##l
269- #define zig_builtin_f16 (name ) __builtin_##name##l
270268#elif FLT16_MANT_DIG == 11
271269typedef _Float16 zig_f16 ;
272270#define zig_suffix_f16 (x ) x##f16
273- #define zig_builtin_f16 (name ) __builtin_##name
274271#elif defined(__SIZEOF_FP16__ )
275272typedef __fp16 zig_f16 ;
276- #define zig_suffix_f16 (x ) x
277- #define zig_builtin_f16 (name ) __builtin_##name
273+ #define zig_suffix_f16 (x ) x##f16
278274#endif
279275
276+ #define zig_builtin_f32 (name ) name##f
277+ #define zig_builtin_constant_f32 (name ) zig_suffix_f32(__builtin_##name)
280278#if FLT_MANT_DIG == 24
281279typedef float zig_f32 ;
282280#define zig_suffix_f32 (x ) x##f
283- #define zig_builtin_f32 (name ) __builtin_##name##f
284281#elif DBL_MANT_DIG == 24
285282typedef double zig_f32 ;
286283#define zig_suffix_f32 (x ) x
287- #define zig_builtin_f32 (name ) __builtin_##name
288284#elif LDBL_MANT_DIG == 24
289285typedef long double zig_f32 ;
290286#define zig_suffix_f32 (x ) x##l
291- #define zig_builtin_f32 (name ) __builtin_##name##l
292287#elif FLT32_MANT_DIG == 24
293288typedef _Float32 zig_f32 ;
294289#define zig_suffix_f32 (x ) x##f32
295- #define zig_builtin_f32 (name ) __builtin_##name
296290#endif
297291
292+ #define zig_builtin_f64 (name ) name
293+ #define zig_builtin_constant_f64 (name ) zig_suffix_f64(__builtin_##name)
298294#if FLT_MANT_DIG == 53
299295typedef float zig_f64 ;
300296#define zig_suffix_f64 (x ) x##f
301- #define zig_builtin_f64 (name ) __builtin_##name##f
302297#elif DBL_MANT_DIG == 53
303298typedef double zig_f64 ;
304299#define zig_suffix_f64 (x ) x
305- #define zig_builtin_f64 (name ) __builtin_##name
306300#elif LDBL_MANT_DIG == 53
307301typedef long double zig_f64 ;
308302#define zig_suffix_f64 (x ) x##l
309- #define zig_builtin_f64 (name ) __builtin_##name##l
310303#elif FLT64_MANT_DIG == 53
311304typedef _Float64 zig_f64 ;
312305#define zig_suffix_f64 (x ) x##f64
313- #define zig_builtin_f64 (name ) __builtin_##name##l
314306#elif FLT32X_MANT_DIG == 53
315307typedef _Float32x zig_f64 ;
316308#define zig_suffix_f64 (x ) x##f32x
317- #define zig_builtin_f64 (name ) __builtin_##name##l
318309#endif
319310
311+ #define zig_builtin_f80 (name ) __##name##x
312+ #define zig_builtin_constant_f80 (name ) zig_suffix_f80(__builtin_##name)
320313#if FLT_MANT_DIG == 64
321314typedef float zig_f80 ;
322315#define zig_suffix_f80 (x ) x##f
323- #define zig_builtin_f80 (name ) __builtin_##name##f
324316#elif DBL_MANT_DIG == 64
325317typedef double zig_f80 ;
326318#define zig_suffix_f80 (x ) x
327- #define zig_builtin_f80 (name ) __builtin_##name
328319#elif LDBL_MANT_DIG == 64
329320typedef long double zig_f80 ;
330321#define zig_suffix_f80 (x ) x##l
331- #define zig_builtin_f80 (name ) __builtin_##name##l
332322#elif FLT80_MANT_DIG == 64
333323typedef _Float80 zig_f80 ;
334324#define zig_suffix_f80 (x ) x##f80
335- #define zig_builtin_f80 (name ) __builtin_##name##l
336325#elif FLT64X_MANT_DIG == 64
337326typedef _Float64x zig_f80 ;
338327#define zig_suffix_f80 (x ) x##f64x
339- #define zig_builtin_f80 (name ) __builtin_##name##l
340328#elif defined(__SIZEOF_FLOAT80__ )
341329typedef __float80 zig_f80 ;
342330#define zig_suffix_f80 (x ) x##l
343- #define zig_builtin_f80 (name ) __builtin_##name##l
344331#endif
345332
333+ #define zig_builtin_f128 (name ) name##q
334+ #define zig_builtin_constant_f128 (name ) zig_suffix_f80(__builtin_##name)
346335#if FLT_MANT_DIG == 113
347336typedef float zig_f128 ;
348337#define zig_suffix_f128 (x ) x##f
349- #define zig_builtin_f128 (name ) __builtin_##name##f
350338#elif DBL_MANT_DIG == 113
351339typedef double zig_f128 ;
352340#define zig_suffix_f128 (x ) x
353- #define zig_builtin_f128 (name ) __builtin_##name
354341#elif LDBL_MANT_DIG == 113
355342typedef long double zig_f128 ;
356343#define zig_suffix_f128 (x ) x##l
357- #define zig_builtin_f128 (name ) __builtin_##name##l
358344#elif FLT128_MANT_DIG == 113
359345typedef _Float128 zig_f128 ;
360346#define zig_suffix_f128 (x ) x##f128
361- #define zig_builtin_f128 (name ) __builtin_##name##l
362347#elif FLT64X_MANT_DIG == 113
363348typedef _Float64x zig_f128 ;
364349#define zig_suffix_f128 (x ) x##f64x
365- #define zig_builtin_f128 (name ) __builtin_##name##l
366350#elif defined(__SIZEOF_FLOAT128__ )
367351typedef __float128 zig_f128 ;
368- #define zig_suffix_f128 (x ) x##l
369- #define zig_builtin_f128 (name ) __builtin_##name##l
352+ #define zig_suffix_f128 (x ) x##q
353+ #undef zig_builtin_constant_f128
354+ #define zig_builtin_constant_f128 (name ) __builtin_##name##f128
370355#endif
371356
357+ typedef long double zig_c_longdouble ;
358+ #define zig_suffix_c_longdouble (x ) x##l
359+ #define zig_builtin_c_longdouble (name ) zig_suffix_c_longdouble(name)
360+ #define zig_builtin_constant_c_longdouble (name ) zig_suffix_c_longdouble(__builtin_##name)
361+
372362zig_extern_c void * memcpy (void * zig_restrict , void const * zig_restrict , zig_usize );
373363zig_extern_c void * memset (void * , int , zig_usize );
374364
@@ -1476,20 +1466,38 @@ static inline zig_i128 zig_bit_reverse_i128(zig_i128 val, zig_u8 bits) {
14761466
14771467/* ========================== Float Point Routines ========================== */
14781468
1479- #define zig_float_builtins (w ) \
1480- static inline zig_f##w zig_div_trunc_f##w(zig_f##w lhs, zig_f##w rhs) { \
1481- return zig_builtin_f##w(trunc)(lhs / rhs); \
1469+ #define zig_float_builtins (Type ) \
1470+ zig_extern_c zig_##Type zig_builtin_##Type(sqrt)(zig_##Type); \
1471+ zig_extern_c zig_##Type zig_builtin_##Type(sin)(zig_##Type); \
1472+ zig_extern_c zig_##Type zig_builtin_##Type(cos)(zig_##Type); \
1473+ zig_extern_c zig_##Type zig_builtin_##Type(tan)(zig_##Type); \
1474+ zig_extern_c zig_##Type zig_builtin_##Type(exp)(zig_##Type); \
1475+ zig_extern_c zig_##Type zig_builtin_##Type(exp2)(zig_##Type); \
1476+ zig_extern_c zig_##Type zig_builtin_##Type(log)(zig_##Type); \
1477+ zig_extern_c zig_##Type zig_builtin_##Type(log2)(zig_##Type); \
1478+ zig_extern_c zig_##Type zig_builtin_##Type(log10)(zig_##Type); \
1479+ zig_extern_c zig_##Type zig_builtin_##Type(fabs)(zig_##Type); \
1480+ zig_extern_c zig_##Type zig_builtin_##Type(floor)(zig_##Type); \
1481+ zig_extern_c zig_##Type zig_builtin_##Type(ceil)(zig_##Type); \
1482+ zig_extern_c zig_##Type zig_builtin_##Type(round)(zig_##Type); \
1483+ zig_extern_c zig_##Type zig_builtin_##Type(trunc)(zig_##Type); \
1484+ zig_extern_c zig_##Type zig_builtin_##Type(fmod)(zig_##Type, zig_##Type); \
1485+ zig_extern_c zig_##Type zig_builtin_##Type(fma)(zig_##Type, zig_##Type, zig_##Type); \
1486+ \
1487+ static inline zig_##Type zig_div_trunc_##Type(zig_##Type lhs, zig_##Type rhs) { \
1488+ return zig_builtin_##Type(trunc)(lhs / rhs); \
14821489 } \
14831490\
1484- static inline zig_f##w zig_div_floor_f##w(zig_f##w lhs, zig_f##w rhs) { \
1485- return zig_builtin_f##w (floor)(lhs / rhs); \
1491+ static inline zig_##Type zig_div_floor_##Type(zig_##Type lhs, zig_##Type rhs) { \
1492+ return zig_builtin_##Type (floor)(lhs / rhs); \
14861493 } \
14871494\
1488- static inline zig_f##w zig_mod_f##w(zig_f##w lhs, zig_f##w rhs) { \
1489- return lhs - zig_div_floor_f##w (lhs, rhs) * rhs; \
1495+ static inline zig_##Type zig_mod_##Type(zig_##Type lhs, zig_##Type rhs) { \
1496+ return lhs - zig_div_floor_##Type (lhs, rhs) * rhs; \
14901497 }
1491- zig_float_builtins (16 )
1492- zig_float_builtins (32 )
1493- zig_float_builtins (64 )
1494- zig_float_builtins (80 )
1495- zig_float_builtins (128 )
1498+ zig_float_builtins (f16 )
1499+ zig_float_builtins (f32 )
1500+ zig_float_builtins (f64 )
1501+ zig_float_builtins (f80 )
1502+ zig_float_builtins (f128 )
1503+ zig_float_builtins (c_longdouble )
0 commit comments