Module Name: src Committed By: martin Date: Wed Apr 18 10:37:37 UTC 2012
Modified Files: src/lib/librumphijack: hijack.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/lib/librumphijack/hijack.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/librumphijack/hijack.c diff -u src/lib/librumphijack/hijack.c:1.91 src/lib/librumphijack/hijack.c:1.92 --- src/lib/librumphijack/hijack.c:1.91 Wed Feb 1 05:34:41 2012 +++ src/lib/librumphijack/hijack.c Wed Apr 18 10:37:37 2012 @@ -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 @@ hostpoll(void *arg) parg->errnum = errno; rump_sys_write(parg->pipefd, &rv, sizeof(rv)); - return (void *)(intptr_t)rv; + return (void *)rv; } int @@ -1676,8 +1676,8 @@ REALPOLLTS(struct pollfd *fds, nfds_t nf 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 @@ REALPOLLTS(struct pollfd *fds, nfds_t nf 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) {