Skip to content

orconce: Fix typo in GCC __sync-based implementation

Jakub Vaněk requested to merge linuxtardis/orc:bugfix/atomic-flipped-args into main

The __sync_val_compare_and_swap() function is defined as 1:

type __sync_val_compare_and_swap (type *ptr, type oldval, type newval, ...)

However, the pre-C11 orc_once_enter() function is calling the function like __sync_val_compare_and_swap(ptr, newval, oldval). This breaks the orconce implementation: the atomic variable is never set to the initialized state and so the initialization function is called every time orc_once_enter() is called.

This bug was originally discovered through Buildroot. GStreamer packages are currently build with -std=c99 or -std=gnu99 there. These flags disable the C11 orconce codepath and instead the old __sync codepath is selected. The ultimate effect of this was that all elements relying on ORC (e.g. videotestsrc, videoconvert) were slowed down significantly by repeated recompiling of the ORC programs.

Merge request reports

Loading