a0d3a7a158
CloudABI executables that are emulated on Mac OS X do not invoke system calls through "syscall". Instead, they make use of a vDSO that is provided by the emulator that provides symbols for all of the system call routines. The emulator can implement these any way it likes. At some point in time we want to do this for native execution as well, so that CloudABI executables are entirely oblivious of how system calls need to be performed. They will simply call into functions and let that deal with all of the details. These source files can be used to generate a simple vDSO that does nothing more than invoke "syscall". All we need to do now is map it into the processes. Obtained from: https://github.com/NuxiNL/cloudabi
1611 lines
40 KiB
C
1611 lines
40 KiB
C
// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors.
|
|
//
|
|
// Redistribution and use in source and binary forms, with or without
|
|
// modification, are permitted provided that the following conditions
|
|
// are met:
|
|
// 1. Redistributions of source code must retain the above copyright
|
|
// notice, this list of conditions and the following disclaimer.
|
|
// 2. Redistributions in binary form must reproduce the above copyright
|
|
// notice, this list of conditions and the following disclaimer in the
|
|
// documentation and/or other materials provided with the distribution.
|
|
//
|
|
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
// SUCH DAMAGE.
|
|
//
|
|
// This file is automatically generated. Do not edit.
|
|
//
|
|
// Source: https://github.com/NuxiNL/cloudabi
|
|
|
|
#include <cloudabi_types.h>
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_clock_res_get(
|
|
cloudabi_clockid_t clock_id,
|
|
cloudabi_timestamp_t *resolution
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 0;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)clock_id;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*resolution = (cloudabi_timestamp_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_clock_time_get(
|
|
cloudabi_clockid_t clock_id,
|
|
cloudabi_timestamp_t precision,
|
|
cloudabi_timestamp_t *time
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 1;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)clock_id;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)precision;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*time = (cloudabi_timestamp_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_condvar_signal(
|
|
_Atomic(cloudabi_condvar_t) *condvar,
|
|
cloudabi_scope_t scope,
|
|
cloudabi_nthreads_t nwaiters
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 2;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)condvar;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)scope;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)nwaiters;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_close(
|
|
cloudabi_fd_t fd
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 3;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_create1(
|
|
cloudabi_filetype_t type,
|
|
cloudabi_fd_t *fd
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 4;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)type;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*fd = (cloudabi_fd_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_create2(
|
|
cloudabi_filetype_t type,
|
|
cloudabi_fd_t *fd1,
|
|
cloudabi_fd_t *fd2
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 5;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)type;
|
|
register uint64_t reg_x1 asm("x1");
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
, "=r"(reg_x1)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*fd1 = (cloudabi_fd_t)reg_x0;
|
|
*fd2 = (cloudabi_fd_t)reg_x1;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_datasync(
|
|
cloudabi_fd_t fd
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 6;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_dup(
|
|
cloudabi_fd_t from,
|
|
cloudabi_fd_t *fd
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 7;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)from;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*fd = (cloudabi_fd_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_pread(
|
|
cloudabi_fd_t fd,
|
|
const cloudabi_iovec_t *iov,
|
|
size_t iovcnt,
|
|
cloudabi_filesize_t offset,
|
|
size_t *nread
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 8;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)iov;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)iovcnt;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)offset;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*nread = (size_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_pwrite(
|
|
cloudabi_fd_t fd,
|
|
const cloudabi_ciovec_t *iov,
|
|
size_t iovcnt,
|
|
cloudabi_filesize_t offset,
|
|
size_t *nwritten
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 9;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)iov;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)iovcnt;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)offset;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*nwritten = (size_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_read(
|
|
cloudabi_fd_t fd,
|
|
const cloudabi_iovec_t *iov,
|
|
size_t iovcnt,
|
|
size_t *nread
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 10;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)iov;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)iovcnt;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*nread = (size_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_replace(
|
|
cloudabi_fd_t from,
|
|
cloudabi_fd_t to
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 11;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)from;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)to;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_seek(
|
|
cloudabi_fd_t fd,
|
|
cloudabi_filedelta_t offset,
|
|
cloudabi_whence_t whence,
|
|
cloudabi_filesize_t *newoffset
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 12;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)offset;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)whence;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*newoffset = (cloudabi_filesize_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_stat_get(
|
|
cloudabi_fd_t fd,
|
|
cloudabi_fdstat_t *buf
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 13;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_stat_put(
|
|
cloudabi_fd_t fd,
|
|
const cloudabi_fdstat_t *buf,
|
|
cloudabi_fdsflags_t flags
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 14;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)flags;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_sync(
|
|
cloudabi_fd_t fd
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 15;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_fd_write(
|
|
cloudabi_fd_t fd,
|
|
const cloudabi_ciovec_t *iov,
|
|
size_t iovcnt,
|
|
size_t *nwritten
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 16;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)iov;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)iovcnt;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*nwritten = (size_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_advise(
|
|
cloudabi_fd_t fd,
|
|
cloudabi_filesize_t offset,
|
|
cloudabi_filesize_t len,
|
|
cloudabi_advice_t advice
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 17;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)offset;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)len;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)advice;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_allocate(
|
|
cloudabi_fd_t fd,
|
|
cloudabi_filesize_t offset,
|
|
cloudabi_filesize_t len
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 18;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)offset;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)len;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_create(
|
|
cloudabi_fd_t fd,
|
|
const char *path,
|
|
size_t pathlen,
|
|
cloudabi_filetype_t type
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 19;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)path;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)type;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_link(
|
|
cloudabi_lookup_t fd1,
|
|
const char *path1,
|
|
size_t path1len,
|
|
cloudabi_fd_t fd2,
|
|
const char *path2,
|
|
size_t path2len
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 20;
|
|
register uint64_t reg_x0 asm("x0") = *(uint64_t *)&fd1;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)path1;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)path1len;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)fd2;
|
|
register uint64_t reg_x4 asm("x4") = (uint64_t)path2;
|
|
register uint64_t reg_x5 asm("x5") = (uint64_t)path2len;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
, "r"(reg_x4)
|
|
, "r"(reg_x5)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_open(
|
|
cloudabi_lookup_t dirfd,
|
|
const char *path,
|
|
size_t pathlen,
|
|
cloudabi_oflags_t oflags,
|
|
const cloudabi_fdstat_t *fds,
|
|
cloudabi_fd_t *fd
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 21;
|
|
register uint64_t reg_x0 asm("x0") = *(uint64_t *)&dirfd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)path;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)oflags;
|
|
register uint64_t reg_x4 asm("x4") = (uint64_t)fds;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
, "r"(reg_x4)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*fd = (cloudabi_fd_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_readdir(
|
|
cloudabi_fd_t fd,
|
|
void *buf,
|
|
size_t nbyte,
|
|
cloudabi_dircookie_t cookie,
|
|
size_t *bufused
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 22;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)nbyte;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)cookie;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*bufused = (size_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_readlink(
|
|
cloudabi_fd_t fd,
|
|
const char *path,
|
|
size_t pathlen,
|
|
char *buf,
|
|
size_t bufsize,
|
|
size_t *bufused
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 23;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)path;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)buf;
|
|
register uint64_t reg_x4 asm("x4") = (uint64_t)bufsize;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
, "r"(reg_x4)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*bufused = (size_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_rename(
|
|
cloudabi_fd_t oldfd,
|
|
const char *old,
|
|
size_t oldlen,
|
|
cloudabi_fd_t newfd,
|
|
const char *new,
|
|
size_t newlen
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 24;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)oldfd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)old;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)oldlen;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)newfd;
|
|
register uint64_t reg_x4 asm("x4") = (uint64_t)new;
|
|
register uint64_t reg_x5 asm("x5") = (uint64_t)newlen;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
, "r"(reg_x4)
|
|
, "r"(reg_x5)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_stat_fget(
|
|
cloudabi_fd_t fd,
|
|
cloudabi_filestat_t *buf
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 25;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_stat_fput(
|
|
cloudabi_fd_t fd,
|
|
const cloudabi_filestat_t *buf,
|
|
cloudabi_fsflags_t flags
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 26;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)flags;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_stat_get(
|
|
cloudabi_lookup_t fd,
|
|
const char *path,
|
|
size_t pathlen,
|
|
cloudabi_filestat_t *buf
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 27;
|
|
register uint64_t reg_x0 asm("x0") = *(uint64_t *)&fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)path;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)buf;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_stat_put(
|
|
cloudabi_lookup_t fd,
|
|
const char *path,
|
|
size_t pathlen,
|
|
const cloudabi_filestat_t *buf,
|
|
cloudabi_fsflags_t flags
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 28;
|
|
register uint64_t reg_x0 asm("x0") = *(uint64_t *)&fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)path;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)buf;
|
|
register uint64_t reg_x4 asm("x4") = (uint64_t)flags;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
, "r"(reg_x4)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_symlink(
|
|
const char *path1,
|
|
size_t path1len,
|
|
cloudabi_fd_t fd,
|
|
const char *path2,
|
|
size_t path2len
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 29;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)path1;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)path1len;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)fd;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)path2;
|
|
register uint64_t reg_x4 asm("x4") = (uint64_t)path2len;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
, "r"(reg_x4)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_file_unlink(
|
|
cloudabi_fd_t fd,
|
|
const char *path,
|
|
size_t pathlen,
|
|
cloudabi_ulflags_t flags
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 30;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)path;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)flags;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_lock_unlock(
|
|
_Atomic(cloudabi_lock_t) *lock,
|
|
cloudabi_scope_t scope
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 31;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)lock;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)scope;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_mem_advise(
|
|
void *addr,
|
|
size_t len,
|
|
cloudabi_advice_t advice
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 32;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)len;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)advice;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_mem_lock(
|
|
const void *addr,
|
|
size_t len
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 33;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)len;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_mem_map(
|
|
void *addr,
|
|
size_t len,
|
|
cloudabi_mprot_t prot,
|
|
cloudabi_mflags_t flags,
|
|
cloudabi_fd_t fd,
|
|
cloudabi_filesize_t off,
|
|
void **mem
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 34;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)len;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)prot;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)flags;
|
|
register uint64_t reg_x4 asm("x4") = (uint64_t)fd;
|
|
register uint64_t reg_x5 asm("x5") = (uint64_t)off;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
, "r"(reg_x4)
|
|
, "r"(reg_x5)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*mem = (void *)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_mem_protect(
|
|
void *addr,
|
|
size_t len,
|
|
cloudabi_mprot_t prot
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 35;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)len;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)prot;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_mem_sync(
|
|
void *addr,
|
|
size_t len,
|
|
cloudabi_msflags_t flags
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 36;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)len;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)flags;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_mem_unlock(
|
|
const void *addr,
|
|
size_t len
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 37;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)len;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_mem_unmap(
|
|
void *addr,
|
|
size_t len
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 38;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)len;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_poll(
|
|
const cloudabi_subscription_t *in,
|
|
cloudabi_event_t *out,
|
|
size_t nsubscriptions,
|
|
size_t *nevents
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 39;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)in;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)out;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)nsubscriptions;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*nevents = (size_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_poll_fd(
|
|
cloudabi_fd_t fd,
|
|
const cloudabi_subscription_t *in,
|
|
size_t nin,
|
|
cloudabi_event_t *out,
|
|
size_t nout,
|
|
const cloudabi_subscription_t *timeout,
|
|
size_t *nevents
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 57;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)in;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)nin;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)out;
|
|
register uint64_t reg_x4 asm("x4") = (uint64_t)nout;
|
|
register uint64_t reg_x5 asm("x5") = (uint64_t)timeout;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
, "r"(reg_x4)
|
|
, "r"(reg_x5)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*nevents = (size_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_proc_exec(
|
|
cloudabi_fd_t fd,
|
|
const void *data,
|
|
size_t datalen,
|
|
const cloudabi_fd_t *fds,
|
|
size_t fdslen
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 40;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)data;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)datalen;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)fds;
|
|
register uint64_t reg_x4 asm("x4") = (uint64_t)fdslen;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
, "r"(reg_x4)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
_Noreturn void
|
|
cloudabi_sys_proc_exit(
|
|
cloudabi_exitcode_t rval
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 41;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)rval;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
:
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
for (;;);
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_proc_fork(
|
|
cloudabi_fd_t *fd,
|
|
cloudabi_tid_t *tid
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 42;
|
|
register uint64_t reg_x0 asm("x0");
|
|
register uint64_t reg_x1 asm("x1");
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
, "=r"(reg_x1)
|
|
: "r"(reg_x8)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*fd = (cloudabi_fd_t)reg_x0;
|
|
*tid = (cloudabi_tid_t)reg_x1;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_proc_raise(
|
|
cloudabi_signal_t sig
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 43;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)sig;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_random_get(
|
|
void *buf,
|
|
size_t nbyte
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 44;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)buf;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)nbyte;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_sock_accept(
|
|
cloudabi_fd_t sock,
|
|
cloudabi_sockstat_t *buf,
|
|
cloudabi_fd_t *conn
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 45;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*conn = (cloudabi_fd_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_sock_bind(
|
|
cloudabi_fd_t sock,
|
|
cloudabi_fd_t fd,
|
|
const char *path,
|
|
size_t pathlen
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 46;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)fd;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)path;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)pathlen;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_sock_connect(
|
|
cloudabi_fd_t sock,
|
|
cloudabi_fd_t fd,
|
|
const char *path,
|
|
size_t pathlen
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 47;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)fd;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)path;
|
|
register uint64_t reg_x3 asm("x3") = (uint64_t)pathlen;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
, "r"(reg_x3)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_sock_listen(
|
|
cloudabi_fd_t sock,
|
|
cloudabi_backlog_t backlog
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 48;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)backlog;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_sock_recv(
|
|
cloudabi_fd_t sock,
|
|
const cloudabi_recv_in_t *in,
|
|
cloudabi_recv_out_t *out
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 49;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)in;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)out;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_sock_send(
|
|
cloudabi_fd_t sock,
|
|
const cloudabi_send_in_t *in,
|
|
cloudabi_send_out_t *out
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 50;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)in;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)out;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_sock_shutdown(
|
|
cloudabi_fd_t sock,
|
|
cloudabi_sdflags_t how
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 51;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)how;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_sock_stat_get(
|
|
cloudabi_fd_t sock,
|
|
cloudabi_sockstat_t *buf,
|
|
cloudabi_ssflags_t flags
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 52;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
|
|
register uint64_t reg_x2 asm("x2") = (uint64_t)flags;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
, "r"(reg_x2)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_thread_create(
|
|
cloudabi_threadattr_t *attr,
|
|
cloudabi_tid_t *tid
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 53;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)attr;
|
|
register uint64_t okay;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
"\tcset %0, cc\n"
|
|
: "=r"(okay)
|
|
, "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
if (okay) {
|
|
*tid = (cloudabi_tid_t)reg_x0;
|
|
return 0;
|
|
}
|
|
return reg_x0;
|
|
}
|
|
|
|
_Noreturn void
|
|
cloudabi_sys_thread_exit(
|
|
_Atomic(cloudabi_lock_t) *lock,
|
|
cloudabi_scope_t scope
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 54;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)lock;
|
|
register uint64_t reg_x1 asm("x1") = (uint64_t)scope;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
:
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
, "r"(reg_x1)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
for (;;);
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_thread_tcb_set(
|
|
void *tcb
|
|
) {
|
|
register uint64_t reg_x8 asm("x8") = 55;
|
|
register uint64_t reg_x0 asm("x0") = (uint64_t)tcb;
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
, "r"(reg_x0)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|
|
cloudabi_errno_t
|
|
cloudabi_sys_thread_yield(void) {
|
|
register uint64_t reg_x8 asm("x8") = 56;
|
|
register uint64_t reg_x0 asm("x0");
|
|
asm volatile (
|
|
"\tsvc 0\n"
|
|
: "=r"(reg_x0)
|
|
: "r"(reg_x8)
|
|
: "memory"
|
|
, "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"
|
|
, "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"
|
|
, "x16", "x17", "x18"
|
|
, "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
|
|
return reg_x0;
|
|
}
|
|
|