[project] Lose the battle between tabs & spaces

I'm a tabs guy. I like tabs, it's an elegant way to represent
indentation instead of brute-forcing it. But I have to admit that the
world seems to be going towards spaces, and tooling tends not to play
nice with tabs. So here we go, changing the whole repo to spaces since
I'm getting tired of all the inconsistent formatting.
This commit is contained in:
F in Chat for Tabs
2021-08-01 17:46:16 -07:00
committed by Justin C. Miller
parent d36b2d8057
commit 8f529046a9
161 changed files with 7958 additions and 7958 deletions

View File

@@ -9,24 +9,24 @@ namespace syscalls {
j6_status_t
channel_create(j6_handle_t *handle)
{
construct_handle<channel>(handle);
return j6_status_ok;
construct_handle<channel>(handle);
return j6_status_ok;
}
j6_status_t
channel_send(j6_handle_t handle, size_t *len, void *data)
{
channel *c = get_handle<channel>(handle);
if (!c) return j6_err_invalid_arg;
return c->enqueue(len, data);
channel *c = get_handle<channel>(handle);
if (!c) return j6_err_invalid_arg;
return c->enqueue(len, data);
}
j6_status_t
channel_receive(j6_handle_t handle, size_t *len, void *data)
{
channel *c = get_handle<channel>(handle);
if (!c) return j6_err_invalid_arg;
return c->dequeue(len, data);
channel *c = get_handle<channel>(handle);
if (!c) return j6_err_invalid_arg;
return c->dequeue(len, data);
}
} // namespace syscalls

View File

@@ -10,58 +10,58 @@ namespace syscalls {
j6_status_t
endpoint_create(j6_handle_t *handle)
{
construct_handle<endpoint>(handle);
return j6_status_ok;
construct_handle<endpoint>(handle);
return j6_status_ok;
}
j6_status_t
endpoint_send(j6_handle_t handle, j6_tag_t tag, size_t len, void *data)
{
if (tag & j6_tag_system_flag)
return j6_err_invalid_arg;
if (tag & j6_tag_system_flag)
return j6_err_invalid_arg;
endpoint *e = get_handle<endpoint>(handle);
if (!e) return j6_err_invalid_arg;
endpoint *e = get_handle<endpoint>(handle);
if (!e) return j6_err_invalid_arg;
return e->send(tag, len, data);
return e->send(tag, len, data);
}
j6_status_t
endpoint_receive(j6_handle_t handle, j6_tag_t *tag, size_t *len, void *data)
{
if (!tag || !len || (*len && !data))
return j6_err_invalid_arg;
if (!tag || !len || (*len && !data))
return j6_err_invalid_arg;
endpoint *e = get_handle<endpoint>(handle);
if (!e) return j6_err_invalid_arg;
endpoint *e = get_handle<endpoint>(handle);
if (!e) return j6_err_invalid_arg;
j6_tag_t out_tag = j6_tag_invalid;
size_t out_len = *len;
j6_status_t s = e->receive(&out_tag, &out_len, data);
*tag = out_tag;
*len = out_len;
return s;
j6_tag_t out_tag = j6_tag_invalid;
size_t out_len = *len;
j6_status_t s = e->receive(&out_tag, &out_len, data);
*tag = out_tag;
*len = out_len;
return s;
}
j6_status_t
endpoint_sendrecv(j6_handle_t handle, j6_tag_t *tag, size_t *len, void *data)
{
if (!tag || (*tag & j6_tag_system_flag))
return j6_err_invalid_arg;
if (!tag || (*tag & j6_tag_system_flag))
return j6_err_invalid_arg;
endpoint *e = get_handle<endpoint>(handle);
if (!e) return j6_err_invalid_arg;
endpoint *e = get_handle<endpoint>(handle);
if (!e) return j6_err_invalid_arg;
j6_status_t status = e->send(*tag, *len, data);
if (status != j6_status_ok)
return status;
j6_status_t status = e->send(*tag, *len, data);
if (status != j6_status_ok)
return status;
j6_tag_t out_tag = j6_tag_invalid;
size_t out_len = *len;
j6_status_t s = e->receive(&out_tag, &out_len, data);
*tag = out_tag;
*len = out_len;
return s;
j6_tag_t out_tag = j6_tag_invalid;
size_t out_len = *len;
j6_status_t s = e->receive(&out_tag, &out_len, data);
*tag = out_tag;
*len = out_len;
return s;
}
} // namespace syscalls

View File

@@ -11,38 +11,38 @@ namespace syscalls {
template <typename T, typename... Args>
T * construct_handle(j6_handle_t *handle, Args... args)
{
process &p = process::current();
T *o = new T {args...};
*handle = p.add_handle(o);
return o;
process &p = process::current();
T *o = new T {args...};
*handle = p.add_handle(o);
return o;
}
template <typename T>
T * get_handle(j6_handle_t handle)
{
process &p = process::current();
kobject *o = p.lookup_handle(handle);
if (!o || o->get_type() != T::type)
return nullptr;
return static_cast<T*>(o);
process &p = process::current();
kobject *o = p.lookup_handle(handle);
if (!o || o->get_type() != T::type)
return nullptr;
return static_cast<T*>(o);
}
template <>
inline kobject * get_handle<kobject>(j6_handle_t handle)
{
process &p = process::current();
return p.lookup_handle(handle);
process &p = process::current();
return p.lookup_handle(handle);
}
template <typename T>
T * remove_handle(j6_handle_t handle)
{
T *o = get_handle<T>(handle);
if (o) {
process &p = process::current();
p.remove_handle(handle);
}
return o;
T *o = get_handle<T>(handle);
if (o) {
process &p = process::current();
p.remove_handle(handle);
}
return o;
}
}

View File

@@ -11,39 +11,39 @@ namespace syscalls {
j6_status_t
object_koid(j6_handle_t handle, j6_koid_t *koid)
{
if (koid == nullptr)
return j6_err_invalid_arg;
if (koid == nullptr)
return j6_err_invalid_arg;
kobject *obj = get_handle<kobject>(handle);
if (!obj)
return j6_err_invalid_arg;
kobject *obj = get_handle<kobject>(handle);
if (!obj)
return j6_err_invalid_arg;
*koid = obj->koid();
return j6_status_ok;
*koid = obj->koid();
return j6_status_ok;
}
j6_status_t
object_wait(j6_handle_t handle, j6_signal_t mask, j6_signal_t *sigs)
{
kobject *obj = get_handle<kobject>(handle);
if (!obj)
return j6_err_invalid_arg;
kobject *obj = get_handle<kobject>(handle);
if (!obj)
return j6_err_invalid_arg;
j6_signal_t current = obj->signals();
if ((current & mask) != 0) {
*sigs = current;
return j6_status_ok;
}
j6_signal_t current = obj->signals();
if ((current & mask) != 0) {
*sigs = current;
return j6_status_ok;
}
thread &th = thread::current();
obj->add_blocked_thread(&th);
th.wait_on_signals(mask);
thread &th = thread::current();
obj->add_blocked_thread(&th);
th.wait_on_signals(mask);
j6_status_t result = th.get_wait_result();
if (result == j6_status_ok) {
*sigs = th.get_wait_data();
}
return result;
j6_status_t result = th.get_wait_result();
if (result == j6_status_ok) {
*sigs = th.get_wait_data();
}
return result;
}
j6_status_t
@@ -70,14 +70,14 @@ object_wait_many(j6_handle_t *handles, uint32_t count, j6_signal_t mask, j6_hand
objects.append(obj);
}
thread &th = thread::current();
thread &th = thread::current();
for (auto *obj : objects)
obj->add_blocked_thread(&th);
th.wait_on_signals(mask);
th.wait_on_signals(mask);
j6_status_t result = th.get_wait_result();
if (result != j6_status_ok)
j6_status_t result = th.get_wait_result();
if (result != j6_status_ok)
return result;
*handle = j6_handle_invalid;
@@ -98,26 +98,26 @@ object_wait_many(j6_handle_t *handles, uint32_t count, j6_signal_t mask, j6_hand
j6_status_t
object_signal(j6_handle_t handle, j6_signal_t signals)
{
if ((signals & j6_signal_user_mask) != signals)
return j6_err_invalid_arg;
if ((signals & j6_signal_user_mask) != signals)
return j6_err_invalid_arg;
kobject *obj = get_handle<kobject>(handle);
if (!obj)
return j6_err_invalid_arg;
kobject *obj = get_handle<kobject>(handle);
if (!obj)
return j6_err_invalid_arg;
obj->assert_signal(signals);
return j6_status_ok;
obj->assert_signal(signals);
return j6_status_ok;
}
j6_status_t
object_close(j6_handle_t handle)
{
kobject *obj = get_handle<kobject>(handle);
if (!obj)
return j6_err_invalid_arg;
kobject *obj = get_handle<kobject>(handle);
if (!obj)
return j6_err_invalid_arg;
obj->close();
return j6_status_ok;
obj->close();
return j6_status_ok;
}
} // namespace syscalls

View File

@@ -10,50 +10,50 @@ namespace syscalls {
j6_status_t
process_create(j6_handle_t *handle)
{
process *child = construct_handle<process>(handle);
log::debug(logs::task, "Process %llx created", child->koid());
return j6_status_ok;
process *child = construct_handle<process>(handle);
log::debug(logs::task, "Process %llx created", child->koid());
return j6_status_ok;
}
j6_status_t
process_start(j6_handle_t handle, uintptr_t entrypoint, j6_handle_t *handles, size_t handle_count)
{
process &p = process::current();
process *c = get_handle<process>(handle);
if (handle_count && !handles)
return j6_err_invalid_arg;
process &p = process::current();
process *c = get_handle<process>(handle);
if (handle_count && !handles)
return j6_err_invalid_arg;
for (size_t i = 0; i < handle_count; ++i) {
kobject *o = p.lookup_handle(handles[i]);
if (o) c->add_handle(o);
}
for (size_t i = 0; i < handle_count; ++i) {
kobject *o = p.lookup_handle(handles[i]);
if (o) c->add_handle(o);
}
return j6_err_nyi;
return j6_err_nyi;
}
j6_status_t
process_kill(j6_handle_t handle)
{
process &p = process::current();
process *c = get_handle<process>(handle);
if (!c) return j6_err_invalid_arg;
process &p = process::current();
process *c = get_handle<process>(handle);
if (!c) return j6_err_invalid_arg;
log::debug(logs::task, "Process %llx killed by process %llx", c->koid(), p.koid());
c->exit(-1u);
log::debug(logs::task, "Process %llx killed by process %llx", c->koid(), p.koid());
c->exit(-1u);
return j6_status_ok;
return j6_status_ok;
}
j6_status_t
process_exit(int32_t status)
{
process &p = process::current();
log::debug(logs::task, "Process %llx exiting with code %d", p.koid(), status);
process &p = process::current();
log::debug(logs::task, "Process %llx exiting with code %d", p.koid(), status);
p.exit(status);
p.exit(status);
log::error(logs::task, "returned to exit syscall");
return j6_err_unexpected;
log::error(logs::task, "returned to exit syscall");
return j6_err_unexpected;
}
} // namespace syscalls

View File

@@ -17,64 +17,64 @@ namespace syscalls {
j6_status_t
system_log(const char *message)
{
if (message == nullptr)
return j6_err_invalid_arg;
if (message == nullptr)
return j6_err_invalid_arg;
thread &th = thread::current();
log::info(logs::syscall, "Message[%llx]: %s", th.koid(), message);
return j6_status_ok;
thread &th = thread::current();
log::info(logs::syscall, "Message[%llx]: %s", th.koid(), message);
return j6_status_ok;
}
j6_status_t
system_noop()
{
thread &th = thread::current();
log::debug(logs::syscall, "Thread %llx called noop syscall.", th.koid());
return j6_status_ok;
thread &th = thread::current();
log::debug(logs::syscall, "Thread %llx called noop syscall.", th.koid());
return j6_status_ok;
}
j6_status_t
system_get_log(j6_handle_t sys, void *buffer, size_t *size)
{
if (!size || (*size && !buffer))
return j6_err_invalid_arg;
if (!size || (*size && !buffer))
return j6_err_invalid_arg;
size_t orig_size = *size;
*size = g_logger.get_entry(buffer, *size);
if (!g_logger.has_log())
system::get().deassert_signal(j6_signal_system_has_log);
size_t orig_size = *size;
*size = g_logger.get_entry(buffer, *size);
if (!g_logger.has_log())
system::get().deassert_signal(j6_signal_system_has_log);
return (*size > orig_size) ? j6_err_insufficient : j6_status_ok;
return (*size > orig_size) ? j6_err_insufficient : j6_status_ok;
}
j6_status_t
system_bind_irq(j6_handle_t sys, j6_handle_t endp, unsigned irq)
{
// TODO: check capabilities on sys handle
endpoint *e = get_handle<endpoint>(endp);
if (!e) return j6_err_invalid_arg;
// TODO: check capabilities on sys handle
endpoint *e = get_handle<endpoint>(endp);
if (!e) return j6_err_invalid_arg;
if (device_manager::get().bind_irq(irq, e))
return j6_status_ok;
if (device_manager::get().bind_irq(irq, e))
return j6_status_ok;
return j6_err_invalid_arg;
return j6_err_invalid_arg;
}
j6_status_t
system_map_phys(j6_handle_t sys, j6_handle_t *vma_handle, uintptr_t phys_addr, size_t size, uint32_t flags)
{
// TODO: check capabilities on sys handle
if (!vma_handle) return j6_err_invalid_arg;
// TODO: check capabilities on sys handle
if (!vma_handle) return j6_err_invalid_arg;
// TODO: check to see if frames are already used? How would that collide with
// the bootloader's allocated pages already being marked used?
if (!(flags & vm_flags::mmio))
frame_allocator::get().used(phys_addr, memory::page_count(size));
// TODO: check to see if frames are already used? How would that collide with
// the bootloader's allocated pages already being marked used?
if (!(flags & vm_flags::mmio))
frame_allocator::get().used(phys_addr, memory::page_count(size));
vm_flags vmf = (static_cast<vm_flags>(flags) & vm_flags::driver_mask);
construct_handle<vm_area_fixed>(vma_handle, phys_addr, size, vmf);
vm_flags vmf = (static_cast<vm_flags>(flags) & vm_flags::driver_mask);
construct_handle<vm_area_fixed>(vma_handle, phys_addr, size, vmf);
return j6_status_ok;
return j6_status_ok;
}
} // namespace syscalls

View File

@@ -10,48 +10,48 @@ namespace syscalls {
j6_status_t
thread_create(void *rip, j6_handle_t *handle)
{
thread &parent = thread::current();
process &p = parent.parent();
thread &parent = thread::current();
process &p = parent.parent();
thread *child = p.create_thread();
child->add_thunk_user(reinterpret_cast<uintptr_t>(rip));
*handle = child->self_handle();
child->clear_state(thread::state::loading);
child->set_state(thread::state::ready);
thread *child = p.create_thread();
child->add_thunk_user(reinterpret_cast<uintptr_t>(rip));
*handle = child->self_handle();
child->clear_state(thread::state::loading);
child->set_state(thread::state::ready);
log::debug(logs::task, "Thread %llx spawned new thread %llx, handle %d",
parent.koid(), child->koid(), *handle);
log::debug(logs::task, "Thread %llx spawned new thread %llx, handle %d",
parent.koid(), child->koid(), *handle);
return j6_status_ok;
return j6_status_ok;
}
j6_status_t
thread_exit(int32_t status)
{
thread &th = thread::current();
log::debug(logs::task, "Thread %llx exiting with code %d", th.koid(), status);
th.exit(status);
thread &th = thread::current();
log::debug(logs::task, "Thread %llx exiting with code %d", th.koid(), status);
th.exit(status);
log::error(logs::task, "returned to exit syscall");
return j6_err_unexpected;
log::error(logs::task, "returned to exit syscall");
return j6_err_unexpected;
}
j6_status_t
thread_pause()
{
thread &th = thread::current();
th.wait_on_signals(-1ull);
return j6_status_ok;
thread &th = thread::current();
th.wait_on_signals(-1ull);
return j6_status_ok;
}
j6_status_t
thread_sleep(uint64_t til)
{
thread &th = thread::current();
log::debug(logs::task, "Thread %llx sleeping until %llu", th.koid(), til);
thread &th = thread::current();
log::debug(logs::task, "Thread %llx sleeping until %llu", th.koid(), til);
th.wait_on_time(til);
return j6_status_ok;
th.wait_on_time(til);
return j6_status_ok;
}
} // namespace syscalls

View File

@@ -13,57 +13,57 @@ namespace syscalls {
j6_status_t
vma_create(j6_handle_t *handle, size_t size, uint32_t flags)
{
vm_flags f = vm_flags::user_mask & flags;
construct_handle<vm_area_open>(handle, size, f);
return j6_status_ok;
vm_flags f = vm_flags::user_mask & flags;
construct_handle<vm_area_open>(handle, size, f);
return j6_status_ok;
}
j6_status_t
vma_create_map(j6_handle_t *handle, size_t size, uintptr_t base, uint32_t flags)
{
vm_flags f = vm_flags::user_mask & flags;
vm_area *a = construct_handle<vm_area_open>(handle, size, f);
process::current().space().add(base, a);
return j6_status_ok;
vm_flags f = vm_flags::user_mask & flags;
vm_area *a = construct_handle<vm_area_open>(handle, size, f);
process::current().space().add(base, a);
return j6_status_ok;
}
j6_status_t
vma_map(j6_handle_t handle, j6_handle_t proc, uintptr_t base)
{
vm_area *a = get_handle<vm_area>(handle);
if (!a) return j6_err_invalid_arg;
vm_area *a = get_handle<vm_area>(handle);
if (!a) return j6_err_invalid_arg;
process *p = get_handle<process>(proc);
if (!p) return j6_err_invalid_arg;
process *p = get_handle<process>(proc);
if (!p) return j6_err_invalid_arg;
p->space().add(base, a);
return j6_status_ok;
p->space().add(base, a);
return j6_status_ok;
}
j6_status_t
vma_unmap(j6_handle_t handle, j6_handle_t proc)
{
vm_area *a = get_handle<vm_area>(handle);
if (!a) return j6_err_invalid_arg;
vm_area *a = get_handle<vm_area>(handle);
if (!a) return j6_err_invalid_arg;
process *p = get_handle<process>(proc);
if (!p) return j6_err_invalid_arg;
process *p = get_handle<process>(proc);
if (!p) return j6_err_invalid_arg;
p->space().remove(a);
return j6_status_ok;
p->space().remove(a);
return j6_status_ok;
}
j6_status_t
vma_resize(j6_handle_t handle, size_t *size)
{
if (!size)
return j6_err_invalid_arg;
if (!size)
return j6_err_invalid_arg;
vm_area *a = get_handle<vm_area>(handle);
if (!a) return j6_err_invalid_arg;
vm_area *a = get_handle<vm_area>(handle);
if (!a) return j6_err_invalid_arg;
*size = a->resize(*size);
return j6_status_ok;
*size = a->resize(*size);
return j6_status_ok;
}