Let each platform typedef the new __cpu_simple_lock_t, which should

be the most efficient type used for the atomic operations in the
simplelock structure, and should also be __volatile.
This commit is contained in:
thorpej 2000-05-02 04:41:04 +00:00
parent 8185691694
commit 855b79db92
12 changed files with 73 additions and 50 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.5 2000/04/29 03:31:46 thorpej Exp $ */
/* $NetBSD: lock.h,v 1.6 2000/05/02 04:41:06 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@ -44,20 +44,22 @@
#ifndef _ALPHA_LOCK_H_
#define _ALPHA_LOCK_H_
typedef __volatile int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0
static __inline void __cpu_simple_lock_init __P((__volatile int *))
static __inline void __cpu_simple_lock_init __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void __cpu_simple_lock __P((__volatile int *))
static __inline void __cpu_simple_lock __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline int __cpu_simple_lock_try __P((__volatile int *))
static __inline int __cpu_simple_lock_try __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void __cpu_simple_unlock __P((__volatile int *))
static __inline void __cpu_simple_unlock __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void
__cpu_simple_lock_init(__volatile int *alp)
__cpu_simple_lock_init(__cpu_simple_lock_t *alp)
{
__asm __volatile(
@ -69,7 +71,7 @@ __cpu_simple_lock_init(__volatile int *alp)
}
static __inline void
__cpu_simple_lock(__volatile int *alp)
__cpu_simple_lock(__cpu_simple_lock_t *alp)
{
unsigned long t0;
@ -100,7 +102,7 @@ __cpu_simple_lock(__volatile int *alp)
}
static __inline int
__cpu_simple_lock_try(__volatile int *alp)
__cpu_simple_lock_try(__cpu_simple_lock_t *alp)
{
unsigned long t0, v0;
@ -126,7 +128,7 @@ __cpu_simple_lock_try(__volatile int *alp)
}
static __inline void
__cpu_simple_unlock(__volatile int *alp)
__cpu_simple_unlock(__cpu_simple_lock_t *alp)
{
__asm __volatile(

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.1 2000/04/29 03:31:47 thorpej Exp $ */
/* $NetBSD: lock.h,v 1.2 2000/05/02 04:41:06 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -43,6 +43,8 @@
#ifndef _ARM32_LOCK_H_
#define _ARM32_LOCK_H_
typedef int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.3 2000/04/29 19:39:51 thorpej Exp $ */
/* $NetBSD: lock.h,v 1.4 2000/05/02 04:41:06 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -43,27 +43,29 @@
#ifndef _I386_LOCK_H_
#define _I386_LOCK_H_
typedef __volatile int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0
static __inline void __cpu_simple_lock_init __P((__volatile int *))
static __inline void __cpu_simple_lock_init __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void __cpu_simple_lock __P((__volatile int *))
static __inline void __cpu_simple_lock __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline int __cpu_simple_lock_try __P((__volatile int *))
static __inline int __cpu_simple_lock_try __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void __cpu_simple_unlock __P((__volatile int *))
static __inline void __cpu_simple_unlock __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void
__cpu_simple_lock_init(__volatile int *alp)
__cpu_simple_lock_init(__cpu_simple_lock_t *alp)
{
*alp = __SIMPLELOCK_UNLOCKED;
}
static __inline void
__cpu_simple_lock(__volatile int *alp)
__cpu_simple_lock(__cpu_simple_lock_t *alp)
{
int __val = __SIMPLELOCK_LOCKED;
@ -75,7 +77,7 @@ __cpu_simple_lock(__volatile int *alp)
}
static __inline int
__cpu_simple_lock_try(__volatile int *alp)
__cpu_simple_lock_try(__cpu_simple_lock_t *alp)
{
int __val = __SIMPLELOCK_LOCKED;
@ -87,7 +89,7 @@ __cpu_simple_lock_try(__volatile int *alp)
}
void
__cpu_simple_unlock(__volatile int *alp)
__cpu_simple_unlock(__cpu_simple_lock_t *alp)
{
*alp = __SIMPLELOCK_UNLOCKED;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.1 2000/04/29 03:31:50 thorpej Exp $ */
/* $NetBSD: lock.h,v 1.2 2000/05/02 04:41:07 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -43,6 +43,8 @@
#ifndef _M68K_LOCK_H_
#define _M68K_LOCK_H_
typedef __volatile int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.1 2000/04/29 03:31:51 thorpej Exp $ */
/* $NetBSD: lock.h,v 1.2 2000/05/02 04:41:07 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -43,6 +43,8 @@
#ifndef _MIPS_LOCK_H_
#define _MIPS_LOCK_H_
typedef __volatile int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.1 2000/04/29 03:31:53 thorpej Exp $ */
/* $NetBSD: lock.h,v 1.2 2000/05/02 04:41:08 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -43,6 +43,8 @@
#ifndef _PC532_LOCK_H_
#define _PC532_LOCK_H_
typedef __volatile int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.1 2000/04/29 03:31:54 thorpej Exp $ */
/* $NetBSD: lock.h,v 1.2 2000/05/02 04:41:10 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -43,6 +43,8 @@
#ifndef _POWERPC_LOCK_H_
#define _POWERPC_LOCK_H_
typedef __volatile int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.1 2000/04/29 03:31:54 thorpej Exp $ */
/* $NetBSD: lock.h,v 1.2 2000/05/02 04:41:10 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -43,6 +43,8 @@
#ifndef _SH3_LOCK_H_
#define _SH3_LOCK_H_
typedef __volatile int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.8 2000/04/30 22:15:30 pk Exp $ */
/* $NetBSD: lock.h,v 1.9 2000/05/02 04:41:11 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@ -47,6 +47,9 @@
* The value for __SIMPLELOCK_LOCKED is what ldstub() naturally stores
* `lock_data' given its address (and the fact that SPARC is big-endian).
*/
typedef __volatile int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 0xff000000
#define __SIMPLELOCK_UNLOCKED 0
@ -63,24 +66,24 @@
__v; \
})
static __inline void __cpu_simple_lock_init __P((__volatile int *))
static __inline void __cpu_simple_lock_init __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void __cpu_simple_lock __P((__volatile int *))
static __inline void __cpu_simple_lock __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline int __cpu_simple_lock_try __P((__volatile int *))
static __inline int __cpu_simple_lock_try __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void __cpu_simple_unlock __P((__volatile int *))
static __inline void __cpu_simple_unlock __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void
__cpu_simple_lock_init(__volatile int *alp)
__cpu_simple_lock_init(__cpu_simple_lock_t *alp)
{
*alp = __SIMPLELOCK_UNLOCKED;
}
static __inline void
__cpu_simple_lock(__volatile int *alp)
__cpu_simple_lock(__cpu_simple_lock_t *alp)
{
/*
@ -97,14 +100,14 @@ __cpu_simple_lock(__volatile int *alp)
}
static __inline int
__cpu_simple_lock_try(__volatile int *alp)
__cpu_simple_lock_try(__cpu_simple_lock_t *alp)
{
return (__ldstub(alp) == __SIMPLELOCK_UNLOCKED);
}
static __inline void
__cpu_simple_unlock(__volatile int *alp)
__cpu_simple_unlock(__cpu_simple_lock_t *alp)
{
*alp = __SIMPLELOCK_UNLOCKED;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.6 2000/05/01 00:46:29 thorpej Exp $ */
/* $NetBSD: lock.h,v 1.7 2000/05/02 04:41:11 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@ -47,6 +47,9 @@
* The value for __SIMPLELOCK_LOCKED is what ldstub() naturally stores
* `lock_data' given its address (and the fact that SPARC is big-endian).
*/
typedef __volatile int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 0xff000000
#define __SIMPLELOCK_UNLOCKED 0
@ -63,24 +66,24 @@
__v; \
})
static __inline void __cpu_simple_lock_init __P((__volatile int *))
static __inline void __cpu_simple_lock_init __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void __cpu_simple_lock __P((__volatile int *))
static __inline void __cpu_simple_lock __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline int __cpu_simple_lock_try __P((__volatile int *))
static __inline int __cpu_simple_lock_try __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void __cpu_simple_unlock __P((__volatile int *))
static __inline void __cpu_simple_unlock __P((__cpu_simple_lock_t *))
__attribute__((__unused__));
static __inline void
__cpu_simple_lock_init(__volatile int *alp)
__cpu_simple_lock_init(__cpu_simple_lock_t *alp)
{
*alp = __SIMPLELOCK_UNLOCKED;
}
static __inline void
__cpu_simple_lock(__volatile int *alp)
__cpu_simple_lock(__cpu_simple_lock_t *alp)
{
/*
@ -97,14 +100,14 @@ __cpu_simple_lock(__volatile int *alp)
}
static __inline int
__cpu_simple_lock_try(__volatile int *alp)
__cpu_simple_lock_try(__cpu_simple_lock_t *alp)
{
return (__ldstub(alp) == __SIMPLELOCK_UNLOCKED);
}
static __inline void
__cpu_simple_unlock(__volatile int *alp)
__cpu_simple_unlock(__cpu_simple_lock_t *alp)
{
*alp = __SIMPLELOCK_UNLOCKED;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.3 2000/05/01 12:09:32 ragge Exp $ */
/* $NetBSD: lock.h,v 1.4 2000/05/02 04:41:11 thorpej Exp $ */
/*
* Copyright (c) 2000 Ludd, University of Lule}, Sweden.
@ -33,18 +33,19 @@
#ifndef _VAX_LOCK_H_
#define _VAX_LOCK_H_
typedef __volatile int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0
static __inline void
__cpu_simple_lock_init(__volatile int *alp)
__cpu_simple_lock_init(__cpu_simple_lock_t *alp)
{
*alp = __SIMPLELOCK_UNLOCKED;
}
static __inline void
__cpu_simple_lock(__volatile int *alp)
__cpu_simple_lock(__cpu_simple_lock_t *alp)
{
__asm__ __volatile ("1:;bbssi $0, (%0), 1b"
: /* No output */
@ -52,13 +53,13 @@ __cpu_simple_lock(__volatile int *alp)
}
static __inline void
__cpu_simple_unlock(__volatile int *alp)
__cpu_simple_unlock(__cpu_simple_lock_t *alp)
{
*alp = __SIMPLELOCK_UNLOCKED;
}
static __inline int
__cpu_simple_lock_try(__volatile int *alp)
__cpu_simple_lock_try(__cpu_simple_lock_t *alp)
{
register int ret;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.26 2000/04/29 03:31:45 thorpej Exp $ */
/* $NetBSD: lock.h,v 1.27 2000/05/02 04:41:04 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -96,7 +96,7 @@
* order for it to work on the widest range of processor types.
*/
struct simplelock {
int lock_data;
__cpu_simple_lock_t lock_data;
#ifdef LOCKDEBUG
const char *lock_file;
const char *unlock_file;