psmedley / gcc

GNU General Public License v2.0
7 stars 1 forks source link

Implement built-in functions for atomic memory access #19

Closed dmik closed 8 years ago

dmik commented 8 years ago

Somehow our GCC builds lack the built-in __sync functions described there: https://gcc.gnu.org/onlinedocs/gcc-4.4.5/gcc/Atomic-Builtins.html. We need to implement them as this will save us from doing that again and again in applications.

dmik commented 8 years ago

One of the programs that needs this is fontconfig: http://trac.netlabs.org/ports/ticket/82.

komh commented 8 years ago

You should use '-march=i486' or later. Atomic builtins are not enabled on i386 which is default.

dmik commented 8 years ago

Great! I confirm that it works. I really wonder though why this isn't mentioned in the GCC docs (e.g. the link above). Closing. Thanks @komh.

dmik commented 8 years ago

Well, I just found that I already used this switch (-march=i486) in mozilla for exactly the same reason. Fun. Perhaps, we should make our GCC generate i686 code by default.

dryeo commented 8 years ago

On 12/13/15 01:09 PM, Dmitriy Kuminov wrote:

Well, I just found that I already used this switch (|-march=i486|) in mozilla for exactly the same reason. Fun. Perhaps, we should make our GCC generate i686 code by default.

Possibly just by updating uname, which on mingw and I believe many Linux dists reports i686 rather then i386. I also understand that i686 is superiour as some i486s have a broken CMPXCHG instruction and GCC works around this as well as i686 doing better alignment (4 byte) and adding more instructions such as cmov though some processors (P4?) have a crappy slow cmov.

dmik commented 8 years ago

@dryeo These are good points, I created #20 for this task.