"Fossies" - the Fresh Open Source Software Archive 
Member "apr-1.7.0/atomic/win32/apr_atomic64.c" (17 Sep 2018, 3001 Bytes) of package /linux/www/apr-1.7.0.tar.bz2:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "apr_atomic64.c" see the
Fossies "Dox" file reference documentation.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "apr.h"
18 #include "apr_atomic.h"
19 #include "apr_thread_mutex.h"
20
21 APR_DECLARE(apr_uint64_t) apr_atomic_add64(volatile apr_uint64_t *mem, apr_uint64_t val)
22 {
23 #if (defined(_M_IA64) || defined(_M_AMD64))
24 return InterlockedExchangeAdd64(mem, val);
25 #else
26 return InterlockedExchangeAdd64((long *)mem, val);
27 #endif
28 }
29
30 /* Of course we want the 2's compliment of the unsigned value, val */
31 #ifdef _MSC_VER
32 #pragma warning(disable: 4146)
33 #endif
34
35 APR_DECLARE(void) apr_atomic_sub64(volatile apr_uint64_t *mem, apr_uint64_t val)
36 {
37 #if (defined(_M_IA64) || defined(_M_AMD64))
38 InterlockedExchangeAdd64(mem, -val);
39 #else
40 InterlockedExchangeAdd64((long *)mem, -val);
41 #endif
42 }
43
44 APR_DECLARE(apr_uint64_t) apr_atomic_inc64(volatile apr_uint64_t *mem)
45 {
46 /* we return old value, win64 returns new value :( */
47 #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
48 return InterlockedIncrement64(mem) - 1;
49 #else
50 return InterlockedIncrement64((long *)mem) - 1;
51 #endif
52 }
53
54 APR_DECLARE(int) apr_atomic_dec64(volatile apr_uint64_t *mem)
55 {
56 #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
57 return InterlockedDecrement64(mem);
58 #else
59 return InterlockedDecrement64((long *)mem);
60 #endif
61 }
62
63 APR_DECLARE(void) apr_atomic_set64(volatile apr_uint64_t *mem, apr_uint64_t val)
64 {
65 #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
66 InterlockedExchange64(mem, val);
67 #else
68 InterlockedExchange64((long*)mem, val);
69 #endif
70 }
71
72 APR_DECLARE(apr_uint64_t) apr_atomic_read64(volatile apr_uint64_t *mem)
73 {
74 return *mem;
75 }
76
77 APR_DECLARE(apr_uint64_t) apr_atomic_cas64(volatile apr_uint64_t *mem, apr_uint64_t with,
78 apr_uint64_t cmp)
79 {
80 #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
81 return InterlockedCompareExchange64(mem, with, cmp);
82 #else
83 return InterlockedCompareExchange64((long*)mem, with, cmp);
84 #endif
85 }
86
87 APR_DECLARE(apr_uint64_t) apr_atomic_xchg64(volatile apr_uint64_t *mem, apr_uint64_t val)
88 {
89 #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
90 return InterlockedExchange64(mem, val);
91 #else
92 return InterlockedExchange64((long *)mem, val);
93 #endif
94 }