authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-11-02 21:15:24-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-11-02 21:42:40-04:00
logfa46f9a3d75e6f3693827bf524244ed3c4902133
tree23f6d74e81eb31437987b7331ac96ff455d8fd02
parentb40fc70188fd097e9e05b5c18b635b67b718380e

cbe: fix extern


4 files changed, 54 insertions(+), 55 deletions(-)

lib/include/zig.h+34-34
...@@ -66,9 +66,9 @@...@@ -66,9 +66,9 @@
66#endif66#endif
6767
68#if defined(__cplusplus)68#if defined(__cplusplus)
69#define zig_extern_c extern "C"69#define zig_extern extern "C"
70#else70#else
71#define zig_extern_c71#define zig_extern extern
72#endif72#endif
7373
74#if zig_has_builtin(debugtrap)74#if zig_has_builtin(debugtrap)
...@@ -265,8 +265,8 @@ typedef int64_t zig_i64;...@@ -265,8 +265,8 @@ typedef int64_t zig_i64;
265#define zig_compiler_rt_abbrev_f80 xf265#define zig_compiler_rt_abbrev_f80 xf
266#define zig_compiler_rt_abbrev_f128 tf266#define zig_compiler_rt_abbrev_f128 tf
267267
268zig_extern_c void *memcpy (void *zig_restrict, void const *zig_restrict, zig_usize);268zig_extern void *memcpy (void *zig_restrict, void const *zig_restrict, zig_usize);
269zig_extern_c void *memset (void *, int, zig_usize);269zig_extern void *memset (void *, int, zig_usize);
270270
271/* ==================== 8/16/32/64-bit Integer Routines ===================== */271/* ==================== 8/16/32/64-bit Integer Routines ===================== */
272272
...@@ -345,7 +345,7 @@ static inline zig_bool zig_addo_u32(zig_u32 *res, zig_u32 lhs, zig_u32 rhs, zig_...@@ -345,7 +345,7 @@ static inline zig_bool zig_addo_u32(zig_u32 *res, zig_u32 lhs, zig_u32 rhs, zig_
345#endif345#endif
346}346}
347347
348zig_extern_c zig_i32 __addosi4(zig_i32 lhs, zig_i32 rhs, zig_c_int *overflow);348zig_extern zig_i32 __addosi4(zig_i32 lhs, zig_i32 rhs, zig_c_int *overflow);
349static inline zig_bool zig_addo_i32(zig_i32 *res, zig_i32 lhs, zig_i32 rhs, zig_u8 bits) {349static inline zig_bool zig_addo_i32(zig_i32 *res, zig_i32 lhs, zig_i32 rhs, zig_u8 bits) {
350#if zig_has_builtin(add_overflow)350#if zig_has_builtin(add_overflow)
351 zig_i32 full_res;351 zig_i32 full_res;
...@@ -371,7 +371,7 @@ static inline zig_bool zig_addo_u64(zig_u64 *res, zig_u64 lhs, zig_u64 rhs, zig_...@@ -371,7 +371,7 @@ static inline zig_bool zig_addo_u64(zig_u64 *res, zig_u64 lhs, zig_u64 rhs, zig_
371#endif371#endif
372}372}
373373
374zig_extern_c zig_i64 __addodi4(zig_i64 lhs, zig_i64 rhs, zig_c_int *overflow);374zig_extern zig_i64 __addodi4(zig_i64 lhs, zig_i64 rhs, zig_c_int *overflow);
375static inline zig_bool zig_addo_i64(zig_i64 *res, zig_i64 lhs, zig_i64 rhs, zig_u8 bits) {375static inline zig_bool zig_addo_i64(zig_i64 *res, zig_i64 lhs, zig_i64 rhs, zig_u8 bits) {
376#if zig_has_builtin(add_overflow)376#if zig_has_builtin(add_overflow)
377 zig_i64 full_res;377 zig_i64 full_res;
...@@ -441,7 +441,7 @@ static inline zig_bool zig_subo_u32(zig_u32 *res, zig_u32 lhs, zig_u32 rhs, zig_...@@ -441,7 +441,7 @@ static inline zig_bool zig_subo_u32(zig_u32 *res, zig_u32 lhs, zig_u32 rhs, zig_
441#endif441#endif
442}442}
443443
444zig_extern_c zig_i32 __subosi4(zig_i32 lhs, zig_i32 rhs, zig_c_int *overflow);444zig_extern zig_i32 __subosi4(zig_i32 lhs, zig_i32 rhs, zig_c_int *overflow);
445static inline zig_bool zig_subo_i32(zig_i32 *res, zig_i32 lhs, zig_i32 rhs, zig_u8 bits) {445static inline zig_bool zig_subo_i32(zig_i32 *res, zig_i32 lhs, zig_i32 rhs, zig_u8 bits) {
446#if zig_has_builtin(sub_overflow)446#if zig_has_builtin(sub_overflow)
447 zig_i32 full_res;447 zig_i32 full_res;
...@@ -467,7 +467,7 @@ static inline zig_bool zig_subo_u64(zig_u64 *res, zig_u64 lhs, zig_u64 rhs, zig_...@@ -467,7 +467,7 @@ static inline zig_bool zig_subo_u64(zig_u64 *res, zig_u64 lhs, zig_u64 rhs, zig_
467#endif467#endif
468}468}
469469
470zig_extern_c zig_i64 __subodi4(zig_i64 lhs, zig_i64 rhs, zig_c_int *overflow);470zig_extern zig_i64 __subodi4(zig_i64 lhs, zig_i64 rhs, zig_c_int *overflow);
471static inline zig_bool zig_subo_i64(zig_i64 *res, zig_i64 lhs, zig_i64 rhs, zig_u8 bits) {471static inline zig_bool zig_subo_i64(zig_i64 *res, zig_i64 lhs, zig_i64 rhs, zig_u8 bits) {
472#if zig_has_builtin(sub_overflow)472#if zig_has_builtin(sub_overflow)
473 zig_i64 full_res;473 zig_i64 full_res;
...@@ -537,7 +537,7 @@ static inline zig_bool zig_mulo_u32(zig_u32 *res, zig_u32 lhs, zig_u32 rhs, zig_...@@ -537,7 +537,7 @@ static inline zig_bool zig_mulo_u32(zig_u32 *res, zig_u32 lhs, zig_u32 rhs, zig_
537#endif537#endif
538}538}
539539
540zig_extern_c zig_i32 __mulosi4(zig_i32 lhs, zig_i32 rhs, zig_c_int *overflow);540zig_extern zig_i32 __mulosi4(zig_i32 lhs, zig_i32 rhs, zig_c_int *overflow);
541static inline zig_bool zig_mulo_i32(zig_i32 *res, zig_i32 lhs, zig_i32 rhs, zig_u8 bits) {541static inline zig_bool zig_mulo_i32(zig_i32 *res, zig_i32 lhs, zig_i32 rhs, zig_u8 bits) {
542#if zig_has_builtin(mul_overflow)542#if zig_has_builtin(mul_overflow)
543 zig_i32 full_res;543 zig_i32 full_res;
...@@ -563,7 +563,7 @@ static inline zig_bool zig_mulo_u64(zig_u64 *res, zig_u64 lhs, zig_u64 rhs, zig_...@@ -563,7 +563,7 @@ static inline zig_bool zig_mulo_u64(zig_u64 *res, zig_u64 lhs, zig_u64 rhs, zig_
563#endif563#endif
564}564}
565565
566zig_extern_c zig_i64 __mulodi4(zig_i64 lhs, zig_i64 rhs, zig_c_int *overflow);566zig_extern zig_i64 __mulodi4(zig_i64 lhs, zig_i64 rhs, zig_c_int *overflow);
567static inline zig_bool zig_mulo_i64(zig_i64 *res, zig_i64 lhs, zig_i64 rhs, zig_u8 bits) {567static inline zig_bool zig_mulo_i64(zig_i64 *res, zig_i64 lhs, zig_i64 rhs, zig_u8 bits) {
568#if zig_has_builtin(mul_overflow)568#if zig_has_builtin(mul_overflow)
569 zig_i64 full_res;569 zig_i64 full_res;
...@@ -1210,7 +1210,7 @@ static inline zig_bool zig_addo_u128(zig_u128 *res, zig_u128 lhs, zig_u128 rhs,...@@ -1210,7 +1210,7 @@ static inline zig_bool zig_addo_u128(zig_u128 *res, zig_u128 lhs, zig_u128 rhs,
1210#endif1210#endif
1211}1211}
12121212
1213zig_extern_c zig_i128 __addoti4(zig_i128 lhs, zig_i128 rhs, zig_c_int *overflow);1213zig_extern zig_i128 __addoti4(zig_i128 lhs, zig_i128 rhs, zig_c_int *overflow);
1214static inline zig_bool zig_addo_i128(zig_i128 *res, zig_i128 lhs, zig_i128 rhs, zig_u8 bits) {1214static inline zig_bool zig_addo_i128(zig_i128 *res, zig_i128 lhs, zig_i128 rhs, zig_u8 bits) {
1215#if zig_has_builtin(add_overflow)1215#if zig_has_builtin(add_overflow)
1216 zig_i128 full_res;1216 zig_i128 full_res;
...@@ -1236,7 +1236,7 @@ static inline zig_bool zig_subo_u128(zig_u128 *res, zig_u128 lhs, zig_u128 rhs,...@@ -1236,7 +1236,7 @@ static inline zig_bool zig_subo_u128(zig_u128 *res, zig_u128 lhs, zig_u128 rhs,
1236#endif1236#endif
1237}1237}
12381238
1239zig_extern_c zig_i128 __suboti4(zig_i128 lhs, zig_i128 rhs, zig_c_int *overflow);1239zig_extern zig_i128 __suboti4(zig_i128 lhs, zig_i128 rhs, zig_c_int *overflow);
1240static inline zig_bool zig_subo_i128(zig_i128 *res, zig_i128 lhs, zig_i128 rhs, zig_u8 bits) {1240static inline zig_bool zig_subo_i128(zig_i128 *res, zig_i128 lhs, zig_i128 rhs, zig_u8 bits) {
1241#if zig_has_builtin(sub_overflow)1241#if zig_has_builtin(sub_overflow)
1242 zig_i128 full_res;1242 zig_i128 full_res;
...@@ -1262,7 +1262,7 @@ static inline zig_bool zig_mulo_u128(zig_u128 *res, zig_u128 lhs, zig_u128 rhs,...@@ -1262,7 +1262,7 @@ static inline zig_bool zig_mulo_u128(zig_u128 *res, zig_u128 lhs, zig_u128 rhs,
1262#endif1262#endif
1263}1263}
12641264
1265zig_extern_c zig_i128 __muloti4(zig_i128 lhs, zig_i128 rhs, zig_c_int *overflow);1265zig_extern zig_i128 __muloti4(zig_i128 lhs, zig_i128 rhs, zig_c_int *overflow);
1266static inline zig_bool zig_mulo_i128(zig_i128 *res, zig_i128 lhs, zig_i128 rhs, zig_u8 bits) {1266static inline zig_bool zig_mulo_i128(zig_i128 *res, zig_i128 lhs, zig_i128 rhs, zig_u8 bits) {
1267#if zig_has_builtin(mul_overflow)1267#if zig_has_builtin(mul_overflow)
1268 zig_i128 full_res;1268 zig_i128 full_res;
...@@ -1552,7 +1552,7 @@ typedef long double zig_c_longdouble;...@@ -1552,7 +1552,7 @@ typedef long double zig_c_longdouble;
1552#define zig_as_special_c_longdouble(sign, name, arg, repr) sign __builtin_##name##l(arg)1552#define zig_as_special_c_longdouble(sign, name, arg, repr) sign __builtin_##name##l(arg)
15531553
1554#define zig_convert_builtin(ResType, operation, ArgType, version) \1554#define zig_convert_builtin(ResType, operation, ArgType, version) \
1555 zig_extern_c zig_##ResType zig_expand_concat(zig_expand_concat(zig_expand_concat(__##operation, \1555 zig_extern zig_##ResType zig_expand_concat(zig_expand_concat(zig_expand_concat(__##operation, \
1556 zig_compiler_rt_abbrev_##ArgType), zig_compiler_rt_abbrev_##ResType), version)(zig_##ArgType);1556 zig_compiler_rt_abbrev_##ArgType), zig_compiler_rt_abbrev_##ResType), version)(zig_##ArgType);
1557zig_convert_builtin(f16, trunc, f32, 2)1557zig_convert_builtin(f16, trunc, f32, 2)
1558zig_convert_builtin(f16, trunc, f64, 2)1558zig_convert_builtin(f16, trunc, f64, 2)
...@@ -1585,7 +1585,7 @@ zig_convert_builtin(f128, extend, f80, 2)...@@ -1585,7 +1585,7 @@ zig_convert_builtin(f128, extend, f80, 2)
1585 }1585 }
15861586
1587#define zig_float_less_builtin_0(Type, operation) \1587#define zig_float_less_builtin_0(Type, operation) \
1588 zig_extern_c zig_i8 zig_expand_concat(zig_expand_concat(__##operation, \1588 zig_extern zig_i8 zig_expand_concat(zig_expand_concat(__##operation, \
1589 zig_compiler_rt_abbrev_##Type), 2)(zig_##Type, zig_##Type); \1589 zig_compiler_rt_abbrev_##Type), 2)(zig_##Type, zig_##Type); \
1590 static inline zig_i8 zig_##operation##_##Type(zig_##Type lhs, zig_##Type rhs) { \1590 static inline zig_i8 zig_##operation##_##Type(zig_##Type lhs, zig_##Type rhs) { \
1591 return (zig_i8)zig_expand_concat(zig_expand_concat(__##operation, zig_compiler_rt_abbrev_##Type), 2)(lhs, rhs); \1591 return (zig_i8)zig_expand_concat(zig_expand_concat(__##operation, zig_compiler_rt_abbrev_##Type), 2)(lhs, rhs); \
...@@ -1603,7 +1603,7 @@ zig_convert_builtin(f128, extend, f80, 2)...@@ -1603,7 +1603,7 @@ zig_convert_builtin(f128, extend, f80, 2)
1603 }1603 }
16041604
1605#define zig_float_binary_builtin_0(Type, operation, operator) \1605#define zig_float_binary_builtin_0(Type, operation, operator) \
1606 zig_extern_c zig_##Type zig_expand_concat(zig_expand_concat(__##operation, \1606 zig_extern zig_##Type zig_expand_concat(zig_expand_concat(__##operation, \
1607 zig_compiler_rt_abbrev_##Type), 3)(zig_##Type, zig_##Type); \1607 zig_compiler_rt_abbrev_##Type), 3)(zig_##Type, zig_##Type); \
1608 static inline zig_##Type zig_##operation##_##Type(zig_##Type lhs, zig_##Type rhs) { \1608 static inline zig_##Type zig_##operation##_##Type(zig_##Type lhs, zig_##Type rhs) { \
1609 return zig_expand_concat(zig_expand_concat(__##operation, zig_compiler_rt_abbrev_##Type), 3)(lhs, rhs); \1609 return zig_expand_concat(zig_expand_concat(__##operation, zig_compiler_rt_abbrev_##Type), 3)(lhs, rhs); \
...@@ -1638,24 +1638,24 @@ zig_convert_builtin(f128, extend, f80, 2)...@@ -1638,24 +1638,24 @@ zig_convert_builtin(f128, extend, f80, 2)
1638 zig_expand_concat(zig_float_binary_builtin_, zig_has_##Type)(Type, sub, -) \1638 zig_expand_concat(zig_float_binary_builtin_, zig_has_##Type)(Type, sub, -) \
1639 zig_expand_concat(zig_float_binary_builtin_, zig_has_##Type)(Type, mul, *) \1639 zig_expand_concat(zig_float_binary_builtin_, zig_has_##Type)(Type, mul, *) \
1640 zig_expand_concat(zig_float_binary_builtin_, zig_has_##Type)(Type, div, /) \1640 zig_expand_concat(zig_float_binary_builtin_, zig_has_##Type)(Type, div, /) \
1641 zig_extern_c zig_##Type zig_libc_name_##Type(sqrt)(zig_##Type); \1641 zig_extern zig_##Type zig_libc_name_##Type(sqrt)(zig_##Type); \
1642 zig_extern_c zig_##Type zig_libc_name_##Type(sin)(zig_##Type); \1642 zig_extern zig_##Type zig_libc_name_##Type(sin)(zig_##Type); \
1643 zig_extern_c zig_##Type zig_libc_name_##Type(cos)(zig_##Type); \1643 zig_extern zig_##Type zig_libc_name_##Type(cos)(zig_##Type); \
1644 zig_extern_c zig_##Type zig_libc_name_##Type(tan)(zig_##Type); \1644 zig_extern zig_##Type zig_libc_name_##Type(tan)(zig_##Type); \
1645 zig_extern_c zig_##Type zig_libc_name_##Type(exp)(zig_##Type); \1645 zig_extern zig_##Type zig_libc_name_##Type(exp)(zig_##Type); \
1646 zig_extern_c zig_##Type zig_libc_name_##Type(exp2)(zig_##Type); \1646 zig_extern zig_##Type zig_libc_name_##Type(exp2)(zig_##Type); \
1647 zig_extern_c zig_##Type zig_libc_name_##Type(log)(zig_##Type); \1647 zig_extern zig_##Type zig_libc_name_##Type(log)(zig_##Type); \
1648 zig_extern_c zig_##Type zig_libc_name_##Type(log2)(zig_##Type); \1648 zig_extern zig_##Type zig_libc_name_##Type(log2)(zig_##Type); \
1649 zig_extern_c zig_##Type zig_libc_name_##Type(log10)(zig_##Type); \1649 zig_extern zig_##Type zig_libc_name_##Type(log10)(zig_##Type); \
1650 zig_extern_c zig_##Type zig_libc_name_##Type(fabs)(zig_##Type); \1650 zig_extern zig_##Type zig_libc_name_##Type(fabs)(zig_##Type); \
1651 zig_extern_c zig_##Type zig_libc_name_##Type(floor)(zig_##Type); \1651 zig_extern zig_##Type zig_libc_name_##Type(floor)(zig_##Type); \
1652 zig_extern_c zig_##Type zig_libc_name_##Type(ceil)(zig_##Type); \1652 zig_extern zig_##Type zig_libc_name_##Type(ceil)(zig_##Type); \
1653 zig_extern_c zig_##Type zig_libc_name_##Type(round)(zig_##Type); \1653 zig_extern zig_##Type zig_libc_name_##Type(round)(zig_##Type); \
1654 zig_extern_c zig_##Type zig_libc_name_##Type(trunc)(zig_##Type); \1654 zig_extern zig_##Type zig_libc_name_##Type(trunc)(zig_##Type); \
1655 zig_extern_c zig_##Type zig_libc_name_##Type(fmod)(zig_##Type, zig_##Type); \1655 zig_extern zig_##Type zig_libc_name_##Type(fmod)(zig_##Type, zig_##Type); \
1656 zig_extern_c zig_##Type zig_libc_name_##Type(fmin)(zig_##Type, zig_##Type); \1656 zig_extern zig_##Type zig_libc_name_##Type(fmin)(zig_##Type, zig_##Type); \
1657 zig_extern_c zig_##Type zig_libc_name_##Type(fmax)(zig_##Type, zig_##Type); \1657 zig_extern zig_##Type zig_libc_name_##Type(fmax)(zig_##Type, zig_##Type); \
1658 zig_extern_c zig_##Type zig_libc_name_##Type(fma)(zig_##Type, zig_##Type, zig_##Type); \1658 zig_extern zig_##Type zig_libc_name_##Type(fma)(zig_##Type, zig_##Type, zig_##Type); \
1659\1659\
1660 static inline zig_##Type zig_div_trunc_##Type(zig_##Type lhs, zig_##Type rhs) { \1660 static inline zig_##Type zig_div_trunc_##Type(zig_##Type lhs, zig_##Type rhs) { \
1661 return zig_libc_name_##Type(trunc)(zig_div_##Type(lhs, rhs)); \1661 return zig_libc_name_##Type(trunc)(zig_div_##Type(lhs, rhs)); \
src/codegen/c.zig+8-10
...@@ -2215,7 +2215,7 @@ pub fn genFunc(f: *Function) !void {...@@ -2215,7 +2215,7 @@ pub fn genFunc(f: *Function) !void {
22152215
2216 const is_global = o.dg.module.decl_exports.contains(f.func.owner_decl);2216 const is_global = o.dg.module.decl_exports.contains(f.func.owner_decl);
2217 const fwd_decl_writer = o.dg.fwd_decl.writer();2217 const fwd_decl_writer = o.dg.fwd_decl.writer();
2218 try fwd_decl_writer.writeAll(if (is_global) "zig_extern_c " else "static ");2218 try fwd_decl_writer.writeAll(if (is_global) "zig_extern " else "static ");
2219 try o.dg.renderFunctionSignature(fwd_decl_writer, .Forward);2219 try o.dg.renderFunctionSignature(fwd_decl_writer, .Forward);
2220 try fwd_decl_writer.writeAll(";\n");2220 try fwd_decl_writer.writeAll(";\n");
22212221
...@@ -2252,9 +2252,10 @@ pub fn genDecl(o: *Object) !void {...@@ -2252,9 +2252,10 @@ pub fn genDecl(o: *Object) !void {
2252 .ty = o.dg.decl.ty,2252 .ty = o.dg.decl.ty,
2253 .val = o.dg.decl.val,2253 .val = o.dg.decl.val,
2254 };2254 };
2255 if (!tv.ty.isFnOrHasRuntimeBitsIgnoreComptime()) return;
2255 if (tv.val.tag() == .extern_fn) {2256 if (tv.val.tag() == .extern_fn) {
2256 const fwd_decl_writer = o.dg.fwd_decl.writer();2257 const fwd_decl_writer = o.dg.fwd_decl.writer();
2257 try fwd_decl_writer.writeAll("zig_extern_c ");2258 try fwd_decl_writer.writeAll("zig_extern ");
2258 try o.dg.renderFunctionSignature(fwd_decl_writer, .Forward);2259 try o.dg.renderFunctionSignature(fwd_decl_writer, .Forward);
2259 try fwd_decl_writer.writeAll(";\n");2260 try fwd_decl_writer.writeAll(";\n");
2260 } else if (tv.val.castTag(.variable)) |var_payload| {2261 } else if (tv.val.castTag(.variable)) |var_payload| {
...@@ -2268,22 +2269,19 @@ pub fn genDecl(o: *Object) !void {...@@ -2268,22 +2269,19 @@ pub fn genDecl(o: *Object) !void {
2268 .decl = o.dg.decl_index,2269 .decl = o.dg.decl_index,
2269 };2270 };
22702271
2271 if (is_global) try fwd_decl_writer.writeAll("zig_extern_c ");2272 try fwd_decl_writer.writeAll(if (is_global) "zig_extern " else "static ");
2272 if (variable.is_threadlocal) try fwd_decl_writer.writeAll("zig_threadlocal ");2273 if (variable.is_threadlocal) try fwd_decl_writer.writeAll("zig_threadlocal ");
2273 try o.dg.renderTypeAndName(fwd_decl_writer, o.dg.decl.ty, decl_c_value, .Mut, o.dg.decl.@"align", .Complete);2274 try o.dg.renderTypeAndName(fwd_decl_writer, o.dg.decl.ty, decl_c_value, .Mut, o.dg.decl.@"align", .Complete);
2274 try fwd_decl_writer.writeAll(";\n");2275 try fwd_decl_writer.writeAll(";\n");
22752276
2276 if (variable.is_extern or variable.init.isUndefDeep()) {2277 if (variable.is_extern) return;
2277 return;
2278 }
22792278
2280 const w = o.writer();2279 const w = o.writer();
2280 if (!is_global) try w.writeAll("static ");
2281 if (variable.is_threadlocal) try w.writeAll("zig_threadlocal ");2281 if (variable.is_threadlocal) try w.writeAll("zig_threadlocal ");
2282 try o.dg.renderTypeAndName(w, o.dg.decl.ty, decl_c_value, .Mut, o.dg.decl.@"align", .Complete);2282 try o.dg.renderTypeAndName(w, o.dg.decl.ty, decl_c_value, .Mut, o.dg.decl.@"align", .Complete);
2283 try w.writeAll(" = ");2283 try w.writeAll(" = ");
2284 if (variable.init.tag() != .unreachable_value) {2284 try o.dg.renderValue(w, tv.ty, variable.init, .Initializer);
2285 try o.dg.renderValue(w, tv.ty, variable.init, .Initializer);
2286 }
2287 try w.writeByte(';');2285 try w.writeByte(';');
2288 try o.indent_writer.insertNewline();2286 try o.indent_writer.insertNewline();
2289 } else {2287 } else {
...@@ -2319,7 +2317,7 @@ pub fn genHeader(dg: *DeclGen) error{ AnalysisFail, OutOfMemory }!void {...@@ -2319,7 +2317,7 @@ pub fn genHeader(dg: *DeclGen) error{ AnalysisFail, OutOfMemory }!void {
2319 .Fn => {2317 .Fn => {
2320 const is_global = dg.declIsGlobal(tv);2318 const is_global = dg.declIsGlobal(tv);
2321 if (is_global) {2319 if (is_global) {
2322 try writer.writeAll("zig_extern_c ");2320 try writer.writeAll("zig_extern ");
2323 try dg.renderFunctionSignature(writer, .Complete);2321 try dg.renderFunctionSignature(writer, .Complete);
2324 try dg.fwd_decl.appendSlice(";\n");2322 try dg.fwd_decl.appendSlice(";\n");
2325 }2323 }
test/behavior/union.zig+1
...@@ -435,6 +435,7 @@ test "global union with single field is correctly initialized" {...@@ -435,6 +435,7 @@ test "global union with single field is correctly initialized" {
435 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;435 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
436 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;436 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
437 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO437 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
438 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
438439
439 glbl = Foo1{440 glbl = Foo1{
440 .f = @typeInfo(Foo1).Union.fields[0].field_type{ .x = 123 },441 .f = @typeInfo(Foo1).Union.fields[0].field_type{ .x = 123 },
test/stage2/cbe.zig+11-11
...@@ -951,7 +951,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -951,7 +951,7 @@ pub fn addCases(ctx: *TestContext) !void {
951 ctx.h("simple header", linux_x64,951 ctx.h("simple header", linux_x64,
952 \\export fn start() void{}952 \\export fn start() void{}
953 ,953 ,
954 \\zig_extern_c zig_void start(zig_void);954 \\zig_extern zig_void start(zig_void);
955 \\955 \\
956 );956 );
957 ctx.h("header with single param function", linux_x64,957 ctx.h("header with single param function", linux_x64,
...@@ -959,7 +959,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -959,7 +959,7 @@ pub fn addCases(ctx: *TestContext) !void {
959 \\ _ = a;959 \\ _ = a;
960 \\}960 \\}
961 ,961 ,
962 \\zig_extern_c zig_void start(zig_u8 const a0);962 \\zig_extern zig_void start(zig_u8 const a0);
963 \\963 \\
964 );964 );
965 ctx.h("header with multiple param function", linux_x64,965 ctx.h("header with multiple param function", linux_x64,
...@@ -967,25 +967,25 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -967,25 +967,25 @@ pub fn addCases(ctx: *TestContext) !void {
967 \\ _ = a; _ = b; _ = c;967 \\ _ = a; _ = b; _ = c;
968 \\}968 \\}
969 ,969 ,
970 \\zig_extern_c zig_void start(zig_u8 const a0, zig_u8 const a1, zig_u8 const a2);970 \\zig_extern zig_void start(zig_u8 const a0, zig_u8 const a1, zig_u8 const a2);
971 \\971 \\
972 );972 );
973 ctx.h("header with u32 param function", linux_x64,973 ctx.h("header with u32 param function", linux_x64,
974 \\export fn start(a: u32) void{ _ = a; }974 \\export fn start(a: u32) void{ _ = a; }
975 ,975 ,
976 \\zig_extern_c zig_void start(zig_u32 const a0);976 \\zig_extern zig_void start(zig_u32 const a0);
977 \\977 \\
978 );978 );
979 ctx.h("header with usize param function", linux_x64,979 ctx.h("header with usize param function", linux_x64,
980 \\export fn start(a: usize) void{ _ = a; }980 \\export fn start(a: usize) void{ _ = a; }
981 ,981 ,
982 \\zig_extern_c zig_void start(zig_usize const a0);982 \\zig_extern zig_void start(zig_usize const a0);
983 \\983 \\
984 );984 );
985 ctx.h("header with bool param function", linux_x64,985 ctx.h("header with bool param function", linux_x64,
986 \\export fn start(a: bool) void{_ = a;}986 \\export fn start(a: bool) void{_ = a;}
987 ,987 ,
988 \\zig_extern_c zig_void start(zig_bool const a0);988 \\zig_extern zig_void start(zig_bool const a0);
989 \\989 \\
990 );990 );
991 ctx.h("header with noreturn function", linux_x64,991 ctx.h("header with noreturn function", linux_x64,
...@@ -993,7 +993,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -993,7 +993,7 @@ pub fn addCases(ctx: *TestContext) !void {
993 \\ unreachable;993 \\ unreachable;
994 \\}994 \\}
995 ,995 ,
996 \\zig_extern_c zig_noreturn start(zig_void);996 \\zig_extern zig_noreturn start(zig_void);
997 \\997 \\
998 );998 );
999 ctx.h("header with multiple functions", linux_x64,999 ctx.h("header with multiple functions", linux_x64,
...@@ -1001,15 +1001,15 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1001,15 +1001,15 @@ pub fn addCases(ctx: *TestContext) !void {
1001 \\export fn b() void{}1001 \\export fn b() void{}
1002 \\export fn c() void{}1002 \\export fn c() void{}
1003 ,1003 ,
1004 \\zig_extern_c zig_void a(zig_void);1004 \\zig_extern zig_void a(zig_void);
1005 \\zig_extern_c zig_void b(zig_void);1005 \\zig_extern zig_void b(zig_void);
1006 \\zig_extern_c zig_void c(zig_void);1006 \\zig_extern zig_void c(zig_void);
1007 \\1007 \\
1008 );1008 );
1009 ctx.h("header with multiple includes", linux_x64,1009 ctx.h("header with multiple includes", linux_x64,
1010 \\export fn start(a: u32, b: usize) void{ _ = a; _ = b; }1010 \\export fn start(a: u32, b: usize) void{ _ = a; _ = b; }
1011 ,1011 ,
1012 \\zig_extern_c zig_void start(zig_u32 const a0, zig_usize const a1);1012 \\zig_extern zig_void start(zig_u32 const a0, zig_usize const a1);
1013 \\1013 \\
1014 );1014 );
1015}1015}