-static inline int _wapi_timestamp_exclusion (volatile gint32 *timestamp,
- guint32 now)
-{
- guint32 then;
- int ret;
-
- then = InterlockedCompareExchange (timestamp, now, 0);
- if (then == 0) {
- ret = 0;
- } else if (now - then > 10) {
- /* Try to overwrite the previous
- * attempt, but make sure noone else
- * got in first
- */
- g_warning ("%s: Breaking a previous timestamp", __func__);
-
- ret = InterlockedCompareExchange (timestamp, now,
- then) == then?0:EBUSY;
- } else {
- /* Someone else is working on this one */
- ret = EBUSY;
- }
-
- return(ret);
-}
-
-static inline int _wapi_timestamp_release (volatile gint32 *timestamp,
- guint32 now)
-{
- /* The timestamp can be either: now, in which case we reset
- * it; 0, in which case we don't do anything; any other value,
- * in which case we don't do anything because someone else is
- * in charge of resetting it.
- */
- return(InterlockedCompareExchange (timestamp, 0, now) != now);
-}
-