summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordzwdz2021-09-21 16:30:43 +0200
committerdzwdz2021-09-21 16:30:43 +0200
commitc7cdfb06c96d4db0649a3565873fda8a10d11ac2 (patch)
tree9dcfe46fe363b13bff1413a9557cb82b9ef5a362
parenta5fffadce4ee1c30fb7b80150821d4164c6012c7 (diff)
add `__force` for marking casts across adress spaces
-rw-r--r--src/kernel/mem/virt.c2
-rw-r--r--src/kernel/syscalls.c2
-rw-r--r--src/shared/types.h4
3 files changed, 5 insertions, 3 deletions
diff --git a/src/kernel/mem/virt.c b/src/kernel/mem/virt.c
index 7a38a88..a9450c7 100644
--- a/src/kernel/mem/virt.c
+++ b/src/kernel/mem/virt.c
@@ -42,7 +42,7 @@ bool virt_iter_next(struct virt_iter *iter) {
} else {
// "iterate" over physical memory
// the double cast supresses the warning about changing address spaces
- iter->frag = (void*)(uintptr_t)iter->_virt;
+ iter->frag = (void* __force)iter->_virt;
}
iter->frag_len = partial;
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index 39cad3a..0ca7867 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -261,7 +261,7 @@ int _syscall_memflag(void __user *addr, size_t len, int flags) {
struct pagedir *pages = process_current->pages;
if (flags != MEMFLAG_PRESENT) panic_unimplemented(); // TODO
- addr = (userptr_t)((int)addr & ~PAGE_MASK); // align to page boundary
+ addr = (userptr_t)((int __force)addr & ~PAGE_MASK); // align to page boundary
for (; addr < goal; addr += PAGE_SIZE) {
if (pagedir_virt2phys(pages, addr, false, false)) {
// allocated page, currently a no-op
diff --git a/src/shared/types.h b/src/shared/types.h
index ea6f886..626e819 100644
--- a/src/shared/types.h
+++ b/src/shared/types.h
@@ -2,9 +2,11 @@
#include <stdint.h>
#ifdef __CHECKER__
-# define __user __attribute__((noderef, address_space(__user)))
+# define __user __attribute__((noderef, address_space(__user)))
+# define __force __attribute__((force))
#else
# define __user
+# define __force
#endif
typedef void __user * userptr_t;