Paul Eggert wrote: > > 2) Is there no other way to implement explicit_bzero without 'asm'? > > There is a another fallback code using volatile pointers, but I'm not > > sure it really has the same semantics. > > That fallback should work, though it's a bit slower.
I'm afraid that the fallback code /* Invoke memset through a volatile function pointer. This defeats compiler optimizations. */ void * (* const volatile volatile_memset) (void *, int, size_t) = memset; (void) volatile_memset (s, '\0', len); will stop working, as compilers get "smarter". The other code based on asm is not so likely to break, since it is documented that "Using the "memory" clobber effectively forms a read/write memory barrier for the compiler." [1] Bruno [1] https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Extended-Asm.html