21 syscall_log(
LOG_DEBUG,
"kill(pid=%d, sig=%d)\n", pid, sig);
37long sys_sigaction(
int sig,
const struct aquila_sigaction *act,
struct aquila_sigaction *oact)
39 syscall_log(
LOG_DEBUG,
"sigaction(sig=%d, act=%p, oact=%p)\n",
46 struct aquila_sigaction new;
48 if (act && copyin(&
new, act,
sizeof(
new))) {
66 if (oact && copyout(oact, &
curproc->sigaction[sig],
sizeof(
struct aquila_sigaction))) {
87 syscall_log(
LOG_DEBUG,
"gettimeofday(tv=%p, tz=%p)\n", tv, tz);
93 if (!err && ((tv && copyout(tv, &ktv,
sizeof(ktv))) || (tz && copyout(tz, &ktz,
sizeof(ktz)))))
110 syscall_log(
LOG_DEBUG,
"sigmask(how=%d, set=%p, oldset=%p)\n", how, set, oldset);
114 if (set && copyin(&kset, set,
sizeof(kset))) {
120 case SIG_BLOCK: mask |= kset;
break;
121 case SIG_UNBLOCK: mask &= ~kset;
break;
122 case SIG_SETMASK: mask = kset;
break;
148 syscall_log(
LOG_DEBUG,
"sigsuspend(set=%p)\n", set);
152 if (copyin(&kset, set,
sizeof(kset))) {
157 struct waitq wait = {0};
201long sys_setitimer(
int which,
const struct aquila_itimer *
new,
struct aquila_itimer *old)
203 syscall_log(
LOG_DEBUG,
"setitimer(which=%d, new=%p, old=%p)\n", which,
new, old);
205 struct aquila_itimer knew;
207 if (
new && copyin(&knew,
new,
sizeof(knew))) {
212 if (which != AQUILA_ITIMER_REAL) {
216 struct aquila_itimer prev = {0};
220 if (old && copyout(old, &prev,
sizeof(prev))) {
229 return old ? copyout(old, &prev,
sizeof(prev)) : 0;
242long sys_nanosleep(
const struct aquila_timespec *req,
struct aquila_timespec *rem)
244 syscall_log(
LOG_DEBUG,
"nanosleep(req=%p, rem=%p)\n", req, rem);
246 struct aquila_timespec kreq;
248 if (copyin(&kreq, req,
sizeof(kreq))) {
252 if (kreq.tv_nsec >= 1000000000) {
259 arch_rtime_ns() + kreq.tv_sec * 1000000000ULL + kreq.tv_nsec;
269 uint64_t left = now < until ? until - now : 0;
270 struct aquila_timespec krem = {
271 .tv_sec = left / 1000000000ULL,
272 .tv_nsec = left % 1000000000ULL,
275 if (copyout(rem, &krem,
sizeof(krem))) {
295 syscall_log(
LOG_DEBUG,
"clock_gettime(clock=%d, ts=%p)\n",
clock, ts);
297 struct aquila_timespec kts;
307 case CLOCK_MONOTONIC:
309 kts.tv_sec = ns / 1000000000ULL;
310 kts.tv_nsec = ns % 1000000000ULL;
316 return copyout(ts, &kts,
sizeof(kts));
void arch_sigreturn(void)
Returns from a signal handler, for sigreturn(): restores the registers, the signal mask and the FPU s...
void sched_alarm_get(struct proc *proc, uint64_t *value, uint64_t *interval)
Reads what is left of a process's real time timer.
void sched_alarm(struct proc *proc, uint64_t value, uint64_t interval, uint64_t *old_value, uint64_t *old_interval)
Sets a process's real time timer, which setitimer() and alarm() use: the process gets SIGALRM once va...
int sched_sleep(uint64_t until)
Puts the current thread to sleep until a time comes, for nanosleep().
int signal_send(int pid, int sig)
Sends a signal as kill() does.
void signal_action_set(struct proc *proc, int sig)
Discards a pending signal that sigaction() just made ignored.
unsigned long long int uint64_t
An installed handler, on its interrupt's list.
int sig_oldmask_set
in sigsuspend() or pselect(): the signal mask they replaced, which the handler's frame keeps (sigretu...
long sys_sigreturn(void)
Implements sigreturn(): a signal handler returns, and the registers and signal mask that its frame sa...
long sys_clock_gettime(int clock, struct aquila_timespec *ts)
Implements clock_gettime(): reads a clock.
long sys_setitimer(int which, const struct aquila_itimer *new, struct aquila_itimer *old)
Implements setitimer(): sets the real time timer, which sends SIGALRM, and reads the old one.
long sys_sigaction(int sig, const struct aquila_sigaction *act, struct aquila_sigaction *oact)
Implements sigaction(): reads a signal's action, and sets a new one.
long sys_kill(pid_t pid, int sig)
Implements kill(): sends a signal to a process or a process group.
long sys_gettimeofday(struct timeval *tv, struct timezone *tz)
Implements gettimeofday(): the time of day.
long sys_nanosleep(const struct aquila_timespec *req, struct aquila_timespec *rem)
Implements nanosleep(): sleeps for a time.
long sys_sigmask(int how, const sigset_t *set, sigset_t *oldset)
Implements sigprocmask(): reads and changes the process's signal mask.
long sys_sigsuspend(const sigset_t *set)
Implements sigsuspend(): replaces the signal mask and waits for a signal.
int gettime(struct timespec *ts)
Reads the wall clock (CLOCK_REALTIME).
int gettimeofday(struct timeval *tv, struct timezone *tz)
Reads the wall clock, in microseconds, for gettimeofday().
uint64_t arch_rtime_ns(void)
Reads the monotonic clock, which starts at boot.
static int uaccess_check(const void *ptr, size_t len)
Checks that [ptr, ptr + len) is in user space.
int waitq_sleep(struct waitq *waitq)
Puts the current thread to sleep on a wait queue until it is woken up.