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


	Yesterday during the Cygnus network outage, I got most of v3 to
compile.  I needed to define _XOPEN_SOURCE=500 and _LARGE_FILE_API (for
stat64) which means that something is confusing the normal AIX mechanism
which handles that.

	I also needed to define the following macros and typedefs:

#define __P(p) p
#define __PMT(p) p
#define __THROW /**/
typedef long long __off_t;
typedef long long __off64_t;
typedef ssize_t __ssize_t;

	AIX has /usr/include/sys/cdefs.h but it does not define __P and
__PMT, so _G_HAVE_CDEFS succeeds incorrectly in libio.h.

	Also, the ctype files in config/aix are not up to date with
respect to the rest of the v3 sources.  I got a little farther by copying
and pasting from more up to date versions, but I don't know what I am
doing. 

	The AIX version of atomicity.h worked fine with src/string-inst.cc
with one additional definition (_Atomic_word) and a typo fix.  The revised
version is appended below.

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]