![]() |
|||||
|
00001 /* 00002 * File: atomic.h 00003 * 00004 * Purpose: Declaration of Linux like atomic functions for the 00005 * Win32 platform. 00006 * 00007 * Created 21st November 2003 00008 * Updated: 18th December 2003 00009 * 00010 * Author: Matthew Wilson, Synesis Software Pty Ltd. 00011 * 00012 * License: (Licensed under the Synesis Software Standard Source License) 00013 * 00014 * Copyright (C) 2002, Synesis Software Pty Ltd. 00015 * 00016 * All rights reserved. 00017 * 00018 * www: http://www.synesis.com.au/ 00019 * http://www.synesis.com.au/software/ 00020 * 00021 * email: software@synesis.com.au 00022 * software@synesis-group.com 00023 * 00024 * Redistribution and use in source and binary forms, with or 00025 * without modification, are permitted provided that the following 00026 * conditions are met: 00027 * 00028 * (i) Redistributions of source code must retain the above 00029 * copyright notice and contact information, this list of 00030 * conditions and the following disclaimer. 00031 * 00032 * (ii) Any derived versions of this software (howsoever modified) 00033 * remain the sole property of Synesis Software. 00034 * 00035 * (iii) Any derived versions of this software (howsoever modified) 00036 * remain subject to all these conditions. 00037 * 00038 * (iv) Neither the name of Synesis Software nor the names of any 00039 * subdivisions, employees or agents of Synesis Software, nor the 00040 * names of any other contributors to this software may be used to 00041 * endorse or promote products derived from this software without 00042 * specific prior written permission. 00043 * 00044 * This source code is provided by Synesis Software "as is" and any 00045 * warranties, whether expressed or implied, including, but not 00046 * limited to, the implied warranties of merchantability and 00047 * fitness for a particular purpose are disclaimed. In no event 00048 * shall the Synesis Software be liable for any direct, indirect, 00049 * incidental, special, exemplary, or consequential damages 00050 * (including, but not limited to, procurement of substitute goods 00051 * or services; loss of use, data, or profits; or business 00052 * interruption) however caused and on any theory of liability, 00053 * whether in contract, strict liability, or tort (including 00054 * negligence or otherwise) arising in any way out of the use of 00055 * this software, even if advised of the possibility of such 00056 * damage. 00057 * 00058 * 00059 00060 00061 #ifndef _SYNSOFT_INCL_H_DIRENT 00062 #define _SYNSOFT_INCL_H_ATOMIC 00063 00064 #ifndef _SYNSOFT_DOCUMENTATION_SKIP_SECTION 00065 # define _SYNSOFT_VER_H_ATOMIC_MAJOR 1 00066 # define _SYNSOFT_VER_H_ATOMIC_MINOR 1 00067 # define _SYNSOFT_VER_H_ATOMIC_REVISION 1 00068 # define _SYNSOFT_VER_H_ATOMIC_EDIT 4 00069 #endif /* !_SYNSOFT_DOCUMENTATION_SKIP_SECTION */ 00070 00071 /* 00072 00073 #ifndef WIN32 00074 # error This file is only currently defined for Win32 compilation units 00075 #endif /* WIN32 */ 00076 00077 /* 00078 * Constants and definitions 00079 */ 00080 00081 00082 /* 00083 * Typedefs 00084 */ 00085 00086 typedef signed long atomic_t; 00087 00088 /* 00089 * API functions 00090 */ 00091 00092 #ifdef __cplusplus 00093 extern "C" { 00094 #endif /* __cplusplus */ 00095 00096 #define ATOMIC_INIT(i) (i) 00097 00098 void atomic_set(atomic_t volatile *v, int i); 00099 int atomic_write(atomic_t volatile *v, int i); 00100 int atomic_read(atomic_t volatile *v); 00101 00102 void atomic_add(int i, atomic_t volatile *v); 00103 void atomic_sub(int i, atomic_t volatile *v); 00104 00105 void atomic_inc(atomic_t volatile *v); 00106 void atomic_dec(atomic_t volatile *v); 00107 00108 // Returns the previous value 00109 int atomic_inc_and_test(atomic_t volatile *v); 00110 // Returns the previous value 00111 int atomic_dec_and_test(atomic_t volatile *v); 00112 00113 // Returns the previous value 00114 int atomic_add_and_test(int i, atomic_t volatile *v); 00115 // Returns the previous value 00116 int atomic_sub_and_test(int i, atomic_t volatile *v); 00117 00118 00119 #ifdef __cplusplus 00120 } 00121 #endif /* __cplusplus */ 00122 00123 /* 00124 00125 #endif /* _SYNSOFT_INCL_H_ATOMIC */ 00126 00127 /*
|
UNIX Emulation for Win32 Libraries documentation © Synesis Software Pty Ltd, 2001-2003 |