This is the mail archive of the pthreads-win32@sourceware.org mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Pthreads-win32 on 64 bit Windows


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]