ReactOS 0.4.16-dev-340-g0540c21
atomic.h
Go to the documentation of this file.
1#ifndef _LINUX_ATOMIC_H
2#define _LINUX_ATOMIC_H
3
4#include <linux/types.h>
5
6//
7// atomic
8//
9
10typedef struct {
11 volatile LONG counter;
12} atomic_t;
13
14#define ATOMIC_INIT(i) (i)
15
23#define atomic_read(v) ((v)->counter)
24
33#define atomic_set(v,i) InterlockedExchange((PLONG)(&(v)->counter), (LONG)(i))
34
43static inline void atomic_add(int volatile i, atomic_t volatile *v)
44{
45 InterlockedExchangeAdd((PLONG)(&v->counter), (LONG) i);
46}
47
56static inline void atomic_sub(int volatile i, atomic_t volatile *v)
57{
58 InterlockedExchangeAdd((PLONG)(&v->counter), (LONG) (-1*i));
59}
60
71static inline int atomic_sub_and_test(int volatile i, atomic_t volatile *v)
72{
73 int counter, result;
74
75 do {
76
77 counter = v->counter;
78 result = counter - i;
79
81 (PLONG) (&v->counter),
82 (LONG) result,
83 (LONG) counter) != counter);
84
85 return (result == 0);
86}
87
95static inline void atomic_inc(atomic_t volatile *v)
96{
97 InterlockedIncrement((PLONG)(&v->counter));
98}
99
107static inline void atomic_dec(atomic_t volatile *v)
108{
109 InterlockedDecrement((PLONG)(&v->counter));
110}
111
121static inline int atomic_dec_and_test(atomic_t volatile *v)
122{
123 return (0 == InterlockedDecrement((PLONG)(&v->counter)));
124}
125
135static inline int atomic_inc_and_test(atomic_t volatile *v)
136{
137 return (0 == InterlockedIncrement((PLONG)(&v->counter)));
138}
139
150static inline int atomic_add_negative(int volatile i, atomic_t volatile *v)
151{
152 return (InterlockedExchangeAdd((PLONG)(&v->counter), (LONG) i) + i);
153}
154
155#endif /* LINUX_ATOMIC_H */
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
static int atomic_sub_and_test(int volatile i, atomic_t volatile *v)
Definition: atomic.h:71
static int atomic_inc_and_test(atomic_t volatile *v)
Definition: atomic.h:135
static int atomic_add_negative(int volatile i, atomic_t volatile *v)
Definition: atomic.h:150
static void atomic_inc(atomic_t volatile *v)
Definition: atomic.h:95
static void atomic_add(int volatile i, atomic_t volatile *v)
Definition: atomic.h:43
static void atomic_dec(atomic_t volatile *v)
Definition: atomic.h:107
static void atomic_sub(int volatile i, atomic_t volatile *v)
Definition: atomic.h:56
static int atomic_dec_and_test(atomic_t volatile *v)
Definition: atomic.h:121
const GLdouble * v
Definition: gl.h:2040
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define InterlockedExchangeAdd
Definition: interlocked.h:181
#define InterlockedCompareExchange
Definition: interlocked.h:104
long LONG
Definition: pedump.c:60
volatile LONG counter
Definition: atomic.h:11
int32_t * PLONG
Definition: typedefs.h:58