mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
This new libc is mostly from scratch, with *printf() functions provided by Marco Paland and Eyal Rozenberg's tiny printf library, and malloc and friends provided by dlmalloc.
57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
import cog
|
|
|
|
supported_architectures = {
|
|
"amd64": "__amd64__",
|
|
}
|
|
|
|
def arch_includes(header):
|
|
prefix = "if"
|
|
for arch, define in supported_architectures.items():
|
|
cog.outl(f"#{prefix} defined({define})")
|
|
cog.outl(f"#include <__j6libc/arch/{arch}/{header}>")
|
|
prefix = "elif"
|
|
cog.outl("#endif")
|
|
|
|
|
|
int_widths = (8, 16, 32, 64)
|
|
int_mods = ("fast", "least")
|
|
|
|
int_types = {
|
|
# type: abbrev
|
|
"char": "char",
|
|
"short": "short",
|
|
"int": "int",
|
|
"long": "long",
|
|
"long long": "llong",
|
|
}
|
|
|
|
def definition(kind, name, val, width=24):
|
|
cog.outl(f"{kind} {name:{width}} {val}")
|
|
|
|
|
|
atomic_types = {
|
|
"_Bool": "bool",
|
|
"signed char": "schar",
|
|
"char16_t": "char16_t",
|
|
"char32_t": "char32_t",
|
|
"wchar_t": "wchar_t",
|
|
"wchar_t": "wchar_t",
|
|
"size_t": "size_t",
|
|
"ptrdiff_t": "ptrdiff_t",
|
|
"intptr_t": "intptr_t",
|
|
"uintptr_t": "uintptr_t",
|
|
"intmax_t": "intmax_t",
|
|
"uintmax_t": "uintmax_t",
|
|
}
|
|
|
|
for name, abbrev in int_types.items():
|
|
atomic_types.update({name: abbrev, f"unsigned {name}": f"u{abbrev}"})
|
|
|
|
for width in int_widths:
|
|
atomic_types.update({t: t for t in (
|
|
f"int_least{width}_t",
|
|
f"uint_least{width}_t",
|
|
f"int_fast{width}_t",
|
|
f"uint_fast{width}_t")})
|
|
|