upgrade enum discriminants

This commit is contained in:
2026-07-17 20:32:12 +02:00
parent 866e28adb8
commit cedc63b28b
19 changed files with 3168 additions and 96 deletions
+1 -1
View File
@@ -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 <header.h>` for native `.bro` bindings from supported C declarations
- `brolang translate-c <header.h>... [--output-dir <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
+6 -1
View File
@@ -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"
+19
View File
@@ -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)
+26 -2
View File
@@ -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..<count {
param := translate_type(ctx, ctx.api.get_arg_type(value, u32(index)), "", depth+1)
param := translate_parameter_type(ctx, ctx.api.get_arg_type(value, u32(index)), depth+1)
append(&params, param)
if param == INVALID_TYPE {
delete(params)
@@ -537,6 +537,30 @@ translate_type :: proc(ctx: ^Context, value: CXType, preferred_record_name := ""
return INVALID_TYPE
}
translate_parameter_type :: proc(ctx: ^Context, value: CXType, depth := 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..<count {
param := translate_type(ctx, ctx.api.get_arg_type(function_type, u32(index)))
param := translate_parameter_type(ctx, ctx.api.get_arg_type(function_type, u32(index)))
append(&params, param)
if param == INVALID_TYPE && len(reason) == 0 {
reason = "function parameter type is not supported"
+131
View File
@@ -1294,6 +1294,136 @@ find_type_import :: proc(module: ^ast.Module, file: ast.File_Id, alias: symbol.I
return ast.INVALID_IMPORT
}
find_visible_enum_global :: proc(
module: ^ast.Module,
pkg: ast.Package_Id,
file: ast.File_Id,
name: symbol.Id,
public_only := false,
) -> 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
+35 -6
View File
@@ -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)
}
+446 -48
View File
@@ -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(&registry.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(&registry)
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],
&registry,
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
} 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 !record.complete || len(record.reason) > 0 {
if !representable {
// opaque / pointer-only struct
fmt.sbprintf(b, "%s :: opaque\n", name)
wrote = true
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 {
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)
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) &&
+101
View File
@@ -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
@@ -3,6 +3,9 @@ Animal :: enum {
cat
}
STATE_STARTED c_int :: 10
STATE_STOPPED c_int :: 20
favorite func() Animal {
return .cat
}
+5 -2
View File
@@ -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 {
+120
View File
@@ -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
+393
View File
@@ -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
-16
View File
@@ -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
+4 -1
View File
@@ -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
+1091 -1
View File
File diff suppressed because it is too large Load Diff
+661
View File
@@ -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
+116 -8
View File
@@ -98,7 +98,7 @@ print_usage :: proc() {
"usage: brolang <package-directory> -o <executable> [--root <project-root>] [--target aarch64-macos] [--c-link <path> | --c-library-path <dir> | --c-library <name> | --c-include-path <dir> | --c-define <name[=value]>]...",
)
fmt.eprintln(
" brolang translate-c|--translate-c <header.h> [--target aarch64-macos] [--c-include-path <dir> | --c-define <name[=value]>]...",
" brolang translate-c|--translate-c <header.h>... [--output-dir <dir>] [--target aarch64-macos] [--c-include-path <dir> | --c-define <name[=value]>]...",
)
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)
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
}
fmt.print(translatec.emit(&result, header))
}
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
}
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
}
+1 -1
View File
@@ -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
}
}
+3 -3
View File
@@ -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
}
}