2000-04-22 04:33:34 +08:00
|
|
|
/* Low-level functions for atomic operations. Stub version.
|
|
|
|
Copyright (C) 1997 Free Software Foundation, Inc.
|
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
|
|
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
2000-04-26 10:51:12 +08:00
|
|
|
#ifndef _BITS_ATOMICITY_H
|
|
|
|
#define _BITS_ATOMICITY_H 1
|
2000-04-22 04:33:34 +08:00
|
|
|
|
2000-04-26 10:51:12 +08:00
|
|
|
typedef int _Atomic_word;
|
2000-04-22 04:33:34 +08:00
|
|
|
|
2000-04-26 10:51:12 +08:00
|
|
|
static inline _Atomic_word
|
2000-08-23 02:24:16 +08:00
|
|
|
__attribute__ ((__unused__))
|
2000-04-26 10:51:12 +08:00
|
|
|
__exchange_and_add (_Atomic_word* __mem, int __val)
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
2000-04-26 10:51:12 +08:00
|
|
|
_Atomic_word __result = *__mem;
|
|
|
|
*__mem += __val;
|
|
|
|
return __result;
|
2000-04-22 04:33:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2000-08-23 02:24:16 +08:00
|
|
|
__attribute__ ((__unused__))
|
2000-04-26 10:51:12 +08:00
|
|
|
__atomic_add (_Atomic_word* __mem, int __val)
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
2000-04-26 10:51:12 +08:00
|
|
|
*__mem += __val;
|
2000-04-22 04:33:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2000-08-23 02:24:16 +08:00
|
|
|
__attribute__ ((__unused__))
|
2000-04-26 10:51:12 +08:00
|
|
|
__compare_and_swap (long *__p, long __oldval, long __newval)
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
2000-04-26 10:51:12 +08:00
|
|
|
if (*__p != __oldval)
|
2000-04-22 04:33:34 +08:00
|
|
|
return 0;
|
|
|
|
|
2000-04-26 10:51:12 +08:00
|
|
|
*__p = __newval;
|
2000-04-22 04:33:34 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* atomicity.h */
|