From cedc63b28ba4474cb7035afba15db72847c5bc74 Mon Sep 17 00:00:00 2001 From: hl-valdemar Date: Fri, 17 Jul 2026 20:32:12 +0200 Subject: [PATCH] upgrade enum discriminants --- LANGUAGE.md | 2 +- README.md | 7 +- compiler/ast/ast.odin | 19 + compiler/cimport/libclang.odin | 28 +- compiler/loader/loader.odin | 131 +++ compiler/parser/parser.odin | 41 +- compiler/translatec/translatec.odin | 500 ++++++++- compiler_tests.odin | 101 ++ examples/programs/enums/animals/animals.bro | 3 + examples/programs/enums/main.bro | 7 +- ffi/c/errno.bro | 120 ++ ffi/c/fcntl.bro | 393 +++++++ ffi/c/posix.bro | 16 - ffi/c/stdio.bro | 5 +- ffi/c/stdlib.bro | 1092 ++++++++++++++++++- ffi/c/unistd.bro | 661 +++++++++++ main.odin | 130 ++- std/debug/debug.bro | 2 +- std/io/file.bro | 6 +- 19 files changed, 3168 insertions(+), 96 deletions(-) create mode 100644 ffi/c/errno.bro create mode 100644 ffi/c/fcntl.bro delete mode 100644 ffi/c/posix.bro create mode 100644 ffi/c/unistd.bro diff --git a/LANGUAGE.md b/LANGUAGE.md index 391b35c..adbbbb4 100644 --- a/LANGUAGE.md +++ b/LANGUAGE.md @@ -168,7 +168,7 @@ as `math.divfloor(a, b)` resolve to ordinary functions. - object-like scalar and plain record/union macro constants - supported static inline C functions through generated external wrappers - C function pointer types, imported nullable callback typedefs, concrete `c_func` callback values, and postfix calls through non-null function pointers -- `brolang translate-c ` for native `.bro` bindings from supported C declarations +- `brolang translate-c ... [--output-dir ]` for native `.bro` bindings from supported C declarations, with package-wide declaration deduplication when writing multiple headers - `brolang --translate-c stdio.h` for offline bindings from Zig-bundled standard C headers - ordered linking of additional C sources, objects, archives, library paths, and libraries through compiler CLI options diff --git a/README.md b/README.md index 2de3ada..0a80982 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,12 @@ pointer-only. Header imports never add linker inputs; implementations must still be supplied explicitly with the C-prefixed linking options. Set `BROLANG_LIBCLANG_PATH` when libclang is not installed in a standard location. For offline bindings, `brolang --translate-c stdio.h` resolves standard C -headers through the Zig libc headers used by the backend. +headers through the Zig libc headers used by the backend. Multiple headers can +be generated into one deduplicated package: + +```sh +brolang --translate-c stdio.h stdlib.h unistd.h fcntl.h errno.h --output-dir ffi/c +``` ```bro native :: import "../include/native.h" diff --git a/compiler/ast/ast.odin b/compiler/ast/ast.odin index 267bbd6..45449b8 100644 --- a/compiler/ast/ast.odin +++ b/compiler/ast/ast.odin @@ -254,6 +254,19 @@ Global :: struct { diagnostic: source.Diagnostic_Id, } +Enum_Value :: struct { + expr: Expr_Id, + span: source.Span, + explicit: bool, +} + +Enum_Declaration :: struct { + type: types.Type, + pkg: Package_Id, + file: File_Id, + values: []Enum_Value, +} + Import :: struct { span: source.Span, alias: symbol.Id, @@ -326,6 +339,7 @@ Module :: struct { statements: [dynamic]Stmt, functions: [dynamic]Function, globals: [dynamic]Global, + enum_declarations: [dynamic]Enum_Declaration, imports: [dynamic]Import, aliases: [dynamic]Declaration_Alias, files: [dynamic]File, @@ -347,6 +361,7 @@ init_module :: proc(allocator := context.allocator) -> Module { module.statements.allocator = allocator module.functions.allocator = allocator module.globals.allocator = allocator + module.enum_declarations.allocator = allocator module.imports.allocator = allocator module.aliases.allocator = allocator module.files.allocator = allocator @@ -382,6 +397,9 @@ destroy_module :: proc(module: ^Module) { for global in module.globals { delete(global.link_name, module.allocator) } + for declaration in module.enum_declarations { + delete(declaration.values, module.allocator) + } for pkg in module.packages { delete(pkg.path, module.allocator) } @@ -400,6 +418,7 @@ destroy_module :: proc(module: ^Module) { delete(module.statements) delete(module.functions) delete(module.globals) + delete(module.enum_declarations) delete(module.imports) delete(module.aliases) delete(module.files) diff --git a/compiler/cimport/libclang.odin b/compiler/cimport/libclang.odin index 3841643..b8380c8 100644 --- a/compiler/cimport/libclang.odin +++ b/compiler/cimport/libclang.odin @@ -502,7 +502,7 @@ translate_type :: proc(ctx: ^Context, value: CXType, preferred_record_name := "" params: [dynamic]Type_Id params.allocator = ctx.allocator for index in 0.. Type_Id { + if depth > 64 { + return INVALID_TYPE + } + array := value + if value.kind != CXType_ConstantArray && value.kind != CXType_IncompleteArray { + canonical := ctx.api.get_canonical_type(value) + if canonical.kind != CXType_ConstantArray && canonical.kind != CXType_IncompleteArray { + return translate_type(ctx, value, "", depth+1) + } + array = canonical + } + element := ctx.api.get_array_element_type(array) + child := translate_type(ctx, element, "", depth+1) + if child == INVALID_TYPE { + return INVALID_TYPE + } + return add_type(ctx, Type{ + kind=.Pointer, + child=child, + mutable=ctx.api.is_const_qualified_type(element) == 0, + }) +} + has_named :: proc(items: []Unsupported, name: string) -> bool { for item in items { if item.name == name { @@ -1385,7 +1409,7 @@ visit_cursor :: proc "c"(cursor, parent: CXCursor, client_data: rawptr) -> i32 { reason = "function declaration has no prototype" } else { for index in 0.. ast.Global_Id { + for global, index in module.globals { + if global.pkg == pkg && global.name == name && + (!global.file_hidden || !public_only && global.file == file) { + return ast.global_id(index) + } + } + return ast.INVALID_GLOBAL +} + +eval_enum_global :: proc( + state: ^State, + id: ast.Global_Id, + visiting: []bool, + depth: int, +) -> (i128, bool) { + index := int(id) + if id == ast.INVALID_GLOBAL || index < 0 || index >= len(state.module.globals) || + depth > 64 || visiting[index] { + return 0, false + } + global := state.module.globals[index] + if !global.immutable || global.external || global.expr == ast.INVALID_EXPR { + return 0, false + } + if types.is_valid(global.type) && !types.is_concrete_integer(global.type) { + return 0, false + } + visiting[index] = true + defer visiting[index] = false + return eval_enum_constant(state, global.expr, global.pkg, global.file, visiting, depth+1) +} + +eval_enum_constant :: proc( + state: ^State, + id: ast.Expr_Id, + pkg: ast.Package_Id, + file: ast.File_Id, + visiting: []bool, + depth: int, +) -> (i128, bool) { + index := int(id) + if id == ast.INVALID_EXPR || index < 0 || index >= len(state.module.exprs) || depth > 64 { + return 0, false + } + expr := state.module.exprs[index] + #partial switch expr.kind { + case .Integer: + return i128(expr.integer), true + case .Negate: + value, ok := eval_enum_constant(state, expr.left, pkg, file, visiting, depth+1) + return -value, ok + case .Name: + if symbol.is_valid(expr.qualifier) { + import_id := find_type_import(state.module, file, expr.qualifier) + if import_id == ast.INVALID_IMPORT { + return 0, false + } + state.module.imports[import_id].used = true + import_item := state.module.imports[import_id] + if !import_item.valid || import_item.target == ast.INVALID_PACKAGE || + int(import_item.target) >= len(state.module.packages) || + !state.module.packages[import_item.target].available { + return 0, false + } + global := find_visible_enum_global( + state.module, + import_item.target, + ast.INVALID_FILE, + expr.name, + public_only=true, + ) + return eval_enum_global(state, global, visiting, depth+1) + } + global := find_visible_enum_global(state.module, pkg, file, expr.name) + return eval_enum_global(state, global, visiting, depth+1) + } + return 0, false +} + +resolve_enum_values :: proc(state: ^State) { + visiting := make([]bool, len(state.module.globals), state.allocator) + defer delete(visiting, state.allocator) + for declaration in state.module.enum_declarations { + members := types.enum_members_for(&state.module.type_store, declaration.type) + if len(members) != len(declaration.values) { + continue + } + next_value: i128 + previous: i128 + has_previous := false + previous_known := true + for &member, index in members { + spec := declaration.values[index] + value := next_value + known := true + if spec.explicit { + if spec.expr == ast.INVALID_EXPR { + value = member.value + } else if resolved, ok := eval_enum_constant( + state, spec.expr, declaration.pkg, declaration.file, visiting, 0, + ); ok { + value = resolved + } else { + source.add(state.diagnostics, spec.span, "enum value must be an immutable integer constant") + known = false + } + } + if known { + member.value = value + if has_previous && previous_known && value <= previous { + source.add(state.diagnostics, spec.span, "enum values must be strictly increasing") + } + next_value = value+1 + } else { + next_value = member.value+1 + } + previous = value + previous_known = known + has_previous = true + } + } +} + alias_declarations_conflict :: proc(left_file: ast.File_Id, left_hidden: bool, right_file: ast.File_Id, right_hidden: bool) -> bool { return left_file == right_file if left_hidden && right_hidden else true } @@ -1783,6 +1913,7 @@ load :: proc( } validate_imports(&state) validate_declaration_aliases(&state) + resolve_enum_values(&state) diagnose_qualified_type_uses(&state) canonicalize_types(&module, allocator) return module, !state.root_failed diff --git a/compiler/parser/parser.odin b/compiler/parser/parser.odin index 697711b..a5c1bdc 100644 --- a/compiler/parser/parser.odin +++ b/compiler/parser/parser.odin @@ -2783,6 +2783,8 @@ parse_enum_body :: proc( explicit_backing: bool, backing: ^types.Type, members: ^[dynamic]types.Enum_Member, + values: ^[dynamic]ast.Enum_Value, + deferred: ^bool, expected_open: string, ) -> bool { skip_newlines(parser) @@ -2793,6 +2795,7 @@ parse_enum_body :: proc( next_value: i128 previous_value: i128 has_previous := false + order_known := true skip_newlines(parser) for current(parser).kind != .Right_Brace && current(parser).kind != .Eof { member, member_ok := parse_member_name(parser) @@ -2817,18 +2820,20 @@ parse_enum_body :: proc( source.addf(parser.diagnostics, member.span, "duplicate enum member '%s'", token_text(parser, member)) } value := next_value + explicit := false + value_expr := ast.INVALID_EXPR if _, ok := allow(parser, .Equal); ok { + explicit = true if !explicit_backing { source.add(parser.diagnostics, member.span, "explicit enum values require a backing type") } + saved := parser.cursor negative := false if _, minus_ok := allow(parser, .Minus); minus_ok { negative = true } literal := current(parser) - if literal.kind != .Integer { - source.add(parser.diagnostics, literal.span, "expected a decimal integer literal for enum value") - } else { + if literal.kind == .Integer { advance(parser) magnitude, magnitude_ok := parse_integer_magnitude(token_text(parser, literal)) if !magnitude_ok { @@ -2839,13 +2844,19 @@ parse_enum_body :: proc( value = -value } } + } else { + parser.cursor = saved + value_expr = parse_expression(parser) + deferred^ = true + order_known = false } } - if has_previous && value <= previous_value { + if order_known && has_previous && value <= previous_value { source.add(parser.diagnostics, member.span, "enum values must be strictly increasing") } if !duplicate { append(members, types.Enum_Member{name=u32(member.symbol), value=value}) + append(values, ast.Enum_Value{expr=value_expr, span=member.span, explicit=explicit}) } previous_value = value has_previous = true @@ -2890,7 +2901,11 @@ parse_inline_enum_type :: proc(parser: ^Parser) -> types.Type { members: [dynamic]types.Enum_Member members.allocator = parser.module.allocator defer delete(members) - if !parse_enum_body(parser, start.span, false, &backing, &members, "expected '{' after inline enum error type") || !valid { + values: [dynamic]ast.Enum_Value + values.allocator = parser.module.allocator + defer delete(values) + deferred := false + if !parse_enum_body(parser, start.span, false, &backing, &members, &values, &deferred, "expected '{' after inline enum error type") || !valid { return types.INVALID } return types.enum_anonymous(&parser.module.type_store, members[:], backing) @@ -2910,7 +2925,11 @@ parse_enum :: proc(parser: ^Parser, name: token.Token, file_hidden: bool) { members: [dynamic]types.Enum_Member members.allocator = parser.module.allocator defer delete(members) - if !parse_enum_body(parser, start.span, explicit_backing, &backing, &members, "expected '{' after enum declaration") { + values: [dynamic]ast.Enum_Value + values.allocator = parser.module.allocator + defer delete(values) + deferred := false + if !parse_enum_body(parser, start.span, explicit_backing, &backing, &members, &values, &deferred, "expected '{' after enum declaration") { _ = finish_statement(parser) return } @@ -2918,6 +2937,16 @@ parse_enum :: proc(parser: ^Parser, name: token.Token, file_hidden: bool) { if !types.define_enum(&parser.module.type_store, id, backing, members[:], explicit_backing) { source.addf(parser.diagnostics, name.span, "duplicate type declaration '%s'", token_text(parser, name)) } + if explicit_backing && deferred { + stored := make([]ast.Enum_Value, len(values), parser.module.allocator) + copy(stored, values[:]) + append(&parser.module.enum_declarations, ast.Enum_Declaration{ + type=id, + pkg=parser.pkg, + file=parser.file, + values=stored, + }) + } _ = finish_statement(parser) } diff --git a/compiler/translatec/translatec.odin b/compiler/translatec/translatec.odin index ef8073b..c14e0e0 100644 --- a/compiler/translatec/translatec.odin +++ b/compiler/translatec/translatec.odin @@ -17,32 +17,206 @@ import "core:fmt" import "core:mem" import "core:strings" +Package_Input :: struct { + result: ^cimport.Result, + header: string, + name: string, +} + +Package_Output :: struct { + name: string, + source: string, +} + +Declaration_Kind :: enum u8 { + Record, + Alias, + Macro, + Function, +} + +Declaration :: struct { + name: string, + canonical: string, + kind: Declaration_Kind, +} + +Declaration_Registry :: struct { + lookup: map[string]int, + declarations: [dynamic]Declaration, + error: string, + allocator: mem.Allocator, +} + +init_declaration_registry :: proc(allocator: mem.Allocator) -> Declaration_Registry { + registry := Declaration_Registry{allocator=allocator} + registry.lookup.allocator = allocator + registry.declarations.allocator = allocator + return registry +} + +destroy_declaration_registry :: proc(registry: ^Declaration_Registry) { + for declaration in registry.declarations { + delete(declaration.name, registry.allocator) + delete(declaration.canonical, registry.allocator) + } + delete(registry.error, registry.allocator) + delete(registry.lookup) + delete(registry.declarations) +} + +write_declaration :: proc( + b: ^strings.Builder, + registry: ^Declaration_Registry, + name: string, + kind: Declaration_Kind, + actual: string, + canonical := "", +) -> (emitted, ok: bool) { + if registry == nil { + strings.write_string(b, actual) + return true, true + } + comparison := canonical if len(canonical) > 0 else actual + if index, found := registry.lookup[name]; found { + previous := registry.declarations[index] + if previous.kind == kind && previous.canonical == comparison { + return false, true + } + if len(registry.error) == 0 { + registry.error = fmt.aprintf( + "conflicting generated C declaration '%s'", + name, + allocator=registry.allocator, + ) + } + return false, false + } + owned_name := strings.clone(name, registry.allocator) + owned_canonical := strings.clone(comparison, registry.allocator) + registry.lookup[owned_name] = len(registry.declarations) + append(®istry.declarations, Declaration{ + name=owned_name, + canonical=owned_canonical, + kind=kind, + }) + strings.write_string(b, actual) + return true, true +} + emit :: proc(result: ^cimport.Result, header: string, allocator := context.allocator) -> string { + record_names := record_name_table(result, allocator) + defer destroy_record_name_table(record_names, allocator) + output, ok := emit_with_record_names(result, header, record_names, nil, allocator) + assert(ok) + return output +} + +destroy_package_outputs :: proc(outputs: []Package_Output, allocator := context.allocator) { + for output in outputs { + delete(output.name, allocator) + delete(output.source, allocator) + } + delete(outputs, allocator) +} + +emit_package :: proc(inputs: []Package_Input, allocator := context.allocator) -> ([]Package_Output, string) { + registry := init_declaration_registry(allocator) + defer destroy_declaration_registry(®istry) + + tables := make([][]string, len(inputs), allocator) + defer { + for table in tables { + destroy_record_name_table(table, allocator) + } + delete(tables, allocator) + } + for input, index in inputs { + tables[index] = record_name_table(input.result, allocator, input.name) + } + identities: map[string]string + identities.allocator = allocator + defer delete(identities) + for input, input_index in inputs { + for record, record_index in input.result.records { + if len(record.identity) == 0 { + continue + } + if canonical, found := identities[record.identity]; found { + delete(tables[input_index][record_index], allocator) + tables[input_index][record_index] = strings.clone(canonical, allocator) + } else { + identities[record.identity] = tables[input_index][record_index] + } + } + } + + outputs: [dynamic]Package_Output + outputs.allocator = allocator + for input, index in inputs { + source, ok := emit_with_record_names( + input.result, + input.header, + tables[index], + ®istry, + allocator, + ) + if !ok { + delete(source, allocator) + destroy_package_outputs(outputs[:], allocator) + return nil, strings.clone(registry.error, allocator) + } + append(&outputs, Package_Output{ + name=strings.clone(input.name, allocator), + source=source, + }) + } + return outputs[:], "" +} + +emit_with_record_names :: proc( + result: ^cimport.Result, + header: string, + record_names: []string, + registry: ^Declaration_Registry, + allocator: mem.Allocator, +) -> (string, bool) { b := strings.builder_make(allocator) fmt.sbprintf(&b, "# generated by brolang translate-c from %s\n\n", header) - record_names := record_name_table(result, allocator) - defer delete(record_names, allocator) - - emit_records(&b, result, record_names) - emit_aliases(&b, result, record_names) - emit_macros(&b, result, record_names) - emit_functions(&b, result, record_names) + if !emit_records(&b, result, record_names, registry) || + !emit_aliases(&b, result, record_names, registry) || + !emit_macros(&b, result, record_names, registry) || + !emit_functions(&b, result, record_names, registry) { + return strings.to_string(b), false + } emit_variables(&b, result) emit_unsupported(&b, result) - return strings.to_string(b) + return strings.to_string(b), true } // record_name_table maps each record index to the brolang identifier it is // emitted under: its C tag name, or — for an anonymous record named only by a // typedef — that typedef's name (the typedef is then skipped). Truly anonymous // records fall back to the loader's synthetic `__c_record_N`. -record_name_table :: proc(result: ^cimport.Result, allocator: mem.Allocator) -> []string { +record_name_table :: proc(result: ^cimport.Result, allocator: mem.Allocator, prefix := "") -> []string { names := make([]string, len(result.records), allocator) for record, idx in result.records { - if len(record.name) > 0 { - names[idx] = record.name + if binding_identifier(record.name) { + if record_name_conflicts(result, idx, record.name) { + fragment := safe_name_fragment(prefix, context.temp_allocator) + if len(fragment) > 0 { + names[idx] = fmt.aprintf("__c_%s_%s_record", fragment, record.name, allocator=allocator) + } else { + names[idx] = fmt.aprintf("__c_%s_record", record.name, allocator=allocator) + } + } else { + names[idx] = strings.clone(record.name, allocator) + } + } else if len(prefix) > 0 { + fragment := safe_name_fragment(prefix, context.temp_allocator) + names[idx] = fmt.aprintf("__c_%s_record_%d", fragment, idx, allocator=allocator) } else { names[idx] = fmt.aprintf("__c_record_%d", idx, allocator=allocator) } @@ -59,13 +233,73 @@ record_name_table :: proc(result: ^cimport.Result, allocator: mem.Allocator) -> if target.kind != .Record || int(target.record) >= len(result.records) { continue } - if len(result.records[target.record].name) == 0 { - names[target.record] = alias.name + if !binding_identifier(result.records[target.record].name) { + delete(names[target.record], allocator) + names[target.record] = strings.clone(alias.name, allocator) } } return names } +binding_identifier :: proc(value: string) -> bool { + if len(value) == 0 || lexer.keyword_kind(value) != .Identifier { + return false + } + for byte, index in transmute([]byte)value { + letter := byte == '_' || byte >= 'a' && byte <= 'z' || byte >= 'A' && byte <= 'Z' + if !letter && (index == 0 || byte < '0' || byte > '9') { + return false + } + } + return true +} + +record_name_conflicts :: proc(result: ^cimport.Result, record_index: int, name: string) -> bool { + for function in result.functions { + if function.name == name && len(function.reason) == 0 && + (len(function.link_name) == 0 || function.link_name == function.name) { + return true + } + } + for macro in result.macros { + if macro.name == name && len(macro.reason) == 0 && + lexer.keyword_kind(macro.name) == .Identifier { + return true + } + } + for alias in result.aliases { + if alias.name != name || len(alias.reason) > 0 || alias.type == cimport.INVALID_TYPE || + int(alias.type) < 0 || int(alias.type) >= len(result.types) { + continue + } + target := result.types[alias.type] + if target.kind != .Record || int(target.record) != record_index { + return true + } + } + return false +} + +destroy_record_name_table :: proc(names: []string, allocator: mem.Allocator) { + for name in names { + delete(name, allocator) + } + delete(names, allocator) +} + +safe_name_fragment :: proc(value: string, allocator: mem.Allocator) -> string { + b := strings.builder_make(allocator) + for byte in transmute([]byte)value { + if byte >= 'a' && byte <= 'z' || byte >= 'A' && byte <= 'Z' || + byte >= '0' && byte <= '9' || byte == '_' { + strings.write_byte(&b, byte) + } else { + strings.write_byte(&b, '_') + } + } + return strings.to_string(b) +} + // render_type writes the brolang spelling of a C type. Mirror of // loader.translate_c_type — keep the two in lockstep. render_type :: proc(b: ^strings.Builder, result: ^cimport.Result, id: cimport.Type_Id, record_names: []string) { @@ -150,36 +384,68 @@ render_c_func :: proc( render_type(b, result, ret, record_names) } -emit_records :: proc(b: ^strings.Builder, result: ^cimport.Result, record_names: []string) { +emit_records :: proc( + b: ^strings.Builder, + result: ^cimport.Result, + record_names: []string, + registry: ^Declaration_Registry, +) -> bool { wrote := false for record, idx in result.records { name := record_names[idx] + representable := record_has_native_spelling(result, u32(idx)) if record.kind == .Union { fmt.sbprintf(b, "# unsupported in bindings: C union '%s' has no native spelling\n", name) wrote = true - continue - } - if !record.complete || len(record.reason) > 0 { - // opaque / pointer-only struct - fmt.sbprintf(b, "%s :: opaque\n", name) + } else if record.complete && len(record.reason) == 0 && !representable { + fmt.sbprintf(b, "# unsupported in bindings: C record '%s' contains an unsupported field type\n", name) wrote = true + } + if !representable { + // opaque / pointer-only struct + text := fmt.tprintf("%s :: opaque\n", name) + canonical := text + if len(record.identity) > 0 { + canonical = fmt.tprintf("%s\n%s", record.identity, text) + } + emitted, ok := write_declaration(b, registry, name, .Record, text, canonical) + if !ok { + return false + } + wrote = wrote || emitted continue } - fmt.sbprintf(b, "%s :: c_struct {{\n", name) + declaration := strings.builder_make(context.temp_allocator) + fmt.sbprintf(&declaration, "%s :: c_struct {{\n", name) for field in record.fields { - fmt.sbprintf(b, "\t%s ", field.name) - render_type(b, result, field.type, record_names) - strings.write_byte(b, '\n') + fmt.sbprintf(&declaration, "\t%s ", field.name) + render_type(&declaration, result, field.type, record_names) + strings.write_byte(&declaration, '\n') } - strings.write_string(b, "}\n") - wrote = true + strings.write_string(&declaration, "}\n") + text := strings.to_string(declaration) + canonical := text + if len(record.identity) > 0 { + canonical = fmt.tprintf("%s\n%s", record.identity, text) + } + emitted, ok := write_declaration(b, registry, name, .Record, text, canonical) + if !ok { + return false + } + wrote = wrote || emitted } if wrote { strings.write_byte(b, '\n') } + return true } -emit_aliases :: proc(b: ^strings.Builder, result: ^cimport.Result, record_names: []string) { +emit_aliases :: proc( + b: ^strings.Builder, + result: ^cimport.Result, + record_names: []string, + registry: ^Declaration_Registry, +) -> bool { wrote := false for alias in result.aliases { if len(alias.reason) > 0 { @@ -187,27 +453,46 @@ emit_aliases :: proc(b: ^strings.Builder, result: ^cimport.Result, record_names: wrote = true continue } + if !type_has_native_spelling(result, alias.type) { + fmt.sbprintf(b, "# unsupported in bindings: typedef '%s' — underlying type has no native spelling\n", alias.name) + wrote = true + continue + } // Skip a typedef that merely (re)names a record under the name we already // emitted the record with (anonymous-struct collapse, or `typedef struct // Foo Foo;`). if ti := alias.type; int(ti) >= 0 && int(ti) < len(result.types) { target := result.types[ti] - if target.kind == .Record && int(target.record) < len(record_names) && - record_names[target.record] == alias.name { - continue + if target.kind == .Record && int(target.record) < len(record_names) { + record := result.records[target.record] + if record_names[target.record] == alias.name || record.name == alias.name { + continue + } } } - fmt.sbprintf(b, "%s :: alias ", alias.name) - render_type(b, result, alias.type, record_names) - strings.write_byte(b, '\n') - wrote = true + declaration := strings.builder_make(context.temp_allocator) + fmt.sbprintf(&declaration, "%s :: alias ", alias.name) + render_type(&declaration, result, alias.type, record_names) + strings.write_byte(&declaration, '\n') + text := strings.to_string(declaration) + emitted, ok := write_declaration(b, registry, alias.name, .Alias, text) + if !ok { + return false + } + wrote = wrote || emitted } if wrote { strings.write_byte(b, '\n') } + return true } -emit_macros :: proc(b: ^strings.Builder, result: ^cimport.Result, record_names: []string) { +emit_macros :: proc( + b: ^strings.Builder, + result: ^cimport.Result, + record_names: []string, + registry: ^Declaration_Registry, +) -> bool { wrote := false for macro in result.macros { if len(macro.reason) > 0 { @@ -223,23 +508,41 @@ emit_macros :: proc(b: ^strings.Builder, result: ^cimport.Result, record_names: continue } if macro.aggregate { - emit_aggregate_macro(b, result, macro, record_names) - wrote = true + declaration := strings.builder_make(context.temp_allocator) + binding := emit_aggregate_macro(&declaration, result, macro, record_names) + text := strings.to_string(declaration) + if binding { + emitted, ok := write_declaration(b, registry, macro.name, .Macro, text) + if !ok { + return false + } + wrote = wrote || emitted + } else { + strings.write_string(b, text) + wrote = true + } continue } - strings.write_string(b, macro.name) + declaration := strings.builder_make(context.temp_allocator) + strings.write_string(&declaration, macro.name) if macro_scalar_kind(result, macro.type) { - strings.write_byte(b, ' ') - render_type(b, result, macro.type, record_names) + strings.write_byte(&declaration, ' ') + render_type(&declaration, result, macro.type, record_names) } - strings.write_string(b, " :: ") - render_macro_value(b, macro.value) - strings.write_byte(b, '\n') - wrote = true + strings.write_string(&declaration, " :: ") + render_macro_value(&declaration, macro.value) + strings.write_byte(&declaration, '\n') + text := strings.to_string(declaration) + emitted, ok := write_declaration(b, registry, macro.name, .Macro, text) + if !ok { + return false + } + wrote = wrote || emitted } if wrote { strings.write_byte(b, '\n') } + return true } emit_aggregate_macro :: proc( @@ -247,11 +550,11 @@ emit_aggregate_macro :: proc( result: ^cimport.Result, macro: cimport.Macro_Constant, record_names: []string, -) { +) -> bool { ti := macro.type if int(ti) >= 0 && int(ti) < len(result.types) && result.types[ti].kind == .Record { ridx := int(result.types[ti].record) - if ridx < len(result.records) { + if ridx < len(result.records) && record_has_native_spelling(result, u32(ridx)) { record := result.records[ridx] if len(record.fields) == len(macro.values) && !record_has_pointer_field(result, record) { fmt.sbprintf(b, "%s :: %s {{", macro.name, record_names[ridx]) @@ -263,14 +566,20 @@ emit_aggregate_macro :: proc( render_macro_value(b, macro.values[index]) } strings.write_string(b, " }\n") - return + return true } } } fmt.sbprintf(b, "# unsupported in bindings: aggregate macro '%s' has no native spelling\n", macro.name) + return false } -emit_functions :: proc(b: ^strings.Builder, result: ^cimport.Result, record_names: []string) { +emit_functions :: proc( + b: ^strings.Builder, + result: ^cimport.Result, + record_names: []string, + registry: ^Declaration_Registry, +) -> bool { wrote := false for function in result.functions { if len(function.reason) > 0 { @@ -278,19 +587,41 @@ emit_functions :: proc(b: ^strings.Builder, result: ^cimport.Result, record_name wrote = true continue } + if !function_has_native_spelling(result, function) { + fmt.sbprintf(b, "# unsupported in bindings: function '%s' — signature has no native spelling\n", function.name) + wrote = true + continue + } if len(function.link_name) > 0 && function.link_name != function.name { fmt.sbprintf(b, "# unsupported in bindings: function '%s' is a static inline function (needs trampoline)\n", function.name) wrote = true continue } - fmt.sbprintf(b, "%s ", function.name) - render_c_func(b, result, function.params, function.param_names, function.result, function.variadic, record_names) - strings.write_byte(b, '\n') - wrote = true + declaration := strings.builder_make(context.temp_allocator) + fmt.sbprintf(&declaration, "%s ", function.name) + render_c_func(&declaration, result, function.params, function.param_names, function.result, function.variadic, record_names) + strings.write_byte(&declaration, '\n') + canonical := strings.builder_make(context.temp_allocator) + fmt.sbprintf(&canonical, "%s ", function.name) + render_c_func(&canonical, result, function.params, nil, function.result, function.variadic, record_names) + strings.write_byte(&canonical, '\n') + emitted, ok := write_declaration( + b, + registry, + function.name, + .Function, + strings.to_string(declaration), + strings.to_string(canonical), + ) + if !ok { + return false + } + wrote = wrote || emitted } if wrote { strings.write_byte(b, '\n') } + return true } emit_variables :: proc(b: ^strings.Builder, result: ^cimport.Result) { @@ -350,6 +681,73 @@ macro_scalar_kind :: proc(result: ^cimport.Result, id: cimport.Type_Id) -> bool return false } +function_has_native_spelling :: proc(result: ^cimport.Result, function: cimport.Function) -> bool { + for param in function.params { + if !type_has_native_spelling(result, param) { + return false + } + } + return type_has_native_spelling(result, function.result, allow_void=true) +} + +record_has_native_spelling :: proc(result: ^cimport.Result, index: u32, depth := 0) -> bool { + if depth > 64 || int(index) < 0 || int(index) >= len(result.records) { + return false + } + record := result.records[index] + if record.kind == .Union || !record.complete || len(record.reason) > 0 || len(record.fields) == 0 { + return false + } + for field in record.fields { + if !type_has_native_spelling(result, field.type, depth=depth+1) { + return false + } + } + return true +} + +type_has_native_spelling :: proc( + result: ^cimport.Result, + id: cimport.Type_Id, + allow_void := false, + depth := 0, +) -> bool { + if depth > 64 || id == cimport.INVALID_TYPE || int(id) < 0 || int(id) >= len(result.types) { + return false + } + item := result.types[id] + switch item.kind { + case .Void: + return allow_void + case .C_Bool, .C_Char, .C_Schar, .C_Uchar, .C_Short, .C_Ushort, .C_Int, .C_Uint, + .C_Long, .C_Ulong, .C_Longlong, .C_Ulonglong, .C_Float, .C_Double, .C_Longdouble: + return true + case .Pointer: + if item.child == cimport.INVALID_TYPE || int(item.child) < 0 || int(item.child) >= len(result.types) { + return false + } + child := result.types[item.child] + if child.kind == .Void || child.kind == .Record { + return true + } + return type_has_native_spelling(result, item.child, allow_void=true, depth=depth+1) + case .Array: + return type_has_native_spelling(result, item.child, depth=depth+1) + case .Function: + for param in item.params { + if !type_has_native_spelling(result, param, depth=depth+1) { + return false + } + } + return type_has_native_spelling(result, item.child, allow_void=true, depth=depth+1) + case .Record: + return record_has_native_spelling(result, item.record, depth+1) + case .Invalid: + return false + } + return false +} + record_has_pointer_field :: proc(result: ^cimport.Result, record: cimport.Record) -> bool { for field in record.fields { if int(field.type) >= 0 && int(field.type) < len(result.types) && diff --git a/compiler_tests.odin b/compiler_tests.odin index 73c548f..bf6f0ae 100644 --- a/compiler_tests.odin +++ b/compiler_tests.odin @@ -11951,6 +11951,107 @@ translate_c_emits_native_bindings_and_round_trips :: proc(t: ^testing.T) { testing.expect_value(t, len(diagnostics.items), 0) } +@(test) +translate_c_package_deduplicates_compatible_declarations :: proc(t: ^testing.T) { + first := cimport.init_result(context.allocator) + second := cimport.init_result(context.allocator) + defer { + delete(first.types) + delete(first.records[0].fields) + delete(first.records) + delete(first.functions) + delete(first.macros) + delete(second.types) + delete(second.records[0].fields) + delete(second.records) + delete(second.functions) + delete(second.macros) + } + + append(&first.types, cimport.Type{kind=.C_Int, child=cimport.INVALID_TYPE}) + append(&first.types, cimport.Type{kind=.Record, record=0, child=cimport.INVALID_TYPE}) + append(&first.types, cimport.Type{kind=.Pointer, child=1, mutable=true}) + append(&second.types, ..first.types[:]) + first_fields: [dynamic]cimport.Field + second_fields: [dynamic]cimport.Field + append(&first_fields, cimport.Field{name="value", type=0}) + append(&second_fields, cimport.Field{name="value", type=0}) + append(&first.records, cimport.Record{ + identity="shared-anonymous-record", + kind=.Struct, + complete=true, + fields=first_fields, + }) + append(&second.records, cimport.Record{ + identity="shared-anonymous-record", + kind=.Struct, + complete=true, + fields=second_fields, + }) + first_params := [?]cimport.Type_Id{0} + second_params := [?]cimport.Type_Id{0} + use_record_params := [?]cimport.Type_Id{2} + first_names := [?]string{"left"} + second_names := [?]string{"right"} + append(&first.functions, cimport.Function{ + name="shared", + params=first_params[:], + param_names=first_names[:], + result=0, + }) + append(&second.functions, cimport.Function{ + name="shared", + params=second_params[:], + param_names=second_names[:], + result=0, + }) + append(&second.functions, cimport.Function{ + name="use_record", + params=use_record_params[:], + result=0, + }) + append(&first.macros, cimport.Macro_Constant{ + name="SHARED_VALUE", + type=0, + value={kind=.Integer, type=0, integer=7}, + }) + append(&second.macros, first.macros[0]) + + inputs := [?]translatec.Package_Input{ + {result=&first, header="first.h", name="first.bro"}, + {result=&second, header="second.h", name="second.bro"}, + } + outputs, generation_error := translatec.emit_package(inputs[:]) + defer translatec.destroy_package_outputs(outputs) + defer delete(generation_error) + testing.expect_value(t, generation_error, "") + testing.expect_value(t, len(outputs), 2) + if len(outputs) == 2 { + combined := fmt.tprintf("%s%s", outputs[0].source, outputs[1].source) + testing.expect_value(t, count_substring_occurrences(combined, "shared c_func("), 1) + testing.expect_value(t, count_substring_occurrences(combined, "SHARED_VALUE c_int :: 7"), 1) + testing.expect(t, strings.contains(outputs[0].source, "__c_first_bro_record_0 :: c_struct")) + testing.expect(t, strings.contains(outputs[1].source, "use_record c_func(_ ?*mut __c_first_bro_record_0) c_int")) + } + + second.macros[0].value.integer = 8 + conflicting, conflict_error := translatec.emit_package(inputs[:]) + defer translatec.destroy_package_outputs(conflicting) + defer delete(conflict_error) + testing.expect_value(t, len(conflicting), 0) + testing.expect(t, strings.contains(conflict_error, "conflicting generated C declaration 'SHARED_VALUE'")) +} + +@(test) +translate_c_package_cli_requires_unambiguous_outputs :: proc(t: ^testing.T) { + testing.expect_value(t, run_translate_c([]string{ + "brolang", "--translate-c", "first.h", "second.h", + }), 2) + testing.expect_value(t, run_translate_c([]string{ + "brolang", "--translate-c", "a/same.h", "b/same.h", "--output-dir", "/tmp/unused", + }), 2) +} + @(test) sink_named_parameters_are_allowed_and_not_duplicates :: proc(t: ^testing.T) { // Generated bindings use `_` for unnamed C params; the parser must accept it and diff --git a/examples/programs/enums/animals/animals.bro b/examples/programs/enums/animals/animals.bro index f7f43d0..89f8ece 100644 --- a/examples/programs/enums/animals/animals.bro +++ b/examples/programs/enums/animals/animals.bro @@ -3,6 +3,9 @@ Animal :: enum { cat } +STATE_STARTED c_int :: 10 +STATE_STOPPED c_int :: 20 + favorite func() Animal { return .cat } diff --git a/examples/programs/enums/main.bro b/examples/programs/enums/main.bro index 0931d52..28e82d8 100644 --- a/examples/programs/enums/main.bro +++ b/examples/programs/enums/main.bro @@ -1,9 +1,9 @@ animals :: import "./animals" State :: enum(u16) { - started = 10 + started = animals.STATE_STARTED running - stopped = 20 + stopped = animals.STATE_STOPPED } initial State :: State.started @@ -21,6 +21,9 @@ main func() i32 { values [2]State :: [.started, State.stopped] animal animals.Animal :: animals.Animal.dog if same(state, .running) and + u16(State.started) == 10 and + u16(State.running) == 11 and + u16(State.stopped) == 20 and values[0] != values[1] and animal != animals.favorite() and initial == State.started { diff --git a/ffi/c/errno.bro b/ffi/c/errno.bro new file mode 100644 index 0000000..17c2484 --- /dev/null +++ b/ffi/c/errno.bro @@ -0,0 +1,120 @@ +# generated by brolang translate-c from errno.h + +errno_t :: alias c_int + +EPERM c_int :: 1 +ENOENT c_int :: 2 +ESRCH c_int :: 3 +EINTR c_int :: 4 +EIO c_int :: 5 +ENXIO c_int :: 6 +E2BIG c_int :: 7 +ENOEXEC c_int :: 8 +EBADF c_int :: 9 +ECHILD c_int :: 10 +EDEADLK c_int :: 11 +ENOMEM c_int :: 12 +EACCES c_int :: 13 +EFAULT c_int :: 14 +ENOTBLK c_int :: 15 +EBUSY c_int :: 16 +EEXIST c_int :: 17 +EXDEV c_int :: 18 +ENODEV c_int :: 19 +ENOTDIR c_int :: 20 +EISDIR c_int :: 21 +EINVAL c_int :: 22 +ENFILE c_int :: 23 +EMFILE c_int :: 24 +ENOTTY c_int :: 25 +ETXTBSY c_int :: 26 +EFBIG c_int :: 27 +ENOSPC c_int :: 28 +ESPIPE c_int :: 29 +EROFS c_int :: 30 +EMLINK c_int :: 31 +EPIPE c_int :: 32 +EDOM c_int :: 33 +ERANGE c_int :: 34 +EAGAIN c_int :: 35 +EINPROGRESS c_int :: 36 +EALREADY c_int :: 37 +ENOTSOCK c_int :: 38 +EDESTADDRREQ c_int :: 39 +EMSGSIZE c_int :: 40 +EPROTOTYPE c_int :: 41 +ENOPROTOOPT c_int :: 42 +EPROTONOSUPPORT c_int :: 43 +ESOCKTNOSUPPORT c_int :: 44 +ENOTSUP c_int :: 45 +EPFNOSUPPORT c_int :: 46 +EAFNOSUPPORT c_int :: 47 +EADDRINUSE c_int :: 48 +EADDRNOTAVAIL c_int :: 49 +ENETDOWN c_int :: 50 +ENETUNREACH c_int :: 51 +ENETRESET c_int :: 52 +ECONNABORTED c_int :: 53 +ECONNRESET c_int :: 54 +ENOBUFS c_int :: 55 +EISCONN c_int :: 56 +ENOTCONN c_int :: 57 +ESHUTDOWN c_int :: 58 +ETOOMANYREFS c_int :: 59 +ETIMEDOUT c_int :: 60 +ECONNREFUSED c_int :: 61 +ELOOP c_int :: 62 +ENAMETOOLONG c_int :: 63 +EHOSTDOWN c_int :: 64 +EHOSTUNREACH c_int :: 65 +ENOTEMPTY c_int :: 66 +EPROCLIM c_int :: 67 +EUSERS c_int :: 68 +EDQUOT c_int :: 69 +ESTALE c_int :: 70 +EREMOTE c_int :: 71 +EBADRPC c_int :: 72 +ERPCMISMATCH c_int :: 73 +EPROGUNAVAIL c_int :: 74 +EPROGMISMATCH c_int :: 75 +EPROCUNAVAIL c_int :: 76 +ENOLCK c_int :: 77 +ENOSYS c_int :: 78 +EFTYPE c_int :: 79 +EAUTH c_int :: 80 +ENEEDAUTH c_int :: 81 +EPWROFF c_int :: 82 +EDEVERR c_int :: 83 +EOVERFLOW c_int :: 84 +EBADEXEC c_int :: 85 +EBADARCH c_int :: 86 +ESHLIBVERS c_int :: 87 +EBADMACHO c_int :: 88 +ECANCELED c_int :: 89 +EIDRM c_int :: 90 +ENOMSG c_int :: 91 +EILSEQ c_int :: 92 +ENOATTR c_int :: 93 +EBADMSG c_int :: 94 +EMULTIHOP c_int :: 95 +ENODATA c_int :: 96 +ENOLINK c_int :: 97 +ENOSR c_int :: 98 +ENOSTR c_int :: 99 +EPROTO c_int :: 100 +ETIME c_int :: 101 +EOPNOTSUPP c_int :: 102 +ENOPOLICY c_int :: 103 +ENOTRECOVERABLE c_int :: 104 +EOWNERDEAD c_int :: 105 +EQFULL c_int :: 106 +ENOTCAPABLE c_int :: 107 +ELAST c_int :: 107 + +__error c_func() ?*mut c_int + +# unsupported in bindings: _SYS_ERRNO_H_ — C macro has no replacement value +# unsupported in bindings: _CDEFS_H_ — C macro has no replacement value +# unsupported in bindings: _ERRNO_T — C macro has no replacement value +# unsupported in bindings: errno — C macro is not a supported constant +# unsupported in bindings: EWOULDBLOCK — C macro is not a supported constant diff --git a/ffi/c/fcntl.bro b/ffi/c/fcntl.bro new file mode 100644 index 0000000..b53ec39 --- /dev/null +++ b/ffi/c/fcntl.bro @@ -0,0 +1,393 @@ +# generated by brolang translate-c from fcntl.h + +# unsupported in bindings: C union '__mbstate_t' has no native spelling +__c_fcntl_bro_flock_record :: c_struct { + l_start c_longlong + l_len c_longlong + l_pid c_int + l_type c_short + l_whence c_short +} +flocktimeout :: c_struct { + fl __c_fcntl_bro_flock_record + timeout timespec +} +radvisory :: c_struct { + ra_offset c_longlong + ra_count c_int +} +fsignatures :: c_struct { + fs_file_start c_longlong + fs_blob_start ?*mut anyopaque + fs_blob_size c_ulong + fs_fsignatures_size c_ulong + fs_cdhash [20]c_char + fs_hash_type c_int +} +fsupplement :: c_struct { + fs_file_start c_longlong + fs_blob_start c_longlong + fs_blob_size c_ulong + fs_orig_fd c_int +} +fchecklv :: c_struct { + lv_file_start c_longlong + lv_error_message_size c_ulong + lv_error_message ?*mut anyopaque +} +fgetsigsinfo :: c_struct { + fg_file_start c_longlong + fg_info_request c_int + fg_sig_is_platform c_int +} +fstore :: c_struct { + fst_flags c_uint + fst_posmode c_int + fst_offset c_longlong + fst_length c_longlong + fst_bytesalloc c_longlong +} +fpunchhole :: c_struct { + fp_flags c_uint + reserved c_uint + fp_offset c_longlong + fp_length c_longlong +} +ftrimactivefile :: c_struct { + fta_offset c_longlong + fta_length c_longlong +} +fspecread :: c_struct { + fsr_flags c_uint + reserved c_uint + fsr_offset c_longlong + fsr_length c_longlong +} +fattributiontag :: c_struct { + ft_flags c_uint + ft_hash c_ulonglong + ft_attribution_name [255]c_char +} +log2phys :: c_struct { + l2p_flags c_uint + l2p_contigbytes c_longlong + l2p_devoffset c_longlong +} +_filesec :: opaque + +# unsupported in bindings: typedef '__mbstate_t' — underlying type has no native spelling +# unsupported in bindings: typedef '__darwin_mbstate_t' — underlying type has no native spelling +fsignatures_t :: alias fsignatures +fsupplement_t :: alias fsupplement +fchecklv_t :: alias fchecklv +fgetsigsinfo_t :: alias fgetsigsinfo +fstore_t :: alias fstore +fpunchhole_t :: alias fpunchhole +ftrimactivefile_t :: alias ftrimactivefile +fspecread_t :: alias fspecread +fattributiontag_t :: alias fattributiontag +# unsupported in bindings: typedef '_filesec' — underlying type has no native spelling +filesec_t :: alias ?*mut _filesec +filesec_property_t :: alias c_uint + +O_RDONLY c_int :: 0 +O_WRONLY c_int :: 1 +O_RDWR c_int :: 2 +O_ACCMODE c_int :: 3 +FREAD c_int :: 1 +FWRITE c_int :: 2 +O_NONBLOCK c_int :: 4 +O_APPEND c_int :: 8 +O_SYNC c_int :: 128 +O_SHLOCK c_int :: 16 +O_EXLOCK c_int :: 32 +O_ASYNC c_int :: 64 +O_NOFOLLOW c_int :: 256 +O_CREAT c_int :: 512 +O_TRUNC c_int :: 1024 +O_EXCL c_int :: 2048 +O_RESOLVE_BENEATH c_int :: 4096 +O_UNIQUE c_int :: 8192 +O_EVTONLY c_int :: 32768 +O_NOCTTY c_int :: 131072 +O_DIRECTORY c_int :: 1048576 +O_SYMLINK c_int :: 2097152 +O_DSYNC c_int :: 4194304 +O_CLOEXEC c_int :: 16777216 +O_NOFOLLOW_ANY c_int :: 536870912 +O_EXEC c_int :: 1073741824 +AT_FDCWD c_int :: -2 +AT_EACCESS c_int :: 16 +AT_SYMLINK_NOFOLLOW c_int :: 32 +AT_SYMLINK_FOLLOW c_int :: 64 +AT_REMOVEDIR c_int :: 128 +AT_REALDEV c_int :: 512 +AT_FDONLY c_int :: 1024 +AT_SYMLINK_NOFOLLOW_ANY c_int :: 2048 +AT_RESOLVE_BENEATH c_int :: 8192 +AT_NODELETEBUSY c_int :: 16384 +AT_UNIQUE c_int :: 32768 +O_DP_GETRAWENCRYPTED c_int :: 1 +O_DP_GETRAWUNENCRYPTED c_int :: 2 +O_DP_AUTHENTICATE c_int :: 4 +AUTH_OPEN_NOAUTHFD c_int :: -1 +CPF_OVERWRITE c_int :: 1 +CPF_IGNORE_MODE c_int :: 2 +F_DUPFD c_int :: 0 +F_GETFD c_int :: 1 +F_SETFD c_int :: 2 +F_GETFL c_int :: 3 +F_SETFL c_int :: 4 +F_GETOWN c_int :: 5 +F_SETOWN c_int :: 6 +F_GETLK c_int :: 7 +F_SETLK c_int :: 8 +F_SETLKW c_int :: 9 +F_SETLKWTIMEOUT c_int :: 10 +F_FLUSH_DATA c_int :: 40 +F_CHKCLEAN c_int :: 41 +F_PREALLOCATE c_int :: 42 +F_SETSIZE c_int :: 43 +F_RDADVISE c_int :: 44 +F_RDAHEAD c_int :: 45 +F_NOCACHE c_int :: 48 +F_LOG2PHYS c_int :: 49 +F_GETPATH c_int :: 50 +F_FULLFSYNC c_int :: 51 +F_PATHPKG_CHECK c_int :: 52 +F_FREEZE_FS c_int :: 53 +F_THAW_FS c_int :: 54 +F_GLOBAL_NOCACHE c_int :: 55 +F_ADDSIGS c_int :: 59 +F_ADDFILESIGS c_int :: 61 +F_NODIRECT c_int :: 62 +F_GETPROTECTIONCLASS c_int :: 63 +F_SETPROTECTIONCLASS c_int :: 64 +F_LOG2PHYS_EXT c_int :: 65 +F_GETLKPID c_int :: 66 +F_SETBACKINGSTORE c_int :: 70 +F_GETPATH_MTMINFO c_int :: 71 +F_GETCODEDIR c_int :: 72 +F_SETNOSIGPIPE c_int :: 73 +F_GETNOSIGPIPE c_int :: 74 +F_TRANSCODEKEY c_int :: 75 +F_SINGLE_WRITER c_int :: 76 +F_GETPROTECTIONLEVEL c_int :: 77 +F_FINDSIGS c_int :: 78 +F_ADDFILESIGS_FOR_DYLD_SIM c_int :: 83 +F_BARRIERFSYNC c_int :: 85 +F_OFD_SETLK c_int :: 90 +F_OFD_SETLKW c_int :: 91 +F_OFD_GETLK c_int :: 92 +F_OFD_SETLKWTIMEOUT c_int :: 93 +F_ADDFILESIGS_RETURN c_int :: 97 +F_CHECK_LV c_int :: 98 +F_PUNCHHOLE c_int :: 99 +F_TRIM_ACTIVE_FILE c_int :: 100 +F_SPECULATIVE_READ c_int :: 101 +F_GETPATH_NOFIRMLINK c_int :: 102 +F_ADDFILESIGS_INFO c_int :: 103 +F_ADDFILESUPPL c_int :: 104 +F_GETSIGSINFO c_int :: 105 +F_SETLEASE c_int :: 106 +F_GETLEASE c_int :: 107 +F_TRANSFEREXTENTS c_int :: 110 +F_ATTRIBUTION_TAG c_int :: 111 +F_NOCACHE_EXT c_int :: 112 +F_ADDSIGS_MAIN_BINARY c_int :: 113 +FCNTL_FS_SPECIFIC_BASE c_int :: 65536 +F_DUPFD_CLOEXEC c_int :: 67 +FD_CLOEXEC c_int :: 1 +F_RDLCK c_int :: 1 +F_UNLCK c_int :: 2 +F_WRLCK c_int :: 3 +S_IFMT c_int :: 61440 +S_IFIFO c_int :: 4096 +S_IFCHR c_int :: 8192 +S_IFDIR c_int :: 16384 +S_IFBLK c_int :: 24576 +S_IFREG c_int :: 32768 +S_IFLNK c_int :: 40960 +S_IFSOCK c_int :: 49152 +S_IFWHT c_int :: 57344 +S_IRWXU c_int :: 448 +S_IRUSR c_int :: 256 +S_IWUSR c_int :: 128 +S_IXUSR c_int :: 64 +S_IRWXG c_int :: 56 +S_IRGRP c_int :: 32 +S_IWGRP c_int :: 16 +S_IXGRP c_int :: 8 +S_IRWXO c_int :: 7 +S_IROTH c_int :: 4 +S_IWOTH c_int :: 2 +S_IXOTH c_int :: 1 +S_ISUID c_int :: 2048 +S_ISGID c_int :: 1024 +S_ISVTX c_int :: 512 +F_ALLOCATECONTIG c_int :: 2 +F_ALLOCATEALL c_int :: 4 +F_ALLOCATEPERSIST c_int :: 8 +F_PEOFPOSMODE c_int :: 3 +F_VOLPOSMODE c_int :: 4 +USER_FSIGNATURES_CDHASH_LEN c_int :: 20 +GETSIGSINFO_PLATFORM_BINARY c_int :: 1 +LOCK_SH c_int :: 1 +LOCK_EX c_int :: 2 +LOCK_NB c_int :: 4 +LOCK_UN c_int :: 8 +ATTRIBUTION_NAME_MAX c_int :: 255 +F_CREATE_TAG c_int :: 1 +F_DELETE_TAG c_int :: 2 +F_QUERY_TAG c_int :: 4 +O_POPUP c_uint :: 2147483648 +O_ALERT c_int :: 536870912 +FILESEC_OWNER c_uint :: 1 +FILESEC_GROUP c_uint :: 2 +FILESEC_UUID c_uint :: 3 +FILESEC_MODE c_uint :: 4 +FILESEC_ACL c_uint :: 5 +FILESEC_GRPUUID c_uint :: 6 +FILESEC_ACL_RAW c_uint :: 100 +FILESEC_ACL_ALLOCSIZE c_uint :: 101 + +open c_func(_ ?*c_char, _ c_int, ...) c_int +openat c_func(_ c_int, _ ?*c_char, _ c_int, ...) c_int +creat c_func(_ ?*c_char, _ c_ushort) c_int +fcntl c_func(_ c_int, _ c_int, ...) c_int +openx_np c_func(_ ?*c_char, _ c_int, _ ?*mut _filesec) c_int +open_dprotected_np c_func(_ ?*c_char, _ c_int, _ c_int, _ c_int, ...) c_int +openat_dprotected_np c_func(_ c_int, _ ?*c_char, _ c_int, _ c_int, _ c_int, ...) c_int +openat_authenticated_np c_func(_ c_int, _ ?*c_char, _ c_int, _ c_int) c_int +flock c_func(_ c_int, _ c_int) c_int +filesec_init c_func() ?*mut _filesec +filesec_dup c_func(_ ?*mut _filesec) ?*mut _filesec +filesec_free c_func(_ ?*mut _filesec) void +filesec_get_property c_func(_ ?*mut _filesec, _ c_uint, _ ?*mut anyopaque) c_int +filesec_query_property c_func(_ ?*mut _filesec, _ c_uint, _ ?*mut c_int) c_int +filesec_set_property c_func(_ ?*mut _filesec, _ c_uint, _ ?*anyopaque) c_int +filesec_unset_property c_func(_ ?*mut _filesec, _ c_uint) c_int + +# unsupported in bindings: _SYS_FCNTL_H_ — C macro has no replacement value +# unsupported in bindings: _SYS__TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _CDEFS_H_ — C macro has no replacement value +# unsupported in bindings: _BSD_MACHINE__TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _BSD_ARM__TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _SYS__PTHREAD_TYPES_H_ — C macro has no replacement value +# unsupported in bindings: MAC_OS_X_VERSION_10_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_8 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_9 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_10 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_10_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_10_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_15 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_15_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_15_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_16 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_16_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_4 — C macro is not a supported constant +# unsupported in bindings: _SIZE_T — C macro has no replacement value +# unsupported in bindings: _MODE_T — C macro has no replacement value +# unsupported in bindings: _OFF_T — C macro has no replacement value +# unsupported in bindings: _PID_T — C macro has no replacement value +# unsupported in bindings: O_FSYNC — C macro is not a supported constant +# unsupported in bindings: O_SEARCH — C macro is not a supported constant +# unsupported in bindings: FAPPEND — C macro is not a supported constant +# unsupported in bindings: FASYNC — C macro is not a supported constant +# unsupported in bindings: FFSYNC — C macro is not a supported constant +# unsupported in bindings: FFDSYNC — C macro is not a supported constant +# unsupported in bindings: FNONBLOCK — C macro is not a supported constant +# unsupported in bindings: FNDELAY — C macro is not a supported constant +# unsupported in bindings: O_NDELAY — C macro is not a supported constant +# unsupported in bindings: CPF_MASK — C macro is not a supported constant +# unsupported in bindings: F_SETLEASE_ARG — C function-like macros are not supported +# unsupported in bindings: _SEEK_SET_H_ — C macro has no replacement value +# unsupported in bindings: S_ISTXT — C macro is not a supported constant +# unsupported in bindings: S_IREAD — C macro is not a supported constant +# unsupported in bindings: S_IWRITE — C macro is not a supported constant +# unsupported in bindings: S_IEXEC — C macro is not a supported constant +# unsupported in bindings: _STRUCT_TIMESPEC — C macro is not a supported constant +# unsupported in bindings: _BSD_MACHINE_TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _ARM_MACHTYPES_H_ — C macro has no replacement value +# unsupported in bindings: _MACHTYPES_H_ — C macro has no replacement value +# unsupported in bindings: _INT8_T — C macro has no replacement value +# unsupported in bindings: _INT16_T — C macro has no replacement value +# unsupported in bindings: _INT32_T — C macro has no replacement value +# unsupported in bindings: _INT64_T — C macro has no replacement value +# unsupported in bindings: _U_INT8_T — C macro has no replacement value +# unsupported in bindings: _U_INT16_T — C macro has no replacement value +# unsupported in bindings: _U_INT32_T — C macro has no replacement value +# unsupported in bindings: _U_INT64_T — C macro has no replacement value +# unsupported in bindings: _INTPTR_T — C macro has no replacement value +# unsupported in bindings: _UINTPTR_T — C macro has no replacement value +# unsupported in bindings: USER_ADDR_NULL — C macro is not a supported constant +# unsupported in bindings: CAST_USER_ADDR_T — C function-like macros are not supported +# unsupported in bindings: _FILESEC_T — C macro has no replacement value +# unsupported in bindings: FILESEC_GUID — C macro is not a supported constant +# unsupported in bindings: _FILESEC_UNSET_PROPERTY — C macro is not a supported constant +# unsupported in bindings: _FILESEC_REMOVE_ACL — C macro is not a supported constant diff --git a/ffi/c/posix.bro b/ffi/c/posix.bro deleted file mode 100644 index 7df17b3..0000000 --- a/ffi/c/posix.bro +++ /dev/null @@ -1,16 +0,0 @@ -O_RDONLY c_int :: 0 -O_WRONLY c_int :: 1 -O_RDWR c_int :: 2 - -STDIN_FILENO c_int :: 0 -STDOUT_FILENO c_int :: 1 -STDERR_FILENO c_int :: 2 - -EINTR c_int :: 4 -EBADF c_int :: 9 - -open c_func(_ *c_char, _ c_int, ...) c_int -close c_func(_ c_int) c_int -read c_func(_ c_int, _ ?*mut anyopaque, _ c_ulong) c_long -write c_func(_ c_int, _ ?*anyopaque, _ c_ulong) c_long -__error c_func() *mut c_int diff --git a/ffi/c/stdio.bro b/ffi/c/stdio.bro index 3f64bc9..bfb5081 100644 --- a/ffi/c/stdio.bro +++ b/ffi/c/stdio.bro @@ -1,6 +1,7 @@ # generated by brolang translate-c from stdio.h # unsupported in bindings: C union '__mbstate_t' has no native spelling +__mbstate_t :: opaque __darwin_pthread_handler_rec :: c_struct { __routine ?*c_func(_ ?*mut anyopaque) void __arg ?*mut anyopaque @@ -82,7 +83,8 @@ __uint64_t :: alias c_ulonglong __darwin_intptr_t :: alias c_long __darwin_natural_t :: alias c_uint __darwin_ct_rune_t :: alias c_int -__darwin_mbstate_t :: alias __mbstate_t +# unsupported in bindings: typedef '__mbstate_t' — underlying type has no native spelling +# unsupported in bindings: typedef '__darwin_mbstate_t' — underlying type has no native spelling __darwin_ptrdiff_t :: alias c_long __darwin_size_t :: alias c_ulong __darwin_va_list :: alias ?*mut c_char @@ -148,6 +150,7 @@ syscall_arg_t :: alias c_ulonglong va_list :: alias ?*mut c_char size_t :: alias c_ulong fpos_t :: alias c_longlong +# unsupported in bindings: typedef '__sFILEX' — underlying type has no native spelling FILE :: alias __sFILE off_t :: alias c_longlong ssize_t :: alias c_long diff --git a/ffi/c/stdlib.bro b/ffi/c/stdlib.bro index c2a0b3b..4840145 100644 --- a/ffi/c/stdlib.bro +++ b/ffi/c/stdlib.bro @@ -1,4 +1,1094 @@ +# generated by brolang translate-c from stdlib.h + +# unsupported in bindings: C union '__mbstate_t' has no native spelling +__darwin_arm_exception_state :: c_struct { + __exception c_uint + __fsr c_uint + __far c_uint +} +__darwin_arm_exception_state64 :: c_struct { + __far c_ulonglong + __esr c_uint + __exception c_uint +} +__darwin_arm_exception_state64_v2 :: c_struct { + __far c_ulonglong + __esr c_ulonglong +} +__darwin_arm_thread_state :: c_struct { + __r [13]c_uint + __sp c_uint + __lr c_uint + __pc c_uint + __cpsr c_uint +} +__darwin_arm_thread_state64 :: c_struct { + __x [29]c_ulonglong + __fp c_ulonglong + __lr c_ulonglong + __sp c_ulonglong + __pc c_ulonglong + __cpsr c_uint + __pad c_uint +} +__darwin_arm_vfp_state :: c_struct { + __r [64]c_uint + __fpscr c_uint +} +__darwin_arm_neon_state64 :: opaque +__darwin_arm_neon_state :: opaque +__arm_pagein_state :: c_struct { + __pagein_error c_int +} +__darwin_arm_sme_state :: c_struct { + __svcr c_ulonglong + __tpidr2_el0 c_ulonglong + __svl_b c_ushort +} +__darwin_arm_sve_z_state :: c_struct { + __z [16][256]c_char +} +__darwin_arm_sve_p_state :: c_struct { + __p [16][32]c_char +} +__darwin_arm_sme_za_state :: c_struct { + __za [4096]c_char +} +__darwin_arm_sme2_state :: c_struct { + __zt0 [64]c_char +} +__arm_legacy_debug_state :: c_struct { + __bvr [16]c_uint + __bcr [16]c_uint + __wvr [16]c_uint + __wcr [16]c_uint +} +__darwin_arm_debug_state32 :: c_struct { + __bvr [16]c_uint + __bcr [16]c_uint + __wvr [16]c_uint + __wcr [16]c_uint + __mdscr_el1 c_ulonglong +} +__darwin_arm_debug_state64 :: c_struct { + __bvr [16]c_ulonglong + __bcr [16]c_ulonglong + __wvr [16]c_ulonglong + __wcr [16]c_ulonglong + __mdscr_el1 c_ulonglong +} +__darwin_arm_cpmu_state64 :: c_struct { + __ctrs [16]c_ulonglong +} +__darwin_mcontext32 :: c_struct { + __es __darwin_arm_exception_state + __ss __darwin_arm_thread_state + __fs __darwin_arm_vfp_state +} +# unsupported in bindings: C record '__darwin_mcontext64' contains an unsupported field type +__darwin_mcontext64 :: opaque +__darwin_sigaltstack :: c_struct { + ss_sp ?*mut anyopaque + ss_size c_ulong + ss_flags c_int +} +__darwin_ucontext :: c_struct { + uc_onstack c_int + uc_sigmask c_uint + uc_stack __darwin_sigaltstack + uc_link ?*mut __darwin_ucontext + uc_mcsize c_ulong + uc_mcontext ?*mut __darwin_mcontext64 +} +# unsupported in bindings: C union 'sigval' has no native spelling +sigval :: opaque +# unsupported in bindings: C record 'sigevent' contains an unsupported field type +sigevent :: opaque +# unsupported in bindings: C record '__siginfo' contains an unsupported field type +__siginfo :: opaque +# unsupported in bindings: C union '__sigaction_u' has no native spelling +__sigaction_u :: opaque +# unsupported in bindings: C record '__sigaction' contains an unsupported field type +__sigaction :: opaque +# unsupported in bindings: C record 'sigaction' contains an unsupported field type +sigaction :: opaque +sigvec :: c_struct { + sv_handler ?*c_func(_ c_int) void + sv_mask c_int + sv_flags c_int +} +sigstack :: c_struct { + ss_sp ?*mut c_char + ss_onstack c_int +} +timeval :: c_struct { + tv_sec c_long + tv_usec c_int +} +rusage :: c_struct { + ru_utime timeval + ru_stime timeval + ru_maxrss c_long + ru_ixrss c_long + ru_idrss c_long + ru_isrss c_long + ru_minflt c_long + ru_majflt c_long + ru_nswap c_long + ru_inblock c_long + ru_oublock c_long + ru_msgsnd c_long + ru_msgrcv c_long + ru_nsignals c_long + ru_nvcsw c_long + ru_nivcsw c_long +} +rusage_info_v0 :: c_struct { + ri_uuid [16]c_uchar + ri_user_time c_ulonglong + ri_system_time c_ulonglong + ri_pkg_idle_wkups c_ulonglong + ri_interrupt_wkups c_ulonglong + ri_pageins c_ulonglong + ri_wired_size c_ulonglong + ri_resident_size c_ulonglong + ri_phys_footprint c_ulonglong + ri_proc_start_abstime c_ulonglong + ri_proc_exit_abstime c_ulonglong +} +rusage_info_v1 :: c_struct { + ri_uuid [16]c_uchar + ri_user_time c_ulonglong + ri_system_time c_ulonglong + ri_pkg_idle_wkups c_ulonglong + ri_interrupt_wkups c_ulonglong + ri_pageins c_ulonglong + ri_wired_size c_ulonglong + ri_resident_size c_ulonglong + ri_phys_footprint c_ulonglong + ri_proc_start_abstime c_ulonglong + ri_proc_exit_abstime c_ulonglong + ri_child_user_time c_ulonglong + ri_child_system_time c_ulonglong + ri_child_pkg_idle_wkups c_ulonglong + ri_child_interrupt_wkups c_ulonglong + ri_child_pageins c_ulonglong + ri_child_elapsed_abstime c_ulonglong +} +rusage_info_v2 :: c_struct { + ri_uuid [16]c_uchar + ri_user_time c_ulonglong + ri_system_time c_ulonglong + ri_pkg_idle_wkups c_ulonglong + ri_interrupt_wkups c_ulonglong + ri_pageins c_ulonglong + ri_wired_size c_ulonglong + ri_resident_size c_ulonglong + ri_phys_footprint c_ulonglong + ri_proc_start_abstime c_ulonglong + ri_proc_exit_abstime c_ulonglong + ri_child_user_time c_ulonglong + ri_child_system_time c_ulonglong + ri_child_pkg_idle_wkups c_ulonglong + ri_child_interrupt_wkups c_ulonglong + ri_child_pageins c_ulonglong + ri_child_elapsed_abstime c_ulonglong + ri_diskio_bytesread c_ulonglong + ri_diskio_byteswritten c_ulonglong +} +rusage_info_v3 :: c_struct { + ri_uuid [16]c_uchar + ri_user_time c_ulonglong + ri_system_time c_ulonglong + ri_pkg_idle_wkups c_ulonglong + ri_interrupt_wkups c_ulonglong + ri_pageins c_ulonglong + ri_wired_size c_ulonglong + ri_resident_size c_ulonglong + ri_phys_footprint c_ulonglong + ri_proc_start_abstime c_ulonglong + ri_proc_exit_abstime c_ulonglong + ri_child_user_time c_ulonglong + ri_child_system_time c_ulonglong + ri_child_pkg_idle_wkups c_ulonglong + ri_child_interrupt_wkups c_ulonglong + ri_child_pageins c_ulonglong + ri_child_elapsed_abstime c_ulonglong + ri_diskio_bytesread c_ulonglong + ri_diskio_byteswritten c_ulonglong + ri_cpu_time_qos_default c_ulonglong + ri_cpu_time_qos_maintenance c_ulonglong + ri_cpu_time_qos_background c_ulonglong + ri_cpu_time_qos_utility c_ulonglong + ri_cpu_time_qos_legacy c_ulonglong + ri_cpu_time_qos_user_initiated c_ulonglong + ri_cpu_time_qos_user_interactive c_ulonglong + ri_billed_system_time c_ulonglong + ri_serviced_system_time c_ulonglong +} +rusage_info_v4 :: c_struct { + ri_uuid [16]c_uchar + ri_user_time c_ulonglong + ri_system_time c_ulonglong + ri_pkg_idle_wkups c_ulonglong + ri_interrupt_wkups c_ulonglong + ri_pageins c_ulonglong + ri_wired_size c_ulonglong + ri_resident_size c_ulonglong + ri_phys_footprint c_ulonglong + ri_proc_start_abstime c_ulonglong + ri_proc_exit_abstime c_ulonglong + ri_child_user_time c_ulonglong + ri_child_system_time c_ulonglong + ri_child_pkg_idle_wkups c_ulonglong + ri_child_interrupt_wkups c_ulonglong + ri_child_pageins c_ulonglong + ri_child_elapsed_abstime c_ulonglong + ri_diskio_bytesread c_ulonglong + ri_diskio_byteswritten c_ulonglong + ri_cpu_time_qos_default c_ulonglong + ri_cpu_time_qos_maintenance c_ulonglong + ri_cpu_time_qos_background c_ulonglong + ri_cpu_time_qos_utility c_ulonglong + ri_cpu_time_qos_legacy c_ulonglong + ri_cpu_time_qos_user_initiated c_ulonglong + ri_cpu_time_qos_user_interactive c_ulonglong + ri_billed_system_time c_ulonglong + ri_serviced_system_time c_ulonglong + ri_logical_writes c_ulonglong + ri_lifetime_max_phys_footprint c_ulonglong + ri_instructions c_ulonglong + ri_cycles c_ulonglong + ri_billed_energy c_ulonglong + ri_serviced_energy c_ulonglong + ri_interval_max_phys_footprint c_ulonglong + ri_runnable_time c_ulonglong +} +rusage_info_v5 :: c_struct { + ri_uuid [16]c_uchar + ri_user_time c_ulonglong + ri_system_time c_ulonglong + ri_pkg_idle_wkups c_ulonglong + ri_interrupt_wkups c_ulonglong + ri_pageins c_ulonglong + ri_wired_size c_ulonglong + ri_resident_size c_ulonglong + ri_phys_footprint c_ulonglong + ri_proc_start_abstime c_ulonglong + ri_proc_exit_abstime c_ulonglong + ri_child_user_time c_ulonglong + ri_child_system_time c_ulonglong + ri_child_pkg_idle_wkups c_ulonglong + ri_child_interrupt_wkups c_ulonglong + ri_child_pageins c_ulonglong + ri_child_elapsed_abstime c_ulonglong + ri_diskio_bytesread c_ulonglong + ri_diskio_byteswritten c_ulonglong + ri_cpu_time_qos_default c_ulonglong + ri_cpu_time_qos_maintenance c_ulonglong + ri_cpu_time_qos_background c_ulonglong + ri_cpu_time_qos_utility c_ulonglong + ri_cpu_time_qos_legacy c_ulonglong + ri_cpu_time_qos_user_initiated c_ulonglong + ri_cpu_time_qos_user_interactive c_ulonglong + ri_billed_system_time c_ulonglong + ri_serviced_system_time c_ulonglong + ri_logical_writes c_ulonglong + ri_lifetime_max_phys_footprint c_ulonglong + ri_instructions c_ulonglong + ri_cycles c_ulonglong + ri_billed_energy c_ulonglong + ri_serviced_energy c_ulonglong + ri_interval_max_phys_footprint c_ulonglong + ri_runnable_time c_ulonglong + ri_flags c_ulonglong +} +rusage_info_v6 :: c_struct { + ri_uuid [16]c_uchar + ri_user_time c_ulonglong + ri_system_time c_ulonglong + ri_pkg_idle_wkups c_ulonglong + ri_interrupt_wkups c_ulonglong + ri_pageins c_ulonglong + ri_wired_size c_ulonglong + ri_resident_size c_ulonglong + ri_phys_footprint c_ulonglong + ri_proc_start_abstime c_ulonglong + ri_proc_exit_abstime c_ulonglong + ri_child_user_time c_ulonglong + ri_child_system_time c_ulonglong + ri_child_pkg_idle_wkups c_ulonglong + ri_child_interrupt_wkups c_ulonglong + ri_child_pageins c_ulonglong + ri_child_elapsed_abstime c_ulonglong + ri_diskio_bytesread c_ulonglong + ri_diskio_byteswritten c_ulonglong + ri_cpu_time_qos_default c_ulonglong + ri_cpu_time_qos_maintenance c_ulonglong + ri_cpu_time_qos_background c_ulonglong + ri_cpu_time_qos_utility c_ulonglong + ri_cpu_time_qos_legacy c_ulonglong + ri_cpu_time_qos_user_initiated c_ulonglong + ri_cpu_time_qos_user_interactive c_ulonglong + ri_billed_system_time c_ulonglong + ri_serviced_system_time c_ulonglong + ri_logical_writes c_ulonglong + ri_lifetime_max_phys_footprint c_ulonglong + ri_instructions c_ulonglong + ri_cycles c_ulonglong + ri_billed_energy c_ulonglong + ri_serviced_energy c_ulonglong + ri_interval_max_phys_footprint c_ulonglong + ri_runnable_time c_ulonglong + ri_flags c_ulonglong + ri_user_ptime c_ulonglong + ri_system_ptime c_ulonglong + ri_pinstructions c_ulonglong + ri_pcycles c_ulonglong + ri_energy_nj c_ulonglong + ri_penergy_nj c_ulonglong + ri_secure_time_in_system c_ulonglong + ri_secure_ptime_in_system c_ulonglong + ri_neural_footprint c_ulonglong + ri_lifetime_max_neural_footprint c_ulonglong + ri_interval_max_neural_footprint c_ulonglong + ri_reserved [9]c_ulonglong +} +rlimit :: c_struct { + rlim_cur c_ulonglong + rlim_max c_ulonglong +} +proc_rlimit_control_wakeupmon :: c_struct { + wm_flags c_uint + wm_rate c_int +} +# unsupported in bindings: C union '__c_stdlib_bro_wait_record' has no native spelling +__c_stdlib_bro_wait_record :: opaque +__c_stdlib_bro_record_53 :: opaque +__c_stdlib_bro_record_54 :: opaque +div_t :: c_struct { + quot c_int + rem c_int +} +ldiv_t :: c_struct { + quot c_long + rem c_long +} +lldiv_t :: c_struct { + quot c_longlong + rem c_longlong +} +_malloc_zone_t :: opaque + +# unsupported in bindings: typedef '__mbstate_t' — underlying type has no native spelling +# unsupported in bindings: typedef '__darwin_mbstate_t' — underlying type has no native spelling +idtype_t :: alias c_uint +pid_t :: alias c_int +id_t :: alias c_uint +sig_atomic_t :: alias c_int +# unsupported in bindings: typedef '__darwin_arm_neon_state64' — underlying type has no native spelling +# unsupported in bindings: typedef '__darwin_arm_neon_state' — underlying type has no native spelling +# unsupported in bindings: typedef '__darwin_mcontext64' — underlying type has no native spelling +mcontext_t :: alias ?*mut __darwin_mcontext64 +pthread_attr_t :: alias _opaque_pthread_attr_t +stack_t :: alias __darwin_sigaltstack +ucontext_t :: alias __darwin_ucontext +sigset_t :: alias c_uint +uid_t :: alias c_uint +# unsupported in bindings: typedef 'sigval' — underlying type has no native spelling +# unsupported in bindings: typedef 'sigevent' — underlying type has no native spelling +# unsupported in bindings: typedef '__siginfo' — underlying type has no native spelling +# unsupported in bindings: typedef 'siginfo_t' — underlying type has no native spelling +# unsupported in bindings: typedef '__sigaction_u' — underlying type has no native spelling +# unsupported in bindings: typedef '__sigaction' — underlying type has no native spelling +# unsupported in bindings: typedef 'sigaction' — underlying type has no native spelling +sig_t :: alias ?*c_func(_ c_int) void +uint8_t :: alias c_uchar +uint16_t :: alias c_ushort +uint32_t :: alias c_uint +uint64_t :: alias c_ulonglong +int_least8_t :: alias c_schar +int_least16_t :: alias c_short +int_least32_t :: alias c_int +int_least64_t :: alias c_longlong +uint_least8_t :: alias c_uchar +uint_least16_t :: alias c_ushort +uint_least32_t :: alias c_uint +uint_least64_t :: alias c_ulonglong +int_fast8_t :: alias c_schar +int_fast16_t :: alias c_short +int_fast32_t :: alias c_int +int_fast64_t :: alias c_longlong +uint_fast8_t :: alias c_uchar +uint_fast16_t :: alias c_ushort +uint_fast32_t :: alias c_uint +uint_fast64_t :: alias c_ulonglong +intmax_t :: alias c_long +uintmax_t :: alias c_ulong +rlim_t :: alias c_ulonglong +rusage_info_t :: alias ?*mut anyopaque +rusage_info_current :: alias rusage_info_v6 +# unsupported in bindings: typedef 'wait' — underlying type has no native spelling +ct_rune_t :: alias c_int +rune_t :: alias c_int +wchar_t :: alias c_int +malloc_type_id_t :: alias c_ulonglong +# unsupported in bindings: typedef '_malloc_zone_t' — underlying type has no native spelling +# unsupported in bindings: typedef 'malloc_zone_t' — underlying type has no native spelling +dev_t :: alias c_int +mode_t :: alias c_ushort + +_ARM_SIGNAL_ c_int :: 1 +SIGHUP c_int :: 1 +SIGINT c_int :: 2 +SIGQUIT c_int :: 3 +SIGILL c_int :: 4 +SIGTRAP c_int :: 5 +SIGABRT c_int :: 6 +SIGEMT c_int :: 7 +SIGFPE c_int :: 8 +SIGKILL c_int :: 9 +SIGBUS c_int :: 10 +SIGSEGV c_int :: 11 +SIGSYS c_int :: 12 +SIGPIPE c_int :: 13 +SIGALRM c_int :: 14 +SIGTERM c_int :: 15 +SIGURG c_int :: 16 +SIGSTOP c_int :: 17 +SIGTSTP c_int :: 18 +SIGCONT c_int :: 19 +SIGCHLD c_int :: 20 +SIGTTIN c_int :: 21 +SIGTTOU c_int :: 22 +SIGIO c_int :: 23 +SIGXCPU c_int :: 24 +SIGXFSZ c_int :: 25 +SIGVTALRM c_int :: 26 +SIGPROF c_int :: 27 +SIGWINCH c_int :: 28 +SIGINFO c_int :: 29 +SIGUSR1 c_int :: 30 +SIGUSR2 c_int :: 31 +SIGEV_NONE c_int :: 0 +SIGEV_SIGNAL c_int :: 1 +SIGEV_THREAD c_int :: 3 +SIGEV_KEVENT c_int :: 4 +ILL_NOOP c_int :: 0 +ILL_ILLOPC c_int :: 1 +ILL_ILLTRP c_int :: 2 +ILL_PRVOPC c_int :: 3 +ILL_ILLOPN c_int :: 4 +ILL_ILLADR c_int :: 5 +ILL_PRVREG c_int :: 6 +ILL_COPROC c_int :: 7 +ILL_BADSTK c_int :: 8 +FPE_NOOP c_int :: 0 +FPE_FLTDIV c_int :: 1 +FPE_FLTOVF c_int :: 2 +FPE_FLTUND c_int :: 3 +FPE_FLTRES c_int :: 4 +FPE_FLTINV c_int :: 5 +FPE_FLTSUB c_int :: 6 +FPE_INTDIV c_int :: 7 +FPE_INTOVF c_int :: 8 +SEGV_NOOP c_int :: 0 +SEGV_MAPERR c_int :: 1 +SEGV_ACCERR c_int :: 2 +BUS_NOOP c_int :: 0 +BUS_ADRALN c_int :: 1 +BUS_ADRERR c_int :: 2 +BUS_OBJERR c_int :: 3 +TRAP_BRKPT c_int :: 1 +TRAP_TRACE c_int :: 2 +CLD_NOOP c_int :: 0 +CLD_EXITED c_int :: 1 +CLD_KILLED c_int :: 2 +CLD_DUMPED c_int :: 3 +CLD_TRAPPED c_int :: 4 +CLD_STOPPED c_int :: 5 +CLD_CONTINUED c_int :: 6 +POLL_IN c_int :: 1 +POLL_OUT c_int :: 2 +POLL_MSG c_int :: 3 +POLL_ERR c_int :: 4 +POLL_PRI c_int :: 5 +POLL_HUP c_int :: 6 +SA_ONSTACK c_int :: 1 +SA_RESTART c_int :: 2 +SA_RESETHAND c_int :: 4 +SA_NOCLDSTOP c_int :: 8 +SA_NODEFER c_int :: 16 +SA_NOCLDWAIT c_int :: 32 +SA_SIGINFO c_int :: 64 +SA_USERTRAMP c_int :: 256 +SA_64REGSET c_int :: 512 +SIG_BLOCK c_int :: 1 +SIG_UNBLOCK c_int :: 2 +SIG_SETMASK c_int :: 3 +SI_USER c_int :: 65537 +SI_QUEUE c_int :: 65538 +SI_TIMER c_int :: 65539 +SI_ASYNCIO c_int :: 65540 +SI_MESGQ c_int :: 65541 +SS_ONSTACK c_int :: 1 +SS_DISABLE c_int :: 4 +MINSIGSTKSZ c_int :: 32768 +SIGSTKSZ c_int :: 131072 +INT8_MAX c_int :: 127 +INT16_MAX c_int :: 32767 +INT32_MAX c_int :: 2147483647 +INT64_MAX c_longlong :: 9223372036854775807 +INT8_MIN c_int :: -128 +INT16_MIN c_int :: -32768 +UINT8_MAX c_int :: 255 +UINT16_MAX c_int :: 65535 +UINT32_MAX c_uint :: 4294967295 +UINT64_MAX c_ulonglong :: 18446744073709551615 +INTPTR_MAX c_long :: 9223372036854775807 +UINTPTR_MAX c_ulong :: 18446744073709551615 +PRIO_PROCESS c_int :: 0 +PRIO_PGRP c_int :: 1 +PRIO_USER c_int :: 2 +PRIO_DARWIN_THREAD c_int :: 3 +PRIO_DARWIN_PROCESS c_int :: 4 +PRIO_MIN c_int :: -20 +PRIO_MAX c_int :: 20 +PRIO_DARWIN_BG c_int :: 4096 +PRIO_DARWIN_NONUI c_int :: 4097 +RUSAGE_SELF c_int :: 0 +RUSAGE_CHILDREN c_int :: -1 +RUSAGE_INFO_V0 c_int :: 0 +RUSAGE_INFO_V1 c_int :: 1 +RUSAGE_INFO_V2 c_int :: 2 +RUSAGE_INFO_V3 c_int :: 3 +RUSAGE_INFO_V4 c_int :: 4 +RUSAGE_INFO_V5 c_int :: 5 +RUSAGE_INFO_V6 c_int :: 6 +RU_PROC_RUNS_RESLIDE c_int :: 1 +RLIMIT_CPU c_int :: 0 +RLIMIT_FSIZE c_int :: 1 +RLIMIT_DATA c_int :: 2 +RLIMIT_STACK c_int :: 3 +RLIMIT_CORE c_int :: 4 +RLIMIT_AS c_int :: 5 +RLIMIT_MEMLOCK c_int :: 6 +RLIMIT_NPROC c_int :: 7 +RLIMIT_NOFILE c_int :: 8 +RLIM_NLIMITS c_int :: 9 +_RLIMIT_POSIX_FLAG c_int :: 4096 +RLIMIT_WAKEUPS_MONITOR c_int :: 1 +RLIMIT_CPU_USAGE_MONITOR c_int :: 2 +RLIMIT_THREAD_CPULIMITS c_int :: 3 +RLIMIT_FOOTPRINT_INTERVAL c_int :: 4 +WAKEMON_ENABLE c_int :: 1 +WAKEMON_DISABLE c_int :: 2 +WAKEMON_GET_PARAMS c_int :: 4 +WAKEMON_SET_DEFAULTS c_int :: 8 +WAKEMON_MAKE_FATAL c_int :: 16 +CPUMON_MAKE_FATAL c_int :: 4096 +FOOTPRINT_INTERVAL_RESET c_int :: 1 +IOPOL_TYPE_DISK c_int :: 0 +IOPOL_TYPE_VFS_ATIME_UPDATES c_int :: 2 +IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES c_int :: 3 +IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME c_int :: 4 +IOPOL_TYPE_VFS_TRIGGER_RESOLVE c_int :: 5 +IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION c_int :: 6 +IOPOL_TYPE_VFS_IGNORE_PERMISSIONS c_int :: 7 +IOPOL_TYPE_VFS_SKIP_MTIME_UPDATE c_int :: 8 +IOPOL_TYPE_VFS_ALLOW_LOW_SPACE_WRITES c_int :: 9 +IOPOL_TYPE_VFS_DISALLOW_RW_FOR_O_EVTONLY c_int :: 10 +IOPOL_TYPE_VFS_ENTITLED_RESERVE_ACCESS c_int :: 14 +IOPOL_SCOPE_PROCESS c_int :: 0 +IOPOL_SCOPE_THREAD c_int :: 1 +IOPOL_SCOPE_DARWIN_BG c_int :: 2 +IOPOL_DEFAULT c_int :: 0 +IOPOL_IMPORTANT c_int :: 1 +IOPOL_PASSIVE c_int :: 2 +IOPOL_THROTTLE c_int :: 3 +IOPOL_UTILITY c_int :: 4 +IOPOL_STANDARD c_int :: 5 +IOPOL_ATIME_UPDATES_DEFAULT c_int :: 0 +IOPOL_ATIME_UPDATES_OFF c_int :: 1 +IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT c_int :: 0 +IOPOL_MATERIALIZE_DATALESS_FILES_OFF c_int :: 1 +IOPOL_MATERIALIZE_DATALESS_FILES_ON c_int :: 2 +IOPOL_MATERIALIZE_DATALESS_FILES_ORIG c_int :: 4 +IOPOL_MATERIALIZE_DATALESS_FILES_BASIC_MASK c_int :: 3 +IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT c_int :: 0 +IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME c_int :: 1 +IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT c_int :: 0 +IOPOL_VFS_TRIGGER_RESOLVE_OFF c_int :: 1 +IOPOL_VFS_CONTENT_PROTECTION_DEFAULT c_int :: 0 +IOPOL_VFS_CONTENT_PROTECTION_IGNORE c_int :: 1 +IOPOL_VFS_IGNORE_PERMISSIONS_OFF c_int :: 0 +IOPOL_VFS_IGNORE_PERMISSIONS_ON c_int :: 1 +IOPOL_VFS_SKIP_MTIME_UPDATE_OFF c_int :: 0 +IOPOL_VFS_SKIP_MTIME_UPDATE_ON c_int :: 1 +IOPOL_VFS_SKIP_MTIME_UPDATE_IGNORE c_int :: 2 +IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_OFF c_int :: 0 +IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_ON c_int :: 1 +IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_DEFAULT c_int :: 0 +IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_ON c_int :: 1 +IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_DEFAULT c_int :: 0 +IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_ON c_int :: 1 +IOPOL_VFS_ENTITLED_RESERVE_ACCESS_OFF c_int :: 0 +IOPOL_VFS_ENTITLED_RESERVE_ACCESS_ON c_int :: 1 +WNOHANG c_int :: 1 +WUNTRACED c_int :: 2 +WCOREFLAG c_int :: 128 +_WSTOPPED c_int :: 127 +WEXITED c_int :: 4 +WSTOPPED c_int :: 8 +WCONTINUED c_int :: 16 +WNOWAIT c_int :: 32 +WAIT_MYPGRP c_int :: 0 +_QUAD_HIGHWORD c_int :: 1 +_QUAD_LOWWORD c_int :: 0 +EXIT_FAILURE c_int :: 1 +EXIT_SUCCESS c_int :: 0 +RAND_MAX c_int :: 2147483647 +_MALLOC_TYPE_MALLOC_BACKDEPLOY_PUBLIC c_int :: 1 +P_ALL c_uint :: 0 +P_PID c_uint :: 1 +P_PGID c_uint :: 2 + +signal c_func(_ c_int, _ ?*c_func(_ c_int) void) ?*c_func(_ c_int) void +getpriority c_func(_ c_int, _ c_uint) c_int +getiopolicy_np c_func(_ c_int, _ c_int) c_int +getrlimit c_func(_ c_int, _ ?*mut rlimit) c_int +getrusage c_func(_ c_int, _ ?*mut rusage) c_int +setpriority c_func(_ c_int, _ c_uint, _ c_int) c_int +setiopolicy_np c_func(_ c_int, _ c_int, _ c_int) c_int +setrlimit c_func(_ c_int, _ ?*rlimit) c_int +# unsupported in bindings: function '_OSSwapInt16' is a static inline function (needs trampoline) +# unsupported in bindings: function '_OSSwapInt32' is a static inline function (needs trampoline) +# unsupported in bindings: function '_OSSwapInt64' is a static inline function (needs trampoline) +wait c_func(_ ?*mut c_int) c_int +waitpid c_func(_ c_int, _ ?*mut c_int, _ c_int) c_int +waitid c_func(_ c_uint, _ c_uint, _ ?*mut __siginfo, _ c_int) c_int +wait3 c_func(_ ?*mut c_int, _ c_int, _ ?*mut rusage) c_int +wait4 c_func(_ c_int, _ ?*mut c_int, _ c_int, _ ?*mut rusage) c_int +alloca c_func(__size c_ulong) ?*mut anyopaque +malloc_type_malloc c_func(size c_ulong, type_id c_ulonglong) ?*mut anyopaque +malloc_type_calloc c_func(count c_ulong, size c_ulong, type_id c_ulonglong) ?*mut anyopaque +malloc_type_free c_func(ptr ?*mut anyopaque, type_id c_ulonglong) void +malloc_type_realloc c_func(ptr ?*mut anyopaque, size c_ulong, type_id c_ulonglong) ?*mut anyopaque +malloc_type_valloc c_func(size c_ulong, type_id c_ulonglong) ?*mut anyopaque +malloc_type_aligned_alloc c_func(alignment c_ulong, size c_ulong, type_id c_ulonglong) ?*mut anyopaque +malloc_type_posix_memalign c_func(memptr ?*mut ?*mut anyopaque, alignment c_ulong, size c_ulong, type_id c_ulonglong) c_int +malloc_type_zone_malloc c_func(zone ?*mut _malloc_zone_t, size c_ulong, type_id c_ulonglong) ?*mut anyopaque +malloc_type_zone_calloc c_func(zone ?*mut _malloc_zone_t, count c_ulong, size c_ulong, type_id c_ulonglong) ?*mut anyopaque +malloc_type_zone_free c_func(zone ?*mut _malloc_zone_t, ptr ?*mut anyopaque, type_id c_ulonglong) void +malloc_type_zone_realloc c_func(zone ?*mut _malloc_zone_t, ptr ?*mut anyopaque, size c_ulong, type_id c_ulonglong) ?*mut anyopaque +malloc_type_zone_valloc c_func(zone ?*mut _malloc_zone_t, size c_ulong, type_id c_ulonglong) ?*mut anyopaque +malloc_type_zone_memalign c_func(zone ?*mut _malloc_zone_t, alignment c_ulong, size c_ulong, type_id c_ulonglong) ?*mut anyopaque malloc c_func(__size c_ulong) ?*mut anyopaque -realloc c_func(__ptr ?*mut anyopaque, __size c_ulong) ?*mut anyopaque +calloc c_func(__count c_ulong, __size c_ulong) ?*mut anyopaque free c_func(_ ?*mut anyopaque) void +realloc c_func(__ptr ?*mut anyopaque, __size c_ulong) ?*mut anyopaque +reallocf c_func(__ptr ?*mut anyopaque, __size c_ulong) ?*mut anyopaque +valloc c_func(__size c_ulong) ?*mut anyopaque +aligned_alloc c_func(__alignment c_ulong, __size c_ulong) ?*mut anyopaque posix_memalign c_func(__memptr ?*mut ?*mut anyopaque, __alignment c_ulong, __size c_ulong) c_int +abort c_func() void +abs c_func(_ c_int) c_int +atexit c_func(_ ?*c_func() void) c_int +at_quick_exit c_func(_ ?*c_func() void) c_int +atof c_func(_ ?*c_char) c_double +atoi c_func(_ ?*c_char) c_int +atol c_func(_ ?*c_char) c_long +atoll c_func(_ ?*c_char) c_longlong +bsearch c_func(__key ?*anyopaque, __base ?*anyopaque, __nel c_ulong, __width c_ulong, __compar ?*c_func(_ ?*anyopaque, _ ?*anyopaque) c_int) ?*mut anyopaque +div c_func(_ c_int, _ c_int) div_t +exit c_func(_ c_int) void +getenv c_func(_ ?*c_char) ?*mut c_char +labs c_func(_ c_long) c_long +ldiv c_func(_ c_long, _ c_long) ldiv_t +llabs c_func(_ c_longlong) c_longlong +lldiv c_func(_ c_longlong, _ c_longlong) lldiv_t +mblen c_func(__s ?*c_char, __n c_ulong) c_int +mbstowcs c_func(_ ?*mut c_int, _ ?*c_char, __n c_ulong) c_ulong +mbtowc c_func(_ ?*mut c_int, _ ?*c_char, __n c_ulong) c_int +qsort c_func(__base ?*mut anyopaque, __nel c_ulong, __width c_ulong, __compar ?*c_func(_ ?*anyopaque, _ ?*anyopaque) c_int) void +quick_exit c_func(_ c_int) void +rand c_func() c_int +srand c_func(_ c_uint) void +strtod c_func(_ ?*c_char, _ ?*mut ?*mut c_char) c_double +strtof c_func(_ ?*c_char, _ ?*mut ?*mut c_char) c_float +strtol c_func(__str ?*c_char, __endptr ?*mut ?*mut c_char, __base c_int) c_long +strtold c_func(_ ?*c_char, _ ?*mut ?*mut c_char) c_longdouble +strtoll c_func(__str ?*c_char, __endptr ?*mut ?*mut c_char, __base c_int) c_longlong +strtoul c_func(__str ?*c_char, __endptr ?*mut ?*mut c_char, __base c_int) c_ulong +strtoull c_func(__str ?*c_char, __endptr ?*mut ?*mut c_char, __base c_int) c_ulonglong +system c_func(_ ?*c_char) c_int +wcstombs c_func(_ ?*mut c_char, _ ?*c_int, __n c_ulong) c_ulong +wctomb c_func(_ ?*mut c_char, _ c_int) c_int +_Exit c_func(_ c_int) void +a64l c_func(_ ?*c_char) c_long +drand48 c_func() c_double +ecvt c_func(_ c_double, _ c_int, _ ?*mut c_int, _ ?*mut c_int) ?*mut c_char +erand48 c_func(_ ?*mut c_ushort) c_double +fcvt c_func(_ c_double, _ c_int, _ ?*mut c_int, _ ?*mut c_int) ?*mut c_char +gcvt c_func(_ c_double, _ c_int, _ ?*mut c_char) ?*mut c_char +getsubopt c_func(_ ?*mut ?*mut c_char, _ ?*?*mut c_char, _ ?*mut ?*mut c_char) c_int +grantpt c_func(_ c_int) c_int +initstate c_func(_ c_uint, _ ?*mut c_char, __size c_ulong) ?*mut c_char +jrand48 c_func(_ ?*mut c_ushort) c_long +l64a c_func(_ c_long) ?*mut c_char +lcong48 c_func(_ ?*mut c_ushort) void +lrand48 c_func() c_long +mktemp c_func(_ ?*mut c_char) ?*mut c_char +mkstemp c_func(_ ?*mut c_char) c_int +mrand48 c_func() c_long +nrand48 c_func(_ ?*mut c_ushort) c_long +posix_openpt c_func(_ c_int) c_int +ptsname c_func(_ c_int) ?*mut c_char +ptsname_r c_func(fildes c_int, buffer ?*mut c_char, buflen c_ulong) c_int +putenv c_func(_ ?*mut c_char) c_int +random c_func() c_long +rand_r c_func(_ ?*mut c_uint) c_int +realpath c_func(_ ?*c_char, _ ?*mut c_char) ?*mut c_char +seed48 c_func(_ ?*mut c_ushort) ?*mut c_ushort +setenv c_func(__name ?*c_char, __value ?*c_char, __overwrite c_int) c_int +setkey c_func(_ ?*c_char) void +setstate c_func(_ ?*c_char) ?*mut c_char +srand48 c_func(_ c_long) void +srandom c_func(_ c_uint) void +unlockpt c_func(_ c_int) c_int +unsetenv c_func(_ ?*c_char) c_int +arc4random c_func() c_uint +arc4random_addrandom c_func(_ ?*mut c_uchar, __datlen c_int) void +arc4random_buf c_func(__buf ?*mut anyopaque, __nbytes c_ulong) void +arc4random_stir c_func() void +arc4random_uniform c_func(__upper_bound c_uint) c_uint +# unsupported in bindings: function 'atexit_b' — function parameter type is not supported +# unsupported in bindings: function 'bsearch_b' — function parameter type is not supported +cgetcap c_func(_ ?*mut c_char, _ ?*c_char, _ c_int) ?*mut c_char +cgetclose c_func() c_int +cgetent c_func(_ ?*mut ?*mut c_char, _ ?*mut ?*mut c_char, _ ?*c_char) c_int +cgetfirst c_func(_ ?*mut ?*mut c_char, _ ?*mut ?*mut c_char) c_int +cgetmatch c_func(_ ?*c_char, _ ?*c_char) c_int +cgetnext c_func(_ ?*mut ?*mut c_char, _ ?*mut ?*mut c_char) c_int +cgetnum c_func(_ ?*mut c_char, _ ?*c_char, _ ?*mut c_long) c_int +cgetset c_func(_ ?*c_char) c_int +cgetstr c_func(_ ?*mut c_char, _ ?*c_char, _ ?*mut ?*mut c_char) c_int +cgetustr c_func(_ ?*mut c_char, _ ?*c_char, _ ?*mut ?*mut c_char) c_int +daemon c_func(_ c_int, _ c_int) c_int +devname c_func(_ c_int, _ c_ushort) ?*mut c_char +devname_r c_func(_ c_int, _ c_ushort, buf ?*mut c_char, len c_int) ?*mut c_char +getbsize c_func(_ ?*mut c_int, _ ?*mut c_long) ?*mut c_char +getloadavg c_func(_ ?*mut c_double, __nelem c_int) c_int +getprogname c_func() ?*c_char +setprogname c_func(_ ?*c_char) void +heapsort c_func(__base ?*mut anyopaque, __nel c_ulong, __width c_ulong, __compar ?*c_func(_ ?*anyopaque, _ ?*anyopaque) c_int) c_int +# unsupported in bindings: function 'heapsort_b' — function parameter type is not supported +mergesort c_func(__base ?*mut anyopaque, __nel c_ulong, __width c_ulong, __compar ?*c_func(_ ?*anyopaque, _ ?*anyopaque) c_int) c_int +# unsupported in bindings: function 'mergesort_b' — function parameter type is not supported +psort c_func(__base ?*mut anyopaque, __nel c_ulong, __width c_ulong, __compar ?*c_func(_ ?*anyopaque, _ ?*anyopaque) c_int) void +# unsupported in bindings: function 'psort_b' — function parameter type is not supported +psort_r c_func(__base ?*mut anyopaque, __nel c_ulong, __width c_ulong, _ ?*mut anyopaque, __compar ?*c_func(_ ?*mut anyopaque, _ ?*anyopaque, _ ?*anyopaque) c_int) void +# unsupported in bindings: function 'qsort_b' — function parameter type is not supported +qsort_r c_func(__base ?*mut anyopaque, __nel c_ulong, __width c_ulong, _ ?*mut anyopaque, __compar ?*c_func(_ ?*mut anyopaque, _ ?*anyopaque, _ ?*anyopaque) c_int) void +radixsort c_func(__base ?*mut ?*c_uchar, __nel c_int, __table ?*c_uchar, __endbyte c_uint) c_int +rpmatch c_func(_ ?*c_char) c_int +sradixsort c_func(__base ?*mut ?*c_uchar, __nel c_int, __table ?*c_uchar, __endbyte c_uint) c_int +sranddev c_func() void +srandomdev c_func() void +strtonum c_func(__numstr ?*c_char, __minval c_longlong, __maxval c_longlong, __errstrp ?*mut ?*c_char) c_longlong +strtoq c_func(__str ?*c_char, __endptr ?*mut ?*mut c_char, __base c_int) c_longlong +strtouq c_func(__str ?*c_char, __endptr ?*mut ?*mut c_char, __base c_int) c_ulonglong + +# unsupported in bindings: external variable '__mb_cur_max' has no native spelling +# unsupported in bindings: external variable 'suboptarg' has no native spelling +# unsupported in bindings: _STDLIB_H_ — C macro has no replacement value +# unsupported in bindings: _LIBC_COUNT__MB_LEN_MAX — C macro is not a supported constant +# unsupported in bindings: _LIBC_COUNT__PATH_MAX — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_8 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_9 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_10 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_10_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_10_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_15 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_15_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_15_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_16 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_16_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_4 — C macro is not a supported constant +# unsupported in bindings: _CDEFS_H_ — C macro has no replacement value +# unsupported in bindings: _LIBC_BOUNDS_H_ — C macro has no replacement value +# unsupported in bindings: _LIBC_COUNT — C function-like macros are not supported +# unsupported in bindings: _LIBC_COUNT_OR_NULL — C function-like macros are not supported +# unsupported in bindings: _LIBC_SIZE — C function-like macros are not supported +# unsupported in bindings: _LIBC_SIZE_OR_NULL — C function-like macros are not supported +# unsupported in bindings: _LIBC_ENDED_BY — C function-like macros are not supported +# unsupported in bindings: _LIBC_SINGLE — C macro has no replacement value +# unsupported in bindings: _LIBC_UNSAFE_INDEXABLE — C macro has no replacement value +# unsupported in bindings: _LIBC_CSTR — C macro has no replacement value +# unsupported in bindings: _LIBC_NULL_TERMINATED — C macro has no replacement value +# unsupported in bindings: _LIBC_FLEX_COUNT — C function-like macros are not supported +# unsupported in bindings: _LIBC_SINGLE_BY_DEFAULT — C function-like macros are not supported +# unsupported in bindings: _LIBC_PTRCHECK_REPLACED — C function-like macros are not supported +# unsupported in bindings: _LIBC_FORGE_PTR — C function-like macros are not supported +# unsupported in bindings: _SYS__TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _BSD_MACHINE__TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _BSD_ARM__TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _SYS__PTHREAD_TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _SYS_WAIT_H_ — C macro has no replacement value +# unsupported in bindings: _PID_T — C macro has no replacement value +# unsupported in bindings: _ID_T — C macro has no replacement value +# unsupported in bindings: _SYS_SIGNAL_H_ — C macro has no replacement value +# unsupported in bindings: NSIG — C macro is not a supported constant +# unsupported in bindings: _BSD_MACHINE_SIGNAL_H_ — C macro has no replacement value +# unsupported in bindings: SIGIOT — C macro is not a supported constant +# unsupported in bindings: SIG_DFL — C macro is not a supported constant +# unsupported in bindings: SIG_IGN — C macro is not a supported constant +# unsupported in bindings: SIG_HOLD — C macro is not a supported constant +# unsupported in bindings: SIG_ERR — C macro is not a supported constant +# unsupported in bindings: _BSD_MACHINE__MCONTEXT_H_ — C macro has no replacement value +# unsupported in bindings: _MACH_MACHINE__STRUCTS_H_ — C macro has no replacement value +# unsupported in bindings: _MACH_ARM__STRUCTS_H_ — C macro has no replacement value +# unsupported in bindings: _BSD_MACHINE_TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _ARM_MACHTYPES_H_ — C macro has no replacement value +# unsupported in bindings: _MACHTYPES_H_ — C macro has no replacement value +# unsupported in bindings: _INT8_T — C macro has no replacement value +# unsupported in bindings: _INT16_T — C macro has no replacement value +# unsupported in bindings: _INT32_T — C macro has no replacement value +# unsupported in bindings: _INT64_T — C macro has no replacement value +# unsupported in bindings: _U_INT8_T — C macro has no replacement value +# unsupported in bindings: _U_INT16_T — C macro has no replacement value +# unsupported in bindings: _U_INT32_T — C macro has no replacement value +# unsupported in bindings: _U_INT64_T — C macro has no replacement value +# unsupported in bindings: _INTPTR_T — C macro has no replacement value +# unsupported in bindings: _UINTPTR_T — C macro has no replacement value +# unsupported in bindings: USER_ADDR_NULL — C macro is not a supported constant +# unsupported in bindings: CAST_USER_ADDR_T — C function-like macros are not supported +# unsupported in bindings: _STRUCT_ARM_EXCEPTION_STATE — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_EXCEPTION_STATE64 — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_EXCEPTION_STATE64_V2 — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_THREAD_STATE — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_THREAD_STATE64 — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_VFP_STATE — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_NEON_STATE64 — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_NEON_STATE — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_PAGEIN_STATE — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_SME_STATE — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_SVE_Z_STATE — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_SVE_P_STATE — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_SME_ZA_STATE — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_SME2_STATE — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_LEGACY_DEBUG_STATE — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_DEBUG_STATE32 — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_DEBUG_STATE64 — C macro is not a supported constant +# unsupported in bindings: _STRUCT_ARM_CPMU_STATE64 — C macro is not a supported constant +# unsupported in bindings: _STRUCT_MCONTEXT32 — C macro is not a supported constant +# unsupported in bindings: _STRUCT_MCONTEXT64 — C macro is not a supported constant +# unsupported in bindings: _MCONTEXT_T — C macro has no replacement value +# unsupported in bindings: _STRUCT_MCONTEXT — C macro is not a supported constant +# unsupported in bindings: _PTHREAD_ATTR_T — C macro has no replacement value +# unsupported in bindings: _STRUCT_SIGALTSTACK — C macro is not a supported constant +# unsupported in bindings: _STRUCT_UCONTEXT — C macro is not a supported constant +# unsupported in bindings: _SIGSET_T — C macro has no replacement value +# unsupported in bindings: _SIZE_T — C macro has no replacement value +# unsupported in bindings: _UID_T — C macro has no replacement value +# unsupported in bindings: sa_handler — C macro is not a supported constant +# unsupported in bindings: sa_sigaction — C macro is not a supported constant +# unsupported in bindings: SA_USERSPACE_MASK — C macro is not a supported constant +# unsupported in bindings: SV_ONSTACK — C macro is not a supported constant +# unsupported in bindings: SV_INTERRUPT — C macro is not a supported constant +# unsupported in bindings: SV_RESETHAND — C macro is not a supported constant +# unsupported in bindings: SV_NODEFER — C macro is not a supported constant +# unsupported in bindings: SV_NOCLDSTOP — C macro is not a supported constant +# unsupported in bindings: SV_SIGINFO — C macro is not a supported constant +# unsupported in bindings: sv_onstack — C macro is not a supported constant +# unsupported in bindings: sigmask — C function-like macros are not supported +# unsupported in bindings: BADSIG — C macro is not a supported constant +# unsupported in bindings: _SYS_RESOURCE_H_ — C macro has no replacement value +# unsupported in bindings: _STDINT_H_ — C macro has no replacement value +# unsupported in bindings: _UINT8_T — C macro has no replacement value +# unsupported in bindings: _UINT16_T — C macro has no replacement value +# unsupported in bindings: _UINT32_T — C macro has no replacement value +# unsupported in bindings: _UINT64_T — C macro has no replacement value +# unsupported in bindings: _INTMAX_T — C macro has no replacement value +# unsupported in bindings: _UINTMAX_T — C macro has no replacement value +# unsupported in bindings: INT8_C — C function-like macros are not supported +# unsupported in bindings: INT16_C — C function-like macros are not supported +# unsupported in bindings: INT32_C — C function-like macros are not supported +# unsupported in bindings: INT64_C — C function-like macros are not supported +# unsupported in bindings: UINT8_C — C function-like macros are not supported +# unsupported in bindings: UINT16_C — C function-like macros are not supported +# unsupported in bindings: UINT32_C — C function-like macros are not supported +# unsupported in bindings: UINT64_C — C function-like macros are not supported +# unsupported in bindings: INTMAX_C — C function-like macros are not supported +# unsupported in bindings: UINTMAX_C — C function-like macros are not supported +# unsupported in bindings: INT32_MIN — C macro is not a supported constant +# unsupported in bindings: INT64_MIN — C macro is not a supported constant +# unsupported in bindings: INT_LEAST8_MIN — C macro is not a supported constant +# unsupported in bindings: INT_LEAST16_MIN — C macro is not a supported constant +# unsupported in bindings: INT_LEAST32_MIN — C macro is not a supported constant +# unsupported in bindings: INT_LEAST64_MIN — C macro is not a supported constant +# unsupported in bindings: INT_LEAST8_MAX — C macro is not a supported constant +# unsupported in bindings: INT_LEAST16_MAX — C macro is not a supported constant +# unsupported in bindings: INT_LEAST32_MAX — C macro is not a supported constant +# unsupported in bindings: INT_LEAST64_MAX — C macro is not a supported constant +# unsupported in bindings: UINT_LEAST8_MAX — C macro is not a supported constant +# unsupported in bindings: UINT_LEAST16_MAX — C macro is not a supported constant +# unsupported in bindings: UINT_LEAST32_MAX — C macro is not a supported constant +# unsupported in bindings: UINT_LEAST64_MAX — C macro is not a supported constant +# unsupported in bindings: INT_FAST8_MIN — C macro is not a supported constant +# unsupported in bindings: INT_FAST16_MIN — C macro is not a supported constant +# unsupported in bindings: INT_FAST32_MIN — C macro is not a supported constant +# unsupported in bindings: INT_FAST64_MIN — C macro is not a supported constant +# unsupported in bindings: INT_FAST8_MAX — C macro is not a supported constant +# unsupported in bindings: INT_FAST16_MAX — C macro is not a supported constant +# unsupported in bindings: INT_FAST32_MAX — C macro is not a supported constant +# unsupported in bindings: INT_FAST64_MAX — C macro is not a supported constant +# unsupported in bindings: UINT_FAST8_MAX — C macro is not a supported constant +# unsupported in bindings: UINT_FAST16_MAX — C macro is not a supported constant +# unsupported in bindings: UINT_FAST32_MAX — C macro is not a supported constant +# unsupported in bindings: UINT_FAST64_MAX — C macro is not a supported constant +# unsupported in bindings: INTPTR_MIN — C macro is not a supported constant +# unsupported in bindings: INTMAX_MAX — C macro is not a supported constant +# unsupported in bindings: UINTMAX_MAX — C macro is not a supported constant +# unsupported in bindings: INTMAX_MIN — C macro is not a supported constant +# unsupported in bindings: PTRDIFF_MIN — C macro is not a supported constant +# unsupported in bindings: PTRDIFF_MAX — C macro is not a supported constant +# unsupported in bindings: SIZE_MAX — C macro is not a supported constant +# unsupported in bindings: RSIZE_MAX — C macro is not a supported constant +# unsupported in bindings: WCHAR_MAX — C macro is not a supported constant +# unsupported in bindings: WCHAR_MIN — C macro is not a supported constant +# unsupported in bindings: WINT_MIN — C macro is not a supported constant +# unsupported in bindings: WINT_MAX — C macro is not a supported constant +# unsupported in bindings: SIG_ATOMIC_MIN — C macro is not a supported constant +# unsupported in bindings: SIG_ATOMIC_MAX — C macro is not a supported constant +# unsupported in bindings: _STRUCT_TIMEVAL — C macro is not a supported constant +# unsupported in bindings: ru_first — C macro is not a supported constant +# unsupported in bindings: ru_last — C macro is not a supported constant +# unsupported in bindings: RUSAGE_INFO_CURRENT — C macro is not a supported constant +# unsupported in bindings: RLIM_INFINITY — C macro is not a supported constant +# unsupported in bindings: RLIM_SAVED_MAX — C macro is not a supported constant +# unsupported in bindings: RLIM_SAVED_CUR — C macro is not a supported constant +# unsupported in bindings: RLIMIT_RSS — C macro is not a supported constant +# unsupported in bindings: IOPOL_APPLICATION — C macro is not a supported constant +# unsupported in bindings: IOPOL_NORMAL — C macro is not a supported constant +# unsupported in bindings: _W_INT — C function-like macros are not supported +# unsupported in bindings: _WSTATUS — C function-like macros are not supported +# unsupported in bindings: WEXITSTATUS — C function-like macros are not supported +# unsupported in bindings: WSTOPSIG — C function-like macros are not supported +# unsupported in bindings: WIFCONTINUED — C function-like macros are not supported +# unsupported in bindings: WIFSTOPPED — C function-like macros are not supported +# unsupported in bindings: WIFEXITED — C function-like macros are not supported +# unsupported in bindings: WIFSIGNALED — C function-like macros are not supported +# unsupported in bindings: WTERMSIG — C function-like macros are not supported +# unsupported in bindings: WCOREDUMP — C function-like macros are not supported +# unsupported in bindings: W_EXITCODE — C function-like macros are not supported +# unsupported in bindings: W_STOPCODE — C function-like macros are not supported +# unsupported in bindings: WAIT_ANY — C macro is not a supported constant +# unsupported in bindings: _BSD_MACHINE_ENDIAN_H_ — C macro has no replacement value +# unsupported in bindings: _ARM__ENDIAN_H_ — C macro has no replacement value +# unsupported in bindings: _SYS__ENDIAN_H_ — C macro has no replacement value +# unsupported in bindings: _BSD_MACHINE__ENDIAN_H_ — C macro has no replacement value +# unsupported in bindings: _ARM___ENDIAN_H_ — C macro has no replacement value +# unsupported in bindings: _SYS___ENDIAN_H_ — C macro has no replacement value +# unsupported in bindings: LITTLE_ENDIAN — C macro is not a supported constant +# unsupported in bindings: BIG_ENDIAN — C macro is not a supported constant +# unsupported in bindings: PDP_ENDIAN — C macro is not a supported constant +# unsupported in bindings: BYTE_ORDER — C macro is not a supported constant +# unsupported in bindings: _OS__OSBYTEORDER_H — C macro has no replacement value +# unsupported in bindings: _OS__OSBYTEORDERARM_H — C macro has no replacement value +# unsupported in bindings: ntohs — C function-like macros are not supported +# unsupported in bindings: htons — C function-like macros are not supported +# unsupported in bindings: ntohl — C function-like macros are not supported +# unsupported in bindings: htonl — C function-like macros are not supported +# unsupported in bindings: ntohll — C function-like macros are not supported +# unsupported in bindings: htonll — C function-like macros are not supported +# unsupported in bindings: NTOHL — C function-like macros are not supported +# unsupported in bindings: NTOHS — C function-like macros are not supported +# unsupported in bindings: NTOHLL — C function-like macros are not supported +# unsupported in bindings: HTONL — C function-like macros are not supported +# unsupported in bindings: HTONS — C function-like macros are not supported +# unsupported in bindings: HTONLL — C function-like macros are not supported +# unsupported in bindings: w_termsig — C macro is not a supported constant +# unsupported in bindings: w_coredump — C macro is not a supported constant +# unsupported in bindings: w_retcode — C macro is not a supported constant +# unsupported in bindings: w_stopval — C macro is not a supported constant +# unsupported in bindings: w_stopsig — C macro is not a supported constant +# unsupported in bindings: _ALLOCA_H_ — C macro has no replacement value +# unsupported in bindings: alloca — C function-like macros are not supported +# unsupported in bindings: _CT_RUNE_T — C macro has no replacement value +# unsupported in bindings: _RUNE_T — C macro has no replacement value +# unsupported in bindings: _WCHAR_T — C macro has no replacement value +# unsupported in bindings: NULL — C macro is not a supported constant +# unsupported in bindings: MB_CUR_MAX — C macro is not a supported constant +# unsupported in bindings: _MALLOC_UNDERSCORE_MALLOC_H_ — C macro has no replacement value +# unsupported in bindings: _MALLOC_UNDERSCORE_MALLOC_TYPE_H_ — C macro has no replacement value +# unsupported in bindings: _MALLOC_UNDERSCORE_PTRCHECK_H_ — C macro has no replacement value +# unsupported in bindings: _MALLOC_TYPED — C function-like macros are not supported +# unsupported in bindings: _DEV_T — C macro has no replacement value +# unsupported in bindings: _MODE_T — C macro has no replacement value diff --git a/ffi/c/unistd.bro b/ffi/c/unistd.bro new file mode 100644 index 0000000..6995147 --- /dev/null +++ b/ffi/c/unistd.bro @@ -0,0 +1,661 @@ +# generated by brolang translate-c from unistd.h + +# unsupported in bindings: C union '__mbstate_t' has no native spelling +accessx_descriptor :: c_struct { + ad_name_offset c_uint + ad_flags c_int + ad_pad [2]c_int +} +fd_set :: c_struct { + fds_bits [32]c_int +} +timespec :: c_struct { + tv_sec c_long + tv_nsec c_long +} +fssearchblock :: opaque +searchstate :: opaque + +# unsupported in bindings: typedef '__mbstate_t' — underlying type has no native spelling +# unsupported in bindings: typedef '__darwin_mbstate_t' — underlying type has no native spelling +gid_t :: alias c_uint +useconds_t :: alias c_uint +time_t :: alias c_long +suseconds_t :: alias c_int +uuid_t :: alias [16]c_uchar +# unsupported in bindings: typedef 'fssearchblock' — underlying type has no native spelling +# unsupported in bindings: typedef 'searchstate' — underlying type has no native spelling + +_POSIX_VERSION c_long :: 200112 +_POSIX2_VERSION c_long :: 200112 +_POSIX_THREAD_KEYS_MAX c_int :: 128 +F_OK c_int :: 0 +ACCESSX_MAX_DESCRIPTORS c_int :: 100 +_PC_LINK_MAX c_int :: 1 +_PC_MAX_CANON c_int :: 2 +_PC_MAX_INPUT c_int :: 3 +_PC_NAME_MAX c_int :: 4 +_PC_PATH_MAX c_int :: 5 +_PC_PIPE_BUF c_int :: 6 +_PC_CHOWN_RESTRICTED c_int :: 7 +_PC_NO_TRUNC c_int :: 8 +_PC_VDISABLE c_int :: 9 +_PC_NAME_CHARS_MAX c_int :: 10 +_PC_CASE_SENSITIVE c_int :: 11 +_PC_CASE_PRESERVING c_int :: 12 +_PC_EXTENDED_SECURITY_NP c_int :: 13 +_PC_AUTH_OPAQUE_NP c_int :: 14 +_PC_2_SYMLINKS c_int :: 15 +_PC_ALLOC_SIZE_MIN c_int :: 16 +_PC_ASYNC_IO c_int :: 17 +_PC_FILESIZEBITS c_int :: 18 +_PC_PRIO_IO c_int :: 19 +_PC_REC_INCR_XFER_SIZE c_int :: 20 +_PC_REC_MAX_XFER_SIZE c_int :: 21 +_PC_REC_MIN_XFER_SIZE c_int :: 22 +_PC_REC_XFER_ALIGN c_int :: 23 +_PC_SYMLINK_MAX c_int :: 24 +_PC_SYNC_IO c_int :: 25 +_PC_XATTR_SIZE_BITS c_int :: 26 +_PC_MIN_HOLE_SIZE c_int :: 27 +_CS_PATH c_int :: 1 +STDIN_FILENO c_int :: 0 +STDOUT_FILENO c_int :: 1 +STDERR_FILENO c_int :: 2 +_XOPEN_VERSION c_int :: 600 +_XOPEN_XCU_VERSION c_int :: 4 +_POSIX_CHOWN_RESTRICTED c_long :: 200112 +_POSIX_FSYNC c_long :: 200112 +_POSIX_IPV6 c_long :: 200112 +_POSIX_JOB_CONTROL c_long :: 200112 +_POSIX_MAPPED_FILES c_long :: 200112 +_POSIX_MEMORY_PROTECTION c_long :: 200112 +_POSIX_NO_TRUNC c_long :: 200112 +_POSIX_READER_WRITER_LOCKS c_long :: 200112 +_POSIX_REGEXP c_long :: 200112 +_POSIX_SAVED_IDS c_long :: 200112 +_POSIX_SHELL c_long :: 200112 +_POSIX_SPAWN c_long :: 200112 +_POSIX_THREAD_ATTR_STACKADDR c_long :: 200112 +_POSIX_THREAD_ATTR_STACKSIZE c_long :: 200112 +_POSIX_THREAD_PROCESS_SHARED c_long :: 200112 +_POSIX_THREAD_SAFE_FUNCTIONS c_long :: 200112 +_POSIX_THREADS c_long :: 200112 +_POSIX2_C_BIND c_long :: 200112 +_POSIX2_C_DEV c_long :: 200112 +_POSIX2_CHAR_TERM c_long :: 200112 +_POSIX2_FORT_RUN c_long :: 200112 +_POSIX2_LOCALEDEF c_long :: 200112 +_POSIX2_SW_DEV c_long :: 200112 +_POSIX2_UPE c_long :: 200112 +_SC_ARG_MAX c_int :: 1 +_SC_CHILD_MAX c_int :: 2 +_SC_CLK_TCK c_int :: 3 +_SC_NGROUPS_MAX c_int :: 4 +_SC_OPEN_MAX c_int :: 5 +_SC_JOB_CONTROL c_int :: 6 +_SC_SAVED_IDS c_int :: 7 +_SC_VERSION c_int :: 8 +_SC_BC_BASE_MAX c_int :: 9 +_SC_BC_DIM_MAX c_int :: 10 +_SC_BC_SCALE_MAX c_int :: 11 +_SC_BC_STRING_MAX c_int :: 12 +_SC_COLL_WEIGHTS_MAX c_int :: 13 +_SC_EXPR_NEST_MAX c_int :: 14 +_SC_LINE_MAX c_int :: 15 +_SC_RE_DUP_MAX c_int :: 16 +_SC_2_VERSION c_int :: 17 +_SC_2_C_BIND c_int :: 18 +_SC_2_C_DEV c_int :: 19 +_SC_2_CHAR_TERM c_int :: 20 +_SC_2_FORT_DEV c_int :: 21 +_SC_2_FORT_RUN c_int :: 22 +_SC_2_LOCALEDEF c_int :: 23 +_SC_2_SW_DEV c_int :: 24 +_SC_2_UPE c_int :: 25 +_SC_STREAM_MAX c_int :: 26 +_SC_TZNAME_MAX c_int :: 27 +_SC_ASYNCHRONOUS_IO c_int :: 28 +_SC_PAGESIZE c_int :: 29 +_SC_MEMLOCK c_int :: 30 +_SC_MEMLOCK_RANGE c_int :: 31 +_SC_MEMORY_PROTECTION c_int :: 32 +_SC_MESSAGE_PASSING c_int :: 33 +_SC_PRIORITIZED_IO c_int :: 34 +_SC_PRIORITY_SCHEDULING c_int :: 35 +_SC_REALTIME_SIGNALS c_int :: 36 +_SC_SEMAPHORES c_int :: 37 +_SC_FSYNC c_int :: 38 +_SC_SHARED_MEMORY_OBJECTS c_int :: 39 +_SC_SYNCHRONIZED_IO c_int :: 40 +_SC_TIMERS c_int :: 41 +_SC_AIO_LISTIO_MAX c_int :: 42 +_SC_AIO_MAX c_int :: 43 +_SC_AIO_PRIO_DELTA_MAX c_int :: 44 +_SC_DELAYTIMER_MAX c_int :: 45 +_SC_MQ_OPEN_MAX c_int :: 46 +_SC_MAPPED_FILES c_int :: 47 +_SC_RTSIG_MAX c_int :: 48 +_SC_SEM_NSEMS_MAX c_int :: 49 +_SC_SEM_VALUE_MAX c_int :: 50 +_SC_SIGQUEUE_MAX c_int :: 51 +_SC_TIMER_MAX c_int :: 52 +_SC_NPROCESSORS_CONF c_int :: 57 +_SC_NPROCESSORS_ONLN c_int :: 58 +_SC_2_PBS c_int :: 59 +_SC_2_PBS_ACCOUNTING c_int :: 60 +_SC_2_PBS_CHECKPOINT c_int :: 61 +_SC_2_PBS_LOCATE c_int :: 62 +_SC_2_PBS_MESSAGE c_int :: 63 +_SC_2_PBS_TRACK c_int :: 64 +_SC_ADVISORY_INFO c_int :: 65 +_SC_BARRIERS c_int :: 66 +_SC_CLOCK_SELECTION c_int :: 67 +_SC_CPUTIME c_int :: 68 +_SC_FILE_LOCKING c_int :: 69 +_SC_GETGR_R_SIZE_MAX c_int :: 70 +_SC_GETPW_R_SIZE_MAX c_int :: 71 +_SC_HOST_NAME_MAX c_int :: 72 +_SC_LOGIN_NAME_MAX c_int :: 73 +_SC_MONOTONIC_CLOCK c_int :: 74 +_SC_MQ_PRIO_MAX c_int :: 75 +_SC_READER_WRITER_LOCKS c_int :: 76 +_SC_REGEXP c_int :: 77 +_SC_SHELL c_int :: 78 +_SC_SPAWN c_int :: 79 +_SC_SPIN_LOCKS c_int :: 80 +_SC_SPORADIC_SERVER c_int :: 81 +_SC_THREAD_ATTR_STACKADDR c_int :: 82 +_SC_THREAD_ATTR_STACKSIZE c_int :: 83 +_SC_THREAD_CPUTIME c_int :: 84 +_SC_THREAD_DESTRUCTOR_ITERATIONS c_int :: 85 +_SC_THREAD_KEYS_MAX c_int :: 86 +_SC_THREAD_PRIO_INHERIT c_int :: 87 +_SC_THREAD_PRIO_PROTECT c_int :: 88 +_SC_THREAD_PRIORITY_SCHEDULING c_int :: 89 +_SC_THREAD_PROCESS_SHARED c_int :: 90 +_SC_THREAD_SAFE_FUNCTIONS c_int :: 91 +_SC_THREAD_SPORADIC_SERVER c_int :: 92 +_SC_THREAD_STACK_MIN c_int :: 93 +_SC_THREAD_THREADS_MAX c_int :: 94 +_SC_TIMEOUTS c_int :: 95 +_SC_THREADS c_int :: 96 +_SC_TRACE c_int :: 97 +_SC_TRACE_EVENT_FILTER c_int :: 98 +_SC_TRACE_INHERIT c_int :: 99 +_SC_TRACE_LOG c_int :: 100 +_SC_TTY_NAME_MAX c_int :: 101 +_SC_TYPED_MEMORY_OBJECTS c_int :: 102 +_SC_V6_ILP32_OFF32 c_int :: 103 +_SC_V6_ILP32_OFFBIG c_int :: 104 +_SC_V6_LP64_OFF64 c_int :: 105 +_SC_V6_LPBIG_OFFBIG c_int :: 106 +_SC_IPV6 c_int :: 118 +_SC_RAW_SOCKETS c_int :: 119 +_SC_SYMLOOP_MAX c_int :: 120 +_SC_ATEXIT_MAX c_int :: 107 +_SC_IOV_MAX c_int :: 56 +_SC_XOPEN_CRYPT c_int :: 108 +_SC_XOPEN_ENH_I18N c_int :: 109 +_SC_XOPEN_LEGACY c_int :: 110 +_SC_XOPEN_REALTIME c_int :: 111 +_SC_XOPEN_REALTIME_THREADS c_int :: 112 +_SC_XOPEN_SHM c_int :: 113 +_SC_XOPEN_STREAMS c_int :: 114 +_SC_XOPEN_UNIX c_int :: 115 +_SC_XOPEN_VERSION c_int :: 116 +_SC_XOPEN_XCU_VERSION c_int :: 121 +_SC_XBS5_ILP32_OFF32 c_int :: 122 +_SC_XBS5_ILP32_OFFBIG c_int :: 123 +_SC_XBS5_LP64_OFF64 c_int :: 124 +_SC_XBS5_LPBIG_OFFBIG c_int :: 125 +_SC_SS_REPL_MAX c_int :: 126 +_SC_TRACE_EVENT_NAME_MAX c_int :: 127 +_SC_TRACE_NAME_MAX c_int :: 128 +_SC_TRACE_SYS_MAX c_int :: 129 +_SC_TRACE_USER_EVENT_MAX c_int :: 130 +_SC_PASS_MAX c_int :: 131 +_SC_PHYS_PAGES c_int :: 200 +_CS_POSIX_V6_ILP32_OFF32_CFLAGS c_int :: 2 +_CS_POSIX_V6_ILP32_OFF32_LDFLAGS c_int :: 3 +_CS_POSIX_V6_ILP32_OFF32_LIBS c_int :: 4 +_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS c_int :: 5 +_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS c_int :: 6 +_CS_POSIX_V6_ILP32_OFFBIG_LIBS c_int :: 7 +_CS_POSIX_V6_LP64_OFF64_CFLAGS c_int :: 8 +_CS_POSIX_V6_LP64_OFF64_LDFLAGS c_int :: 9 +_CS_POSIX_V6_LP64_OFF64_LIBS c_int :: 10 +_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS c_int :: 11 +_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS c_int :: 12 +_CS_POSIX_V6_LPBIG_OFFBIG_LIBS c_int :: 13 +_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS c_int :: 14 +_CS_XBS5_ILP32_OFF32_CFLAGS c_int :: 20 +_CS_XBS5_ILP32_OFF32_LDFLAGS c_int :: 21 +_CS_XBS5_ILP32_OFF32_LIBS c_int :: 22 +_CS_XBS5_ILP32_OFF32_LINTFLAGS c_int :: 23 +_CS_XBS5_ILP32_OFFBIG_CFLAGS c_int :: 24 +_CS_XBS5_ILP32_OFFBIG_LDFLAGS c_int :: 25 +_CS_XBS5_ILP32_OFFBIG_LIBS c_int :: 26 +_CS_XBS5_ILP32_OFFBIG_LINTFLAGS c_int :: 27 +_CS_XBS5_LP64_OFF64_CFLAGS c_int :: 28 +_CS_XBS5_LP64_OFF64_LDFLAGS c_int :: 29 +_CS_XBS5_LP64_OFF64_LIBS c_int :: 30 +_CS_XBS5_LP64_OFF64_LINTFLAGS c_int :: 31 +_CS_XBS5_LPBIG_OFFBIG_CFLAGS c_int :: 32 +_CS_XBS5_LPBIG_OFFBIG_LDFLAGS c_int :: 33 +_CS_XBS5_LPBIG_OFFBIG_LIBS c_int :: 34 +_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS c_int :: 35 +_CS_DARWIN_USER_DIR c_int :: 65536 +_CS_DARWIN_USER_TEMP_DIR c_int :: 65537 +_CS_DARWIN_USER_CACHE_DIR c_int :: 65538 +F_ULOCK c_int :: 0 +F_LOCK c_int :: 1 +F_TLOCK c_int :: 2 +F_TEST c_int :: 3 +SYNC_VOLUME_FULLSYNC c_int :: 1 +SYNC_VOLUME_WAIT c_int :: 2 + +getattrlistbulk c_func(_ c_int, _ ?*mut anyopaque, _ ?*mut anyopaque, _ c_ulong, _ c_ulonglong) c_int +getattrlistat c_func(_ c_int, _ ?*c_char, _ ?*mut anyopaque, _ ?*mut anyopaque, _ c_ulong, _ c_ulong) c_int +setattrlistat c_func(_ c_int, _ ?*c_char, _ ?*mut anyopaque, _ ?*mut anyopaque, _ c_ulong, _ c_uint) c_int +freadlink c_func(_ c_int, _ ?*mut c_char, _ c_ulong) c_long +faccessat c_func(_ c_int, _ ?*c_char, _ c_int, _ c_int) c_int +fchownat c_func(_ c_int, _ ?*c_char, _ c_uint, _ c_uint, _ c_int) c_int +linkat c_func(_ c_int, _ ?*c_char, _ c_int, _ ?*c_char, _ c_int) c_int +readlinkat c_func(_ c_int, _ ?*c_char, _ ?*mut c_char, _ c_ulong) c_long +symlinkat c_func(_ ?*c_char, _ c_int, _ ?*c_char) c_int +unlinkat c_func(_ c_int, _ ?*c_char, _ c_int) c_int +_exit c_func(_ c_int) void +access c_func(_ ?*c_char, _ c_int) c_int +alarm c_func(_ c_uint) c_uint +chdir c_func(_ ?*c_char) c_int +chown c_func(_ ?*c_char, _ c_uint, _ c_uint) c_int +close c_func(_ c_int) c_int +dup c_func(_ c_int) c_int +dup2 c_func(_ c_int, _ c_int) c_int +execl c_func(__path ?*c_char, __arg0 ?*c_char, ...) c_int +execle c_func(__path ?*c_char, __arg0 ?*c_char, ...) c_int +execlp c_func(__file ?*c_char, __arg0 ?*c_char, ...) c_int +execv c_func(__path ?*c_char, __argv ?*?*mut c_char) c_int +execve c_func(__file ?*c_char, __argv ?*?*mut c_char, __envp ?*?*mut c_char) c_int +execvp c_func(__file ?*c_char, __argv ?*?*mut c_char) c_int +fork c_func() c_int +fpathconf c_func(_ c_int, _ c_int) c_long +getcwd c_func(_ ?*mut c_char, __size c_ulong) ?*mut c_char +getegid c_func() c_uint +geteuid c_func() c_uint +getgid c_func() c_uint +getgroups c_func(__gidsetsize c_int, _ ?*mut c_uint) c_int +getlogin c_func() ?*mut c_char +getpgrp c_func() c_int +getpid c_func() c_int +getppid c_func() c_int +getuid c_func() c_uint +isatty c_func(_ c_int) c_int +link c_func(_ ?*c_char, _ ?*c_char) c_int +lseek c_func(_ c_int, _ c_longlong, _ c_int) c_longlong +pathconf c_func(_ ?*c_char, _ c_int) c_long +pause c_func() c_int +pipe c_func(_ ?*mut c_int) c_int +read c_func(_ c_int, _ ?*mut anyopaque, __nbyte c_ulong) c_long +rmdir c_func(_ ?*c_char) c_int +setgid c_func(_ c_uint) c_int +setpgid c_func(_ c_int, _ c_int) c_int +setsid c_func() c_int +setuid c_func(_ c_uint) c_int +sleep c_func(_ c_uint) c_uint +sysconf c_func(_ c_int) c_long +tcgetpgrp c_func(_ c_int) c_int +tcsetpgrp c_func(_ c_int, _ c_int) c_int +ttyname c_func(_ c_int) ?*mut c_char +ttyname_r c_func(_ c_int, _ ?*mut c_char, __len c_ulong) c_int +unlink c_func(_ ?*c_char) c_int +write c_func(__fd c_int, __buf ?*anyopaque, __nbyte c_ulong) c_long +confstr c_func(_ c_int, _ ?*mut c_char, __len c_ulong) c_ulong +getopt c_func(__argc c_int, _ ?*?*mut c_char, _ ?*c_char) c_int +brk c_func(_ ?*anyopaque) ?*mut anyopaque +chroot c_func(_ ?*c_char) c_int +crypt c_func(_ ?*c_char, _ ?*c_char) ?*mut c_char +encrypt c_func(_ ?*mut c_char, _ c_int) void +fchdir c_func(_ c_int) c_int +gethostid c_func() c_long +getpgid c_func(_ c_int) c_int +getsid c_func(_ c_int) c_int +getdtablesize c_func() c_int +getpagesize c_func() c_int +getpass c_func(_ ?*c_char) ?*mut c_char +getwd c_func(_ ?*mut c_char) ?*mut c_char +lchown c_func(_ ?*c_char, _ c_uint, _ c_uint) c_int +lockf c_func(_ c_int, _ c_int, _ c_longlong) c_int +nice c_func(_ c_int) c_int +pread c_func(__fd c_int, __buf ?*mut anyopaque, __nbyte c_ulong, __offset c_longlong) c_long +pwrite c_func(__fd c_int, __buf ?*anyopaque, __nbyte c_ulong, __offset c_longlong) c_long +sbrk c_func(_ c_int) ?*mut anyopaque +setpgrp c_func() c_int +setregid c_func(_ c_uint, _ c_uint) c_int +setreuid c_func(_ c_uint, _ c_uint) c_int +swab c_func(_ ?*anyopaque, _ ?*mut anyopaque, __nbytes c_long) void +sync c_func() void +truncate c_func(_ ?*c_char, _ c_longlong) c_int +ualarm c_func(_ c_uint, _ c_uint) c_uint +usleep c_func(_ c_uint) c_int +vfork c_func() c_int +fsync c_func(_ c_int) c_int +ftruncate c_func(_ c_int, _ c_longlong) c_int +getlogin_r c_func(_ ?*mut c_char, __namelen c_ulong) c_int +fchown c_func(_ c_int, _ c_uint, _ c_uint) c_int +gethostname c_func(_ ?*mut c_char, __namelen c_ulong) c_int +readlink c_func(_ ?*c_char, _ ?*mut c_char, __bufsize c_ulong) c_long +setegid c_func(_ c_uint) c_int +seteuid c_func(_ c_uint) c_int +symlink c_func(_ ?*c_char, _ ?*c_char) c_int +__darwin_check_fd_set_overflow c_func(_ c_int, _ ?*anyopaque, _ c_int) c_int +__darwin_check_fd_set c_func(_a c_int, _b ?*anyopaque) c_int +__darwin_fd_isset c_func(_fd c_int, _p ?*fd_set) c_int +__darwin_fd_set c_func(_fd c_int, _p ?*mut fd_set) void +__darwin_fd_clr c_func(_fd c_int, _p ?*mut fd_set) void +pselect c_func(_ c_int, _ ?*mut fd_set, _ ?*mut fd_set, _ ?*mut fd_set, _ ?*timespec, _ ?*c_uint) c_int +select c_func(_ c_int, _ ?*mut fd_set, _ ?*mut fd_set, _ ?*mut fd_set, _ ?*mut timeval) c_int +accessx_np c_func(_ ?*accessx_descriptor, __sz c_ulong, _ ?*mut c_int, _ c_uint) c_int +acct c_func(_ ?*c_char) c_int +add_profil c_func(_ ?*mut c_char, __bufsiz c_ulong, _ c_ulong, _ c_uint) c_int +endusershell c_func() void +execvP c_func(__file ?*c_char, __searchpath ?*c_char, __argv ?*?*mut c_char) c_int +fflagstostr c_func(_ c_ulong) ?*mut c_char +getdomainname c_func(_ ?*mut c_char, __namelen c_int) c_int +getgrouplist c_func(_ ?*c_char, _ c_int, _ ?*mut c_int, __ngroups ?*mut c_int) c_int +gethostuuid c_func(_ ?*mut c_uchar, _ ?*timespec) c_int +getmode c_func(_ ?*anyopaque, _ c_ushort) c_ushort +getpeereid c_func(_ c_int, _ ?*mut c_uint, _ ?*mut c_uint) c_int +getsgroups_np c_func(_ ?*mut c_int, _ ?*mut c_uchar) c_int +getusershell c_func() ?*mut c_char +getwgroups_np c_func(_ ?*mut c_int, _ ?*mut c_uchar) c_int +initgroups c_func(_ ?*c_char, _ c_int) c_int +issetugid c_func() c_int +mkdtemp c_func(_ ?*mut c_char) ?*mut c_char +mknod c_func(_ ?*c_char, _ c_ushort, _ c_int) c_int +mkpath_np c_func(path ?*c_char, omode c_ushort) c_int +mkpathat_np c_func(dfd c_int, path ?*c_char, omode c_ushort) c_int +mkstemps c_func(_ ?*mut c_char, _ c_int) c_int +mkostemp c_func(path ?*mut c_char, oflags c_int) c_int +mkostemps c_func(path ?*mut c_char, slen c_int, oflags c_int) c_int +mkstemp_dprotected_np c_func(path ?*mut c_char, dpclass c_int, dpflags c_int) c_int +mkdtempat_np c_func(dfd c_int, path ?*mut c_char) ?*mut c_char +mkstempsat_np c_func(dfd c_int, path ?*mut c_char, slen c_int) c_int +mkostempsat_np c_func(dfd c_int, path ?*mut c_char, slen c_int, oflags c_int) c_int +nfssvc c_func(_ c_int, _ ?*mut anyopaque) c_int +profil c_func(_ ?*mut c_char, __bufsiz c_ulong, _ c_ulong, _ c_uint) c_int +pthread_setugid_np c_func(_ c_uint, _ c_uint) c_int +pthread_getugid_np c_func(_ ?*mut c_uint, _ ?*mut c_uint) c_int +reboot c_func(_ c_int) c_int +revoke c_func(_ ?*c_char) c_int +rcmd c_func(_ ?*mut ?*mut c_char, _ c_int, _ ?*c_char, _ ?*c_char, _ ?*c_char, _ ?*mut c_int) c_int +rcmd_af c_func(_ ?*mut ?*mut c_char, _ c_int, _ ?*c_char, _ ?*c_char, _ ?*c_char, _ ?*mut c_int, _ c_int) c_int +rresvport c_func(_ ?*mut c_int) c_int +rresvport_af c_func(_ ?*mut c_int, _ c_int) c_int +iruserok c_func(_ c_ulong, _ c_int, _ ?*c_char, _ ?*c_char) c_int +iruserok_sa c_func(_ ?*anyopaque, _ c_int, _ c_int, _ ?*c_char, _ ?*c_char) c_int +ruserok c_func(_ ?*c_char, _ c_int, _ ?*c_char, _ ?*c_char) c_int +setdomainname c_func(_ ?*c_char, __namelen c_int) c_int +setgroups c_func(_ c_int, _ ?*c_uint) c_int +sethostid c_func(_ c_long) void +sethostname c_func(_ ?*c_char, __namelen c_int) c_int +setlogin c_func(_ ?*c_char) c_int +setmode c_func(_ ?*c_char) ?*mut anyopaque +setrgid c_func(_ c_uint) c_int +setruid c_func(_ c_uint) c_int +setsgroups_np c_func(_ c_int, _ ?*mut c_uchar) c_int +setusershell c_func() void +setwgroups_np c_func(_ c_int, _ ?*mut c_uchar) c_int +strtofflags c_func(_ ?*mut ?*mut c_char, _ ?*mut c_ulong, _ ?*mut c_ulong) c_int +swapon c_func(_ ?*c_char) c_int +ttyslot c_func() c_int +undelete c_func(_ ?*c_char) c_int +unwhiteout c_func(_ ?*c_char) c_int +syscall c_func(_ c_int, ...) c_int +fgetattrlist c_func(_ c_int, _ ?*mut anyopaque, _ ?*mut anyopaque, __attrBufSize c_ulong, _ c_uint) c_int +fsetattrlist c_func(_ c_int, _ ?*mut anyopaque, _ ?*mut anyopaque, __attrBufSize c_ulong, _ c_uint) c_int +getattrlist c_func(_ ?*c_char, _ ?*mut anyopaque, _ ?*mut anyopaque, __attrBufSize c_ulong, _ c_uint) c_int +setattrlist c_func(_ ?*c_char, _ ?*mut anyopaque, _ ?*mut anyopaque, __attrBufSize c_ulong, _ c_uint) c_int +exchangedata c_func(_ ?*c_char, _ ?*c_char, _ c_uint) c_int +getdirentriesattr c_func(_ c_int, _ ?*mut anyopaque, _ ?*mut anyopaque, __attrBufSize c_ulong, _ ?*mut c_uint, _ ?*mut c_uint, _ ?*mut c_uint, _ c_uint) c_int +searchfs c_func(_ ?*c_char, _ ?*mut fssearchblock, _ ?*mut c_ulong, _ c_uint, _ c_uint, _ ?*mut searchstate) c_int +fsctl c_func(_ ?*c_char, _ c_ulong, _ ?*mut anyopaque, _ c_uint) c_int +ffsctl c_func(_ c_int, _ c_ulong, _ ?*mut anyopaque, _ c_uint) c_int +fsync_volume_np c_func(_ c_int, _ c_int) c_int +sync_volume_np c_func(_ ?*c_char, _ c_int) c_int + +# unsupported in bindings: external variable 'optarg' has no native spelling +# unsupported in bindings: external variable 'optind' has no native spelling +# unsupported in bindings: external variable 'opterr' has no native spelling +# unsupported in bindings: external variable 'optopt' has no native spelling +# unsupported in bindings: external variable 'suboptarg' has no native spelling +# unsupported in bindings: external variable 'optreset' has no native spelling +# unsupported in bindings: _UNISTD_H_ — C macro has no replacement value +# unsupported in bindings: _LIBC_BOUNDS_H_ — C macro has no replacement value +# unsupported in bindings: _CDEFS_H_ — C macro has no replacement value +# unsupported in bindings: _LIBC_COUNT — C function-like macros are not supported +# unsupported in bindings: _LIBC_COUNT_OR_NULL — C function-like macros are not supported +# unsupported in bindings: _LIBC_SIZE — C function-like macros are not supported +# unsupported in bindings: _LIBC_SIZE_OR_NULL — C function-like macros are not supported +# unsupported in bindings: _LIBC_ENDED_BY — C function-like macros are not supported +# unsupported in bindings: _LIBC_SINGLE — C macro has no replacement value +# unsupported in bindings: _LIBC_UNSAFE_INDEXABLE — C macro has no replacement value +# unsupported in bindings: _LIBC_CSTR — C macro has no replacement value +# unsupported in bindings: _LIBC_NULL_TERMINATED — C macro has no replacement value +# unsupported in bindings: _LIBC_FLEX_COUNT — C function-like macros are not supported +# unsupported in bindings: _LIBC_SINGLE_BY_DEFAULT — C function-like macros are not supported +# unsupported in bindings: _LIBC_PTRCHECK_REPLACED — C function-like macros are not supported +# unsupported in bindings: _LIBC_FORGE_PTR — C function-like macros are not supported +# unsupported in bindings: _SYS__TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _BSD_MACHINE__TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _BSD_ARM__TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _SYS__PTHREAD_TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _SYS_UNISTD_H_ — C macro has no replacement value +# unsupported in bindings: _POSIX_VDISABLE — C macro is not a supported constant +# unsupported in bindings: X_OK — C macro is not a supported constant +# unsupported in bindings: W_OK — C macro is not a supported constant +# unsupported in bindings: R_OK — C macro is not a supported constant +# unsupported in bindings: _READ_OK — C macro is not a supported constant +# unsupported in bindings: _WRITE_OK — C macro is not a supported constant +# unsupported in bindings: _EXECUTE_OK — C macro is not a supported constant +# unsupported in bindings: _DELETE_OK — C macro is not a supported constant +# unsupported in bindings: _APPEND_OK — C macro is not a supported constant +# unsupported in bindings: _RMFILE_OK — C macro is not a supported constant +# unsupported in bindings: _RATTR_OK — C macro is not a supported constant +# unsupported in bindings: _WATTR_OK — C macro is not a supported constant +# unsupported in bindings: _REXT_OK — C macro is not a supported constant +# unsupported in bindings: _WEXT_OK — C macro is not a supported constant +# unsupported in bindings: _RPERM_OK — C macro is not a supported constant +# unsupported in bindings: _WPERM_OK — C macro is not a supported constant +# unsupported in bindings: _CHOWN_OK — C macro is not a supported constant +# unsupported in bindings: _ACCESS_EXTENDED_MASK — C macro is not a supported constant +# unsupported in bindings: _SEEK_SET_H_ — C macro has no replacement value +# unsupported in bindings: L_SET — C macro is not a supported constant +# unsupported in bindings: L_INCR — C macro is not a supported constant +# unsupported in bindings: L_XTND — C macro is not a supported constant +# unsupported in bindings: ACCESSX_MAX_TABLESIZE — C macro is not a supported constant +# unsupported in bindings: _SIZE_T — C macro has no replacement value +# unsupported in bindings: _SSIZE_T — C macro has no replacement value +# unsupported in bindings: _BSD_MACHINE_TYPES_H_ — C macro has no replacement value +# unsupported in bindings: _ARM_MACHTYPES_H_ — C macro has no replacement value +# unsupported in bindings: _MACHTYPES_H_ — C macro has no replacement value +# unsupported in bindings: _INT8_T — C macro has no replacement value +# unsupported in bindings: _INT16_T — C macro has no replacement value +# unsupported in bindings: _INT32_T — C macro has no replacement value +# unsupported in bindings: _INT64_T — C macro has no replacement value +# unsupported in bindings: _U_INT8_T — C macro has no replacement value +# unsupported in bindings: _U_INT16_T — C macro has no replacement value +# unsupported in bindings: _U_INT32_T — C macro has no replacement value +# unsupported in bindings: _U_INT64_T — C macro has no replacement value +# unsupported in bindings: _INTPTR_T — C macro has no replacement value +# unsupported in bindings: _UINTPTR_T — C macro has no replacement value +# unsupported in bindings: USER_ADDR_NULL — C macro is not a supported constant +# unsupported in bindings: CAST_USER_ADDR_T — C function-like macros are not supported +# unsupported in bindings: _UINT64_T — C macro has no replacement value +# unsupported in bindings: _UINT32_T — C macro has no replacement value +# unsupported in bindings: MAC_OS_X_VERSION_10_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_8 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_9 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_10 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_10_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_10_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_11_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_12_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_13_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_14_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_15 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_15_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_15_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_X_VERSION_10_16 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_11_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_12_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_13_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_14_7 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_4 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_5 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_15_6 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_16_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_0 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_1 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_2 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_3 — C macro is not a supported constant +# unsupported in bindings: MAC_OS_VERSION_26_4 — C macro is not a supported constant +# unsupported in bindings: _UID_T — C macro has no replacement value +# unsupported in bindings: _GID_T — C macro has no replacement value +# unsupported in bindings: _LIBC_COUNT__PATH_MAX — C macro is not a supported constant +# unsupported in bindings: _OFF_T — C macro has no replacement value +# unsupported in bindings: _PID_T — C macro has no replacement value +# unsupported in bindings: _USECONDS_T — C macro has no replacement value +# unsupported in bindings: NULL — C macro is not a supported constant +# unsupported in bindings: _POSIX_ADVISORY_INFO — C macro is not a supported constant +# unsupported in bindings: _POSIX_ASYNCHRONOUS_IO — C macro is not a supported constant +# unsupported in bindings: _POSIX_BARRIERS — C macro is not a supported constant +# unsupported in bindings: _POSIX_CLOCK_SELECTION — C macro is not a supported constant +# unsupported in bindings: _POSIX_CPUTIME — C macro is not a supported constant +# unsupported in bindings: _POSIX_MEMLOCK — C macro is not a supported constant +# unsupported in bindings: _POSIX_MEMLOCK_RANGE — C macro is not a supported constant +# unsupported in bindings: _POSIX_MESSAGE_PASSING — C macro is not a supported constant +# unsupported in bindings: _POSIX_MONOTONIC_CLOCK — C macro is not a supported constant +# unsupported in bindings: _POSIX_PRIORITIZED_IO — C macro is not a supported constant +# unsupported in bindings: _POSIX_PRIORITY_SCHEDULING — C macro is not a supported constant +# unsupported in bindings: _POSIX_RAW_SOCKETS — C macro is not a supported constant +# unsupported in bindings: _POSIX_REALTIME_SIGNALS — C macro is not a supported constant +# unsupported in bindings: _POSIX_SEMAPHORES — C macro is not a supported constant +# unsupported in bindings: _POSIX_SHARED_MEMORY_OBJECTS — C macro is not a supported constant +# unsupported in bindings: _POSIX_SPIN_LOCKS — C macro is not a supported constant +# unsupported in bindings: _POSIX_SPORADIC_SERVER — C macro is not a supported constant +# unsupported in bindings: _POSIX_SYNCHRONIZED_IO — C macro is not a supported constant +# unsupported in bindings: _POSIX_THREAD_CPUTIME — C macro is not a supported constant +# unsupported in bindings: _POSIX_THREAD_PRIO_INHERIT — C macro is not a supported constant +# unsupported in bindings: _POSIX_THREAD_PRIO_PROTECT — C macro is not a supported constant +# unsupported in bindings: _POSIX_THREAD_PRIORITY_SCHEDULING — C macro is not a supported constant +# unsupported in bindings: _POSIX_THREAD_SPORADIC_SERVER — C macro is not a supported constant +# unsupported in bindings: _POSIX_TIMEOUTS — C macro is not a supported constant +# unsupported in bindings: _POSIX_TIMERS — C macro is not a supported constant +# unsupported in bindings: _POSIX_TRACE — C macro is not a supported constant +# unsupported in bindings: _POSIX_TRACE_EVENT_FILTER — C macro is not a supported constant +# unsupported in bindings: _POSIX_TRACE_INHERIT — C macro is not a supported constant +# unsupported in bindings: _POSIX_TRACE_LOG — C macro is not a supported constant +# unsupported in bindings: _POSIX_TYPED_MEMORY_OBJECTS — C macro is not a supported constant +# unsupported in bindings: _POSIX2_FORT_DEV — C macro is not a supported constant +# unsupported in bindings: _POSIX2_PBS — C macro is not a supported constant +# unsupported in bindings: _POSIX2_PBS_ACCOUNTING — C macro is not a supported constant +# unsupported in bindings: _POSIX2_PBS_CHECKPOINT — C macro is not a supported constant +# unsupported in bindings: _POSIX2_PBS_LOCATE — C macro is not a supported constant +# unsupported in bindings: _POSIX2_PBS_MESSAGE — C macro is not a supported constant +# unsupported in bindings: _POSIX2_PBS_TRACK — C macro is not a supported constant +# unsupported in bindings: _POSIX_V6_ILP32_OFF32 — C macro is not a supported constant +# unsupported in bindings: _POSIX_V6_ILP32_OFFBIG — C macro is not a supported constant +# unsupported in bindings: _POSIX_V6_LP64_OFF64 — C macro is not a supported constant +# unsupported in bindings: _POSIX_V6_LPBIG_OFFBIG — C macro is not a supported constant +# unsupported in bindings: _POSIX_V7_ILP32_OFF32 — C macro is not a supported constant +# unsupported in bindings: _POSIX_V7_ILP32_OFFBIG — C macro is not a supported constant +# unsupported in bindings: _POSIX_V7_LP64_OFF64 — C macro is not a supported constant +# unsupported in bindings: _POSIX_V7_LPBIG_OFFBIG — C macro is not a supported constant +# unsupported in bindings: _V6_ILP32_OFF32 — C macro is not a supported constant +# unsupported in bindings: _V6_ILP32_OFFBIG — C macro is not a supported constant +# unsupported in bindings: _V6_LP64_OFF64 — C macro is not a supported constant +# unsupported in bindings: _V6_LPBIG_OFFBIG — C macro is not a supported constant +# unsupported in bindings: _XBS5_ILP32_OFF32 — C macro is not a supported constant +# unsupported in bindings: _XBS5_ILP32_OFFBIG — C macro is not a supported constant +# unsupported in bindings: _XBS5_LP64_OFF64 — C macro is not a supported constant +# unsupported in bindings: _XBS5_LPBIG_OFFBIG — C macro is not a supported constant +# unsupported in bindings: _XOPEN_CRYPT — C macro is not a supported constant +# unsupported in bindings: _XOPEN_ENH_I18N — C macro is not a supported constant +# unsupported in bindings: _XOPEN_LEGACY — C macro is not a supported constant +# unsupported in bindings: _XOPEN_REALTIME — C macro is not a supported constant +# unsupported in bindings: _XOPEN_REALTIME_THREADS — C macro is not a supported constant +# unsupported in bindings: _XOPEN_SHM — C macro is not a supported constant +# unsupported in bindings: _XOPEN_STREAMS — C macro is not a supported constant +# unsupported in bindings: _XOPEN_UNIX — C macro is not a supported constant +# unsupported in bindings: _SC_PAGE_SIZE — C macro is not a supported constant +# unsupported in bindings: _CTERMID_H_ — C macro has no replacement value +# unsupported in bindings: _LIBC_COUNT__L_CTERMID — C macro is not a supported constant +# unsupported in bindings: _SYS_SELECT_H_ — C macro has no replacement value +# unsupported in bindings: _FD_SET — C macro has no replacement value +# unsupported in bindings: _STRUCT_TIMESPEC — C macro is not a supported constant +# unsupported in bindings: _STRUCT_TIMEVAL — C macro is not a supported constant +# unsupported in bindings: _TIME_T — C macro has no replacement value +# unsupported in bindings: _SUSECONDS_T — C macro has no replacement value +# unsupported in bindings: _SIGSET_T — C macro has no replacement value +# unsupported in bindings: FD_SETSIZE — C macro is not a supported constant +# unsupported in bindings: FD_SET — C function-like macros are not supported +# unsupported in bindings: FD_CLR — C function-like macros are not supported +# unsupported in bindings: FD_ISSET — C function-like macros are not supported +# unsupported in bindings: FD_ZERO — C function-like macros are not supported +# unsupported in bindings: FD_COPY — C function-like macros are not supported +# unsupported in bindings: _SYS__SELECT_H_ — C macro has no replacement value +# unsupported in bindings: _DEV_T — C macro has no replacement value +# unsupported in bindings: _MODE_T — C macro has no replacement value +# unsupported in bindings: _UUID_T — C macro has no replacement value diff --git a/main.odin b/main.odin index 85b6d64..fa277d8 100644 --- a/main.odin +++ b/main.odin @@ -98,7 +98,7 @@ print_usage :: proc() { "usage: brolang -o [--root ] [--target aarch64-macos] [--c-link | --c-library-path | --c-library | --c-include-path | --c-define ]...", ) fmt.eprintln( - " brolang translate-c|--translate-c [--target aarch64-macos] [--c-include-path | --c-define ]...", + " brolang translate-c|--translate-c ... [--output-dir ] [--target aarch64-macos] [--c-include-path | --c-define ]...", ) fmt.eprintln( " brolang build [root] (reads root/build.bro; writes root/build/name)", @@ -429,11 +429,14 @@ run_translate_c :: proc(args: []string) -> int { print_usage() return 2 } - header := args[2] selected := target.DEFAULT + headers: [dynamic]string include_paths: [dynamic]string owned_include_paths: [dynamic]string defines: [dynamic]string + output_dir := "" + output_dir_set := false + defer delete(headers) defer delete(include_paths) defer { for path in owned_include_paths { @@ -442,10 +445,14 @@ run_translate_c :: proc(args: []string) -> int { delete(owned_include_paths) } defer delete(defines) - cursor := 3 + cursor := 2 for cursor < len(args) { option := args[cursor] cursor += 1 + if !strings.has_prefix(option, "--") { + append(&headers, option) + continue + } if cursor >= len(args) { fmt.eprintfln("missing value for %s", option) return 2 @@ -457,6 +464,13 @@ run_translate_c :: proc(args: []string) -> int { append(&include_paths, value) case "--c-define": append(&defines, value) + case "--output-dir": + if output_dir_set || len(value) == 0 { + fmt.eprintln("--output-dir may be provided once with a non-empty value") + return 2 + } + output_dir = value + output_dir_set = true case "--target": parsed, ok := target.parse(value) if !ok { @@ -469,18 +483,112 @@ run_translate_c :: proc(args: []string) -> int { return 2 } } + if len(headers) == 0 { + print_usage() + return 2 + } + if len(headers) > 1 && !output_dir_set { + fmt.eprintln("multiple headers require --output-dir") + return 2 + } + names := make([]string, len(headers)) + defer { + for name in names { + delete(name) + } + delete(names) + } + if output_dir_set { + seen_names: map[string]bool + defer delete(seen_names) + for header, index in headers { + base := filepath.base(header) + extension := filepath.ext(base) + stem := base[:len(base)-len(extension)] + if len(stem) == 0 { + fmt.eprintfln("cannot derive an output name from header '%s'", header) + return 2 + } + name := fmt.aprintf("%s.bro", stem) + if seen_names[name] { + fmt.eprintfln("duplicate generated output name '%s'", name) + delete(name) + return 2 + } + seen_names[name] = true + names[index] = name + } + } _ = append_zig_libc_include_paths(&include_paths, &owned_include_paths, selected) - import_header, _ := resolve_translate_c_header(header, include_paths[:]) - defer delete(import_header) c_options := cimport.Options{include_paths=include_paths[:], defines=defines[:]} - result := cimport.import_header(c_options, import_header, selected) - defer cimport.destroy_result(&result) - if !result.available { - message := result.error_message if len(result.error_message) > 0 else "failed to import header" - fmt.eprintln(message) + resolved_headers: [dynamic]string + results: [dynamic]cimport.Result + defer { + for header in resolved_headers { + delete(header) + } + delete(resolved_headers) + for &result in results { + cimport.destroy_result(&result) + } + delete(results) + } + for header in headers { + resolved, _ := resolve_translate_c_header(header, include_paths[:]) + append(&resolved_headers, resolved) + result := cimport.import_header(c_options, resolved, selected) + append(&results, result) + if !result.available { + message := result.error_message if len(result.error_message) > 0 else "failed to import header" + fmt.eprintln(message) + return 1 + } + } + if !output_dir_set { + fmt.print(translatec.emit(&results[0], headers[0])) + return 0 + } + + inputs := make([]translatec.Package_Input, len(headers)) + defer delete(inputs) + for header, index in headers { + inputs[index] = translatec.Package_Input{ + result=&results[index], + header=header, + name=names[index], + } + } + outputs, generation_error := translatec.emit_package(inputs[:]) + defer translatec.destroy_package_outputs(outputs) + defer delete(generation_error) + if len(generation_error) > 0 { + fmt.eprintln(generation_error) return 1 } - fmt.print(translatec.emit(&result, header)) + if !ensure_directory(output_dir) { + return 1 + } + paths := make([]string, len(outputs)) + defer { + for path in paths { + delete(path) + } + delete(paths) + } + for output, index in outputs { + path, join_error := filepath.join({output_dir, output.name}) + if join_error != nil { + fmt.eprintfln("failed to form output path for '%s'", output.name) + return 1 + } + paths[index] = path + } + for output, index in outputs { + if !os.write_entire_file(paths[index], transmute([]byte)output.source) { + fmt.eprintfln("failed to write generated bindings '%s'", paths[index]) + return 1 + } + } return 0 } diff --git a/std/debug/debug.bro b/std/debug/debug.bro index a7a69d8..edb7e87 100644 --- a/std/debug/debug.bro +++ b/std/debug/debug.bro @@ -21,7 +21,7 @@ hide write func(_ ?@mut anyopaque, handle io.Handle, bytes []u8) usize ! io.Writ if count >= 0 { return usize(count) } - if c.__error()^ != c.EINTR { + if c.__error()?^ != c.EINTR { return .write_failed } } diff --git a/std/io/file.bro b/std/io/file.bro index 141a862..9e98b05 100644 --- a/std/io/file.bro +++ b/std/io/file.bro @@ -57,7 +57,7 @@ hide system_read func(_ ?@mut anyopaque, handle Handle, buffer []mut u8) usize ! if count >= 0 { return usize(count) } - errno c_int :: c.__error()^ + errno c_int :: c.__error()?^ if errno == c.EINTR { continue } @@ -79,7 +79,7 @@ hide system_write func(_ ?@mut anyopaque, handle Handle, bytes []u8) usize ! Wri if count >= 0 { return usize(count) } - errno c_int :: c.__error()^ + errno c_int :: c.__error()?^ if errno == c.EINTR { continue } @@ -102,7 +102,7 @@ hide system_open func(_ ?@mut anyopaque, path [;0]u8, mode FileMode) Handle ! Op if fd >= 0 { return Handle {file_desc = fd} } - if c.__error()^ != c.EINTR { + if c.__error()?^ != c.EINTR { return .open_failed } }