stud icon indicating copy to clipboard operation
stud copied to clipboard

shctx.c could use less assembler

Open sesse opened this issue 14 years ago • 2 comments

It seems like shctx.c is written with several inline assembler parts to get atomic operations. GCC has a relatively rich set1 of these; possibly not everything that the file needs, but at least the cmpxchg() function could probably be replaced by __sync_val_compare_and_swap().

sesse avatar Oct 01 '11 14:10 sesse

__sync_val_compare_and_swap gcc builtin appear in gcc v4.1.* . My embedded solution product, as a lot of embedded solutions, use a gcc v3 based toolchain.

If the assembled code is a problem, pthread_mutex usage is more portable.

EmericBr avatar Feb 20 '12 12:02 EmericBr

#109 use atomic ops sync built-ins in fallback if current arch does not support x86 asm (built-ins atomics op implementation is less optimized).

EmericBr avatar Aug 24 '12 16:08 EmericBr