c - Better way to implement a generic atomic load or store in GCC? -


I am aware of GCC's built-in nuclear operations:

but this list does not include very simple operation Like loads and stores, I can apply them on limited architecture with these inline assemblies (in fact for many types of x86 they will basically just run on regular basis), but in general the case is not something like this:

  // ptr returns the value at zero * atomic_load_ptr (zero ** ptr) {v Püssi __sync_fetch_and_add (ptr, 0); } // After setting it to NewWell Zero * atomic_store_peter (zero ** TTR, zero * navy), the old value returns PTR {void * oldval = atomic_load_ptr (ptr) void * oldval2; Do {oldval2 = old; } While ((oldname = = __ sync_val_compress_ and_swap (ptr, old, novel)) = = oldname 2); Old old return; }   

You can apply the following level mutex with test_and_set Load function is a good IO , But you should use test_and_set instead of

  while storing the function (oldwidth = __ sync_val_compress_ and_swap (ptr, old, novel))! = Old Naval 2);  

To prevent errors.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -