[PATCH] s_lock support for win32 - Mailing list pgsql-patches

From Manfred Spraul
Subject [PATCH] s_lock support for win32
Date
Msg-id 40E2F60E.4060000@colorfullife.com
Whole thread Raw
Responses Re: [PATCH] s_lock support for win32  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-patches
Hi,

The win32 port doesn't have a native user space spinlock implementation
yet. Attached is an untested patch - could someone test it? I don't have
Visual C++.

--
    Manfred
Index: src/include/storage/s_lock.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/storage/s_lock.h,v
retrieving revision 1.126
diff -c -r1.126 s_lock.h
*** src/include/storage/s_lock.h    19 Jun 2004 23:02:32 -0000    1.126
--- src/include/storage/s_lock.h    30 Jun 2004 17:14:08 -0000
***************
*** 648,653 ****
--- 648,661 ----

  #endif    /* !defined(HAS_TEST_AND_SET) */

+ #if defined(WIN32)
+ #define HAS_TEST_AND_SET
+
+ typedef long slock_t;
+
+ #define TAS(lock)    (InterlockedExchange(lock, 1))
+ #define S_UNLOCK(lock)    (InterlockedExchange(lock, 0))
+ #endif

  /* Blow up if we didn't have any way to do spinlocks */
  #ifndef HAS_TEST_AND_SET

pgsql-patches by date:

Previous
From: Manfred Spraul
Date:
Subject: [PATCH] fix libpq mutex initialization for multithreaded win32 libs
Next
From: Kris Jurka
Date:
Subject: Re: psql schema permissions