summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpj <rpj>2011-06-29 06:19:26 +0000
committerrpj <rpj>2011-06-29 06:19:26 +0000
commit5fdebbca2831af55fcd17d1819ec68dc17e2ec58 (patch)
treeafc3ee148258f406a98c78e801b5c58ef551ac00
parent3f334b78ab4447a37ed40b34c5fdd1aac76d3df7 (diff)
See the ChangeLog
-rw-r--r--ChangeLog10
-rw-r--r--global.c2
-rw-r--r--implement.h4
-rw-r--r--pthread.h1
-rwxr-xr-xpthread_getunique_np.c2
-rw-r--r--ptw32_relmillisecs.c8
-rw-r--r--ptw32_timespec.c10
7 files changed, 25 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index a987cf4..956ad53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-06-29 Daniel Richard G. <skunk at iskunk dot org>
+
+ * ptw32_relmillisecs.c (ftime):
+ _ftime64_s() is only available in MSVC 2005 or later;
+ _ftime64() is available in MinGW or MSVC 2002 or later;
+ _ftime() is always available.
+ * pthread.h (long long): Not defined in older MSVC 6.
+ * implement.h (long long): Likewise.
+ * pthread_getunique_np.c (long long): Likewise.
+
2011-06-29 Ross Johnson <ross dot johnson at homemail dot com dot au>
* *.[ch] (PTW32_INTERLOCKED_*): These macros should now work for
diff --git a/global.c b/global.c
index b73a399..f1e9b3f 100644
--- a/global.c
+++ b/global.c
@@ -55,7 +55,7 @@ int ptw32_features = 0;
/*
* Global [process wide] thread sequence Number
*/
-unsigned long long ptw32_threadSeqNumber = 0;
+unsigned __int64 ptw32_threadSeqNumber = 0;
/*
* Function pointer to QueueUserAPCEx if it exists, otherwise
diff --git a/implement.h b/implement.h
index 0053193..a221128 100644
--- a/implement.h
+++ b/implement.h
@@ -136,7 +136,7 @@ struct ptw32_thread_t_
#if defined(_UWIN)
DWORD dummy[5];
#endif
- UINT64 seqNumber; /* Process-unique thread sequence number */
+ unsigned __int64 seqNumber; /* Process-unique thread sequence number */
DWORD thread; /* Win32 thread ID */
HANDLE threadH; /* Win32 thread handle - POSIX thread is invalid if threadH == 0 */
pthread_t ptHandle; /* This thread's permanent pthread_t handle */
@@ -561,7 +561,7 @@ extern pthread_cond_t ptw32_cond_list_tail;
extern int ptw32_mutex_default_kind;
-extern unsigned long long ptw32_threadSeqNumber;
+extern unsigned __int64 ptw32_threadSeqNumber;
extern int ptw32_concurrency;
diff --git a/pthread.h b/pthread.h
index 1d2d7d3..9f5e8f1 100644
--- a/pthread.h
+++ b/pthread.h
@@ -203,6 +203,7 @@
* VC++6.0 or early compiler's header has no DWORD_PTR type.
*/
typedef unsigned long DWORD_PTR;
+typedef unsigned long ULONG_PTR;
#endif
/*
* -----------------
diff --git a/pthread_getunique_np.c b/pthread_getunique_np.c
index f81fc61..4496c68 100755
--- a/pthread_getunique_np.c
+++ b/pthread_getunique_np.c
@@ -40,7 +40,7 @@
/*
*
*/
-unsigned long long
+unsigned __int64
pthread_getunique_np (pthread_t thread)
{
return ((ptw32_thread_t*)thread.p)->seqNumber;
diff --git a/ptw32_relmillisecs.c b/ptw32_relmillisecs.c
index c9224ff..894d5c9 100644
--- a/ptw32_relmillisecs.c
+++ b/ptw32_relmillisecs.c
@@ -57,7 +57,8 @@ ptw32_relmillisecs (const struct timespec * abstime)
FILETIME ft;
SYSTEMTIME st;
#else /* ! NEED_FTIME */
-#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601
+#if ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \
+ ( (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 )
struct __timeb64 currSysTime;
#else
struct _timeb currSysTime;
@@ -98,9 +99,10 @@ ptw32_relmillisecs (const struct timespec * abstime)
#else /* ! NEED_FTIME */
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && _MSC_VER >= 1400
_ftime64_s(&currSysTime);
-#elif (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601
+#elif ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \
+ ( (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 )
_ftime64(&currSysTime);
#else
_ftime(&currSysTime);
diff --git a/ptw32_timespec.c b/ptw32_timespec.c
index c448645..6318957 100644
--- a/ptw32_timespec.c
+++ b/ptw32_timespec.c
@@ -45,7 +45,7 @@
* time between jan 1, 1601 and jan 1, 1970 in units of 100 nanoseconds
*/
#define PTW32_TIMESPEC_TO_FILETIME_OFFSET \
- ( ((LONGLONG) 27111902 << 32) + (LONGLONG) 3577643008 )
+ ( ((int64_t) 27111902 << 32) + (int64_t) 3577643008 )
INLINE void
ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft)
@@ -58,7 +58,7 @@ ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft)
* -------------------------------------------------------------------
*/
{
- *(LONGLONG *) ft = ts->tv_sec * 10000000
+ *(int64_t *) ft = ts->tv_sec * 10000000
+ (ts->tv_nsec + 50) / 100 + PTW32_TIMESPEC_TO_FILETIME_OFFSET;
}
@@ -74,10 +74,10 @@ ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts)
*/
{
ts->tv_sec =
- (int) ((*(LONGLONG *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET) / 10000000);
+ (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET) / 10000000);
ts->tv_nsec =
- (int) ((*(LONGLONG *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET -
- ((LONGLONG) ts->tv_sec * (LONGLONG) 10000000)) * 100);
+ (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET -
+ ((int64_t) ts->tv_sec * (int64_t) 10000000)) * 100);
}
#endif /* NEED_FTIME */