1ace9bad4SMark Rutlandcat <<EOF 2765dcd20SMarco Elverstatic __always_inline bool 3ace9bad4SMark Rutland${atomic}_inc_unless_negative(${atomic}_t *v) 4ace9bad4SMark Rutland{ 5ace9bad4SMark Rutland ${int} c = ${atomic}_read(v); 6ace9bad4SMark Rutland 7ace9bad4SMark Rutland do { 8ace9bad4SMark Rutland if (unlikely(c < 0)) 9ace9bad4SMark Rutland return false; 10ace9bad4SMark Rutland } while (!${atomic}_try_cmpxchg(v, &c, c + 1)); 11ace9bad4SMark Rutland 12ace9bad4SMark Rutland return true; 13ace9bad4SMark Rutland} 14ace9bad4SMark RutlandEOF 15