diff options
author | Mike Frysinger <vapier@gentoo.org> | 2021-06-20 12:38:27 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2021-06-22 19:36:28 -0400 |
commit | c45cffdbe1a1b816fd9a88f88bb83bd7078a1e4e (patch) | |
tree | ce8e3f7618908cb5d1c0472b0923a91442640b92 /sim/common | |
parent | e173c80fbb01dfed80a1b628157de3c0040d774b (diff) | |
download | gdb-c45cffdbe1a1b816fd9a88f88bb83bd7078a1e4e.zip gdb-c45cffdbe1a1b816fd9a88f88bb83bd7078a1e4e.tar.gz gdb-c45cffdbe1a1b816fd9a88f88bb83bd7078a1e4e.tar.bz2 |
sim: callback: add a getpid interface
Rather than hit the OS interface directly, use the existing callback
layer so the instantiator can decide behavior.
Diffstat (limited to 'sim/common')
-rw-r--r-- | sim/common/ChangeLog | 6 | ||||
-rw-r--r-- | sim/common/callback.c | 13 | ||||
-rw-r--r-- | sim/common/syscall.c | 3 |
3 files changed, 21 insertions, 1 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index bcf9242..5545771 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,5 +1,11 @@ 2021-06-22 Mike Frysinger <vapier@gentoo.org> + * callback.c (os_getpid): New function. + (default_callback): Add os_getpid. + * syscall.c (cb_syscall): Change getpid to cb->getpid. + +2021-06-22 Mike Frysinger <vapier@gentoo.org> + * Make-common.in (VPATH): Use $(srcdir). (config.status): New variable. (stamp-hw): Depend on $(config.status). diff --git a/sim/common/callback.c b/sim/common/callback.c index f2587a4..071e7b1 100644 --- a/sim/common/callback.c +++ b/sim/common/callback.c @@ -557,6 +557,17 @@ os_truncate (host_callback *p, const char *file, int64_t len) } static int +os_getpid (host_callback *p) +{ + int result; + + result = getpid (); + /* POSIX says getpid always succeeds. */ + p->last_errno = 0; + return result; +} + +static int os_pipe (host_callback *p, int *filedes) { int i; @@ -737,6 +748,8 @@ host_callback default_callback = os_ftruncate, os_truncate, + os_getpid, + os_pipe, os_pipe_empty, os_pipe_nonempty, diff --git a/sim/common/syscall.c b/sim/common/syscall.c index 4e76d20..7ef34b9 100644 --- a/sim/common/syscall.c +++ b/sim/common/syscall.c @@ -579,7 +579,8 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc) break; case CB_SYS_getpid: - result = getpid (); + /* POSIX says getpid always succeeds. */ + result = (*cb->getpid) (cb); break; case CB_SYS_time : |