![]() |
|||||
|
00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: unixem/asm/atomic.h 00003 * 00004 * Purpose: Declaration of Linux like atomic functions for the 00005 * Win32 platform. 00006 * 00007 * Created: 21st November 2003 00008 * Updated: 12th August 2010 00009 * 00010 * Home: http://synesis.com.au/software/ 00011 * 00012 * Copyright (c) 2003-2010, Matthew Wilson and Synesis Software 00013 * All rights reserved. 00014 * 00015 * Redistribution and use in source and binary forms, with or without 00016 * modification, are permitted provided that the following conditions are 00017 * met: 00018 * 00019 * - Redistributions of source code must retain the above copyright notice, 00020 * this list of conditions and the following disclaimer. 00021 * - Redistributions in binary form must reproduce the above copyright 00022 * notice, this list of conditions and the following disclaimer in the 00023 * documentation and/or other materials provided with the distribution. 00024 * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 00025 * names of any contributors may be used to endorse or promote products 00026 * derived from this software without specific prior written permission. 00027 * 00028 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00029 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00030 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00031 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00032 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00033 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00034 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00035 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00036 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00037 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00038 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00039 * 00040 * ////////////////////////////////////////////////////////////////////// */ 00041 00042 00043 #ifndef SYNSOFT_UNIXEM_INCL_UNIXEM_ASM_H_ATOMIC 00044 #define SYNSOFT_UNIXEM_INCL_UNIXEM_ASM_H_ATOMIC 00045 00046 #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 00047 # define SYNSOFT_UNIXEM_VER_UNIXEM_ASM_H_ATOMIC_MAJOR 3 00048 # define SYNSOFT_UNIXEM_VER_UNIXEM_ASM_H_ATOMIC_MINOR 0 00049 # define SYNSOFT_UNIXEM_VER_UNIXEM_ASM_H_ATOMIC_REVISION 1 00050 # define SYNSOFT_UNIXEM_VER_UNIXEM_ASM_H_ATOMIC_EDIT 17 00051 #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 00052 00053 /* ////////////////////////////////////////////////////////////////////// */ 00054 00055 #ifndef _WIN32 00056 # error This file is only currently defined for compilation on Win32 systems 00057 #endif /* _WIN32 */ 00058 00059 /* ///////////////////////////////////////////////////////////////////////// 00060 * Constants and definitions 00061 */ 00062 00063 #include <unixem/unixem.h> 00064 00065 /* ///////////////////////////////////////////////////////////////////////// 00066 * Typedefs 00067 */ 00068 00069 typedef signed long unixem_atomic_t; 00070 00071 /* ///////////////////////////////////////////////////////////////////////// 00072 * API functions 00073 */ 00074 00075 #ifdef __cplusplus 00076 extern "C" { 00077 #endif /* __cplusplus */ 00078 00079 #define UNIXEM_ATOMIC_INIT(i) (i) 00080 00081 void unixem_atomic_set(unixem_atomic_t volatile *v, int i); 00082 int unixem_atomic_write(unixem_atomic_t volatile *v, int i); 00083 int unixem_atomic_read(unixem_atomic_t volatile *v); 00084 00085 void unixem_atomic_add(int i, unixem_atomic_t volatile *v); 00086 void unixem_atomic_sub(int i, unixem_atomic_t volatile *v); 00087 00088 void unixem_atomic_inc(unixem_atomic_t volatile *v); 00089 void unixem_atomic_dec(unixem_atomic_t volatile *v); 00090 00092 int unixem_atomic_inc_and_test(unixem_atomic_t volatile *v); 00094 int unixem_atomic_dec_and_test(unixem_atomic_t volatile *v); 00095 00097 int unixem_atomic_add_and_test(int i, unixem_atomic_t volatile *v); 00099 int unixem_atomic_sub_and_test(int i, unixem_atomic_t volatile *v); 00100 00101 #ifdef __cplusplus 00102 } 00103 #endif /* __cplusplus */ 00104 00105 /* ////////////////////////////////////////////////////////////////////// */ 00106 00107 #endif /* SYNSOFT_UNIXEM_INCL_UNIXEM_ASM_H_ATOMIC */ 00108 00109 /* ///////////////////////////// end of file //////////////////////////// */
|
UNIX Emulation for Win32 Libraries documentation © Synesis Software Pty Ltd, 2002-2010 |