Browse Source

sim: callback: add a getpid interface

Rather than hit the OS interface directly, use the existing callback
layer so the instantiator can decide behavior.
binutils-2_37-branch
Mike Frysinger 5 years ago
parent
commit
c45cffdbe1
  1. 4
      include/sim/ChangeLog
  2. 1
      include/sim/callback.h
  3. 6
      sim/common/ChangeLog
  4. 13
      sim/common/callback.c
  5. 3
      sim/common/syscall.c

4
include/sim/ChangeLog

@ -1,3 +1,7 @@
2021-06-22 Mike Frysinger <vapier@gentoo.org>
* sim/callback.h (struct host_callback_struct): Add getpid.
2021-05-14 Mike Frysinger <vapier@gentoo.org>
* sim/callback.h (struct host_callback_struct): Change lseek return and

1
include/sim/callback.h

@ -91,6 +91,7 @@ struct host_callback_struct
int (*to_lstat) (host_callback *, const char *, struct stat *);
int (*ftruncate) (host_callback *, int, int64_t);
int (*truncate) (host_callback *, const char *, int64_t);
int (*getpid) (host_callback *);
int (*pipe) (host_callback *, int *);
/* Called by the framework when a read call has emptied a pipe buffer. */

6
sim/common/ChangeLog

@ -1,3 +1,9 @@
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).

13
sim/common/callback.c

@ -556,6 +556,17 @@ os_truncate (host_callback *p, const char *file, int64_t len)
#endif
}
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)
{
@ -737,6 +748,8 @@ host_callback default_callback =
os_ftruncate,
os_truncate,
os_getpid,
os_pipe,
os_pipe_empty,
os_pipe_nonempty,

3
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 :

Loading…
Cancel
Save