1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-26 08:41:47 -07:00

Lockisheld implementation for generic ("ansi") locks.

When CONFIG_THREAD_SINGLE is defined, use the generic lock module rather than compiling out all lock calls via lock.h. (Otherwise test cases that check LockIsHeld will fail.)

Copied from Perforce
 Change: 192254
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Gareth Rees 2016-09-09 11:01:04 +01:00
parent d8c32f0d3f
commit cf6c484a89
7 changed files with 34 additions and 24 deletions

View file

@ -167,8 +167,9 @@
/* CONFIG_THREAD_SINGLE -- support single-threaded execution only
*
* This symbol causes the MPS to be built for single-threaded
* execution only, where locks are not needed and so lock operations
* can be defined as no-ops by lock.h.
* execution only, where locks are not needed and so the generic
* ("ANSI") lock module lockan.c can be used instead of the
* platform-specific lock module.
*/
#if !defined(CONFIG_THREAD_SINGLE)

View file

@ -128,27 +128,6 @@ extern void LockClaimGlobal(void);
extern void LockReleaseGlobal(void);
#if defined(LOCK)
/* Nothing to do: functions declared in all lock configurations. */
#elif defined(LOCK_NONE)
#define LockSize() MPS_PF_ALIGN
#define LockInit(lock) UNUSED(lock)
#define LockFinish(lock) UNUSED(lock)
#define LockClaimRecursive(lock) UNUSED(lock)
#define LockReleaseRecursive(lock) UNUSED(lock)
#define LockClaim(lock) UNUSED(lock)
#define LockRelease(lock) UNUSED(lock)
#define LockIsHeld(lock) ((void)lock, FALSE)
#define LockCheck(lock) ((void)lock, TRUE)
#define LockClaimGlobalRecursive()
#define LockReleaseGlobalRecursive()
#define LockClaimGlobal()
#define LockReleaseGlobal()
#else
#error "No lock configuration."
#endif /* LOCK */
#endif /* lock_h */

View file

@ -79,6 +79,12 @@ void (LockReleaseRecursive)(Lock lock)
--lock->claims;
}
Bool (LockIsHeld)(Lock lock)
{
AVERT(Lock, lock);
return lock->claims > 0;
}
/* Global locking is performed by normal locks.
* A separate lock structure is used for recursive and

View file

@ -45,6 +45,7 @@
SRCID(lockix, "$Id$");
#if defined(LOCK)
/* LockStruct -- the MPS lock structure
*
@ -260,6 +261,13 @@ void (LockReleaseGlobal)(void)
}
#elif defined(LOCK_NONE)
#include "lockan.c"
#else
#error "No lock configuration."
#endif
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2016 Ravenbrook Limited <http://www.ravenbrook.com/>.

View file

@ -31,6 +31,7 @@
SRCID(lockw3, "$Id$");
#if defined(LOCK)
/* .lock.win32: Win32 lock structure; uses CRITICAL_SECTION */
typedef struct LockStruct {
@ -165,6 +166,13 @@ void (LockReleaseGlobal)(void)
}
#elif defined(LOCK_NONE)
#include "lockan.c"
#else
#error "No lock configuration."
#endif
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2016 Ravenbrook Limited <http://www.ravenbrook.com/>.

View file

@ -542,7 +542,8 @@ platform instead.
_`.opt.thread`: ``CONFIG_THREAD_SINGLE`` causes the MPS to be built
for single-threaded execution only, where locks are not needed and so
lock operations can be defined as no-ops by ``lock.h``.
the generic ("ANSI") lock module ``lockan.c`` can be used instead of
the platform-specific lock module.
_`.opt.poll`: ``CONFIG_POLL_NONE`` causes the MPS to be built without
support for polling. This means that garbage collections will only

View file

@ -983,6 +983,13 @@ Arena introspection and debugging
mps_arena_postmortem(arena);
}
.. warning::
This function only gives a reliable result in single-threaded
programs, and in multi-threaded programs where all threads but
one are known to be stopped (as they are when the debugger is
decoding the call stack in the use case described above).
.. c:function:: mps_bool_t mps_arena_has_addr(mps_arena_t arena, mps_addr_t addr)