Declaration grouping uses () rather than {}; Fix some problem with compilation on *nix

This commit is contained in:
Ginger Bill
2017-06-17 12:01:53 +01:00
parent 3fa398ec43
commit 2deb2f8eeb
32 changed files with 195 additions and 197 deletions
+17 -17
View File
@@ -1,16 +1,16 @@
foreign_system_library {
foreign_system_library (
dl "dl";
libc "c";
}
)
import "strings.odin";
type {
type (
Handle i32;
FileTime u64;
Errno i32;
}
)
const {
const (
O_RDONLY = 0x00000;
O_WRONLY = 0x00001;
O_RDWR = 0x00002;
@@ -23,24 +23,24 @@ const {
O_SYNC = 0x01000;
O_ASYNC = 0x02000;
O_CLOEXEC = 0x80000;
}
)
const {
const (
SEEK_SET = 0;
SEEK_CUR = 1;
SEEK_END = 2;
SEEK_DATA = 3;
SEEK_HOLE = 4;
SEEK_MAX = SEEK_HOLE;
}
const {
)
const (
// NOTE(zangent): These are OS specific!
// Do not mix these up!
RTLD_LAZY = 0x001;
RTLD_NOW = 0x002;
RTLD_BINDING_MASK = 0x3;
RTLD_GLOBAL = 0x100;
}
)
// "Argv" arguments converted to Odin strings
let args = _alloc_command_line_arguments();
@@ -80,7 +80,7 @@ type Stat struct #ordered {
};
// File type
const {
const (
S_IFMT = 0170000; // Type of file mask
S_IFIFO = 0010000; // Named pipe (fifo)
S_IFCHR = 0020000; // Character special
@@ -112,7 +112,7 @@ const {
S_ISUID = 0004000; // Set user id on execution
S_ISGID = 0002000; // Set group id on execution
S_ISVTX = 0001000; // Directory restrcted delete
}
)
proc S_ISLNK (m: u32) -> bool #inline {return (m & S_IFMT) == S_IFLNK; }
proc S_ISREG (m: u32) -> bool #inline {return (m & S_IFMT) == S_IFREG; }
@@ -122,12 +122,12 @@ proc S_ISBLK (m: u32) -> bool #inline {return (m & S_IFMT) == S_IFBLK; }
proc S_ISFIFO(m: u32) -> bool #inline {return (m & S_IFMT) == S_IFIFO; }
proc S_ISSOCK(m: u32) -> bool #inline {return (m & S_IFMT) == S_IFSOCK;}
const {
const (
R_OK = 4; // Test for read permission
W_OK = 2; // Test for write permission
X_OK = 1; // Test for execute permission
F_OK = 0; // Test for file existance
}
)
foreign libc {
proc _unix_open (path: ^u8, mode: int) -> Handle #link_name "open";
@@ -165,7 +165,7 @@ proc open_simple(path: string, mode: int) -> (Handle, Errno) {
return handle, 0;
}
// NOTE(zangent): This is here for compatability reasons. Should this be here?
proc open(path: string, mode: int, perm: u32) -> (Handle, Errno) {
proc open(path: string, mode: int = O_RDONLY, perm: u32 = 0) -> (Handle, Errno) {
return open_simple(path, mode);
}
@@ -197,11 +197,11 @@ proc file_size(fd: Handle) -> (i64, Errno) {
// NOTE(bill): Uses startup to initialize it
var {
var (
stdin: Handle = 0;
stdout: Handle = 1;
stderr: Handle = 2;
}
)
/* TODO(zangent): Implement these!
proc last_write_time(fd: Handle) -> FileTime {}
proc last_write_time_by_name(name: string) -> FileTime {}