1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-08 23:31:35 -07:00

Fix for rh6 (change.dylan.lapwing.160307)

Copied from Perforce
 Change: 21516
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Pekka Pirinen 2000-09-15 16:08:36 +01:00
parent 9d8802c632
commit bb6f4bb592
2 changed files with 98 additions and 47 deletions

View file

@ -1,61 +1,69 @@
/* impl.c.lockli: RECURSIVE LOCKS FOR POSIX SYSTEMS
*
* $HopeName: $
* Copyright (C) 2000 Harlequin Ltd. All rights reserved.
* $HopeName$
* Copyright (C) 2000 Harlequin Limited. All rights reserved.
*
* .linux: This implementation currently just supports LinuxThreads
* (platform MPS_OS_LI)
* .linux: This implementation currently just supports LinuxThreads
* (platform MPS_OS_LI), Single Unix i/f.
*
* .posix: In fact, the implementation should be reusable for most POSIX
* implementations, but may need some customization for each.
* .posix: In fact, the implementation should be reusable for most POSIX
* implementations, but may need some customization for each.
*
* .design: These locks are implemented using mutexes.
* .design: These locks are implemented using mutexes.
*
* .recursive: Mutexes support both non-recursive and recursive locking, but
* only at initialization time. This doesn't match the API of MPS Lock module,
* which chooses at locking time, so all locks are made (non recursive)
* errorchecking. Recursive locks are implemented by checking the error
* code.
* .recursive: Mutexes support both non-recursive and recursive locking, but
* only at initialization time. This doesn't match the API of MPS Lock module,
* which chooses at locking time, so all locks are made (non-recursive)
* errorchecking. Recursive locks are implemented by checking the error
* code.
*
* .claims: During use the claims field is updated to remember the number of
* claims acquired on a lock. This field must only be modified
* while we hold the mutex.
* .claims: During use the claims field is updated to remember the number of
* claims acquired on a lock. This field must only be modified
* while we hold the mutex.
*/
#include "mpm.h"
#define _XOPEN_SOURCE 500
#include <pthread.h>
#include <semaphore.h>
#include <errno.h>
#include "mpmtypes.h"
#include "lock.h"
#include "config.h"
/* .linux */
#ifndef MPS_OS_LI
#error "lockli.c is specific to LinuxThreads but MPS_OS_LI not defined"
#endif
#include <pthread.h>
#include <semaphore.h>
SRCID(lockli, "$HopeName: $");
SRCID(lockli, "$HopeName$");
/* LockAttrSetRecursive -- Set mutexattr to permimt recursive locking
/* LockAttrSetRecursive -- Set mutexattr to permit recursive locking
*
* There's a standard way to do this - but LinuxThreads doesn't quite follow
* the standard. Some other implementations might not either. Keep the code
* general to permit future reuse. (.posix)
* There's a standard way to do this - but early LinuxThreads doesn't
* quite follow the standard. Some other implementations might not
* either.
*/
#ifdef MPS_OS_LI
#ifdef OLD_LINUXTHREADS
#define LockAttrSetRecursive(attrptr) \
(pthread_mutexattr_setkind_np((attrptr), PTHREAD_MUTEX_ERRORCHECK_NP))
pthread_mutexattr_setkind_np(attrptr, PTHREAD_MUTEX_ERRORCHECK_NP)
#else
#define LockAttrSetRecursive(attrptr) \
(pthread_mutexattr_settype((attrptr), PTHREAD_MUTEX_ERRORCHECK))
pthread_mutexattr_settype(attrptr, PTHREAD_MUTEX_ERRORCHECK)
#endif
/* .lock.posix: Posix lock structure; uses a mutex */
/* LockStruct -- the MPS lock structure
*
* .lock.posix: Posix lock structure; uses a mutex.
*/
typedef struct LockStruct {
Sig sig; /* design.mps.sig */
unsigned long claims; /* # claims held by owner */
@ -63,17 +71,27 @@ typedef struct LockStruct {
} LockStruct;
/* LockSize -- size of a LockStruct */
size_t LockSize(void)
{
return sizeof(LockStruct);
}
/* LockCheck -- check a lock */
Bool LockCheck(Lock lock)
{
CHECKS(Lock, lock);
/* While claims can't be very large, I don't dare to put a limit on it. */
/* There's no way to test the mutex, or check if it's held by somebody. */
return TRUE;
}
/* LockInit -- initialize a lock */
void LockInit(Lock lock)
{
pthread_mutexattr_t attr;
@ -93,6 +111,9 @@ void LockInit(Lock lock)
AVERT(Lock, lock);
}
/* LockFinish -- finish a lock */
void LockFinish(Lock lock)
{
int res;
@ -105,6 +126,9 @@ void LockFinish(Lock lock)
lock->sig = SigInvalid;
}
/* LockClaim -- claim a lock (non-recursive) */
void LockClaim(Lock lock)
{
int res;
@ -121,6 +145,9 @@ void LockClaim(Lock lock)
lock->claims = 1;
}
/* LockReleaseMPM -- release a lock (non-recursive) */
void LockReleaseMPM(Lock lock)
{
int res;
@ -133,6 +160,9 @@ void LockReleaseMPM(Lock lock)
AVER(res == 0);
}
/* LockClaimRecursive -- claim a lock (recursive) */
void LockClaimRecursive(Lock lock)
{
int res;
@ -150,6 +180,9 @@ void LockClaimRecursive(Lock lock)
AVER(lock->claims > 0);
}
/* LockReleaseRecursive -- release a lock (recursive) */
void LockReleaseRecursive(Lock lock)
{
int res;
@ -165,10 +198,9 @@ void LockReleaseRecursive(Lock lock)
}
/* Global locking is performed by normal locks.
* A separate lock structure is used for recursive and
* non-recursive locks so that each may be differently ordered
* with respect to client-allocated locks.
/* Global locks
*
* .global: The two "global" locks are statically allocated normal locks.
*/
static LockStruct globalLockStruct;
@ -183,6 +215,9 @@ static void globalLockInit(void)
LockInit(globalRecLock);
}
/* LockClaimGlobalRecursive -- claim the global recursive lock */
void LockClaimGlobalRecursive(void)
{
int res;
@ -193,11 +228,17 @@ void LockClaimGlobalRecursive(void)
LockClaimRecursive(globalRecLock);
}
/* LockReleaseGlobalRecursive -- release the global recursive lock */
void LockReleaseGlobalRecursive(void)
{
LockReleaseRecursive(globalRecLock);
}
/* LockClaimGlobal -- claim the global non-recursive lock */
void LockClaimGlobal(void)
{
int res;
@ -208,8 +249,10 @@ void LockClaimGlobal(void)
LockClaim(globalLock);
}
/* LockReleaseGlobal -- release the global non-recursive lock */
void LockReleaseGlobal(void)
{
LockReleaseMPM(globalLock);
}

View file

@ -1,6 +1,6 @@
/* impl.c.vmli: VIRTUAL MEMORY MAPPING FOR LINUX
*
* $HopeName: MMsrc!vmli.c(trunk.5) $
* $HopeName: MMsrc!vmli.c(trunk.6) $
* Copyright (C) 2000 Harlequin Limited. All rights reserved.
*
* .purpose: This is the implementation of the virtual memory mapping
@ -25,33 +25,37 @@
* in the off_t type (define by the system (POSIX?)). In fact we test
* the more stringent requirement that they are the same size. This
* assumption is made in VMUnmap.
*
* .remap: Possibly this should use mremap to reduce the number of
* distinct mappings. According to our current testing, it doesn't
* seem to be a problem.
*/
#include "mpm.h"
#ifndef MPS_OS_LI
#error "vmli.c is LINUX specific, but MPS_OS_LI is not set"
#endif
/* open sesame magic, see standards(5) */
#define _POSIX_C_SOURCE 199309L
#define _XOPEN_SOURCE_EXTENDED 1
/* Use all extensions */
#define _GNU_SOURCE 1
/* for open(2) */
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
/* for mmap(2),munmap(2) */
/* for mmap(2), munmap(2) */
#include <sys/mman.h>
/* for errno(2) */
#include <errno.h>
/* for sysconf(2),close(2) */
/* for sysconf(2), close(2) */
#include <unistd.h>
SRCID(vmli, "$HopeName: MMsrc!vmli.c(trunk.5) $");
#include "mpm.h"
#ifndef MPS_OS_LI
#error "vmli.c is LINUX specific, but MPS_OS_LI is not set"
#endif
SRCID(vmli, "$HopeName$");
/* VMStruct -- virtual memory structure */
@ -67,12 +71,16 @@ typedef struct VMStruct {
} VMStruct;
/* VMAlign -- return page size */
Align VMAlign(VM vm)
{
return vm->align;
}
/* VMCheck -- check a VM */
Bool VMCheck(VM vm)
{
CHECKS(VM, vm);