while (! sem_compare_and_swap(sem, oldstatus, newstatus)); return 0;
return retval;
int sem_trywait(sem_t * sem){  long oldstatus, newstatus;  do {    oldstatus = sem->sem_status;    if ((oldstatus & 1) == 0 || (oldstatus == 1)) {      errno = EAGAIN;      return -1;    }    newstatus = oldstatus - 2;  }  while (! sem_compare_and_swap(sem, oldstatus, newstatus));  return 0;}