toolchain: xpcg: add an offset type for signed offset values

This commit is contained in:
2026-03-21 10:33:01 +00:00
parent 08a9627548
commit 68ae449731
3 changed files with 31 additions and 0 deletions

View File

@@ -176,6 +176,9 @@ static int emit_msg_struct_member(
case TYPE_SIZE:
emit(ctx, "uint64_t %s;\n", param->p_name);
break;
case TYPE_OFFSET:
emit(ctx, "int64_t %s;\n", param->p_name);
break;
case TYPE_STRING:
case TYPE_BUFFER:
emit(ctx, "uint16_t %s_offset;\n", param->p_name);
@@ -336,6 +339,7 @@ static int emit_interface_msg_function_send_impl(
switch (param->p_type->ty_id) {
case TYPE_INT:
case TYPE_SIZE:
case TYPE_OFFSET:
emit(ctx,
"msg_data.msg_request.%s = %s;\n\n",
param->p_name,
@@ -578,6 +582,9 @@ static int emit_interface_msg_function_send(
case TYPE_SIZE:
emit(ctx, "size_t %s", param->p_name);
break;
case TYPE_OFFSET:
emit(ctx, "off_t %s", param->p_name);
break;
case TYPE_STRING:
emit(ctx, "const char *%s", param->p_name);
break;
@@ -604,6 +611,9 @@ static int emit_interface_msg_function_send(
case TYPE_SIZE:
emit(ctx, "size_t *out_%s", param->p_name);
break;
case TYPE_OFFSET:
emit(ctx, "off_t *out_%s", param->p_name);
break;
case TYPE_HANDLE:
emit(ctx, "kern_handle_t *out_%s", param->p_name);
break;
@@ -681,6 +691,12 @@ static int emit_interface_dispatcher_impl_msg(
param->p_name,
param->p_name);
break;
case TYPE_OFFSET:
emit(ctx,
"off_t %s = " MSG_STRUCT_NAME ".msg_request.%s;\n",
param->p_name,
param->p_name);
break;
case TYPE_STRING:
emit(ctx,
"xpc_string_t %s = "
@@ -719,6 +735,9 @@ static int emit_interface_dispatcher_impl_msg(
case TYPE_SIZE:
emit(ctx, "size_t %s = 0;\n", param->p_name);
break;
case TYPE_OFFSET:
emit(ctx, "off_t %s = 0;\n", param->p_name);
break;
case TYPE_HANDLE:
emit(ctx,
"kern_handle_t %s = KERN_HANDLE_INVALID;\n",
@@ -795,6 +814,7 @@ static int emit_interface_dispatcher_impl_msg(
= b_unbox(struct msg_parameter, entry, p_entry);
switch (param->p_type->ty_id) {
case TYPE_INT:
case TYPE_OFFSET:
emit(ctx,
MSG_STRUCT_NAME ".msg_response.%s = %s;\n",
param->p_name,
@@ -976,6 +996,9 @@ static int emit_interface_vtable_entry(
case TYPE_SIZE:
emit(ctx, "size_t %s", param->p_name);
break;
case TYPE_OFFSET:
emit(ctx, "off_t %s", param->p_name);
break;
case TYPE_BUFFER:
emit(ctx, "const xpc_buffer_t *%s", param->p_name);
break;
@@ -1012,6 +1035,9 @@ static int emit_interface_vtable_entry(
case TYPE_SIZE:
emit(ctx, "size_t *out_%s", param->p_name);
break;
case TYPE_OFFSET:
emit(ctx, "off_t *out_%s", param->p_name);
break;
case TYPE_BUFFER:
emit(ctx, "xpc_buffer_t *out_%s", param->p_name);
break;

View File

@@ -47,6 +47,10 @@ const struct type *ctx_get_type(struct ctx *ctx, const char *name)
return ctx_get_builtin_type(ctx, TYPE_SIZE);
}
if (!strcmp(name, "offset")) {
return ctx_get_builtin_type(ctx, TYPE_OFFSET);
}
if (!strcmp(name, "buffer")) {
return ctx_get_builtin_type(ctx, TYPE_BUFFER);
}

View File

@@ -4,6 +4,7 @@
enum type_id {
TYPE_NONE,
TYPE_INT,
TYPE_OFFSET,
TYPE_SIZE,
TYPE_STRING,
TYPE_BUFFER,