Initial original import from: fuse-2.4.2-2.fc4
[captive.git] / src / libcaptive / halcaptive / intrlck.c
1 /* $Id$
2  * reactos inter lock increments emulation of libcaptive
3  * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #include "config.h"
21
22 #include "reactos/ddk/exfuncs.h"        /* self */
23
24
25 /**
26  * InterlockedIncrement:
27  * @Addend: #LONG variable to be +1ed.
28  *
29  * Adds 1 to a #LONG variable and returns.
30  * Currently libcaptive doesn't use multithreading
31  * and thus this function is just a simple increment now.
32  *
33  * Returns: a negative number if the @result < %0,
34  * zero if the @result == %0
35  * a positive number if the @result > %0.
36  * The returned number need not be equal to the result!!!!
37  */
38 LONG InterlockedIncrement(PLONG Addend)
39 {
40         /* TODO:thread; really? */
41         return ++*Addend;
42 }
43
44
45 /**
46  * InterlockedDecrement:
47  * @Addend: #LONG variable to be -1ed.
48  *
49  * Subtracts 1 from a #LONG variable and returns.
50  * Currently libcaptive doesn't use multithreading
51  * and thus this function is just a simple decrement now.
52  *
53  * Returns: a negative number if the @result < %0,
54  * zero if the @result == %0
55  * a positive number if the @result > %0.
56  * The returned number need not be equal to the result!!!!
57  */
58 LONG InterlockedDecrement(PLONG Subend)
59 {
60         /* TODO:thread; really? */
61         return --*Subend;
62 }
63
64
65 /**
66  * InterlockedExchange:
67  * @Target: Pointer to #LONG variable to exchange @Value with.
68  * @Value: Value to store to @Target value.
69  *
70  * Atomic value exchange between *@Target and @Value.
71  * Currently libcaptive doesn't use multithreading
72  * and thus this function is just a simple value exchange now.
73  *
74  * Returns: Previous value of @Target;
75  */
76 LONG InterlockedExchange(PLONG Target,LONG Value)
77 {
78 LONG r;
79
80         /* TODO:thread */
81         r=*Target;
82         *Target=Value;
83         return r;
84 }
85
86
87 /**
88  * InterlockedExchangeAdd:
89  * @Addend: Pointer to #LONG variable to add @Value to.
90  * @Value: Value to add to @Addend value.
91  *
92  * Atomic value add of @Value to *@Addend.
93  * Currently libcaptive doesn't use multithreading
94  * and thus this function is just a simple value add now.
95  *
96  * Returns: Previous value of *@Addend;
97  */
98 LONG InterlockedExchangeAdd(PLONG Addend,LONG Value)
99 {
100 LONG r;
101
102         /* TODO:thread */
103         r=*Addend;
104         *Addend+=Value;
105         return r;
106 }