kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

atomic_ops.c (504B)


      1 /* A spread of atomic RMW operators (and/or/xor/sub) on a global, exercising
      2  * the exclusive-monitor loop for each. Exit computed to 42. */
      3 _Atomic unsigned g = 0xFF;
      4 int test_main(void) {
      5   __atomic_fetch_and(&g, 0x3F, __ATOMIC_SEQ_CST); /* 0x3F = 63 */
      6   __atomic_fetch_or(&g, 0x40, __ATOMIC_SEQ_CST);  /* 0x7F = 127 */
      7   __atomic_fetch_xor(&g, 0x01, __ATOMIC_SEQ_CST); /* 0x7E = 126 */
      8   __atomic_fetch_sub(&g, 84, __ATOMIC_SEQ_CST);   /* 42 */
      9   return (int)__atomic_load_n(&g, __ATOMIC_SEQ_CST);
     10 }