mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-30 07:14:09 +08:00
atomicity.h (_Atomic_add_mutex): Fix declaration.
2003-02-12 Phil Edwards <pme@gcc.gnu.org> * config/cpu/generic/atomicity.h (_Atomic_add_mutex): Fix declaration. (_GLIBCPP_NEED_GENERIC_MUTEX): Define for this file. (_Atomic_add_mutex_once, __gthread_atomic_add_mutex_once): Declare when we don't have static mutex initialization. (__exchange_and_add): Use _Atomic_add_mutex_once. * src/misc-inst.cc: Definitions of all the above. From-SVN: r62818
This commit is contained in:
parent
6a540f3ca3
commit
8d55a4aa3b
@ -1,3 +1,12 @@
|
||||
2003-02-12 Phil Edwards <pme@gcc.gnu.org>
|
||||
|
||||
* config/cpu/generic/atomicity.h (_Atomic_add_mutex): Fix declaration.
|
||||
(_GLIBCPP_NEED_GENERIC_MUTEX): Define for this file.
|
||||
(_Atomic_add_mutex_once, __gthread_atomic_add_mutex_once): Declare
|
||||
when we don't have static mutex initialization.
|
||||
(__exchange_and_add): Use _Atomic_add_mutex_once.
|
||||
* src/misc-inst.cc: Definitions of all the above.
|
||||
|
||||
2003-02-12 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
PR libstdc++/9563
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Low-level functions for atomic operations: Generic version -*- C++ -*-
|
||||
|
||||
// Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
|
||||
// Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -32,24 +32,35 @@
|
||||
|
||||
#include <bits/gthr.h>
|
||||
|
||||
#define _GLIBCPP_NEED_GENERIC_MUTEX
|
||||
|
||||
typedef int _Atomic_word;
|
||||
|
||||
namespace __gnu_cxx
|
||||
{
|
||||
__gthread_mutex_t _Atomic_add_mutex __attribute__ ((__weak__))
|
||||
= __GTHREAD_MUTEX_INIT;
|
||||
extern __gthread_mutex_t _Atomic_add_mutex;
|
||||
|
||||
#ifndef __GTHREAD_MUTEX_INIT
|
||||
extern __gthread_once_t _Atomic_add_mutex_once;
|
||||
extern void __gthread_atomic_add_mutex_once();
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline _Atomic_word
|
||||
__attribute__ ((__unused__))
|
||||
__exchange_and_add (volatile _Atomic_word* __mem, int __val)
|
||||
{
|
||||
_Atomic_word __result;
|
||||
#ifndef __GTHREAD_MUTEX_INIT
|
||||
__gthread_once (&__gnu_cxx::_Atomic_add_mutex_once,
|
||||
__gnu_cxx::__gthread_atomic_add_mutex_once);
|
||||
#endif
|
||||
|
||||
__gthread_mutex_lock (&__gnu_cxx::_Atomic_add_mutex);
|
||||
_Atomic_word __result;
|
||||
|
||||
__result = *__mem;
|
||||
*__mem += __val;
|
||||
__gthread_mutex_lock (&__gnu_cxx::_Atomic_add_mutex);
|
||||
|
||||
__result = *__mem;
|
||||
*__mem += __val;
|
||||
|
||||
__gthread_mutex_unlock (&__gnu_cxx::_Atomic_add_mutex);
|
||||
return __result;
|
||||
|
@ -72,3 +72,21 @@ namespace std
|
||||
template volatile int __Atomicity_lock<0>::_S_atomicity_lock;
|
||||
#endif
|
||||
} // namespace std
|
||||
|
||||
#ifdef _GLIBCPP_NEED_GENERIC_MUTEX
|
||||
namespace __gnu_cxx
|
||||
{
|
||||
#ifdef __GTHREAD_MUTEX_INIT
|
||||
__gthread_mutex_t _Atomic_add_mutex = __GTHREAD_MUTEX_INIT;
|
||||
#else
|
||||
// generic atomicity.h without static initialization
|
||||
__gthread_mutex_t _Atomic_add_mutex;
|
||||
__gthread_once_t _Atomic_add_mutex_once = __GTHREAD_ONCE_INIT;
|
||||
void __gthread_atomic_add_mutex_once()
|
||||
{
|
||||
__GTHREAD_MUTEX_INIT_FUNCTION (&_Atomic_add_mutex);
|
||||
}
|
||||
#endif
|
||||
} // namespace __gnu_cxx
|
||||
#endif // _GLIBCPP_NEED_GLOBAL_MUTEX
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user