Declaration grouping uses braces rather than parentheses

This commit is contained in:
Ginger Bill
2017-06-13 15:04:23 +01:00
parent 6b464e3558
commit 6a88dc322a
27 changed files with 184 additions and 200 deletions
+17 -13
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,20 +23,24 @@ const (
O_SYNC = 0x01000;
O_ASYNC = 0x02000;
O_CLOEXEC = 0x80000;
}
const {
SEEK_SET = 0;
SEEK_CUR = 1;
SEEK_END = 2;
SEEK_DATA = 3;
SEEK_HOLE = 4;
SEEK_MAX = SEEK_HOLE;
}
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();
@@ -76,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
@@ -108,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; }
@@ -118,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";
@@ -193,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 {}