Merge pull request #3524 from Feoramund/freebsd-amd64-syscall-errno

Add `intrinsics.syscall_bsd`
This commit is contained in:
gingerBill
2024-06-20 11:47:01 +01:00
committed by GitHub
7 changed files with 203 additions and 62 deletions

View File

@@ -5115,15 +5115,9 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
isize max_arg_count = 32;
switch (build_context.metrics.os) {
case TargetOs_windows:
case TargetOs_freestanding:
error(call, "'%.*s' is not supported on this platform (%.*s)", LIT(builtin_name), LIT(target_os_names[build_context.metrics.os]));
break;
case TargetOs_darwin:
case TargetOs_linux:
case TargetOs_essence:
case TargetOs_freebsd:
case TargetOs_openbsd:
case TargetOs_haiku:
switch (build_context.metrics.arch) {
case TargetArch_i386:
@@ -5133,6 +5127,9 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
break;
}
break;
default:
error(call, "'%.*s' is not supported on this platform (%.*s)", LIT(builtin_name), LIT(target_os_names[build_context.metrics.os]));
break;
}
if (ce->args.count > max_arg_count) {
@@ -5146,6 +5143,55 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
return true;
}
break;
case BuiltinProc_syscall_bsd:
{
convert_to_typed(c, operand, t_uintptr);
if (!is_type_uintptr(operand->type)) {
gbString t = type_to_string(operand->type);
error(operand->expr, "Argument 0 must be of type 'uintptr', got %s", t);
gb_string_free(t);
}
for (isize i = 1; i < ce->args.count; i++) {
Operand x = {};
check_expr(c, &x, ce->args[i]);
if (x.mode != Addressing_Invalid) {
convert_to_typed(c, &x, t_uintptr);
}
convert_to_typed(c, &x, t_uintptr);
if (!is_type_uintptr(x.type)) {
gbString t = type_to_string(x.type);
error(x.expr, "Argument %td must be of type 'uintptr', got %s", i, t);
gb_string_free(t);
}
}
isize max_arg_count = 32;
switch (build_context.metrics.os) {
case TargetOs_freebsd:
case TargetOs_netbsd:
case TargetOs_openbsd:
switch (build_context.metrics.arch) {
case TargetArch_amd64:
case TargetArch_arm64:
max_arg_count = 7;
break;
}
break;
default:
error(call, "'%.*s' is not supported on this platform (%.*s)", LIT(builtin_name), LIT(target_os_names[build_context.metrics.os]));
break;
}
if (ce->args.count > max_arg_count) {
error(ast_end_token(call), "'%.*s' has a maximum of %td arguments on this platform (%.*s), got %td", LIT(builtin_name), max_arg_count, LIT(target_os_names[build_context.metrics.os]), ce->args.count);
}
operand->mode = Addressing_Value;
operand->type = make_optional_ok_type(t_uintptr);
return true;
}
break;
case BuiltinProc_type_base_type: