Do CPU features detection from 'constructor' function when compiled with gcc
authorSiarhei Siamashka <siarhei.siamashka@nokia.com>
Fri, 24 Sep 2010 13:36:16 +0000 (16:36 +0300)
committerSiarhei Siamashka <siarhei.siamashka@nokia.com>
Fri, 5 Nov 2010 14:02:28 +0000 (16:02 +0200)
commitfed4a2fde540916fc182917762b85b38052c04de
tree8d4a03e3a86526e9b78a2e3127f9448898a0aa2b
parent99699771cd82e108fbace655bf44013bdccde3bf
Do CPU features detection from 'constructor' function when compiled with gcc

There is attribute 'constructor' supported since gcc 2.7 which allows
to have a constructor function for library initialization. This eliminates
an extra branch for each composite operation and also helps to avoid
complains from race condition detection tools like helgrind.

The other compilers may or may not support this attribute properly.
Ideally, the compilers should fail to compile the code with unknown
attribute, so the configure check should do the right job. But in
reality the problems are surely possible. Fortunately such problems
should be quite easy to find because NULL pointer dereference should
happen almost immediately if the constructor fails to run.

clang 2.7:
  supports __attribute__((constructor)) properly and pretends to be gcc

tcc 0.9.25:
  ignores __attribute__((constructor)), but does not pretend to be gcc
configure.ac
pixman/pixman.c