[m-rev.] diff: initial support for .par grades with MinGW64
Julien Fischer
jfischer at opturion.com
Fri Apr 5 17:11:47 AEDT 2013
Initial support for .par grades with MinGW64.
The pthreads-win32 has worked with 64-bit compilers since version 2.9.
This diff adds the initial support for the .par grades with MinGW64 and
pthreads-win32.
configure.ac:
Set C compiler and linker flags for x86_64-w64-mingw32.
(This is provisional; on my system the library appears
to have a different name, but I'm not sure how normal
this is.)
runtime/mercury_thread.h:
Adjust the definition of the MR_SELF_THREAD_ID macro
so that the integer it expands to is at least as big
as a pointer. (Needed for pthreads-win32 since thread
ids are pointer values, not integers with that.)
runtime/mercury_thread.c:
Avoid warnings in some debugging code.
Julien.
diff --git a/configure.ac b/configure.ac
index 87a0adc..a1d0dee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2977,10 +2977,6 @@ case "$host" in
esac
;;
- # NOTE: do *not* attempt to use pthreads if we are cross compiling
- # with the x86_64-w64-mingw32 GCC.
- # XXX we we will need to do something different here when we support
- # threads on 64-bit Windows.
i*86-pc-mingw*)
THREAD_LIBS=""
case "$mercury_cv_cc_type" in
@@ -2999,6 +2995,12 @@ case "$host" in
esac
;;
+ x86_64*w64*mingw32)
+ THREAD_LIBS=""
+ CFLAGS_FOR_THREADS="$WIN32_GC_THREADLIB"
+ THREAD_LIBS="-lpthread"
+ ;;
+
*apple*darwin*)
CFLAGS_FOR_THREADS="-DGC_DARWIN_THREADS"
THREAD_LIBS=""
diff --git a/runtime/mercury_thread.c b/runtime/mercury_thread.c
index d6cf167..99b5f68 100644
--- a/runtime/mercury_thread.c
+++ b/runtime/mercury_thread.c
@@ -264,11 +264,13 @@ MR_mutex_lock(MercuryLock *lock, const char *from)
{
int err;
- fprintf(stderr, "%ld locking on %p (%s)\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d locking on %p (%s)\n",
MR_SELF_THREAD_ID, lock, from);
fflush(stderr);
err = pthread_mutex_lock(lock);
- fprintf(stderr, "%ld lock returned %d\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d lock returned %d\n",
MR_SELF_THREAD_ID, err);
fflush(stderr);
assert(err == 0);
@@ -280,11 +282,13 @@ MR_mutex_unlock(MercuryLock *lock, const char *from)
{
int err;
- fprintf(stderr, "%ld unlocking on %p (%s)\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d unlocking on %p (%s)\n",
MR_SELF_THREAD_ID, lock, from);
fflush(stderr);
err = pthread_mutex_unlock(lock);
- fprintf(stderr, "%ld unlock returned %d\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d unlock returned %d\n",
MR_SELF_THREAD_ID, err);
fflush(stderr);
assert(err == 0);
@@ -296,11 +300,13 @@ MR_cond_signal(MercuryCond *cond, const char *from)
{
int err;
- fprintf(stderr, "%ld signaling %p (%s)\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d signaling %p (%s)\n",
MR_SELF_THREAD_ID, cond, from);
fflush(stderr);
err = pthread_cond_signal(cond);
- fprintf(stderr, "%ld signal returned %d\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d signal returned %d\n",
MR_SELF_THREAD_ID, err);
fflush(stderr);
assert(err == 0);
@@ -312,11 +318,13 @@ MR_cond_broadcast(MercuryCond *cond, const char *from)
{
int err;
- fprintf(stderr, "%ld broadcasting %p (%s)\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d broadcasting %p (%s)\n",
MR_SELF_THREAD_ID, cond, from);
fflush(stderr);
err = pthread_cond_broadcast(cond);
- fprintf(stderr, "%ld broadcast returned %d\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d broadcast returned %d\n",
MR_SELF_THREAD_ID, err);
fflush(stderr);
assert(err == 0);
@@ -328,11 +336,13 @@ MR_cond_wait(MercuryCond *cond, MercuryLock
*lock, const char *from)
{
int err;
- fprintf(stderr, "%ld waiting on cond: %p lock: %p (%s)\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d waiting on cond: %p lock: %p (%s)\n",
MR_SELF_THREAD_ID, cond, lock, from);
fflush(stderr);
err = pthread_cond_wait(cond, lock);
- fprintf(stderr, "%ld wait returned %d\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d wait returned %d\n",
MR_SELF_THREAD_ID, err);
fflush(stderr);
assert(err == 0);
@@ -345,11 +355,13 @@ MR_cond_timed_wait(MercuryCond *cond, MercuryLock *lock,
{
int err;
- fprintf(stderr, "%ld timed-waiting on cond: %p lock: %p (%s)\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d timed-waiting on cond: %p
lock: %p (%s)\n",
MR_SELF_THREAD_ID, cond, lock, from);
fflush(stderr);
err = pthread_cond_timedwait(cond, lock, abstime);
- fprintf(stderr, "%ld timed-wait returned %d\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d timed-wait returned %d\n",
MR_SELF_THREAD_ID, err);
fflush(stderr);
return err;
@@ -360,11 +372,13 @@ MR_sem_wait(MercurySem *sem, const char *from)
{
int err;
- fprintf(stderr, "%ld waiting on sem: %p (%s)\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d waiting on sem: %p (%s)\n",
MR_SELF_THREAD_ID, sem, from);
fflush(stderr);
err = sem_wait(sem);
- fprintf(stderr, "%ld wait returned %d\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d wait returned %d\n",
MR_SELF_THREAD_ID, err);
fflush(stderr);
@@ -376,11 +390,13 @@ MR_sem_post(MercurySem *sem, const char *from)
{
int err;
- fprintf(stderr, "%ld posting to sem: %p (%s)\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d posting to sem: %p (%s)\n",
MR_SELF_THREAD_ID, sem, from);
fflush(stderr);
err = sem_post(sem);
- fprintf(stderr, "%ld post returned %d\n",
+ fprintf(stderr,
+ "%" MR_INTEGER_LENGTH_MODIFIER "d post returned %d\n",
MR_SELF_THREAD_ID, err);
fflush(stderr);
diff --git a/runtime/mercury_thread.h b/runtime/mercury_thread.h
index 4a0e5b6..51965db 100644
--- a/runtime/mercury_thread.h
+++ b/runtime/mercury_thread.h
@@ -63,9 +63,9 @@ MR_null_thread(void);
#define MR_thread_equal(a, b) pthread_equal((a), (b))
#if defined(MR_PTHREADS_WIN32)
- #define MR_SELF_THREAD_ID ((long) pthread_self().p)
+ #define MR_SELF_THREAD_ID ((MR_Integer) pthread_self().p)
#else
- #define MR_SELF_THREAD_ID ((long) pthread_self())
+ #define MR_SELF_THREAD_ID ((MR_Integer) pthread_self())
#endif
extern MR_bool MR_debug_threads;
More information about the reviews
mailing list