mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
[libc] Add new libc
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.
This commit is contained in:
@@ -78,17 +78,17 @@ class Module:
|
||||
def update(cls, mods):
|
||||
from . import BonnibelError
|
||||
|
||||
def resolve(modlist):
|
||||
def resolve(source, modlist):
|
||||
resolved = set()
|
||||
for dep in modlist:
|
||||
if not dep in mods:
|
||||
raise BonnibelError(f"module '{mod.name}' references unknown module '{dep}'")
|
||||
raise BonnibelError(f"module '{source.name}' references unknown module '{dep}'")
|
||||
mod = mods[dep]
|
||||
resolved.add(mod)
|
||||
return resolved
|
||||
|
||||
for mod in mods.values():
|
||||
mod.depmods = resolve(mod.deps)
|
||||
mod.depmods = resolve(mod, mod.deps)
|
||||
|
||||
target_mods = [mod for mod in mods.values() if mod.targets]
|
||||
for mod in target_mods:
|
||||
|
||||
56
scripts/j6libc.py
Normal file
56
scripts/j6libc.py
Normal file
@@ -0,0 +1,56 @@
|
||||
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")})
|
||||
|
||||
Reference in New Issue
Block a user