Implemented extern functions
This commit is contained in:
12
lib/io/io.q
12
lib/io/io.q
@ -4,18 +4,18 @@ in(buffer []Int8) -> Int {
|
||||
return sys.read(0, buffer, len(buffer))
|
||||
}
|
||||
|
||||
out(message []Int8) -> Int {
|
||||
return sys.write(1, message, len(message))
|
||||
out(buffer []Int8) -> Int {
|
||||
return sys.write(1, buffer, len(buffer))
|
||||
}
|
||||
|
||||
error(message []Int8) -> Int {
|
||||
return sys.write(2, message, len(message))
|
||||
error(buffer []Int8) -> Int {
|
||||
return sys.write(2, buffer, len(buffer))
|
||||
}
|
||||
|
||||
read(fd Int, buffer []Int8) -> Int {
|
||||
return sys.read(fd, buffer, len(buffer))
|
||||
}
|
||||
|
||||
write(fd Int, message []Int8) -> Int {
|
||||
return sys.write(fd, message, len(message))
|
||||
write(fd Int, buffer []Int8) -> Int {
|
||||
return sys.write(fd, buffer, len(buffer))
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
read(fd Int, address *Any, length Int) -> Int {
|
||||
return syscall(0, fd, address, length)
|
||||
read(fd Int, buffer *Any, length Int) -> Int {
|
||||
return syscall(0, fd, buffer, length)
|
||||
}
|
||||
|
||||
write(fd Int, address *Any, length Int) -> Int {
|
||||
return syscall(1, fd, address, length)
|
||||
write(fd Int, buffer *Any, length Int) -> Int {
|
||||
return syscall(1, fd, buffer, length)
|
||||
}
|
||||
|
||||
open(path *Any, flags Int, mode Int) -> Int {
|
||||
|
@ -1,9 +1,9 @@
|
||||
read(fd Int, address *Any, length Int) -> Int {
|
||||
return syscall(0x2000003, fd, address, length)
|
||||
read(fd Int, buffer *Any, length Int) -> Int {
|
||||
return syscall(0x2000003, fd, buffer, length)
|
||||
}
|
||||
|
||||
write(fd Int, address *Any, length Int) -> Int {
|
||||
return syscall(0x2000004, fd, address, length)
|
||||
write(fd Int, buffer *Any, length Int) -> Int {
|
||||
return syscall(0x2000004, fd, buffer, length)
|
||||
}
|
||||
|
||||
open(path *Any, flags Int, mode Int) -> Int {
|
||||
|
@ -1,10 +1,16 @@
|
||||
read(fd Int, address *Any, length Int) -> Int {
|
||||
kernel32.ReadFile(fd, address, length)
|
||||
extern kernel32 {
|
||||
GetStdHandle(handle Int) -> Int
|
||||
WriteConsoleA(fd Int, buffer *Any, length Int, written *Int) -> Bool
|
||||
ReadFile(fd Int, buffer *Any, length Int) -> Bool
|
||||
}
|
||||
|
||||
read(fd Int, buffer *Any, length Int) -> Int {
|
||||
kernel32.ReadFile(fd, buffer, length)
|
||||
return length
|
||||
}
|
||||
|
||||
write(fd Int, address *Any, length Int) -> Int {
|
||||
write(fd Int, buffer *Any, length Int) -> Int {
|
||||
fd = kernel32.GetStdHandle(-10 - fd)
|
||||
kernel32.WriteConsoleA(fd, address, length, 0)
|
||||
kernel32.WriteConsoleA(fd, buffer, length, 0)
|
||||
return length
|
||||
}
|
@ -1,3 +1,8 @@
|
||||
extern kernel32 {
|
||||
VirtualAlloc(address Int, length Int, flags Int, protection Int)
|
||||
VirtualFree(address *Any, length Int, type Int) -> Bool
|
||||
}
|
||||
|
||||
mmap(address Int, length Int, protection Int, flags Int) -> *Any {
|
||||
return kernel32.VirtualAlloc(address, length, flags, protection)
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
extern kernel32 {
|
||||
ExitProcess(code UInt)
|
||||
}
|
||||
|
||||
exit(code Int) {
|
||||
kernel32.ExitProcess(code)
|
||||
}
|
Reference in New Issue
Block a user