From a432e18a24569804c82f14b36ae7d8dfcc245da7 Mon Sep 17 00:00:00 2001 From: hunt Date: Mon, 28 Nov 2005 22:08:39 +0000 Subject: 2005-11-28 Martin Hunt * alloc.c (__stp_valloc_percpu): Use same code for up and smp. (_stp_per_cpu_ptr): New macro. * user/alloc.c: Ditto. * map.c: Use _stp_map_cpu_ptr(). * map-stat.c: Ditto. * pmap-gen.c: Ditto. * runtime.h: Include alloc.c * user/runtime.h: Ditto. --- runtime/user/alloc.c | 7 +++++++ runtime/user/runtime.h | 1 + 2 files changed, 8 insertions(+) (limited to 'runtime/user') diff --git a/runtime/user/alloc.c b/runtime/user/alloc.c index 9c7fa5c0..2691a36a 100644 --- a/runtime/user/alloc.c +++ b/runtime/user/alloc.c @@ -78,6 +78,13 @@ void *_stp_valloc(size_t len) #define _stp_valloc_percpu(type) \ ((type *)(__stp_valloc_percpu(sizeof(type), __alignof__(type)))) #define _stp_percpu_dptr(ptr) (((struct percpu_data *)~(unsigned long)(ptr))->blkp) +#define _stp_per_cpu_ptr(ptr, cpu) \ +({ \ + struct percpu_data *__p = (struct percpu_data *)~(unsigned long)(ptr); \ + (__typeof__(ptr))__p->ptrs[(cpu)]; \ +}) + + /** Frees memory allocated by _stp_alloc or _stp_calloc. * @param ptr pointer to memory to free */ diff --git a/runtime/user/runtime.h b/runtime/user/runtime.h index 725147a4..79a9dc22 100644 --- a/runtime/user/runtime.h +++ b/runtime/user/runtime.h @@ -51,5 +51,6 @@ void exit(int status); #include "print.c" #include "string.c" #include "arith.c" +#include "alloc.c" #endif /* _RUNTIME_H_ */ -- cgit