Browse code

- first attempt at sparc64 asm sync

Andrei Pelinescu-Onciul authored on 12/02/2002 20:09:20
Showing 4 changed files
... ...
@@ -76,6 +76,10 @@ ifeq ($(ARCH), i386)
76 76
 	DEFS+= -DFAST_LOCK
77 77
 endif
78 78
 
79
+ifeq ($(ARCH), sparc64)
80
+	DEFS+= -DFAST_LOCK
81
+endif
82
+
79 83
 
80 84
 #PROFILE=  -pg #set this if you want profiling
81 85
 #mode = debug
... ...
@@ -15,7 +15,6 @@
15 15
 #include <sched.h>
16 16
 
17 17
 
18
-#ifdef __i386
19 18
 
20 19
 
21 20
 typedef  volatile int lock_t;
... ...
@@ -30,12 +29,20 @@ typedef  volatile int lock_t;
30 30
 inline static int tsl(lock_t* lock)
31 31
 {
32 32
 	volatile char val;
33
+#ifdef __i386
33 34
 	
34 35
 	val=1;
35 36
 	asm volatile( 
36 37
 		" xchg %b0, %1" : "=q" (val), "=m" (*lock) : "0" (val) : "memory"
37 38
 	);
38 39
 	return val;
40
+#elif defined __sparc64
41
+	asm volatile(
42
+			"ldstub [%1], %0 \n\t"
43
+			"membar #StoreStore | #StoreLoad \n\t"
44
+			: "=r"(val) : "r"(lock):"memory"
45
+	);
46
+#endif
39 47
 }
40 48
 
41 49
 
... ...
@@ -54,13 +61,22 @@ inline static void release_lock(lock_t* lock)
54 54
 {
55 55
 	char val;
56 56
 
57
+#ifdef __i386
57 58
 	val=0;
58 59
 	asm volatile(
59 60
 		" xchg %b0, %1" : "=q" (val), "=m" (*lock) : "0" (val) : "memory"
61
+	); /* hmm, maybe lock; movb $0, [%1] would be faster ???*/
62
+#elif defined __sparc64
63
+	asm volatile(
64
+			"membar #LoadStore | #StoreStore \n\t" /*is this really needed?*/
65
+			"stb %%g0, [%0] \n\t"
66
+			: /*no output*/
67
+			: "r" (lock)
68
+			: "memory"
60 69
 	);
70
+#endif
61 71
 }
62 72
 
63
-#endif
64 73
 
65 74
 
66 75
 #endif
... ...
@@ -647,7 +647,8 @@ int main(int argc, char** argv)
647 647
 	
648 648
 	if (children_no<=0) children_no=CHILD_NO;
649 649
 	else if (children_no >= MAX_PROCESSES ) {
650
-		fprintf(stderr, "ERROR: too many children processes configured; maximum is %d\n",
650
+		fprintf(stderr, "ERROR: too many children processes configured;"
651
+				" maximum is %d\n",
651 652
 			MAX_PROCESSES-1 );
652 653
 		goto error;
653 654
 	}
... ...
@@ -28,25 +28,25 @@
28 28
 int init_mallocs()
29 29
 {
30 30
 #ifdef PKG_MALLOC
31
-        /*init mem*/
31
+	/*init mem*/
32 32
 	#ifdef VQ_MALLOC
33
-        	mem_block=vqm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
33
+		mem_block=vqm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
34 34
 	#elif F_MALLOC
35 35
 		mem_block=fm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
36 36
 	#else
37
-        	mem_block=qm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
37
+		mem_block=qm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
38 38
 	#endif
39
-        if (mem_block==0){
40
-                LOG(L_CRIT, "could not initialize memory pool\n");
39
+	if (mem_block==0){
40
+		LOG(L_CRIT, "could not initialize memory pool\n");
41 41
 		return -1;
42
-        }
42
+	}
43 43
 #endif
44 44
 
45 45
 #ifdef SHM_MEM
46
-        if (shm_mem_init()<0) {
47
-                LOG(L_CRIT, "could not initialize shared memory pool, exiting...\n");
48
-                return -1;
49
-        }
46
+	if (shm_mem_init()<0) {
47
+		LOG(L_CRIT, "could not initialize shared memory pool, exiting...\n");
48
+		return -1;
49
+	}
50 50
 #endif
51 51
 	return 0;
52 52