/* The purpose of this file is to export a small set of atomic-related *functionsfromtheClibrary,toensurebinaryABIcompatibilityfor *theNDK. * *ThesefunctionswereinitiallyexposedbytheNDKthrough<sys/atomics.h>, *whichwasunfortunatebecausetheirimplementationdidn'tprovideany *memorybarriersatall. * *Thiswasn'taproblemfortheplatformcodethatusedthem,becauseit *usedexplicitbarrierinstructionsaroundthem.Ontheotherhand,itmeans *thatanyNDK-generatedmachinecodethatlinkedagainstthemwouldnot *performcorrectlywhenrunningonmulti-coredevices. * *Tofixthis,theplatformcodewasfirstmodifiedtonotuseanyofthese *functions(everythingisnowinlinedthroughassemblystatements,see *libc/private/bionic_arm_inline.handtheheadersitincludes. * *ThefunctionsherearethusonlyforthebenefitofNDKapplications, *andnowincludesfullmemorybarrierstopreventanyrandommemoryordering *issuefromcropping. * *Notethatwealsoprovideanupdated<sys/atomics.h>headerthatdefines *always_inlinedversionsofthefunctionsthatusetheGCCbuiltin *intrinsicstoperformthesamething. * *NOTE:Thereisnoneedforasimilarfilefornon-ARMplatforms.
*/
/* DO NOT INCLUDE <sys/atomics.h> HERE ! */
int
__atomic_cmpxchg(int old, int _new, volatileint *ptr)
{ /* We must return 0 on success */ return __sync_val_compare_and_swap(ptr, old, _new) != old;
}
int
__atomic_swap(int _new, volatileint *ptr)
{ int prev; do {
prev = *ptr;
} while (__sync_val_compare_and_swap(ptr, prev, _new) != prev); return prev;
}
int
__atomic_dec(volatileint *ptr)
{ return __sync_fetch_and_sub (ptr, 1);
}
int
__atomic_inc(volatileint *ptr)
{ return __sync_fetch_and_add (ptr, 1);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet am 2026-06-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.