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 29
 inline static int tsl(lock_t* lock)
31 30
 {
32 31
 	volatile char val;
32
+#ifdef __i386
33 33
 	
34 34
 	val=1;
35 35
 	asm volatile( 
36 36
 		" xchg %b0, %1" : "=q" (val), "=m" (*lock) : "0" (val) : "memory"
37 37
 	);
38 38
 	return val;
39
+#elif defined __sparc64
40
+	asm volatile(
41
+			"ldstub [%1], %0 \n\t"
42
+			"membar #StoreStore | #StoreLoad \n\t"
43
+			: "=r"(val) : "r"(lock):"memory"
44
+	);
45
+#endif
39 46
 }
40 47
 
41 48
 
... ...
@@ -54,13 +61,22 @@ inline static void release_lock(lock_t* lock)
54 61
 {
55 62
 	char val;
56 63
 
64
+#ifdef __i386
57 65
 	val=0;
58 66
 	asm volatile(
59 67
 		" xchg %b0, %1" : "=q" (val), "=m" (*lock) : "0" (val) : "memory"
68
+	); /* hmm, maybe lock; movb $0, [%1] would be faster ???*/
69
+#elif defined __sparc64
70
+	asm volatile(
71
+			"membar #LoadStore | #StoreStore \n\t" /*is this really needed?*/
72
+			"stb %%g0, [%0] \n\t"
73
+			: /*no output*/
74
+			: "r" (lock)
75
+			: "memory"
60 76
 	);
77
+#endif
61 78
 }
62 79
 
63
-#endif
64 80
 
65 81
 
66 82
 #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