#include "thread/Task.h" #include "std/string.h" void set_context_from_task(Task& task, Context* ctx) { memcpy(ctx, &task.regs, sizeof(Context)); } void get_context_to_task(Task& task, Context* ctx) { memcpy(&task.regs, ctx, sizeof(Context)); } void task_save_floating(Task& task) { task.floating_saved = true; asm volatile("fxsave (%0)" : : "r"(&task.floating_region)); } void task_restore_floating(Task& task) { if (!task.floating_saved) return; asm volatile("fxrstor (%0)" : : "r"(&task.floating_region)); } bool Task::is_user_task() { return user_task; } int Task::alloc_fd() { int fd; for (fd = 0; fd < TASK_MAX_FDS; fd++) { if (!files[fd].is_open()) break; } if (fd == TASK_MAX_FDS) { return -1; } return fd; }