Opened 14 years ago

Closed 14 years ago

#2263 closed Bugs (fixed)

On PA-RISC with GCC 4.3.1, thread primitives are misdetected

Reported by: river@… Owned by: Peter Dimov
Milestone: Boost 1.37.0 Component: None
Version: Boost 1.36.0 Severity: Problem
Keywords: Cc:

Description

In at least two places (boost/detail/spinlock.hpp and boost/detail/atomic_count.hpp), Boost assumes that if the following condition is true:

defined( GNUC ) && ( GNUC * 100 + GNUC_MINOR >= 401 )

then GCC sync primitives (e.g. sync_lock_test_and_set, sync_fetch_and_add) are available. This is not correct; GCC 4.3.1 on PA-RISC does not provide these operations. The following link error results:

/usr/ccs/bin/ld: Unsatisfied symbols:

sync_add_and_fetch_4 (first referenced in main.o) (code)

The test can be fixed like this:

defined( GNUC ) && ( GNUC * 100 + GNUC_MINOR >= 401 ) && !defined(hppa)

However, it seems like it would be more resiliant to list the platforms which do support these primitves (e.g. Itanium, i386...) rather than excepting specific platforms.

(Tested on HP-UX 11.11 using HP GCC 4.3.1 on a PA-8200 CPU.)

Change History (6)

comment:1 by Marshall Clow, 14 years ago

Owner: set to Peter Dimov

comment:2 by Peter Dimov, 14 years ago

Status: newassigned

comment:3 by Peter Dimov, 14 years ago

In addition to __hppa, need to also check __arm.

comment:4 by Peter Dimov, 14 years ago

Does GCC on PA-RISC indeed not provide even sync_lock_test_and_set? Or is it just sync_fetch_and_add that is not present?

comment:5 by river@…, 14 years ago

it does not:

river@maiden:~>cat test.c
int i;
int main() {
        __sync_lock_test_and_set(&i, 1);
        return 0;
}
river@maiden:~>gcc test.c -o test -W -Wall
/usr/ccs/bin/ld: Unsatisfied symbols:
   __sync_lock_test_and_set_4 (first referenced in /var/tmp//ccgdGbo1.o) (code)
collect2: ld returned 1 exit status
 river@maiden:~>gcc -v
Using built-in specs.
Target: hppa1.1-hp-hpux11.11
Configured with: /tmp/gcc-4.3.1.tar.gz/gcc-4.3.1/configure --host=hppa1.1-hp-hpux11.11 --target=hppa1.1-hp-hpux11.11 --build=hppa1.1-hp-hpux11.11 --prefix=/opt/hp-gcc-4.3.1 --with-gnu-as --without-gnu-ld --with-ld=/usr/ccs/bin/ld --enable-threads=posix --enable-languages=c,c++ --with-gmp=/proj/opensrc/be/hppa1.1-hp-hpux11.11 --with-mpfr=/proj/opensrc/be/hppa1.1-hp-hpux11.11
Thread model: posix
gcc version 4.3.1 (GCC) 

(PA-RISC does provide a single atomic operation - 'load and clear word' (ldcw), which is roughly equivalent to __sync_lock_test_and_set(&x, 1). Unfortunately, I'm not comfortable enough with the platform to provide an implementation.)

comment:6 by Peter Dimov, 14 years ago

Resolution: fixed
Status: assignedclosed

(In [48838]) Fix #2263. See also [48835].

Note: See TracTickets for help on using tickets.