Commit 6df548d2 by Paolo Carlini Committed by Paolo Carlini

re PR libstdc++/35221 (libstdc++ broken)

2008-02-17  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/35221
	* include/parallel/types.h: Reinstate integer types typedefs.
	* include/parallel/multiseq_selection.h: Adjust.
	* include/parallel/compatibility.h: Likewise.
	* include/parallel/random_shuffle.h: Likewise.
	* include/parallel/random_number.h: Likewise.
	* include/parallel/base.h: Likewise.

From-SVN: r132380
parent f0a77246
2008-02-17 Paolo Carlini <pcarlini@suse.de> 2008-02-17 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/35221
* include/parallel/types.h: Reinstate integer types typedefs.
* include/parallel/multiseq_selection.h: Adjust.
* include/parallel/compatibility.h: Likewise.
* include/parallel/random_shuffle.h: Likewise.
* include/parallel/random_number.h: Likewise.
* include/parallel/base.h: Likewise.
2008-02-17 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/35209 PR libstdc++/35209
* config/abi/pre/gnu.ver: Export stdio_sync_filebuf symbols. * config/abi/pre/gnu.ver: Export stdio_sync_filebuf symbols.
* testsuite/ext/stdio_sync_filebuf/char/35209.cc: New. * testsuite/ext/stdio_sync_filebuf/char/35209.cc: New.
......
...@@ -388,8 +388,8 @@ template<typename T, typename _DifferenceTp> ...@@ -388,8 +388,8 @@ template<typename T, typename _DifferenceTp>
public: public:
typedef _DifferenceTp difference_type; typedef _DifferenceTp difference_type;
// Better case down to uint64_t, than up to _DifferenceTp. // Better case down to uint64, than up to _DifferenceTp.
typedef pseudo_sequence_iterator<T, uint64_t> iterator; typedef pseudo_sequence_iterator<T, uint64> iterator;
/** @brief Constructor. /** @brief Constructor.
* @param val Element of the sequence. * @param val Element of the sequence.
......
...@@ -68,7 +68,7 @@ namespace __gnu_parallel ...@@ -68,7 +68,7 @@ namespace __gnu_parallel
{ {
#if defined(__ICC) #if defined(__ICC)
template<typename must_be_int = int> template<typename must_be_int = int>
int32_t faa32(int32_t* x, int32_t inc) int32 faa32(int32* x, int32 inc)
{ {
asm volatile("lock xadd %0,%1" asm volatile("lock xadd %0,%1"
: "=r" (inc), "=m" (*x) : "=r" (inc), "=m" (*x)
...@@ -78,7 +78,7 @@ namespace __gnu_parallel ...@@ -78,7 +78,7 @@ namespace __gnu_parallel
} }
#if defined(__x86_64) #if defined(__x86_64)
template<typename must_be_int = int> template<typename must_be_int = int>
int64_t faa64(int64_t* x, int64_t inc) int64 faa64(int64* x, int64 inc)
{ {
asm volatile("lock xadd %0,%1" asm volatile("lock xadd %0,%1"
: "=r" (inc), "=m" (*x) : "=r" (inc), "=m" (*x)
...@@ -97,8 +97,8 @@ namespace __gnu_parallel ...@@ -97,8 +97,8 @@ namespace __gnu_parallel
* @param ptr Pointer to a 32-bit signed integer. * @param ptr Pointer to a 32-bit signed integer.
* @param addend Value to add. * @param addend Value to add.
*/ */
inline int32_t inline int32
fetch_and_add_32(volatile int32_t* ptr, int32_t addend) fetch_and_add_32(volatile int32* ptr, int32 addend)
{ {
#if defined(__ICC) //x86 version #if defined(__ICC) //x86 version
return _InterlockedExchangeAdd((void*)ptr, addend); return _InterlockedExchangeAdd((void*)ptr, addend);
...@@ -110,7 +110,7 @@ namespace __gnu_parallel ...@@ -110,7 +110,7 @@ namespace __gnu_parallel
#elif defined(__GNUC__) #elif defined(__GNUC__)
return __sync_fetch_and_add(ptr, addend); return __sync_fetch_and_add(ptr, addend);
#elif defined(__SUNPRO_CC) && defined(__sparc) #elif defined(__SUNPRO_CC) && defined(__sparc)
volatile int32_t before, after; volatile int32 before, after;
do do
{ {
before = *ptr; before = *ptr;
...@@ -120,7 +120,7 @@ namespace __gnu_parallel ...@@ -120,7 +120,7 @@ namespace __gnu_parallel
return before; return before;
#else //fallback, slow #else //fallback, slow
#pragma message("slow fetch_and_add_32") #pragma message("slow fetch_and_add_32")
int32_t res; int32 res;
#pragma omp critical #pragma omp critical
{ {
res = *ptr; res = *ptr;
...@@ -136,11 +136,11 @@ namespace __gnu_parallel ...@@ -136,11 +136,11 @@ namespace __gnu_parallel
* @param ptr Pointer to a 64-bit signed integer. * @param ptr Pointer to a 64-bit signed integer.
* @param addend Value to add. * @param addend Value to add.
*/ */
inline int64_t inline int64
fetch_and_add_64(volatile int64_t* ptr, int64_t addend) fetch_and_add_64(volatile int64* ptr, int64 addend)
{ {
#if defined(__ICC) && defined(__x86_64) //x86 version #if defined(__ICC) && defined(__x86_64) //x86 version
return faa64<int>((int64_t*)ptr, addend); return faa64<int>((int64*)ptr, addend);
#elif defined(__ECC) //IA-64 version #elif defined(__ECC) //IA-64 version
return _InterlockedExchangeAdd64((void*)ptr, addend); return _InterlockedExchangeAdd64((void*)ptr, addend);
#elif defined(__ICL) || defined(_MSC_VER) #elif defined(__ICL) || defined(_MSC_VER)
...@@ -156,7 +156,7 @@ namespace __gnu_parallel ...@@ -156,7 +156,7 @@ namespace __gnu_parallel
(defined(__i686) || defined(__pentium4) || defined(__athlon)) (defined(__i686) || defined(__pentium4) || defined(__athlon))
return __sync_fetch_and_add(ptr, addend); return __sync_fetch_and_add(ptr, addend);
#elif defined(__SUNPRO_CC) && defined(__sparc) #elif defined(__SUNPRO_CC) && defined(__sparc)
volatile int64_t before, after; volatile int64 before, after;
do do
{ {
before = *ptr; before = *ptr;
...@@ -170,7 +170,7 @@ namespace __gnu_parallel ...@@ -170,7 +170,7 @@ namespace __gnu_parallel
//#warning "please compile with -march=i686 or better" //#warning "please compile with -march=i686 or better"
#endif #endif
#pragma message("slow fetch_and_add_64") #pragma message("slow fetch_and_add_64")
int64_t res; int64 res;
#pragma omp critical #pragma omp critical
{ {
res = *ptr; res = *ptr;
...@@ -190,10 +190,10 @@ namespace __gnu_parallel ...@@ -190,10 +190,10 @@ namespace __gnu_parallel
inline T inline T
fetch_and_add(volatile T* ptr, T addend) fetch_and_add(volatile T* ptr, T addend)
{ {
if (sizeof(T) == sizeof(int32_t)) if (sizeof(T) == sizeof(int32))
return (T)fetch_and_add_32((volatile int32_t*) ptr, (int32_t)addend); return (T)fetch_and_add_32((volatile int32*) ptr, (int32)addend);
else if (sizeof(T) == sizeof(int64_t)) else if (sizeof(T) == sizeof(int64))
return (T)fetch_and_add_64((volatile int64_t*) ptr, (int64_t)addend); return (T)fetch_and_add_64((volatile int64*) ptr, (int64)addend);
else else
_GLIBCXX_PARALLEL_ASSERT(false); _GLIBCXX_PARALLEL_ASSERT(false);
} }
...@@ -202,10 +202,10 @@ namespace __gnu_parallel ...@@ -202,10 +202,10 @@ namespace __gnu_parallel
#if defined(__ICC) #if defined(__ICC)
template<typename must_be_int = int> template<typename must_be_int = int>
inline int32_t inline int32
cas32(volatile int32_t* ptr, int32_t old, int32_t nw) cas32(volatile int32* ptr, int32 old, int32 nw)
{ {
int32_t before; int32 before;
__asm__ __volatile__("lock; cmpxchgl %1,%2" __asm__ __volatile__("lock; cmpxchgl %1,%2"
: "=a"(before) : "=a"(before)
: "q"(nw), "m"(*(volatile long long*)(ptr)), "0"(old) : "q"(nw), "m"(*(volatile long long*)(ptr)), "0"(old)
...@@ -215,10 +215,10 @@ namespace __gnu_parallel ...@@ -215,10 +215,10 @@ namespace __gnu_parallel
#if defined(__x86_64) #if defined(__x86_64)
template<typename must_be_int = int> template<typename must_be_int = int>
inline int64_t inline int64
cas64(volatile int64_t *ptr, int64_t old, int64_t nw) cas64(volatile int64 *ptr, int64 old, int64 nw)
{ {
int64_t before; int64 before;
__asm__ __volatile__("lock; cmpxchgq %1,%2" __asm__ __volatile__("lock; cmpxchgq %1,%2"
: "=a"(before) : "=a"(before)
: "q"(nw), "m"(*(volatile long long*)(ptr)), "0"(old) : "q"(nw), "m"(*(volatile long long*)(ptr)), "0"(old)
...@@ -238,7 +238,7 @@ namespace __gnu_parallel ...@@ -238,7 +238,7 @@ namespace __gnu_parallel
* @param replacement Replacement value. * @param replacement Replacement value.
*/ */
inline bool inline bool
compare_and_swap_32(volatile int32_t* ptr, int32_t comparand, int32_t replacement) compare_and_swap_32(volatile int32* ptr, int32 comparand, int32 replacement)
{ {
#if defined(__ICC) //x86 version #if defined(__ICC) //x86 version
return _InterlockedCompareExchange((void*)ptr, replacement, return _InterlockedCompareExchange((void*)ptr, replacement,
...@@ -278,7 +278,7 @@ namespace __gnu_parallel ...@@ -278,7 +278,7 @@ namespace __gnu_parallel
* @param replacement Replacement value. * @param replacement Replacement value.
*/ */
inline bool inline bool
compare_and_swap_64(volatile int64_t* ptr, int64_t comparand, int64_t replacement) compare_and_swap_64(volatile int64* ptr, int64 comparand, int64 replacement)
{ {
#if defined(__ICC) && defined(__x86_64) //x86 version #if defined(__ICC) && defined(__x86_64) //x86 version
return cas64<int>(ptr, comparand, replacement) == comparand; return cas64<int>(ptr, comparand, replacement) == comparand;
...@@ -332,10 +332,10 @@ namespace __gnu_parallel ...@@ -332,10 +332,10 @@ namespace __gnu_parallel
inline bool inline bool
compare_and_swap(volatile T* ptr, T comparand, T replacement) compare_and_swap(volatile T* ptr, T comparand, T replacement)
{ {
if (sizeof(T) == sizeof(int32_t)) if (sizeof(T) == sizeof(int32))
return compare_and_swap_32((volatile int32_t*) ptr, (int32_t)comparand, (int32_t)replacement); return compare_and_swap_32((volatile int32*) ptr, (int32)comparand, (int32)replacement);
else if (sizeof(T) == sizeof(int64_t)) else if (sizeof(T) == sizeof(int64))
return compare_and_swap_64((volatile int64_t*) ptr, (int64_t)comparand, (int64_t)replacement); return compare_and_swap_64((volatile int64*) ptr, (int64)comparand, (int64)replacement);
else else
_GLIBCXX_PARALLEL_ASSERT(false); _GLIBCXX_PARALLEL_ASSERT(false);
} }
......
...@@ -264,7 +264,7 @@ namespace __gnu_parallel ...@@ -264,7 +264,7 @@ namespace __gnu_parallel
} }
difference_type skew = static_cast<difference_type> difference_type skew = static_cast<difference_type>
(static_cast<uint64_t>(total) * rank / N - leftsize); (static_cast<uint64>(total) * rank / N - leftsize);
if (skew > 0) if (skew > 0)
{ {
......
...@@ -48,29 +48,29 @@ namespace __gnu_parallel ...@@ -48,29 +48,29 @@ namespace __gnu_parallel
{ {
private: private:
std::tr1::mt19937 mt; std::tr1::mt19937 mt;
uint64_t supremum; uint64 supremum;
uint64_t RAND_SUP; uint64 RAND_SUP;
double supremum_reciprocal; double supremum_reciprocal;
double RAND_SUP_REC; double RAND_SUP_REC;
// Assumed to be twice as long as the usual random number. // Assumed to be twice as long as the usual random number.
uint64_t cache; uint64 cache;
// Bit results. // Bit results.
int bits_left; int bits_left;
static uint32_t static uint32
scale_down(uint64_t x, scale_down(uint64 x,
#if _GLIBCXX_SCALE_DOWN_FPU #if _GLIBCXX_SCALE_DOWN_FPU
uint64_t /*supremum*/, double supremum_reciprocal) uint64 /*supremum*/, double supremum_reciprocal)
#else #else
uint64_t supremum, double /*supremum_reciprocal*/) uint64 supremum, double /*supremum_reciprocal*/)
#endif #endif
{ {
#if _GLIBCXX_SCALE_DOWN_FPU #if _GLIBCXX_SCALE_DOWN_FPU
return uint32_t(x * supremum_reciprocal); return uint32(x * supremum_reciprocal);
#else #else
return static_cast<uint32_t>(x % supremum); return static_cast<uint32>(x % supremum);
#endif #endif
} }
...@@ -78,7 +78,7 @@ namespace __gnu_parallel ...@@ -78,7 +78,7 @@ namespace __gnu_parallel
/** @brief Default constructor. Seed with 0. */ /** @brief Default constructor. Seed with 0. */
random_number() random_number()
: mt(0), supremum(0x100000000ULL), : mt(0), supremum(0x100000000ULL),
RAND_SUP(1ULL << (sizeof(uint32_t) * 8)), RAND_SUP(1ULL << (sizeof(uint32) * 8)),
supremum_reciprocal(double(supremum) / double(RAND_SUP)), supremum_reciprocal(double(supremum) / double(RAND_SUP)),
RAND_SUP_REC(1.0 / double(RAND_SUP)), RAND_SUP_REC(1.0 / double(RAND_SUP)),
cache(0), bits_left(0) { } cache(0), bits_left(0) { }
...@@ -87,22 +87,22 @@ namespace __gnu_parallel ...@@ -87,22 +87,22 @@ namespace __gnu_parallel
* @param seed Random seed. * @param seed Random seed.
* @param supremum Generate integer random numbers in the * @param supremum Generate integer random numbers in the
* interval @c [0,supremum). */ * interval @c [0,supremum). */
random_number(uint32_t seed, uint64_t supremum = 0x100000000ULL) random_number(uint32 seed, uint64 supremum = 0x100000000ULL)
: mt(seed), supremum(supremum), : mt(seed), supremum(supremum),
RAND_SUP(1ULL << (sizeof(uint32_t) * 8)), RAND_SUP(1ULL << (sizeof(uint32) * 8)),
supremum_reciprocal(double(supremum) / double(RAND_SUP)), supremum_reciprocal(double(supremum) / double(RAND_SUP)),
RAND_SUP_REC(1.0 / double(RAND_SUP)), RAND_SUP_REC(1.0 / double(RAND_SUP)),
cache(0), bits_left(0) { } cache(0), bits_left(0) { }
/** @brief Generate unsigned random 32-bit integer. */ /** @brief Generate unsigned random 32-bit integer. */
uint32_t uint32
operator()() operator()()
{ return scale_down(mt(), supremum, supremum_reciprocal); } { return scale_down(mt(), supremum, supremum_reciprocal); }
/** @brief Generate unsigned random 32-bit integer in the /** @brief Generate unsigned random 32-bit integer in the
interval @c [0,local_supremum). */ interval @c [0,local_supremum). */
uint32_t uint32
operator()(uint64_t local_supremum) operator()(uint64 local_supremum)
{ {
return scale_down(mt(), local_supremum, return scale_down(mt(), local_supremum,
double(local_supremum * RAND_SUP_REC)); double(local_supremum * RAND_SUP_REC));
...@@ -118,7 +118,7 @@ namespace __gnu_parallel ...@@ -118,7 +118,7 @@ namespace __gnu_parallel
bits_left -= bits; bits_left -= bits;
if (bits_left < 32) if (bits_left < 32)
{ {
cache |= ((uint64_t(mt())) << bits_left); cache |= ((uint64(mt())) << bits_left);
bits_left += 32; bits_left += 32;
} }
return res; return res;
......
...@@ -106,7 +106,7 @@ template<typename RandomAccessIterator, typename RandomNumberGenerator> ...@@ -106,7 +106,7 @@ template<typename RandomAccessIterator, typename RandomNumberGenerator>
bin_index bins_end; bin_index bins_end;
/** @brief Random seed for this thread. */ /** @brief Random seed for this thread. */
uint32_t seed; uint32 seed;
/** @brief Pointer to global data. */ /** @brief Pointer to global data. */
DRandomShufflingGlobalData<RandomAccessIterator>* sd; DRandomShufflingGlobalData<RandomAccessIterator>* sd;
...@@ -368,7 +368,7 @@ template<typename RandomAccessIterator, typename RandomNumberGenerator> ...@@ -368,7 +368,7 @@ template<typename RandomAccessIterator, typename RandomNumberGenerator>
for (; j < bin_cursor; ++j) for (; j < bin_cursor; ++j)
sd.bin_proc[j] = i; sd.bin_proc[j] = i;
pus[i].num_threads = num_threads; pus[i].num_threads = num_threads;
pus[i].seed = rng(std::numeric_limits<uint32_t>::max()); pus[i].seed = rng(std::numeric_limits<uint32>::max());
pus[i].sd = &sd; pus[i].sd = &sd;
} }
starts[num_threads] = start; starts[num_threads] = start;
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#define _GLIBCXX_PARALLEL_TYPES_H 1 #define _GLIBCXX_PARALLEL_TYPES_H 1
#include <cstdlib> #include <cstdlib>
#include <tr1/cstdint>
namespace __gnu_parallel namespace __gnu_parallel
{ {
...@@ -70,33 +69,42 @@ namespace __gnu_parallel ...@@ -70,33 +69,42 @@ namespace __gnu_parallel
inline bool inline bool
is_parallel(const parallelism __p) { return __p != sequential; } is_parallel(const parallelism __p) { return __p != sequential; }
/// Integer Types. // XXX need to use <cstdint>
using std::tr1::int16_t; /** @brief 16-bit signed integer. */
using std::tr1::uint16_t; typedef short int16;
using std::tr1::int32_t; /** @brief 16-bit unsigned integer. */
using std::tr1::uint32_t; typedef unsigned short uint16;
using std::tr1::int64_t; /** @brief 32-bit signed integer. */
using std::tr1::uint64_t; typedef int int32;
/** @brief 32-bit unsigned integer. */
typedef unsigned int uint32;
/** @brief 64-bit signed integer. */
typedef long long int64;
/** @brief 64-bit unsigned integer. */
typedef unsigned long long uint64;
/** /**
* @brief Unsigned integer to index elements. * @brief Unsigned integer to index elements.
* The total number of elements for each algorithm must fit into this type. * The total number of elements for each algorithm must fit into this type.
*/ */
typedef uint64_t sequence_index_t; typedef uint64 sequence_index_t;
/** /**
* @brief Unsigned integer to index a thread number. * @brief Unsigned integer to index a thread number.
* The maximum thread number (for each processor) must fit into this type. * The maximum thread number (for each processor) must fit into this type.
*/ */
typedef uint16_t thread_index_t; typedef uint16 thread_index_t;
// XXX atomics interface? // XXX atomics interface?
/** /**
* @brief Longest compare-and-swappable integer type on this platform. * @brief Longest compare-and-swappable integer type on this platform.
*/ */
typedef int64_t lcas_t; typedef int64 lcas_t;
// XXX numeric_limits::digits? // XXX numeric_limits::digits?
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment