Apply clang-format for core/shared and product-mini files (#785)
Apply clang-format for core/shared and product-mini files
This commit is contained in:
@ -19,8 +19,8 @@
|
||||
#include <poll.h>
|
||||
#include <errno.h>
|
||||
|
||||
int ocall_open(const char *pathname, int flags,
|
||||
bool has_mode, unsigned mode)
|
||||
int
|
||||
ocall_open(const char *pathname, int flags, bool has_mode, unsigned mode)
|
||||
{
|
||||
if (has_mode) {
|
||||
return open(pathname, flags, (mode_t)mode);
|
||||
@ -30,9 +30,9 @@ int ocall_open(const char *pathname, int flags,
|
||||
}
|
||||
}
|
||||
|
||||
int ocall_openat(int dirfd,
|
||||
const char *pathname, int flags,
|
||||
bool has_mode, unsigned mode)
|
||||
int
|
||||
ocall_openat(int dirfd, const char *pathname, int flags, bool has_mode,
|
||||
unsigned mode)
|
||||
{
|
||||
if (has_mode) {
|
||||
return openat(dirfd, pathname, flags, (mode_t)mode);
|
||||
@ -42,12 +42,14 @@ int ocall_openat(int dirfd,
|
||||
}
|
||||
}
|
||||
|
||||
int ocall_close(int fd)
|
||||
int
|
||||
ocall_close(int fd)
|
||||
{
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
ssize_t ocall_read(int fd, void *buf, size_t read_size)
|
||||
ssize_t
|
||||
ocall_read(int fd, void *buf, size_t read_size)
|
||||
{
|
||||
if (buf != NULL) {
|
||||
return read(fd, buf, read_size);
|
||||
@ -57,45 +59,53 @@ ssize_t ocall_read(int fd, void *buf, size_t read_size)
|
||||
}
|
||||
}
|
||||
|
||||
off_t ocall_lseek(int fd, off_t offset, int whence)
|
||||
off_t
|
||||
ocall_lseek(int fd, off_t offset, int whence)
|
||||
{
|
||||
return lseek(fd, offset, whence);
|
||||
}
|
||||
|
||||
int ocall_ftruncate(int fd, off_t length)
|
||||
int
|
||||
ocall_ftruncate(int fd, off_t length)
|
||||
{
|
||||
return ftruncate(fd, length);
|
||||
}
|
||||
|
||||
int ocall_fsync(int fd)
|
||||
int
|
||||
ocall_fsync(int fd)
|
||||
{
|
||||
return fsync(fd);
|
||||
}
|
||||
|
||||
int ocall_fdatasync(int fd)
|
||||
int
|
||||
ocall_fdatasync(int fd)
|
||||
{
|
||||
return fdatasync(fd);
|
||||
}
|
||||
|
||||
int ocall_isatty(int fd)
|
||||
int
|
||||
ocall_isatty(int fd)
|
||||
{
|
||||
return isatty(fd);
|
||||
}
|
||||
|
||||
void ocall_fdopendir(int fd, void **dirp)
|
||||
void
|
||||
ocall_fdopendir(int fd, void **dirp)
|
||||
{
|
||||
if (dirp) {
|
||||
*(DIR **)dirp = fdopendir(fd);
|
||||
}
|
||||
}
|
||||
|
||||
void *ocall_readdir(void *dirp)
|
||||
void *
|
||||
ocall_readdir(void *dirp)
|
||||
{
|
||||
DIR *p_dirp = (DIR *)dirp;
|
||||
return readdir(p_dirp);
|
||||
}
|
||||
|
||||
void ocall_rewinddir(void *dirp)
|
||||
void
|
||||
ocall_rewinddir(void *dirp)
|
||||
{
|
||||
DIR *p_dirp = (DIR *)dirp;
|
||||
if (p_dirp) {
|
||||
@ -103,7 +113,8 @@ void ocall_rewinddir(void *dirp)
|
||||
}
|
||||
}
|
||||
|
||||
void ocall_seekdir(void *dirp, long loc)
|
||||
void
|
||||
ocall_seekdir(void *dirp, long loc)
|
||||
{
|
||||
DIR *p_dirp = (DIR *)dirp;
|
||||
|
||||
@ -112,7 +123,8 @@ void ocall_seekdir(void *dirp, long loc)
|
||||
}
|
||||
}
|
||||
|
||||
long ocall_telldir(void *dirp)
|
||||
long
|
||||
ocall_telldir(void *dirp)
|
||||
{
|
||||
DIR *p_dirp = (DIR *)dirp;
|
||||
if (p_dirp) {
|
||||
@ -121,7 +133,8 @@ long ocall_telldir(void *dirp)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ocall_closedir(void* dirp)
|
||||
int
|
||||
ocall_closedir(void *dirp)
|
||||
{
|
||||
DIR *p_dirp = (DIR *)dirp;
|
||||
if (p_dirp) {
|
||||
@ -130,82 +143,91 @@ int ocall_closedir(void* dirp)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ocall_stat(const char *pathname,
|
||||
void *buf, unsigned int buf_len)
|
||||
int
|
||||
ocall_stat(const char *pathname, void *buf, unsigned int buf_len)
|
||||
{
|
||||
return stat(pathname, (struct stat *)buf);
|
||||
}
|
||||
|
||||
int ocall_fstat(int fd, void *buf, unsigned int buf_len)
|
||||
int
|
||||
ocall_fstat(int fd, void *buf, unsigned int buf_len)
|
||||
{
|
||||
return fstat(fd, (struct stat *)buf);
|
||||
}
|
||||
|
||||
int ocall_fstatat(int dirfd, const char *pathname, void *buf,
|
||||
unsigned int buf_len, int flags)
|
||||
int
|
||||
ocall_fstatat(int dirfd, const char *pathname, void *buf, unsigned int buf_len,
|
||||
int flags)
|
||||
{
|
||||
return fstatat(dirfd, pathname, (struct stat *)buf, flags);
|
||||
}
|
||||
|
||||
int ocall_mkdirat(int dirfd, const char *pathname, unsigned mode)
|
||||
int
|
||||
ocall_mkdirat(int dirfd, const char *pathname, unsigned mode)
|
||||
{
|
||||
return mkdirat(dirfd, pathname, (mode_t)mode);
|
||||
}
|
||||
|
||||
int ocall_link(const char *oldpath, const char *newpath)
|
||||
int
|
||||
ocall_link(const char *oldpath, const char *newpath)
|
||||
{
|
||||
return link(oldpath, newpath);
|
||||
}
|
||||
|
||||
int ocall_linkat(int olddirfd, const char *oldpath,
|
||||
int newdirfd, const char *newpath, int flags)
|
||||
int
|
||||
ocall_linkat(int olddirfd, const char *oldpath, int newdirfd,
|
||||
const char *newpath, int flags)
|
||||
{
|
||||
return linkat(olddirfd, oldpath, newdirfd, newpath, flags);
|
||||
}
|
||||
|
||||
int ocall_unlinkat(int dirfd, const char *pathname, int flags)
|
||||
int
|
||||
ocall_unlinkat(int dirfd, const char *pathname, int flags)
|
||||
{
|
||||
return unlinkat(dirfd, pathname, flags);
|
||||
}
|
||||
|
||||
ssize_t ocall_readlinkat(int dirfd, const char *pathname,
|
||||
char *buf, size_t bufsiz)
|
||||
ssize_t
|
||||
ocall_readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz)
|
||||
{
|
||||
return readlinkat(dirfd, pathname, buf, bufsiz);
|
||||
}
|
||||
|
||||
int ocall_renameat(int olddirfd, const char *oldpath,
|
||||
int newdirfd, const char *newpath)
|
||||
int
|
||||
ocall_renameat(int olddirfd, const char *oldpath, int newdirfd,
|
||||
const char *newpath)
|
||||
{
|
||||
return renameat(olddirfd, oldpath, newdirfd, newpath);
|
||||
}
|
||||
|
||||
int ocall_symlinkat(const char *target, int newdirfd,
|
||||
const char *linkpath)
|
||||
int
|
||||
ocall_symlinkat(const char *target, int newdirfd, const char *linkpath)
|
||||
{
|
||||
return symlinkat(target, newdirfd, linkpath);
|
||||
}
|
||||
|
||||
int ocall_ioctl(int fd, unsigned long request,
|
||||
void *arg, unsigned int arg_len)
|
||||
int
|
||||
ocall_ioctl(int fd, unsigned long request, void *arg, unsigned int arg_len)
|
||||
{
|
||||
/* support just int *arg temporally */
|
||||
return ioctl(fd, request, (int *)arg);
|
||||
}
|
||||
|
||||
int ocall_fcntl(int fd, int cmd)
|
||||
int
|
||||
ocall_fcntl(int fd, int cmd)
|
||||
{
|
||||
return fcntl(fd, cmd);
|
||||
return fcntl(fd, cmd);
|
||||
}
|
||||
|
||||
int ocall_fcntl_long(int fd, int cmd, long arg)
|
||||
int
|
||||
ocall_fcntl_long(int fd, int cmd, long arg)
|
||||
{
|
||||
return fcntl(fd, cmd, arg);
|
||||
return fcntl(fd, cmd, arg);
|
||||
}
|
||||
|
||||
ssize_t ocall_readv(int fd, char *iov_buf,
|
||||
unsigned int buf_size, int iovcnt,
|
||||
bool has_offset, off_t offset)
|
||||
ssize_t
|
||||
ocall_readv(int fd, char *iov_buf, unsigned int buf_size, int iovcnt,
|
||||
bool has_offset, off_t offset)
|
||||
{
|
||||
struct iovec *iov = (struct iovec *)iov_buf;
|
||||
ssize_t ret;
|
||||
@ -223,9 +245,9 @@ ssize_t ocall_readv(int fd, char *iov_buf,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ssize_t ocall_writev(int fd, char *iov_buf,
|
||||
unsigned int buf_size, int iovcnt,
|
||||
bool has_offset, off_t offset)
|
||||
ssize_t
|
||||
ocall_writev(int fd, char *iov_buf, unsigned int buf_size, int iovcnt,
|
||||
bool has_offset, off_t offset)
|
||||
{
|
||||
struct iovec *iov = (struct iovec *)iov_buf;
|
||||
int i;
|
||||
@ -243,9 +265,10 @@ ssize_t ocall_writev(int fd, char *iov_buf,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ocall_realpath(const char *path, char *buf, unsigned int buf_len)
|
||||
int
|
||||
ocall_realpath(const char *path, char *buf, unsigned int buf_len)
|
||||
{
|
||||
char* val = NULL;
|
||||
char *val = NULL;
|
||||
val = realpath(path, buf);
|
||||
if (val != NULL) {
|
||||
return 0;
|
||||
@ -253,47 +276,53 @@ int ocall_realpath(const char *path, char *buf, unsigned int buf_len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ocall_posix_fallocate(int fd, off_t offset, off_t len)
|
||||
int
|
||||
ocall_posix_fallocate(int fd, off_t offset, off_t len)
|
||||
{
|
||||
return posix_fallocate(fd, offset, len);
|
||||
}
|
||||
|
||||
int ocall_poll(void *fds, unsigned nfds, int timeout,
|
||||
unsigned int fds_len)
|
||||
int
|
||||
ocall_poll(void *fds, unsigned nfds, int timeout, unsigned int fds_len)
|
||||
{
|
||||
return poll((struct pollfd *)fds, (nfds_t)nfds, timeout);
|
||||
}
|
||||
|
||||
int ocall_getopt(int argc, char *argv_buf, unsigned int argv_buf_len,
|
||||
const char *optstring)
|
||||
int
|
||||
ocall_getopt(int argc, char *argv_buf, unsigned int argv_buf_len,
|
||||
const char *optstring)
|
||||
{
|
||||
int ret;
|
||||
int i;
|
||||
char **argv = (char **)argv_buf;
|
||||
|
||||
for (i=0; i < argc; i++) {
|
||||
for (i = 0; i < argc; i++) {
|
||||
argv[i] = argv_buf + (uintptr_t)argv[i];
|
||||
}
|
||||
|
||||
return getopt(argc, argv, optstring);
|
||||
}
|
||||
|
||||
ssize_t ocall_getrandom(void *buf, size_t buflen, unsigned int flags)
|
||||
ssize_t
|
||||
ocall_getrandom(void *buf, size_t buflen, unsigned int flags)
|
||||
{
|
||||
return getrandom(buf, buflen, flags);
|
||||
}
|
||||
|
||||
int ocall_getentropy(void *buffer, size_t length)
|
||||
int
|
||||
ocall_getentropy(void *buffer, size_t length)
|
||||
{
|
||||
return getentropy(buffer, length);
|
||||
}
|
||||
|
||||
int ocall_sched_yield()
|
||||
int
|
||||
ocall_sched_yield()
|
||||
{
|
||||
return sched_yield();
|
||||
}
|
||||
|
||||
int ocall_get_errno()
|
||||
int
|
||||
ocall_get_errno()
|
||||
{
|
||||
return errno;
|
||||
}
|
||||
|
||||
@ -6,7 +6,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
int ocall_pthread_rwlock_init(void **rwlock, void *attr)
|
||||
int
|
||||
ocall_pthread_rwlock_init(void **rwlock, void *attr)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@ -15,7 +16,7 @@ int ocall_pthread_rwlock_init(void **rwlock, void *attr)
|
||||
return -1;
|
||||
|
||||
ret = pthread_rwlock_init((pthread_rwlock_t *)*rwlock, NULL);
|
||||
if (ret != 0) {
|
||||
if (ret != 0) {
|
||||
free(*rwlock);
|
||||
*rwlock = NULL;
|
||||
}
|
||||
@ -23,7 +24,8 @@ int ocall_pthread_rwlock_init(void **rwlock, void *attr)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ocall_pthread_rwlock_destroy(void *rwlock)
|
||||
int
|
||||
ocall_pthread_rwlock_destroy(void *rwlock)
|
||||
{
|
||||
pthread_rwlock_t *lock = (pthread_rwlock_t *)rwlock;
|
||||
int ret;
|
||||
@ -33,18 +35,20 @@ int ocall_pthread_rwlock_destroy(void *rwlock)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ocall_pthread_rwlock_rdlock(void *rwlock)
|
||||
int
|
||||
ocall_pthread_rwlock_rdlock(void *rwlock)
|
||||
{
|
||||
return pthread_rwlock_rdlock((pthread_rwlock_t *)rwlock);
|
||||
}
|
||||
|
||||
int ocall_pthread_rwlock_wrlock(void *rwlock)
|
||||
int
|
||||
ocall_pthread_rwlock_wrlock(void *rwlock)
|
||||
{
|
||||
return pthread_rwlock_wrlock((pthread_rwlock_t *)rwlock);
|
||||
}
|
||||
|
||||
int ocall_pthread_rwlock_unlock(void *rwlock)
|
||||
int
|
||||
ocall_pthread_rwlock_unlock(void *rwlock)
|
||||
{
|
||||
return pthread_rwlock_unlock((pthread_rwlock_t *)rwlock);
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,8 @@
|
||||
*/
|
||||
#include <signal.h>
|
||||
|
||||
int ocall_raise(int sig)
|
||||
int
|
||||
ocall_raise(int sig)
|
||||
{
|
||||
return raise(sig);
|
||||
}
|
||||
@ -7,20 +7,21 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
int ocall_socket(int domain, int type, int protocol)
|
||||
int
|
||||
ocall_socket(int domain, int type, int protocol)
|
||||
{
|
||||
return socket(domain, type, protocol);
|
||||
}
|
||||
|
||||
int ocall_getsockopt(int sockfd, int level, int optname, void *val_buf,
|
||||
unsigned int val_buf_size, void *len_buf)
|
||||
int
|
||||
ocall_getsockopt(int sockfd, int level, int optname, void *val_buf,
|
||||
unsigned int val_buf_size, void *len_buf)
|
||||
{
|
||||
return getsockopt(sockfd, level, optname, val_buf,
|
||||
(socklen_t *)len_buf);
|
||||
return getsockopt(sockfd, level, optname, val_buf, (socklen_t *)len_buf);
|
||||
}
|
||||
|
||||
ssize_t ocall_sendmsg(int sockfd, void *msg_buf,
|
||||
unsigned int msg_buf_size, int flags)
|
||||
ssize_t
|
||||
ocall_sendmsg(int sockfd, void *msg_buf, unsigned int msg_buf_size, int flags)
|
||||
{
|
||||
struct msghdr *msg = (struct msghdr *)msg_buf;
|
||||
int i;
|
||||
@ -35,16 +36,16 @@ ssize_t ocall_sendmsg(int sockfd, void *msg_buf,
|
||||
if (msg->msg_iov != NULL) {
|
||||
msg->msg_iov = msg_buf + (unsigned)(uintptr_t)msg->msg_iov;
|
||||
for (i = 0; i < msg->msg_iovlen; i++) {
|
||||
msg->msg_iov[i].iov_base = msg_buf + (unsigned)(uintptr_t)
|
||||
msg->msg_iov[i].iov_base;
|
||||
msg->msg_iov[i].iov_base =
|
||||
msg_buf + (unsigned)(uintptr_t)msg->msg_iov[i].iov_base;
|
||||
}
|
||||
}
|
||||
|
||||
return sendmsg(sockfd, msg, flags);
|
||||
}
|
||||
|
||||
ssize_t ocall_recvmsg(int sockfd, void *msg_buf, unsigned int msg_buf_size,
|
||||
int flags)
|
||||
ssize_t
|
||||
ocall_recvmsg(int sockfd, void *msg_buf, unsigned int msg_buf_size, int flags)
|
||||
{
|
||||
struct msghdr *msg = (struct msghdr *)msg_buf;
|
||||
int i;
|
||||
@ -58,16 +59,17 @@ ssize_t ocall_recvmsg(int sockfd, void *msg_buf, unsigned int msg_buf_size,
|
||||
|
||||
if (msg->msg_iov != NULL) {
|
||||
msg->msg_iov = msg_buf + (unsigned)(uintptr_t)msg->msg_iov;
|
||||
for (i = 0; i <msg->msg_iovlen; i++) {
|
||||
msg->msg_iov[i].iov_base = msg_buf + (unsigned)(uintptr_t)
|
||||
msg->msg_iov[i].iov_base;
|
||||
for (i = 0; i < msg->msg_iovlen; i++) {
|
||||
msg->msg_iov[i].iov_base =
|
||||
msg_buf + (unsigned)(uintptr_t)msg->msg_iov[i].iov_base;
|
||||
}
|
||||
}
|
||||
|
||||
return recvmsg(sockfd, msg, flags);
|
||||
}
|
||||
|
||||
int ocall_shutdown(int sockfd, int how)
|
||||
int
|
||||
ocall_shutdown(int sockfd, int how)
|
||||
{
|
||||
return shutdown(sockfd, how);
|
||||
}
|
||||
@ -7,41 +7,38 @@
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
/** time clock **/
|
||||
int ocall_clock_gettime(unsigned clock_id, void *tp_buf,
|
||||
unsigned int tp_buf_size)
|
||||
int
|
||||
ocall_clock_gettime(unsigned clock_id, void *tp_buf, unsigned int tp_buf_size)
|
||||
{
|
||||
return clock_gettime((clockid_t)clock_id,
|
||||
(struct timespec *)tp_buf);
|
||||
return clock_gettime((clockid_t)clock_id, (struct timespec *)tp_buf);
|
||||
}
|
||||
|
||||
int ocall_clock_getres(int clock_id, void *res_buf,
|
||||
unsigned int res_buf_size)
|
||||
int
|
||||
ocall_clock_getres(int clock_id, void *res_buf, unsigned int res_buf_size)
|
||||
{
|
||||
return clock_getres(clock_id, (struct timespec *)res_buf);
|
||||
}
|
||||
|
||||
int ocall_utimensat(int dirfd, const char *pathname,
|
||||
const void *times_buf,
|
||||
unsigned int times_buf_size, int flags)
|
||||
int
|
||||
ocall_utimensat(int dirfd, const char *pathname, const void *times_buf,
|
||||
unsigned int times_buf_size, int flags)
|
||||
{
|
||||
return utimensat(dirfd, pathname, (struct timespec *)times_buf, flags);
|
||||
|
||||
}
|
||||
|
||||
int ocall_futimens(int fd, const void *times_buf,
|
||||
unsigned int times_buf_size)
|
||||
int
|
||||
ocall_futimens(int fd, const void *times_buf, unsigned int times_buf_size)
|
||||
{
|
||||
return futimens(fd, (struct timespec *)times_buf);
|
||||
}
|
||||
|
||||
int ocall_clock_nanosleep(unsigned clock_id, int flags,
|
||||
const void *req_buf, unsigned int req_buf_size,
|
||||
const void *rem_buf, unsigned int rem_buf_size)
|
||||
int
|
||||
ocall_clock_nanosleep(unsigned clock_id, int flags, const void *req_buf,
|
||||
unsigned int req_buf_size, const void *rem_buf,
|
||||
unsigned int rem_buf_size)
|
||||
{
|
||||
return clock_nanosleep((clockid_t)clock_id, flags,
|
||||
(struct timespec *)req_buf,
|
||||
(struct timespec *)rem_buf);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user