1 /* ///////////////////////////////////////////////////////////////////////// 2 * File: asm/atomic.h 3 * 4 * Purpose: Declaration of Linux like atomic functions for the 5 * Win32 platform. 6 * 7 * Created: 21st November 2003 8 * Updated: 12th August 2010 9 * 10 * Home: http://synesis.com.au/software/ 11 * 12 * Copyright (c) 2003-2010, Matthew Wilson and Synesis Software 13 * All rights reserved. 14 * 15 * Redistribution and use in source and binary forms, with or without 16 * modification, are permitted provided that the following conditions are met: 17 * 18 * - Redistributions of source code must retain the above copyright notice, this 19 * list of conditions and the following disclaimer. 20 * - Redistributions in binary form must reproduce the above copyright notice, 21 * this list of conditions and the following disclaimer in the documentation 22 * and/or other materials provided with the distribution. 23 * - Neither the names of Matthew Wilson and Synesis Software nor the names of 24 * any contributors may be used to endorse or promote products derived from 25 * this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * POSSIBILITY OF SUCH DAMAGE. 38 * 39 * ////////////////////////////////////////////////////////////////////// */ 40 41 42 #ifndef SYNSOFT_UNIXEM_INCL_SYS_H_ATOMIC 43 #define SYNSOFT_UNIXEM_INCL_SYS_H_ATOMIC 44 45 #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 46 # define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_MAJOR 3 47 # define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_MINOR 0 48 # define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_REVISION 1 49 # define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_EDIT 18 50 #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 51 52 /* ///////////////////////////////////////////////////////////////////////// 53 * Includes 54 */ 55 56 #include <unixem/asm/atomic.h> 57 58 /* ////////////////////////////////////////////////////////////////////// */ 59 60 #ifndef _WIN32 61 # error This file is only currently defined for compilation on Win32 systems 62 #endif /* _WIN32 */ 63 64 /* ///////////////////////////////////////////////////////////////////////// 65 * Typedefs 66 */ 67 68 typedef unixem_atomic_t atomic_t; 69 70 /* ///////////////////////////////////////////////////////////////////////// 71 * API functions 72 */ 73 74 #ifdef __cplusplus 75 extern "C" { 76 #endif /* __cplusplus */ 77 78 #define ATOMIC_INIT(i) UNIXEM_ATOMIC_INIT(i) 79 80 #define atomic_set unixem_atomic_set 81 #define atomic_write unixem_atomic_write 82 #define atomic_read unixem_atomic_read 83 #define atomic_add unixem_atomic_add 84 #define atomic_sub unixem_atomic_sub 85 #define atomic_inc unixem_atomic_inc 86 #define atomic_dec unixem_atomic_dec 87 /** Returns the previous value */ 88 #define atomic_inc_and_test unixem_atomic_inc_and_test 89 /** Returns the previous value */ 90 #define atomic_dec_and_test unixem_atomic_dec_and_test 91 /** Returns the previous value */ 92 #define atomic_add_and_test unixem_atomic_add_and_test 93 /** Returns the previous value */ 94 #define atomic_sub_and_test unixem_atomic_sub_and_test 95 96 #ifdef __cplusplus 97 } 98 #endif /* __cplusplus */ 99 100 /* ////////////////////////////////////////////////////////////////////// */ 101 102 #endif /* SYNSOFT_UNIXEM_INCL_SYS_H_ATOMIC */ 103 104 /* ///////////////////////////// end of file //////////////////////////// */ 105