From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17522 invoked by alias); 24 Feb 2010 15:32:27 -0000 Received: (qmail 17502 invoked by uid 22791); 24 Feb 2010 15:32:25 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail-bw0-f212.google.com (HELO mail-bw0-f212.google.com) (209.85.218.212) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 24 Feb 2010 15:32:20 +0000 Received: by bwz4 with SMTP id 4so3888382bwz.8 for ; Wed, 24 Feb 2010 07:32:17 -0800 (PST) Received: by 10.204.15.17 with SMTP id i17mr6804684bka.173.1267025536858; Wed, 24 Feb 2010 07:32:16 -0800 (PST) Received: from michelangelo (a91-152-169-252.elisa-laajakaista.fi [91.152.169.252]) by mx.google.com with ESMTPS id 14sm2747854bwz.6.2010.02.24.07.32.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 24 Feb 2010 07:32:16 -0800 (PST) From: Tommi Vainikainen To: pthreads-win32@sourceware.org Subject: Pthreads-win32 on 64 bit Windows Date: Wed, 24 Feb 2010 15:32:00 -0000 Message-ID: <87hbp6tzsx.fsf@thv.iki.fi> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2010/txt/msg00002.txt.bz2 Hi, I'm also in need of pthreads-win32 for 64-bit Windows. I played first a bit by cross-compiling with GCC pthreads-win32 CVS HEAD and with Kai Tietz's patch. I did not find any feedback on Kai Tietz's patch on the mailing list archive but at least for me some unit tests did not compile with it, and after some more patching, there is some issues running those. There is at least one big issue with Kai Tietz's patch which comes from _endthreadex(unsigned). In the patch the thread's return value is explicitly casted and assumed to be enough in size to store pointer type. This obviously fails on 64-bit environment. This seems to be however only problem with interoperating between native and pthreads-win32 created threads. However I'd like to submit some minor, trivial changes to be applied even if 64-bit support is not achieved with these only. First PAPCFUNC prototype on MSDN ( is: VOID CALLBACK APCProc( __in ULONG_PTR dwParam ); but in pthreads codebase param value is DWORD dwParam, which breaks on 64-bit, so here is a trivial patch: --- pthread_cancel.c 2010-02-17 12:25:57 +0000 +++ pthread_cancel.c 2010-02-17 12:30:22 +0000 @@ -47,7 +47,7 @@ } static void CALLBACK -ptw32_cancel_callback (DWORD unused) +ptw32_cancel_callback (ULONG_PTR unused) { ptw32_throw (PTW32_EPS_CANCEL); Also when compiling different targets, I noticed that GCE-inlined target does not compile. The following patch fixes this by inlining when wanted: --- ptw32_MCS_lock.c 2010-02-17 12:25:57 +0000 +++ ptw32_MCS_lock.c 2010-02-17 14:21:39 +0000 @@ -148,7 +148,10 @@ * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. */ -INLINE void +#ifdef PTW32_BUILD_INLINED +INLINE +#endif /* PTW32_BUILD_INLINED */ +void ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node) { ptw32_mcs_local_node_t *pred; @@ -179,7 +182,10 @@ * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. */ -INLINE void +#ifdef PTW32_BUILD_INLINED +INLINE +#endif /* PTW32_BUILD_INLINED */ +void ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node) { ptw32_mcs_lock_t *lock = node->lock; === modified file 'ptw32_relmillisecs.c' --- ptw32_relmillisecs.c 2010-02-17 12:25:57 +0000 +++ ptw32_relmillisecs.c 2010-02-17 14:21:39 +0000 @@ -44,7 +44,10 @@ #endif -INLINE DWORD +#ifdef PTW32_BUILD_INLINED +INLINE +#endif /* PTW32_BUILD_INLINED */ +DWORD ptw32_relmillisecs (const struct timespec * abstime) { const int64_t NANOSEC_PER_MILLISEC = 1000000; Third, there is extra ^M character (which was messing up diffs for the file in Kai Tietz's patch) in tests/stress1.c: --- tests/stress1.c 2010-02-17 12:25:57 +0000 +++ tests/stress1.c 2010-02-17 12:27:15 +0000 @@ -97,7 +97,7 @@ static int signalsTakenCount = 0; static int signalsSent = 0; static int bias = 0; -static int timeout = 10;^M // Must be > 0 +static int timeout = 10; // Must be > 0 enum { CTL_STOP = -1 -- Tommi Vainikainen