diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2010-01-10 04:07:19 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2010-01-10 04:07:19 +0000 |
commit | 228ad5a9f1a5db64df3c670fecd1b37f469c6ccb (patch) | |
tree | a432c9aa01d1695f4e030ffbcef8f4c9d9e418fe /sys/arch/hppa/include | |
parent | 3b19757bd89e2d656d732c7d9b54e46472ea7f98 (diff) |
GCC doesn't respect the aligned attribute for automatic variables. So
having mutexes on the stack, like dlg@ added recently to the scsi code,
doesn't work on hppa. So instead of relying on mutexes being properly
alligned just reserve 4 words and use the one that has the proper alignment.
ok miod@
Diffstat (limited to 'sys/arch/hppa/include')
-rw-r--r-- | sys/arch/hppa/include/mutex.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/arch/hppa/include/mutex.h b/sys/arch/hppa/include/mutex.h index 6bea7b9b110..f5b9d51327c 100644 --- a/sys/arch/hppa/include/mutex.h +++ b/sys/arch/hppa/include/mutex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.h,v 1.3 2009/12/29 15:01:59 jsing Exp $ */ +/* $OpenBSD: mutex.h,v 1.4 2010/01/10 04:07:18 kettenis Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -28,16 +28,16 @@ #ifndef _MACHINE_MUTEX_H_ #define _MACHINE_MUTEX_H_ -#define MUTEX_LOCKED 0 -#define MUTEX_UNLOCKED 1 +#define MUTEX_LOCKED { 0, 0, 0, 0 } +#define MUTEX_UNLOCKED { 1, 1, 1, 1 } /* Note: mtx_lock must be 16-byte aligned. */ struct mutex { - volatile int mtx_lock; + volatile int mtx_lock[4]; int mtx_wantipl; int mtx_oldipl; void *mtx_owner; -} __attribute__ ((__aligned__(16))); +}; void mtx_init(struct mutex *, int); @@ -45,12 +45,14 @@ void mtx_init(struct mutex *, int); #ifdef DIAGNOSTIC #define MUTEX_ASSERT_LOCKED(mtx) do { \ - if ((mtx)->mtx_lock != MUTEX_LOCKED) \ + if ((mtx)->mtx_lock[0] == 1 && (mtx)->mtx_lock[1] == 1 && \ + (mtx)->mtx_lock[2] == 1 && (mtx)->mtx_lock[3] == 1) \ panic("mutex %p not held in %s", (mtx), __func__); \ } while (0) #define MUTEX_ASSERT_UNLOCKED(mtx) do { \ - if ((mtx)->mtx_lock != MUTEX_UNLOCKED) \ + if ((mtx)->mtx_lock[0] != 1 && (mtx)->mtx_lock[1] != 1 && \ + (mtx)->mtx_lock[2] != 1 && (mtx)->mtx_lock[3] != 1) \ panic("mutex %p held in %s", (mtx), __func__); \ } while (0) #else |