raindrops.git  about / heads / tags
real-time stats for preforking Rack servers
blob fd5f23b04ac965580b3b4f166743177b2439a8b8 610 bytes (raw)
$ git show v0.4.0:ext/raindrops/raindrops_atomic.h	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
/*
 * use wrappers around libatomic-ops for folks that don't have GCC
 * or a new enough version of GCC
 */
#ifndef HAVE_GCC_ATOMIC_BUILTINS
#include <atomic_ops.h>

static inline unsigned long
__sync_add_and_fetch(unsigned long *dst, unsigned long incr)
{
        AO_t tmp = AO_fetch_and_add((AO_t *)dst, (AO_t)incr);

        return (unsigned long)tmp + incr;
}

static inline unsigned long
__sync_sub_and_fetch(unsigned long *dst, unsigned long incr)
{
        AO_t tmp = AO_fetch_and_add((AO_t *)dst, (AO_t)(-(long)incr));

        return (unsigned long)tmp - incr;
}
#endif /* HAVE_GCC_ATOMIC_BUILTINS */

git clone https://yhbt.net/raindrops.git