1 /* src/threads/native/generic-primitives.h - machine independent atomic
4 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
5 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
6 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
7 J. Wenninger, Institut f. Computersprachen - TU Wien
9 This file is part of CACAO.
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2, or (at
14 your option) any later version.
16 This program is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 Contact: cacao@cacaojvm.org
28 Authors: Christian Thalinger
33 $Id: generic-primitives.h 4357 2006-01-22 23:33:38Z twisti $
38 #ifndef _MACHINE_INSTR_H
39 #define _MACHINE_INSTR_H
43 extern pthread_mutex_t _atomic_add_lock;
44 extern pthread_mutex_t _cas_lock;
45 extern pthread_mutex_t _mb_lock;
48 static inline void atomic_add(volatile int *mem, int val)
50 pthread_mutex_lock(&_atomic_add_lock);
52 /* do the atomic add */
55 pthread_mutex_unlock(&_atomic_add_lock);
59 static inline long compare_and_swap(volatile long *p, long oldval, long newval)
63 pthread_mutex_lock(&_cas_lock);
65 /* do the compare-and-swap */
72 pthread_mutex_unlock(&_cas_lock);
78 #define MEMORY_BARRIER() (pthread_mutex_lock(&_mb_lock), \
79 pthread_mutex_unlock(&_mb_lock))
80 #define STORE_ORDER_BARRIER() MEMORY_BARRIER()
81 #define MEMORY_BARRIER_BEFORE_ATOMIC() /* nothing */
82 #define MEMORY_BARRIER_AFTER_ATOMIC() /* nothing */
84 #endif /* _MACHINE_INSTR_H */
88 * These are local overrides for various environment variables in Emacs.
89 * Please do not remove this and leave it at the end of the file, where
90 * Emacs will automagically detect them.
91 * ---------------------------------------------------------------------