Browse code

- moved shm_*lock back to shm_mem.h (to have them properly inlined)

Andrei Pelinescu-Onciul authored on 15/01/2002 18:01:23
Showing 2 changed files
... ...
@@ -104,56 +104,7 @@ void* _shm_resize( void* p , unsigned int s)
104 104
 }
105 105
 
106 106
 
107
-inline void shm_lock()
108
-{
109
-	struct sembuf sop;
110
-	
111
-	sop.sem_num=0;
112
-	sop.sem_op=-1; /*down*/
113
-	sop.sem_flg=0 /*SEM_UNDO*/;
114
-again:
115
-	semop(shm_semid, &sop, 1);
116
-#if 0
117
-	switch(ret){
118
-		case 0: /*ok*/
119
-			break;
120
-		case EINTR: /*interrupted by signal, try again*/
121
-			DBG("sh_lock: interrupted by signal, trying again...\n");
122
-			goto again;
123
-		default:
124
-			LOG(L_ERR, "ERROR: sh_lock: error waiting on semaphore: %s\n",
125
-					strerror(errno));
126
-	}
127
-#endif
128
-}
129
-
130
-
131
-
132
-inline void shm_unlock()
133
-{
134
-	struct sembuf sop;
135
-	
136
-	sop.sem_num=0;
137
-	sop.sem_op=1; /*up*/
138
-	sop.sem_flg=0 /*SEM_UNDO*/;
139
-again:
140
-	semop(shm_semid, &sop, 1);
141
-#if 0
142
-	/*should ret immediately*/
143
-	switch(ret){
144
-		case 0: /*ok*/
145
-			break;
146
-		case EINTR: /*interrupted by signal, try again*/
147
-			DBG("sh_lock: interrupted by signal, trying again...\n");
148
-			goto again;
149
-		default:
150
-			LOG(L_ERR, "ERROR: sh_lock: error waiting on semaphore: %s\n",
151
-					strerror(errno));
152
-	}
153
-#endif
154
-}
155 107
 
156
-/* ret -1 on erro*/
157 108
 int shm_mem_init()
158 109
 {
159 110
 
... ...
@@ -44,11 +44,62 @@ extern int shm_semid;
44 44
 
45 45
 int shm_mem_init();
46 46
 void shm_mem_destroy();
47
-inline void shm_lock();
48
-inline void shm_unlock();
49 47
 
50 48
 
51 49
 
50
+/* inline functions (do not move them to *.c, they won't be inlined anymore) */
51
+static inline void shm_lock()
52
+{
53
+	struct sembuf sop;
54
+	
55
+	sop.sem_num=0;
56
+	sop.sem_op=-1; /*down*/
57
+	sop.sem_flg=0 /*SEM_UNDO*/;
58
+again:
59
+	semop(shm_semid, &sop, 1);
60
+#if 0
61
+	switch(ret){
62
+		case 0: /*ok*/
63
+			break;
64
+		case EINTR: /*interrupted by signal, try again*/
65
+			DBG("sh_lock: interrupted by signal, trying again...\n");
66
+			goto again;
67
+		default:
68
+			LOG(L_ERR, "ERROR: sh_lock: error waiting on semaphore: %s\n",
69
+					strerror(errno));
70
+	}
71
+#endif
72
+}
73
+
74
+
75
+
76
+static inline void shm_unlock()
77
+{
78
+	struct sembuf sop;
79
+	
80
+	sop.sem_num=0;
81
+	sop.sem_op=1; /*up*/
82
+	sop.sem_flg=0 /*SEM_UNDO*/;
83
+again:
84
+	semop(shm_semid, &sop, 1);
85
+#if 0
86
+	/*should ret immediately*/
87
+	switch(ret){
88
+		case 0: /*ok*/
89
+			break;
90
+		case EINTR: /*interrupted by signal, try again*/
91
+			DBG("sh_lock: interrupted by signal, trying again...\n");
92
+			goto again;
93
+		default:
94
+			LOG(L_ERR, "ERROR: sh_lock: error waiting on semaphore: %s\n",
95
+					strerror(errno));
96
+	}
97
+#endif
98
+}
99
+
100
+/* ret -1 on erro*/
101
+
102
+
52 103
 
53 104
 #ifdef DBG_QM_MALLOC
54 105