This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: *ping* generic atomicity.h


Hi,

Without either your patch or always using the i486 version of atomicity.h (as
per the submission at http://gcc.gnu.org/ml/libstdc++/2002-12/msg00232.html)
I cannot build libstdc++ for i386-pc-mingw with trunk or 3.3

With the patch I can build i386-pc-cygwin (which has _GTHREAD_MUTEX_INIT) and
i386-pc-mingw (which doesn't).

Danny

 --- Phil Edwards wrote: 
Date: Mon, 27 Jan 2003 11:20:29 -0500

> 
> Here's what I plan on actually checking in on the trunk, then 3.3 if no
> problems arise.
> 
> v3 will compile with this atomicity.h, but of course I can't runtest it.
> Sanity check?
> 
> 
> 
> Index: config/cpu/generic/atomicity.h
> ===================================================================
> RCS file:
> /home/pme/Repositories/GCC/gcc/libstdc++-v3/config/cpu/generic/atomicity.h,v
> retrieving revision 1.4
> diff -u -3 -p -r1.4 atomicity.h
> --- config/cpu/generic/atomicity.h	8 Nov 2002 19:24:41 -0000	1.4
> +++ config/cpu/generic/atomicity.h	27 Jan 2003 16:17:17 -0000
> @@ -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
> +
> +  _Atomic_word __result;
>  
> -   __gthread_mutex_lock (&__gnu_cxx::_Atomic_add_mutex);
> +  __gthread_mutex_lock (&__gnu_cxx::_Atomic_add_mutex);
>  
> -   __result = *__mem;
> -   *__mem += __val;
> +  __result = *__mem;
> +  *__mem += __val;
>  
>    __gthread_mutex_unlock (&__gnu_cxx::_Atomic_add_mutex);
>    return __result;
> Index: src/misc-inst.cc
> ===================================================================
> RCS file: /home/pme/Repositories/GCC/gcc/libstdc++-v3/src/misc-inst.cc,v
> retrieving revision 1.21
> diff -u -3 -p -r1.21 misc-inst.cc
> --- src/misc-inst.cc	23 Jan 2003 17:21:11 -0000	1.21
> +++ src/misc-inst.cc	27 Jan 2003 16:17:31 -0000
> @@ -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
> + 

http://greetings.yahoo.com.au - Yahoo! Greetings
- Send some online love this Valentine's Day.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]