This is the mail archive of the libstdc++@sources.redhat.com 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]

Re: AIX atomicity.h support


>>>>> Benjamin Kosnik writes:

Ben> This stuff is supposed to be in complex.h, not math.h. Perhaps you can use
Ben> fixincludes, as I believe HPUX does for this issue?

	I applied a patch to fixinc to deal with the spacing changes in
math.h that was causing fixinc to miss the problem.

	Appended is the current version of AIX atomicity.h which worked.
The only piece that I had forgotten was a typedef for _Atomic_word.  I am
not sure whether it should use a type that is 64-bits in a 64-bit
program.  Both 32-bits and 64-bits can be atomic on 64-bit PowerPC.

David


/* Low-level functions for atomic operations.  AIX version.
   Copyright (C) 2000 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.  */

#ifndef _BITS_ATOMICITY_H
#define _BITS_ATOMICITY_H	1

/* Should this be type long so 64-bit word in 64-bit mode?  */
typedef int _Atomic_word;

#include <sys/atomic_op.h>

static inline int
__attribute__ ((unused))
__exchange_and_add (atomic_p __mem, int __val)
{
  return fetch_and_add (__mem, __val);
}

static inline void
__attribute__ ((unused))
__atomic_add (atomic_p __mem, int __val)
{
  (void) fetch_and_add (__mem, __val);
}

static inline int
__attribute__ ((unused))
__compare_and_swap (atomic_l __p, long int __oldval, long int __newval)
{
  return compare_and_swaplp (__p, &__oldval, __newval);
}

static inline long
__attribute__ ((unused))
__always_swap (atomic_l __p, long int __newval)
{
  long __val = *__p;

  while (! compare_and_swaplp (__p, &__val, __newval))
    /* EMPTY */;

  return __val;
}

static inline int
__attribute__ ((unused))
__test_and_set (atomic_l __p, long int __newval)
{
  long __val = 0;

  (void) compare_and_swaplp (__p, &__val, __newval);

  return __val;
}

#endif /* atomicity.h */

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