From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24968 invoked by alias); 15 Nov 2007 22:15:38 -0000 Received: (qmail 24942 invoked by uid 48); 15 Nov 2007 22:15:28 -0000 Date: Thu, 15 Nov 2007 22:15:00 -0000 Subject: [Bug c/34115] New: atomic builtins not supported on i686? X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "scovich at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-11/txt/msg01443.txt.bz2 Linking fails for the program below, with the error: undefined reference to `___sync_val_compare_and_swap_4' // gcc -Wall atomic.c int main() { int *a, b, c; return __sync_val_compare_and_swap(a, b, c); } According to the atomic builtins docs (), "Not all operations are supported by all target processors. If a particular operation cannot be implemented on the target processor, a warning will be generated and a call an external function will be generated. The external function will carry the same name as the builtin, with an additional suffix `_n' where n is the size of the data type." If CAS is not supported, how come I don't get a warning? Why would i686 *not* support compare and swap? The cmpxchg instruction has been around since 80486, according to the intel IA-32 processor manual. Also, does an unsupported builtin mean the user is responsible to write that function, or simply that the compiler must make a function call to synthesize its behavior? FWIW, my x86_64 cross-compile gcc 4.2.0 handles it fine, emitting a "lock"+"cmpxchg" pair. -- Summary: atomic builtins not supported on i686? Product: gcc Version: 4.2.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: scovich at gmail dot com GCC host triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115