public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: Tommi Vainikainen <tvainika@gmail.com>
To: pthreads-win32@sourceware.org
Subject: Pthreads-win32 on 64 bit Windows
Date: Wed, 24 Feb 2010 15:32:00 -0000	[thread overview]
Message-ID: <87hbp6tzsx.fsf@thv.iki.fi> (raw)

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
(<URL: http://msdn.microsoft.com/en-us/library/ms681947(VS.85).aspx > 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

                 reply	other threads:[~2010-02-24 15:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87hbp6tzsx.fsf@thv.iki.fi \
    --to=tvainika@gmail.com \
    --cc=pthreads-win32@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).