From: Antti Kantee Date: Wed, 15 Apr 2015 10:10:31 +0000 (+0000) Subject: separate stubs which should return error or -1 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5a8ba2d88461809c17cde37b5d4440347b778d9a;p=people%2Fliuw%2Frumprun.git separate stubs which should return error or -1 --- diff --git a/lib/librumprun_base/libc_stubs.c b/lib/librumprun_base/libc_stubs.c index 6dbdace..40bb691 100644 --- a/lib/librumprun_base/libc_stubs.c +++ b/lib/librumprun_base/libc_stubs.c @@ -26,7 +26,8 @@ #include #include -#define STUB(name) \ +/* XXX: incorrect return value, need to fix other things first */ +#define STUB_ERRNO(name) \ int name(void); int name(void) { \ static int done = 0; \ errno = ENOTSUP; \ @@ -34,31 +35,39 @@ fprintf(stderr, "STUB ``%s'' called\n", #name); \ return ENOTSUP;} -STUB(__sigaction14); -STUB(__sigaction_sigtramp); -STUB(sigaction); -STUB(sigprocmask); -STUB(__getrusage50); +#define STUB_RETURN(name) \ + int name(void); int name(void) { \ + static int done = 0; \ + if (done) return ENOTSUP; done = 1; \ + fprintf(stderr, "STUB ``%s'' called\n", #name); \ + return ENOTSUP;} + +STUB_RETURN(posix_spawn); + +STUB_ERRNO(__sigaction14); +STUB_ERRNO(__sigaction_sigtramp); +STUB_ERRNO(sigaction); +STUB_ERRNO(sigprocmask); +STUB_ERRNO(__getrusage50); -STUB(__fork); -STUB(__vfork14); -STUB(kill); -STUB(getpriority); -STUB(setpriority); -STUB(posix_spawn); +STUB_ERRNO(__fork); +STUB_ERRNO(__vfork14); +STUB_ERRNO(kill); +STUB_ERRNO(getpriority); +STUB_ERRNO(setpriority); -STUB(mlockall); +STUB_ERRNO(mlockall); /* for pthread_cancelstub */ -STUB(_sys_mq_send); -STUB(_sys_mq_receive); -STUB(_sys___mq_timedsend50); -STUB(_sys___mq_timedreceive50); -STUB(_sys_msgrcv); -STUB(_sys_msgsnd); -STUB(_sys___msync13); -STUB(_sys___wait450); -STUB(_sys___sigsuspend14); +STUB_ERRNO(_sys_mq_send); +STUB_ERRNO(_sys_mq_receive); +STUB_ERRNO(_sys___mq_timedsend50); +STUB_ERRNO(_sys___mq_timedreceive50); +STUB_ERRNO(_sys_msgrcv); +STUB_ERRNO(_sys_msgsnd); +STUB_ERRNO(_sys___msync13); +STUB_ERRNO(_sys___wait450); +STUB_ERRNO(_sys___sigsuspend14); /* execve is open-coded to match the prototype to avoid a compiler warning */ int execve(const char *, char *const[], char *const[]);