diff src/gearsTools/lib/Gears/Context/Template/XV6.pm @ 173:7c200a8328fa

fix user malloc and spinlock redefinition
author kono
date Fri, 17 Jan 2020 14:30:07 +0900
parents 124c59d99fc9
children de3934dd522a
line wrap: on
line diff
--- a/src/gearsTools/lib/Gears/Context/Template/XV6.pm	Fri Jan 17 13:14:19 2020 +0900
+++ b/src/gearsTools/lib/Gears/Context/Template/XV6.pm	Fri Jan 17 14:30:07 2020 +0900
@@ -35,6 +35,7 @@
 #define calloc(a,b)  kmalloc((a)*(b))
 #define free(a)  kfree(a)
 #else
+extern void* malloc(unsigned int sz);
 #define calloc(a,b)  malloc((a)*(b))
 #define free(a)  free(a)
 #endif
@@ -109,9 +110,6 @@
 
 #define GearImpl(cbc_context, intf, name) (Gearef(cbc_context, intf)->name->intf.name)
 
-#ifndef CBC_XV6_CONTEXT
-#define CBC_XV6_CONTEXT TRUE
-
 #include "c/enumCode.h"
 
 #include "types.h"
@@ -158,6 +156,7 @@
     enum Code before;
 };
 
+#include "spinlock.h"
 typedef int Int;
 #ifndef USE_CUDAWorker
 typedef unsigned long long CUdeviceptr;
@@ -172,6 +171,8 @@
 print $out "union Data {\n";
 print $out $dgs;
 print $out  <<'EOF';
+
+#ifndef CbC_XV6_CONTEXT
     struct Context Context;
 }; // union Data end       this is necessary for context generator
 typedef union Data Data;
@@ -190,6 +191,7 @@
 
 #include "c/extern.h"
 
+#define CbC_XV6_CONTEXT 1
 extern __code start_code(struct Context* cbc_context);
 extern __code exit_code(struct Context* cbc_context);
 extern __code meta(struct Context* cbc_context, enum Code next);