You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2003/12/03 02:05:07 UTC
cvs commit: apr/atomic/win32 apr_atomic.c
trawick 2003/12/02 17:05:07
Modified: . apr.dsp libapr.dsp
atomic/unix apr_atomic.c
Added: atomic/win32 apr_atomic.c
Log:
move win32 atomic functions out of the unix file (which wasn't built
on win32 anyway) and into a unique file
apr_atomic_casptr() is busted for me on win32, as I am missing the
magic bits for InterlockedCompareExchangePointer()
Revision Changes Path
1.129 +8 -0 apr/apr.dsp
Index: apr.dsp
===================================================================
RCS file: /home/cvs/apr/apr.dsp,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -r1.128 -r1.129
--- apr.dsp 16 Nov 2003 23:49:14 -0000 1.128
+++ apr.dsp 3 Dec 2003 01:05:07 -0000 1.129
@@ -84,6 +84,14 @@
# Begin Group "Source Files"
# PROP Default_Filter ".c"
+# Begin Group "atomic"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\atomic\win32\apr_atomic.c
+# End Source File
+# End Group
# Begin Group "dso"
# PROP Default_Filter ""
1.94 +8 -0 apr/libapr.dsp
Index: libapr.dsp
===================================================================
RCS file: /home/cvs/apr/libapr.dsp,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -r1.93 -r1.94
--- libapr.dsp 28 Sep 2003 16:46:29 -0000 1.93
+++ libapr.dsp 3 Dec 2003 01:05:07 -0000 1.94
@@ -90,6 +90,14 @@
# Begin Group "Source Files"
# PROP Default_Filter ".c"
+# Begin Group "atomic"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\atomic\win32\apr_atomic.c
+# End Source File
+# End Group
# Begin Group "dso"
# PROP Default_Filter ""
1.28 +0 -70 apr/atomic/unix/apr_atomic.c
Index: apr_atomic.c
===================================================================
RCS file: /home/cvs/apr/atomic/unix/apr_atomic.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- apr_atomic.c 3 Dec 2003 00:10:03 -0000 1.27
+++ apr_atomic.c 3 Dec 2003 01:05:07 -0000 1.28
@@ -56,76 +56,6 @@
#include "apr_atomic.h"
#include "apr_thread_mutex.h"
-#if defined(WIN32)
-
-APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
-{
- return APR_SUCCESS;
-}
-
-APR_DECLARE(void *) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
-{
- return InterlockedCompareExchangePointer(mem, with, cmp);
-}
-
-/*
- * Remapping function pointer type to accept apr_uint32_t's type-safely
- * as the arguments for as our apr_atomic_foo32 Functions
- */
-typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_fn)
- (apr_uint32_t volatile *);
-typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_val_fn)
- (apr_uint32_t volatile *,
- apr_uint32_t);
-typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_val_val_fn)
- (apr_uint32_t volatile *,
- apr_uint32_t, apr_uint32_t);
-
-APR_DECLARE(void) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
-{
- ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, val);
-}
-#define APR_OVERRIDE_ATOMIC_ADD32
-
-APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
-{
- ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, -val);
-}
-#define APR_OVERRIDE_ATOMIC_SUB32
-
-APR_DECLARE(void) apr_atomic_inc32(volatile apr_uint32_t *mem)
-{
- ((apr_atomic_win32_ptr_fn)InterlockedIncrement)(mem);
-}
-#define APR_OVERRIDE_ATOMIC_INC32
-
-APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
-{
- return ((apr_atomic_win32_ptr_fn)InterlockedDecrement)(mem);
-}
-#define APR_OVERRIDE_ATOMIC_DEC32
-
-APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
-{
- ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val);
-}
-#define APR_OVERRIDE_ATOMIC_SET32
-
-APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,
- apr_uint32_t cmp)
-{
- return ((apr_atomic_win32_ptr_val_val_fn)InterlockedCompareExchange)(mem, with, cmp);
-}
-#define APR_OVERRIDE_ATOMIC_CAS32
-
-APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val)
-{
- return ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val);
-}
-#define APR_OVERRIDE_ATOMIC_XCHG32
-
-#endif /* WIN32 */
-
#if defined(__FreeBSD__) && !defined(__i386__) && !APR_FORCE_ATOMIC_GENERIC
#include <machine/atomic.h>
1.1 apr/atomic/win32/apr_atomic.c
Index: apr_atomic.c
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "apr.h"
#include "apr_atomic.h"
#include "apr_thread_mutex.h"
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
{
return APR_SUCCESS;
}
APR_DECLARE(void *) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
{
return InterlockedCompareExchangePointer(mem, with, cmp);
}
/*
* Remapping function pointer type to accept apr_uint32_t's type-safely
* as the arguments for as our apr_atomic_foo32 Functions
*/
typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_fn)
(apr_uint32_t volatile *);
typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_val_fn)
(apr_uint32_t volatile *,
apr_uint32_t);
typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_val_val_fn)
(apr_uint32_t volatile *,
apr_uint32_t, apr_uint32_t);
APR_DECLARE(void) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
{
((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, val);
}
APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
{
((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, -val);
}
APR_DECLARE(void) apr_atomic_inc32(volatile apr_uint32_t *mem)
{
((apr_atomic_win32_ptr_fn)InterlockedIncrement)(mem);
}
APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
{
return ((apr_atomic_win32_ptr_fn)InterlockedDecrement)(mem);
}
APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
{
((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val);
}
APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem)
{
return *mem;
}
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,
apr_uint32_t cmp)
{
return ((apr_atomic_win32_ptr_val_val_fn)InterlockedCompareExchange)(mem, with, cmp);
}
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val)
{
return ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val);
}