Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/_mutex.h
| Show All 25 Lines | |||||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| * SUCH DAMAGE. | * SUCH DAMAGE. | ||||
| */ | */ | ||||
| #ifndef _SYS__MUTEX_H_ | #ifndef _SYS__MUTEX_H_ | ||||
| #define _SYS__MUTEX_H_ | #define _SYS__MUTEX_H_ | ||||
| #include <sys/_types.h> | |||||
| #include <sys/_lock.h> | |||||
| #include <machine/param.h> | #include <machine/param.h> | ||||
| /* | /* | ||||
| * Sleep/spin mutex. | * Sleep/spin mutex. | ||||
| * | * | ||||
| * All mutex implementations must always have a member called mtx_lock. | * All mutex implementations must always have a member called mtx_lock. | ||||
| * Other locking primitive structures are not allowed to use this name | * Other locking primitive structures are not allowed to use this name | ||||
| * for their members. | * for their members. | ||||
| * If this rule needs to change, the bits in the mutex implementation must | * If this rule needs to change, the bits in the mutex implementation must | ||||
| * be modified appropriately. | * be modified appropriately. | ||||
| */ | */ | ||||
| struct mtx { | struct mtx { | ||||
| struct lock_object lock_object; /* Common lock properties. */ | struct lock_object lock_object; /* Common lock properties. */ | ||||
| volatile uintptr_t mtx_lock; /* Owner and flags. */ | volatile __uintptr_t mtx_lock; /* Owner and flags. */ | ||||
| }; | }; | ||||
| /* | /* | ||||
| * Members of struct mtx_padalign must mirror members of struct mtx. | * Members of struct mtx_padalign must mirror members of struct mtx. | ||||
| * mtx_padalign mutexes can use the mtx(9) API transparently without | * mtx_padalign mutexes can use the mtx(9) API transparently without | ||||
| * modification. | * modification. | ||||
| * Pad-aligned mutexes used within structures should generally be the | * Pad-aligned mutexes used within structures should generally be the | ||||
| * first member of the struct. Otherwise, the compiler can generate | * first member of the struct. Otherwise, the compiler can generate | ||||
| * additional padding for the struct to keep a correct alignment for | * additional padding for the struct to keep a correct alignment for | ||||
| * the mutex. | * the mutex. | ||||
| */ | */ | ||||
| struct mtx_padalign { | struct mtx_padalign { | ||||
| struct lock_object lock_object; /* Common lock properties. */ | struct lock_object lock_object; /* Common lock properties. */ | ||||
| volatile uintptr_t mtx_lock; /* Owner and flags. */ | volatile __uintptr_t mtx_lock; /* Owner and flags. */ | ||||
| } __aligned(CACHE_LINE_SIZE); | } __aligned(CACHE_LINE_SIZE); | ||||
| #endif /* !_SYS__MUTEX_H_ */ | #endif /* !_SYS__MUTEX_H_ */ | ||||