Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/librumphijack poll(), pollts() and select() all return i...



details:   https://anonhg.NetBSD.org/src/rev/6f726032a0e9
branches:  trunk
changeset: 778876:6f726032a0e9
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Apr 18 10:37:37 2012 +0000

description:
poll(), pollts() and select() all return int values, but in the hijack
emulation of them these get passed as exit values from a pthread as
a void* (c.f. pthread_join(), pthread_exit()).
Do not use the address of an int variable for these, but provide the address
of a void* and assign the value afterwards.
Fixes hijacking of pollts/select on 64bit big endian hosts.
Spotted by and fix from pooka.

diffstat:

 lib/librumphijack/hijack.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (48 lines):

diff -r ff103c6e4e82 -r 6f726032a0e9 lib/librumphijack/hijack.c
--- a/lib/librumphijack/hijack.c        Wed Apr 18 05:54:07 2012 +0000
+++ b/lib/librumphijack/hijack.c        Wed Apr 18 10:37:37 2012 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: hijack.c,v 1.91 2012/02/01 05:34:41 dholland Exp $    */
+/*      $NetBSD: hijack.c,v 1.92 2012/04/18 10:37:37 martin Exp $      */
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
 #undef _FORTIFY_SOURCE
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: hijack.c,v 1.91 2012/02/01 05:34:41 dholland Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.92 2012/04/18 10:37:37 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -1654,7 +1654,7 @@
                parg->errnum = errno;
        rump_sys_write(parg->pipefd, &rv, sizeof(rv));
 
-       return (void *)(intptr_t)rv;
+       return (void *)rv;
 }
 
 int
@@ -1676,8 +1676,8 @@
                struct pollfd *pfd_host = NULL, *pfd_rump = NULL;
                int rpipe[2] = {-1,-1}, hpipe[2] = {-1,-1};
                struct pollarg parg;
-               uintptr_t lrv;
-               int sverrno = 0, trv;
+               void *trv_val;
+               int sverrno = 0, lrv, trv;
 
                /*
                 * ok, this is where it gets tricky.  We must support
@@ -1770,7 +1770,8 @@
                lrv = op_pollts(pfd_rump, nfds+1, ts, NULL);
                sverrno = errno;
                write(hpipe[1], &rv, sizeof(rv));
-               pthread_join(pt, (void *)&trv);
+               pthread_join(pt, &trv_val);
+               trv = (int)(intptr_t)trv_val;
 
                /* check who "won" and merge results */
                if (lrv != 0 && pfd_host[nfds].revents & POLLIN) {



Home | Main Index | Thread Index | Old Index