1 /* This header supplies atomic operations. So far, we rely on GCC's
2 * atomic builtins. I have no idea if we can check them via autotools,
3 * but I am making the necessary provisioning to live without them if
4 * they are not available. Please note that you should only use the macros
5 * here if you think you can actually live WITHOUT an explicit atomic operation,
6 * because in the non-presence of them, we simply do it without atomicitiy.
7 * Which, for word-aligned data types, usually (but only usually!) should work.
9 * We are using the functions described in
10 * http:/gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html
12 * THESE MACROS MUST ONLY BE USED WITH WORD-SIZED DATA TYPES!
14 * Copyright 2008 Rainer Gerhards and Adiscon GmbH.
16 * This file is part of rsyslog.
18 * Rsyslog is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * (at your option) any later version.
23 * Rsyslog is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
31 * A copy of the GPL can be found in the file "COPYING" in this distribution.
33 #include "config.h" /* autotools! */
35 #ifndef INCLUDED_ATOMIC_H
36 #define INCLUDED_ATOMIC_H
38 /* set the following to 1 if we have atomic operations (and #undef it otherwise) */
39 /* #define DO_HAVE_ATOMICS 1 */
40 /* for this release, we disable atomic calls because there seem to be some
41 * portability problems and we can not fix that without destabilizing the build.
42 * They simply came in too late. -- rgerhards, 2008-04-02
44 /* make sure they are not used!
45 #define ATOMIC_INC(data) ((void) __sync_fetch_and_add(&data, 1))
46 #define ATOMIC_DEC_AND_FETCH(data) __sync_sub_and_fetch(&data, 1)
48 #define ATOMIC_INC(data) (++(data))
50 #endif /* #ifndef INCLUDED_ATOMIC_H */