lang: rename signed integer types sN -> iN
Surface rename of the signed integer family: s1..s64 become i1..i64
(u1..u64, usize, isize unchanged). 'string' keeps the s-prefix arm in
name classification; width parsing moves to the i-prefix arm next to
isize.
Internal TypeId tags follow the surface (.s8/.s16/.s32/.s64 ->
.i8/.i16/.i32/.i64), as do mono-key mangle fragments (ptr_i64,
tu_i64_bool) and all display/diagnostic formatting (i{d}).
Migrated in the same sweep: stdlib + examples + issue repros + FFI C
companions (shared symbol names like ffi_id_i64), expected
stdout/stderr/ir snapshots, specs.md, readme.md, CLAUDE.md/AGENTS.md,
implementation_plan.md, docs/, issue writeups. Vendored stb_image and
historical flow state left untouched.
zig build test: 426/426; examples suite: 595/595.
This commit is contained in:
@@ -24,36 +24,36 @@ libc :: #library "c";
|
||||
// API below wraps them. Users should not call these directly.
|
||||
//
|
||||
// macOS `open` is variadic in C (`int open(const char*, int, ...)`);
|
||||
// declared with `..args: []s32` so the mode is passed via the C
|
||||
// declared with `..args: []i32` so the mode is passed via the C
|
||||
// variadic tail. Without that, the mode arg goes to the wrong
|
||||
// register on arm64 and the file ends up with mode 0.
|
||||
|
||||
open :: (path: [:0]u8, flags: s32, ..args: []s32) -> s32 #foreign libc;
|
||||
close :: (fd: s32) -> s32 #foreign libc;
|
||||
read :: (fd: s32, buf: [*]u8, count: usize) -> isize #foreign libc;
|
||||
write :: (fd: s32, buf: [*]u8, count: usize) -> isize #foreign libc;
|
||||
lseek :: (fd: s32, offset: s64, whence: s32) -> s64 #foreign libc;
|
||||
unlink :: (path: [:0]u8) -> s32 #foreign libc;
|
||||
rmdir :: (path: [:0]u8) -> s32 #foreign libc;
|
||||
mkdir :: (path: [:0]u8, mode: u32) -> s32 #foreign libc;
|
||||
access :: (path: [:0]u8, mode: s32) -> s32 #foreign libc;
|
||||
chmod :: (path: [:0]u8, mode: u32) -> s32 #foreign libc;
|
||||
rename :: (oldp: [:0]u8, newp: [:0]u8) -> s32 #foreign libc;
|
||||
open :: (path: [:0]u8, flags: i32, ..args: []i32) -> i32 #foreign libc;
|
||||
close :: (fd: i32) -> i32 #foreign libc;
|
||||
read :: (fd: i32, buf: [*]u8, count: usize) -> isize #foreign libc;
|
||||
write :: (fd: i32, buf: [*]u8, count: usize) -> isize #foreign libc;
|
||||
lseek :: (fd: i32, offset: i64, whence: i32) -> i64 #foreign libc;
|
||||
unlink :: (path: [:0]u8) -> i32 #foreign libc;
|
||||
rmdir :: (path: [:0]u8) -> i32 #foreign libc;
|
||||
mkdir :: (path: [:0]u8, mode: u32) -> i32 #foreign libc;
|
||||
access :: (path: [:0]u8, mode: i32) -> i32 #foreign libc;
|
||||
chmod :: (path: [:0]u8, mode: u32) -> i32 #foreign libc;
|
||||
rename :: (oldp: [:0]u8, newp: [:0]u8) -> i32 #foreign libc;
|
||||
|
||||
// macOS POSIX constants. Linux values differ; split into platform-
|
||||
// conditional includes when we gain a Linux host.
|
||||
O_RDONLY :s32: 0x0000;
|
||||
O_WRONLY :s32: 0x0001;
|
||||
O_RDWR :s32: 0x0002;
|
||||
O_APPEND :s32: 0x0008;
|
||||
O_CREAT :s32: 0x0200;
|
||||
O_TRUNC :s32: 0x0400;
|
||||
O_RDONLY :i32: 0x0000;
|
||||
O_WRONLY :i32: 0x0001;
|
||||
O_RDWR :i32: 0x0002;
|
||||
O_APPEND :i32: 0x0008;
|
||||
O_CREAT :i32: 0x0200;
|
||||
O_TRUNC :i32: 0x0400;
|
||||
|
||||
SEEK_SET :s32: 0;
|
||||
SEEK_CUR :s32: 1;
|
||||
SEEK_END :s32: 2;
|
||||
SEEK_SET :i32: 0;
|
||||
SEEK_CUR :i32: 1;
|
||||
SEEK_END :i32: 2;
|
||||
|
||||
F_OK :s32: 0;
|
||||
F_OK :i32: 0;
|
||||
|
||||
// ── Public types ─────────────────────────────────────────────────────
|
||||
|
||||
@@ -67,7 +67,7 @@ OpenMode :: enum {
|
||||
SeekFrom :: enum { set; current; end; }
|
||||
|
||||
File :: struct {
|
||||
fd: s32 = -1;
|
||||
fd: i32 = -1;
|
||||
|
||||
is_valid :: (self: *File) -> bool { self.fd >= 0 }
|
||||
|
||||
@@ -78,19 +78,19 @@ File :: struct {
|
||||
rc == 0
|
||||
}
|
||||
|
||||
read :: (self: *File, buf: string) -> s64 {
|
||||
read :: (self: *File, buf: string) -> i64 {
|
||||
if self.fd < 0 { return -1; }
|
||||
n := read(self.fd, buf.ptr, xx buf.len);
|
||||
cast(s64) n
|
||||
cast(i64) n
|
||||
}
|
||||
|
||||
write :: (self: *File, data: string) -> s64 {
|
||||
write :: (self: *File, data: string) -> i64 {
|
||||
if self.fd < 0 { return -1; }
|
||||
n := write(self.fd, data.ptr, xx data.len);
|
||||
cast(s64) n
|
||||
cast(i64) n
|
||||
}
|
||||
|
||||
seek :: (self: *File, offset: s64, whence: SeekFrom) -> s64 {
|
||||
seek :: (self: *File, offset: i64, whence: SeekFrom) -> i64 {
|
||||
if self.fd < 0 { return -1; }
|
||||
w := SEEK_SET;
|
||||
if whence == .current { w = SEEK_CUR; }
|
||||
@@ -105,7 +105,7 @@ File :: struct {
|
||||
// idea for `delete_file`/`delete_dir` vs libc's `unlink`/`rmdir`,
|
||||
// `set_mode` vs libc's `chmod`, etc.
|
||||
|
||||
mode_to_flags :: (m: OpenMode) -> s32 {
|
||||
mode_to_flags :: (m: OpenMode) -> i32 {
|
||||
if m == .read { return O_RDONLY; }
|
||||
if m == .write { return O_WRONLY | O_CREAT | O_TRUNC; }
|
||||
if m == .append { return O_WRONLY | O_CREAT | O_APPEND; }
|
||||
@@ -133,7 +133,7 @@ read_file :: (path: [:0]u8) -> ?string {
|
||||
buf := cstring(size);
|
||||
n := read(fd, buf.ptr, xx size);
|
||||
close(fd);
|
||||
if cast(s64) n != size { return null; }
|
||||
if cast(i64) n != size { return null; }
|
||||
buf
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ write_file :: (path: [:0]u8, data: string) -> bool {
|
||||
if fd < 0 { return false; }
|
||||
n := write(fd, data.ptr, xx data.len);
|
||||
close(fd);
|
||||
cast(s64) n == cast(s64) data.len
|
||||
cast(i64) n == cast(i64) data.len
|
||||
}
|
||||
|
||||
append_file :: (path: [:0]u8, data: string) -> bool {
|
||||
@@ -151,7 +151,7 @@ append_file :: (path: [:0]u8, data: string) -> bool {
|
||||
if fd < 0 { return false; }
|
||||
n := write(fd, data.ptr, xx data.len);
|
||||
close(fd);
|
||||
cast(s64) n == cast(s64) data.len
|
||||
cast(i64) n == cast(i64) data.len
|
||||
}
|
||||
|
||||
// ── Single-syscall ops ───────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user