mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58:22 +00:00
kernel: misc fixes
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#ifndef _UTIL_H
|
||||
#define _UTIL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define UTIL_ZEROBUFFERSIZE (1024 * 64)
|
||||
|
||||
#define ROUND_DOWN(v, n) ((v) - ((v) % (n)))
|
||||
#define ROUND_UP(v, n) ROUND_DOWN((v) + (n) - 1, n)
|
||||
|
||||
@@ -16,4 +20,6 @@ static inline long min(long x, long y) {
|
||||
return x > y ? y : x;
|
||||
}
|
||||
|
||||
extern uint8_t util_zerobuffer[];
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <util.h>
|
||||
|
||||
uint8_t util_zerobuffer[UTIL_ZEROBUFFERSIZE];
|
||||
@@ -46,11 +46,11 @@ syscallret_t syscall_fcntl(context_t *, int fd, int cmd, uint64_t arg) {
|
||||
break;
|
||||
default:
|
||||
ret.errno = EINVAL;
|
||||
break;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fd_release(file);
|
||||
|
||||
ret.errno = 0;
|
||||
|
||||
cleanup:
|
||||
fd_release(file);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ syscallret_t syscall_mmap(context_t *context, void *hint, size_t len, int prot,
|
||||
__assert((~KNOWN_PROT & prot) == 0);
|
||||
|
||||
// check alignment
|
||||
if (len == 0 || (uintptr_t)hint % PAGE_SIZE || len % PAGE_SIZE) {
|
||||
if (len == 0 || (uintptr_t)hint % PAGE_SIZE) {
|
||||
ret.errno = EINVAL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user