compile syscall.c without errors
This commit is contained in:
parent
49833bdadb
commit
227cb420ca
|
@ -139,7 +139,7 @@ QEMU_CFLAGS+=-I$(SRC_PATH)/darwin-user/$(TARGET_ABI_DIR) \
|
|||
-I$(SRC_PATH)/darwin-user
|
||||
|
||||
obj-y += darwin-user/
|
||||
obj-y += gdbstub.o
|
||||
obj-y += gdbstub.o thunk.o
|
||||
|
||||
endif #CONFIG_DARWIN_USER
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ struct target_dirent {
|
|||
char d_name[1];
|
||||
};
|
||||
/* size of struct target_dirent without the name array */
|
||||
#define target_dirent_len (offsetof(struct target_dirent, d_name));
|
||||
#define target_dirent_len (offsetof(struct target_dirent, d_name))
|
||||
|
||||
/* IRIX sys/types.h */
|
||||
typedef uint64_t target_ino64_t;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/** Shim for macOS lack of `fallocate`
|
||||
* Based on:
|
||||
* https://stackoverflow.com/questions/11497567/fallocate-command-equivalent-in-os-x
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "shim_fallocate.h"
|
||||
|
||||
/** This emulates the Linux fallocate, so the errno is set, not returned
|
||||
* as in Posix
|
||||
*/
|
||||
int shim_fallocate(int fd, int mode, off_t offset, off_t len) {
|
||||
if (mode == SHIM_FALLOC_DEFAULT) {
|
||||
fstore_t store = {F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE, 0, len, 0};
|
||||
// Try to get a continous chunk of disk space
|
||||
int ret = fcntl(fd, F_PREALLOCATE, &store);
|
||||
// If too fragmented, allocated non-continous
|
||||
if (ret == -1) {
|
||||
store.fst_flags = F_ALLOCATEALL;
|
||||
ret = fcntl(fd, F_PREALLOCATE, &store);
|
||||
}
|
||||
|
||||
return ret;
|
||||
} else if (mode == SHIM_FALLOC_FL_PUNCH_HOLE) {
|
||||
fpunchhole_t hole = {0, 0, offset, len};
|
||||
int ret = fcntl(fd, F_PUNCHHOLE, &hole);
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
// TODO: set errno EINVAL, but this should be unreachable
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef SHIM_FALLOCATE_H
|
||||
#define SHIM_FALLOCATE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
int shim_fallocate(int fd, int mode, off_t offset, off_t len);
|
||||
|
||||
enum FALLOCATE_SHIM_MODES {
|
||||
SHIM_FALLOC_DEFAULT = 0,
|
||||
SHIM_FALLOC_FL_PUNCH_HOLE
|
||||
};
|
||||
|
||||
#endif /* SHIM_FALLOCATE_H */
|
|
@ -0,0 +1,47 @@
|
|||
/** Shim for macOS lack of POSIX `timer_*` functions and types
|
||||
* Right now, the timers don't seem to match IRIX anyways, so
|
||||
* these are all stub functions.
|
||||
*
|
||||
* The irix timer_t function is a struct, but `tagert_timer_t` is
|
||||
* defined for Linux qemu-irix as an int...
|
||||
*
|
||||
* For later:
|
||||
* https://nitschinger.at/Scheduling-Timers-on-OS-X-with-Rust-and-Kqueue/
|
||||
* https://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_getoverrun.html
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/signal.h>
|
||||
|
||||
#include "shim_timers.h"
|
||||
|
||||
|
||||
int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int timer_delete(timer_t timerid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int timer_getoverrun(timer_t timerid) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int timer_gettime(timer_t timerid, struct itimerspec *value) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int timer_settime(
|
||||
timer_t timerid,
|
||||
int flags,
|
||||
const struct itimerspec *value,
|
||||
struct itimerspec *ovalue
|
||||
){
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef SHIM_TIMERS_H
|
||||
#define SHIM_TIMERS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
struct itimerspec {
|
||||
struct timespec it_interval; /* timer period */
|
||||
struct timespec it_value; /* timer expiration */
|
||||
};
|
||||
|
||||
typedef int timer_t;
|
||||
|
||||
int timer_create(clockid_t, struct sigevent *, timer_t *);
|
||||
int timer_delete(timer_t);
|
||||
int timer_getoverrun(timer_t);
|
||||
int timer_gettime(timer_t, struct itimerspec *);
|
||||
int timer_settime(timer_t, int, const struct itimerspec *, struct itimerspec *);
|
||||
|
||||
#endif /* SHIM_TIMERS_H */
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue