提交 2eb42789 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

get rid of macros around gcc __sync_* ops

上级 8e76d1ae
......@@ -27,14 +27,14 @@
#if CILKENABLE
#include "types.h"
#include "kernel.h"
#include "kernel.hh"
#include "amd64.h"
#include "cpu.h"
#include "bits.h"
#include "cpu.hh"
#include "bits.hh"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "proc.hh"
#include "mtrace.h"
#include "qlock.h"
......@@ -114,7 +114,7 @@ __cilk_pop(struct cilkqueue *q)
i = q->head;
if ((i - q->tail) == 0) {
ql_unlock(&q->lock, &qn);
return NULL;
return 0;
}
i = (i-1) & (NSLOTS-1);
q->head--;
......@@ -134,7 +134,7 @@ __cilk_steal(struct cilkqueue *q)
i = q->tail;
if ((i - q->head) == 0) {
ql_unlock(&q->lock, &qn);
return NULL;
return 0;
}
i = i & (NSLOTS-1);
q->tail++;
......@@ -147,13 +147,13 @@ __cilk_steal(struct cilkqueue *q)
static void
__cilk_run(struct cilkthread *th)
{
void (*fn)(uptr arg0, uptr arg1) = (void*)th->rip;
void (*fn)(uptr arg0, uptr arg1) = (void(*)(uptr,uptr))th->rip;
struct cilkframe *old = mycpu()->cilkframe;
mycpu()->cilkframe = th->frame;
fn(th->arg0, th->arg1);
mycpu()->cilkframe = old;
subfetch(&th->frame->ref, 1);
th->frame->ref--;
kfree(th);
}
......@@ -163,7 +163,7 @@ __cilk_run(struct cilkthread *th)
void
cilk_push(void *rip, u64 arg0, u64 arg1)
{
void (*fn)(uptr, uptr) = rip;
void (*fn)(uptr, uptr) = (void(*)(uptr,uptr))rip;
struct cilkthread *th;
th = (struct cilkthread *) kalloc();
......@@ -180,7 +180,7 @@ cilk_push(void *rip, u64 arg0, u64 arg1)
kfree(th);
fn(arg0, arg1);
} else
fetchadd(&cilk_frame()->ref, 1);
cilk_frame()->ref++;
}
// Try to execute one cilkthread.
......@@ -248,7 +248,7 @@ cilk_end(void)
}
}
}
mycpu()->cilkframe = NULL;
mycpu()->cilkframe = 0;
popcli();
}
......@@ -281,7 +281,7 @@ testcilk(void)
s = rdtsc();
cilk_start();
for (i = 0; i < iters; i++)
cilk_push(__test_stub, i, i);
cilk_push((void*) __test_stub, i, i);
cilk_end();
e = rdtsc();
cprintf("testcilk: %lu\n", (e-s)/iters);
......
......@@ -18,11 +18,7 @@
#define NELEM(x) (sizeof(x)/sizeof((x)[0]))
#define cmpswap(ptr, old, new) __sync_bool_compare_and_swap(ptr, old, new)
#define subfetch(ptr, val) __sync_sub_and_fetch(ptr, val)
#define fetchadd(ptr, val) __sync_fetch_and_add(ptr, val)
#define __offsetof offsetof
#define __mpalign__ __attribute__((aligned(CACHELINE)))
#define __padout__ char __padout[0] __attribute__((aligned(CACHELINE)))
#define __noret__ __attribute__((noreturn))
#include "spinlock.h"
#include "atomic.hh"
// Saved registers for kernel context switches.
// (also implicitly defined in swtch.S)
......@@ -14,7 +15,7 @@ struct context {
// Work queue frame
struct cilkframe {
volatile u64 ref;
volatile std::atomic<u64> ref;
};
// Per-process, per-stack meta data for mtrace
......
......@@ -12,7 +12,7 @@ typedef struct {
static inline void
ql_init(qlock_t *l, const char *name)
{
l->v = NULL;
l->v = 0;
l->name = name;
}
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论