In a multi-threaded (Linux / amd64, Pthreads, C11) application, I have a struct ( momitem_st in monimelt.h ) containing, in particular, two fields
uint16_t i_paylkind; void* i_payload;
(if necessary, I could change the i_paylkind type to some other integral type, for example uintptr_t or atomic_uint )
FWIW, i_paylkind is a discriminant that defines the actual struct type of runtime that i_payload points i_payload .
Is it possible to access these two fields atomically (wrt other threads, referring to the same struct ). Of course, I also have pthread_mutex_t i_mtx; in the same structure that I could lock (using pthread_mutex_lock ). But for performance reasons, I could have avoided this (maybe transactional memory might have been relevant)
It seems that <stdtomic.h> does not provide any mechanisms for this.
(question related to my MELT monitor GPLv3 +)
source share