9
9
*
10
10
*
11
11
* IDENTIFICATION
12
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.31 2004/08/30 02:54:38 momjian Exp $
12
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.32 2004/08/30 23:47:20 tgl Exp $
13
13
*
14
14
*-------------------------------------------------------------------------
15
15
*/
@@ -249,40 +249,73 @@ tas_dummy() /* really means: extern int tas(slock_t
249
249
* test program for verifying a port's spinlock support.
250
250
*/
251
251
252
- volatile slock_t test_lock ;
252
+ struct test_lock_struct
253
+ {
254
+ char pad1 ;
255
+ slock_t lock ;
256
+ char pad2 ;
257
+ };
258
+
259
+ volatile struct test_lock_struct test_lock ;
253
260
254
261
int
255
262
main ()
256
263
{
257
264
srandom ((unsigned int ) time (NULL ));
258
265
259
- S_INIT_LOCK (& test_lock );
266
+ test_lock .pad1 = test_lock .pad2 = 0x44 ;
267
+
268
+ S_INIT_LOCK (& test_lock .lock );
269
+
270
+ if (test_lock .pad1 != 0x44 || test_lock .pad2 != 0x44 )
271
+ {
272
+ printf ("S_LOCK_TEST: failed, declared datatype is wrong size\n" );
273
+ return 1 ;
274
+ }
260
275
261
- if (!S_LOCK_FREE (& test_lock ))
276
+ if (!S_LOCK_FREE (& test_lock . lock ))
262
277
{
263
278
printf ("S_LOCK_TEST: failed, lock not initialized\n" );
264
279
return 1 ;
265
280
}
266
281
267
- S_LOCK (& test_lock );
282
+ S_LOCK (& test_lock . lock );
268
283
269
- if (S_LOCK_FREE (& test_lock ))
284
+ if (test_lock .pad1 != 0x44 || test_lock .pad2 != 0x44 )
285
+ {
286
+ printf ("S_LOCK_TEST: failed, declared datatype is wrong size\n" );
287
+ return 1 ;
288
+ }
289
+
290
+ if (S_LOCK_FREE (& test_lock .lock ))
270
291
{
271
292
printf ("S_LOCK_TEST: failed, lock not locked\n" );
272
293
return 1 ;
273
294
}
274
295
275
- S_UNLOCK (& test_lock );
296
+ S_UNLOCK (& test_lock .lock );
297
+
298
+ if (test_lock .pad1 != 0x44 || test_lock .pad2 != 0x44 )
299
+ {
300
+ printf ("S_LOCK_TEST: failed, declared datatype is wrong size\n" );
301
+ return 1 ;
302
+ }
276
303
277
- if (!S_LOCK_FREE (& test_lock ))
304
+ if (!S_LOCK_FREE (& test_lock . lock ))
278
305
{
279
306
printf ("S_LOCK_TEST: failed, lock not unlocked\n" );
280
307
return 1 ;
281
308
}
282
309
283
- S_LOCK (& test_lock );
310
+ S_LOCK (& test_lock .lock );
311
+
312
+ if (test_lock .pad1 != 0x44 || test_lock .pad2 != 0x44 )
313
+ {
314
+ printf ("S_LOCK_TEST: failed, declared datatype is wrong size\n" );
315
+ return 1 ;
316
+ }
284
317
285
- if (S_LOCK_FREE (& test_lock ))
318
+ if (S_LOCK_FREE (& test_lock . lock ))
286
319
{
287
320
printf ("S_LOCK_TEST: failed, lock not re-locked\n" );
288
321
return 1 ;
@@ -293,7 +326,7 @@ main()
293
326
printf (" if S_LOCK() and TAS() are working.\n" );
294
327
fflush (stdout );
295
328
296
- s_lock (& test_lock , __FILE__ , __LINE__ );
329
+ s_lock (& test_lock . lock , __FILE__ , __LINE__ );
297
330
298
331
printf ("S_LOCK_TEST: failed, lock not locked\n" );
299
332
return 1 ;
0 commit comments