List:Commits« Previous MessageNext Message »
From:Stewart Smith Date:October 15 2008 4:35am
Subject:bzr commit into mysql-5.1 branch (stewart:3005)
View as plain text  
#At file:///C:/cygwin/home/stewart/mysql/win-ndbwin32/

 3005 Stewart Smith	2008-10-15
       convert Win32 pthread implementation to static inline functions rather than macros. All have correct signature then.
modified:
  include/my_pthread.h
  mysys/my_winthread.c

=== modified file 'include/my_pthread.h'
--- a/include/my_pthread.h	2008-08-21 06:38:03 +0000
+++ b/include/my_pthread.h	2008-10-15 05:27:54 +0000
@@ -101,7 +101,6 @@ struct timespec {
 }
 
 void win_pthread_init(void);
-int win_pthread_mutex_trylock(pthread_mutex_t *mutex);
 int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
 int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
 int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
@@ -135,18 +134,58 @@ void pthread_exit(void *a);	 /* was #def
 #undef SAFE_MUTEX				/* This will cause conflicts */
 typedef DWORD pthread_key_t;
 #define pthread_key(T,V)  DWORD V
-#define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF)
-#define pthread_key_delete(A) TlsFree(A)
-#define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V)))
-#define pthread_setspecific(A,B) (!TlsSetValue((A),(B)))
-#define pthread_getspecific(A) (TlsGetValue(A))
-#define my_pthread_getspecific(T,A) ((T) TlsGetValue(A))
-#define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(V))
 
-#define pthread_equal(A,B) ((A) == (B))
-#define pthread_mutex_init(A,B)  (InitializeCriticalSection(A),0)
-#define pthread_mutex_lock(A)	 (EnterCriticalSection(A),0)
-#define pthread_mutex_trylock(A) win_pthread_mutex_trylock((A))
+static inline int pthread_key_create(pthread_key_t *key, void (*destr_function)(void*))
+{
+  *key= TlsAlloc();
+  if(*key == TLS_OUT_OF_INDEXES)
+    return EAGAIN;
+  return 0;
+}
+
+static inline int pthread_key_delete(pthread_key_t key)
+{
+  if(TlsFree(key))
+    return 0;
+  return 1;
+}
+
+#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,V)
+
+static inline int pthread_setspecific(pthread_key_t key, const void *pointer)
+{
+  if(TlsSetValue(key, (void*)pointer))
+    return 0;
+  return 1;
+}
+
+static inline void* pthread_getspecific(pthread_key_t key)
+{
+  return TlsGetValue(key);
+}
+
+#define my_pthread_getspecific(T,A) ((T) pthread_getspecific(A))
+#define my_pthread_getspecific_ptr(T,V) ((T) pthread_getspecific(V))
+
+static inline int pthread_equal(pthread_t thread1, pthread_t thread2)
+{
+  return thread1 == thread2;
+}
+
+typedef void pthread_mutex_attr_t;
+static inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutex_attr_t *mutex_attr)
+{
+  InitializeCriticalSection(mutex);
+  return 0;
+}
+
+static inline int pthread_mutex_lock(pthread_mutex_t *mutex)
+{
+  EnterCriticalSection(mutex);
+  return 0;
+}
+
+int pthread_mutex_trylock(pthread_mutex_t *mutex);
 
 static inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
 {

=== modified file 'mysys/my_winthread.c'
--- a/mysys/my_winthread.c	2008-09-19 08:52:44 +0000
+++ b/mysys/my_winthread.c	2008-10-15 05:27:54 +0000
@@ -47,8 +47,7 @@ void win_pthread_init(void)
    @retval 0      Mutex was acquired
    @retval EBUSY  Mutex was already locked by a thread
  */
-int
-win_pthread_mutex_trylock(pthread_mutex_t *mutex)
+int pthread_mutex_trylock(pthread_mutex_t *mutex)
 {
   if (TryEnterCriticalSection(mutex))
   {

Thread
bzr commit into mysql-5.1 branch (stewart:3005) Stewart Smith15 Oct
  • RE: bzr commit into mysql-5.1 branch (stewart:3005)Vladislav Vaintroub15 Oct
    • Re: bzr commit into mysql-5.1 branch (stewart:3005)Stewart Smith15 Oct