Add support for clock syscalls
This commit is contained in:
@@ -294,4 +294,82 @@ ssize_t recvfrom(int sockfd, const void* buf, size_t size, int flags, const void
|
||||
return rtn;
|
||||
}
|
||||
|
||||
|
||||
int clock_settime(clockid_t clockid, const struct timespec *tp) {
|
||||
long int rtn;
|
||||
asm volatile (
|
||||
// Assembly Instructions
|
||||
"mov x8, #112\n" // Syscall number for 'listen' is 201 in AArch64
|
||||
"mov x0, %1\n" // fd
|
||||
"mov x1, %2\n" // backlog
|
||||
"svc #0\n" // Make the syscall
|
||||
"mov %0, x0\n" // save return value
|
||||
// Output operands
|
||||
: "=r" (rtn)
|
||||
// Input operand
|
||||
: "r" ((int64_t)clockid), "r"(tp)
|
||||
// Clobbered registers
|
||||
: "x0", "x1", "x8"
|
||||
);
|
||||
return (int32_t)rtn;
|
||||
}
|
||||
|
||||
int clock_gettime(clockid_t clockid, struct timespec *tp) {
|
||||
long int rtn;
|
||||
asm volatile (
|
||||
// Assembly Instructions
|
||||
"mov x8, #113\n" // Syscall number for 'listen' is 201 in AArch64
|
||||
"mov x0, %1\n" // fd
|
||||
"mov x1, %2\n" // backlog
|
||||
"svc #0\n" // Make the syscall
|
||||
"mov %0, x0\n" // save return value
|
||||
// Output operands
|
||||
: "=r" (rtn)
|
||||
// Input operand
|
||||
: "r" ((int64_t)clockid), "r"(tp)
|
||||
// Clobbered registers
|
||||
: "x0", "x1", "x8", "memory"
|
||||
);
|
||||
return (int32_t)rtn;
|
||||
}
|
||||
|
||||
int clock_getres(clockid_t clockid, struct timespec *res) {
|
||||
long int rtn;
|
||||
asm volatile (
|
||||
// Assembly Instructions
|
||||
"mov x8, #114\n" // Syscall number for 'listen' is 201 in AArch64
|
||||
"mov x0, %1\n" // fd
|
||||
"mov x1, %2\n" // backlog
|
||||
"svc #0\n" // Make the syscall
|
||||
"mov %0, x0\n" // save return value
|
||||
// Output operands
|
||||
: "=r" (rtn)
|
||||
// Input operand
|
||||
: "r" ((int64_t)clockid), "r"(res)
|
||||
// Clobbered registers
|
||||
: "x0", "x1", "x8", "memory"
|
||||
);
|
||||
return (int32_t)rtn;
|
||||
}
|
||||
|
||||
int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *t, struct timespec* remain) {
|
||||
long int rtn;
|
||||
asm volatile (
|
||||
// Assembly Instructions
|
||||
"mov x8, #115\n" // Syscall number for 'listen' is 201 in AArch64
|
||||
"mov x0, %1\n" // fd
|
||||
"mov x1, %2\n" // backlog
|
||||
"mov x2, %3\n" // backlog
|
||||
"svc #0\n" // Make the syscall
|
||||
"mov %0, x0\n" // save return value
|
||||
// Output operands
|
||||
: "=r" (rtn)
|
||||
// Input operand
|
||||
: "r" ((int64_t)clockid), "r"((int64_t)flags), "r"(t), "r"(remain)
|
||||
// Clobbered registers
|
||||
: "x0", "x1", "x8", "memory"
|
||||
);
|
||||
return (int32_t)rtn;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user