04be94a87d
1997-12-01 17:27 Ulrich Drepper <drepper@cygnus.com> * Makefile (subdirs): Add iconvdata and localedata. * iconv/gconv.h: Define UNKNOWN_10646_CHAR as error value. * iconv/gconv_conf.c (read_conf_file): Little optimization. * iconvdata/8bit-gap.c: New file. * iconvdata/8bit-generic.c: Renamed from ... * iconvdata/iso8859-generic.c: ...this. * iconvdata/configure: Removed. * iconvdata/Makefile: Add new modules and better rules. * iconvdata/iso6937.c: Minor bug fixes. * iconvdata/iso8859-1.c: Likewise. * iconvdata/t61.c: Likewise. * iconvdata/iso8859-2.c: Change to use 8bit-generic.c. Minor bug fixes. * iconvdata/iso8859-3.c: Likewise. * iconvdata/iso8859-4.c: Likewise. * iconvdata/iso8859-5.c: Likewise. * iconvdata/iso8859-6.c: Likewise. * iconvdata/iso8859-7.c: Likewise. * iconvdata/iso8859-8.c: Likewise. * iconvdata/iso8859-9.c: Likewise. * iconvdata/iso8859-10.c: Likewise. * iconvdata/ebcdic-at-de-a.c: New file. * iconvdata/ebcdic-at-de.c: New file. * iconvdata/ebcdic-ca-fr.c: New file. * iconvdata/hp-roman8.c: New file. * iconvdata/koi-8.c: New file. * iconvdata/koi8-r.c: New file. * iconvdata/koi8-h.c: New file. * iconvdata/latin-greek-1.c: New file. * iconvdata/latin-greek-1.h: New file. * iconvdata/latin-greek.c: New file. * iconvdata/latin-greek.h: New file. * iconvdata/jis0201.c: New file. * iconvdata/jis0201.h: New file. * iconvdata/jis0208.c: New file. * iconvdata/jis0208.h: New file. * iconvdata/jis0212.c: New file. * iconvdata/jis0212.h: New file. * iconvdata/sjis.c: New file. * iconvdata/gap.pl: New file. Script to generate table header. * iconvdata/gaptab.pl: New file. * iconvdata/gconv-modules: Add info about new modules. * locale/programs/charmap.c: Also examine alias names given in charmap files. * localedata/*: Add to here from add-on. We need the information to generate tables for iconv. Update from db-2.3.14. * db2/Makefile: Updated. * db2/config.h: Likewise. * db2/db.h: Likewise. * db2/db_int.h: Likewise. * db2/btree/bt_cursor.c: Likewise. * db2/btree/bt_delete.c: Likewise. * db2/btree/bt_put.c: Likewise. * db2/btree/bt_search.c: Likewise. * db2/btree/bt_split.c: Likewise. * db2/btree/btree_auto.c: Likewise. * db2/common/db_appinit.c: Likewise. * db2/common/db_apprec.c: Likewise. * db2/common/db_err.c: Likewise. * db2/common/db_region.c: Likewise. * db2/db/db_auto.c: Likewise. * db2/db/db_dispatch.c: Likewise. * db2/db/db_ret.c: Likewise. * db2/dbm/dbm.c: Likewise. * db2/hash/hash_auto.c: Likewise. * db2/include/btree_ext.h: Likewise. * db2/include/common_ext.h: Likewise. * db2/include/db.h.src: Likewise. * db2/include/db_cxx.h: Likewise. * db2/include/db_ext.h: Likewise. * db2/include/db_int.h.src: Likewise. * db2/include/lock.h: Likewise. * db2/include/log.h: Likewise. * db2/include/mp.h: Likewise. * db2/include/mp_ext.h: Likewise. * db2/include/os_ext.h: Likewise. * db2/include/os_func.h: Likewise. * db2/lock/lock.c: Likewise. * db2/lock/lock_deadlock.c: Likewise. * db2/log/log.c: Likewise. * db2/log/log_archive.c: Likewise. * db2/log/log_auto.c: Likewise. * db2/log/log_get.c: Likewise. * db2/log/log_put.c: Likewise. * db2/mp/mp_bh.c: Likewise. * db2/mp/mp_fget.c: Likewise. * db2/mp/mp_fopen.c: Likewise. * db2/mp/mp_fput.c: Likewise. * db2/mp/mp_fset.c: Likewise. * db2/mp/mp_open.c: Likewise. * db2/mp/mp_pr.c: Likewise. * db2/mp/mp_region.c: Likewise. * db2/mp/mp_sync.c: Likewise. * db2/mutex/README: Likewise. * db2/mutex/mutex.c: Likewise. * db2/os/os_open.c: Likewise. * db2/os/os_func.c: Removed. * db2/os/os_config.c: New file. * db2/os/os_spin.c: New file. * db2/txn/txn.c: Likewise. * db2/txn/txn_auto.c: Likewise. 1997-11-30 06:01 Ulrich Drepper <drepper@cygnus.com> * posix/sys/wait.h (__WAIT_INT): Don't use complex version with __typeof for C++ since this fails for class members. Reported by Neal Becker <neal@ctd.comsat.com>. 1997-11-28 11:21 Zack Weinberg <zack@rabi.phys.columbia.edu> * configure.in: Check for a working makeinfo (3.11 or better). * config.make.in: Add MAKEINFO to be substituted. * manual/Makefile: Don't update info if makeinfo is too old. 1997-11-30 05:21 Ulrich Drepper <drepper@cygnus.com> * sysdeps/alpha/setjmp.S: Define _ASM and _SETJMP_H to get definitions. * sysdeps/alpha/__longjmp.S: Likewise. * sysdeps/unix/sysv/linux/alpha/kernel_termios.h: Include <termios.h> not <bits/termios.h>. * sysdeps/unix/sysv/linux/alpha/syscalls.list: Define syscall as __llseek and make llseek and lseek64 weak aliases. * sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise. Patches by a sun <asun@zoology.washington.edu>. 1997-11-29 19:19 Zack Weinberg <zack@rabi.phys.columbia.edu> * misc/sys/syslog.h: Delete KERNEL preprocessor conditional. * sysdeps/unix/sysv/linux/powerpc/bits/termios.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/termios.h: Likewise. * misc/sys/syslog.h: Clean up BSD header. 1997-11-29 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/unix/sysv/linux/bits/in.h: Add changes from Linux 2.1.67. * sysdeps/libm-ieee754/s_ctan.c (__ctan): Raise invalid exception for ctan(+-inf,x). * sysdeps/libm-ieee754/s_ctanl.c (__ctanl): Likewise. * sysdeps/libm-ieee754/s_ctanf.c (__ctanf): Likewise. * math/libm-test.c (csqrt_test): Add tests for cabs, carg, ctan, csqrt (-1), ctanh(i*pi/4). 1997-11-26 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/generic/bits/confname.h: Fix comma in enumerator. 1997-11-28 13:28 Philip Blundell <Philip.Blundell@pobox.com> * sysdeps/unix/sysv/linux/net/if_arp.h: Add more ARPHRD_ constants. 1997-11-26 Andreas Jaeger <aj@arthur.rhein-neckar.de> * wcsmbs/wcrtomb.c (__wcrtomb): Remove unused variable fake. 1997-11-26 21:28 Ulrich Drepper <drepper@cygnus.com> * sysdeps/posix/getcwd.c (GETCWD_STORYGE_CLASS): Remove definition and use. Define GETCWD_RETURN_TYPE instead and use it. * sysdeps/unix/sysv/linux/getcwd.c: Define GETCWD_RETURN_TYPE instead of GETCWD_STORYGE_CLASS and put the return type and the `internal_function' in the right order for gcc 2.7.2. 1997-11-26 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/unix/sysv/linux/sys/module.h: Remove file. It's incompatible with Linux 2.1.x. Packages using modules (e.g. modutils) should/do provide their own version. Suggested by Richard Henderson. * sysdeps/unix/sysv/linux/Dist: Remove sys/module.h. * sysdeps/unix/sysv/linux/Makefile (sysdep_headers) [$(subdir)=socket]: Remove sys/module.h. * libio/stdio.h: Correct comment of sys_nerr/sys_errlist.
270 lines
5.5 KiB
C
270 lines
5.5 KiB
C
/*-
|
|
* See the file LICENSE for redistribution information.
|
|
*
|
|
* Copyright (c) 1996, 1997
|
|
* Sleepycat Software. All rights reserved.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#ifndef lint
|
|
static const char sccsid[] = "@(#)mutex.c 10.29 (Sleepycat) 11/25/97";
|
|
#endif /* not lint */
|
|
|
|
#ifndef NO_SYSTEM_INCLUDES
|
|
#include <sys/types.h>
|
|
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include "db_int.h"
|
|
#include "common_ext.h"
|
|
|
|
#ifdef HAVE_SPINLOCKS
|
|
|
|
#ifdef HAVE_FUNC_AIX
|
|
#define TSL_INIT(x)
|
|
#define TSL_SET(x) (!_check_lock(x, 0, 1))
|
|
#define TSL_UNSET(x) _clear_lock(x, 0)
|
|
#endif
|
|
|
|
#ifdef HAVE_ASSEM_MC68020_GCC
|
|
#include "68020.gcc"
|
|
#endif
|
|
|
|
#if defined(HAVE_FUNC_MSEM)
|
|
/*
|
|
* XXX
|
|
* Should we not use MSEM_IF_NOWAIT and let the system block for us?
|
|
* I've no idea if this will block all threads in the process or not.
|
|
*/
|
|
#define TSL_INIT(x) msem_init(x, MSEM_UNLOCKED)
|
|
#define TSL_SET(x) (!msem_lock(x, MSEM_IF_NOWAIT))
|
|
#define TSL_UNSET(x) msem_unlock(x, 0)
|
|
#endif
|
|
|
|
#ifdef HAVE_FUNC_SGI
|
|
#define TSL_INIT(x) init_lock(x)
|
|
#define TSL_SET(x) (!acquire_lock(x))
|
|
#define TSL_UNSET(x) release_lock(x)
|
|
#endif
|
|
|
|
#ifdef HAVE_FUNC_SOLARIS
|
|
/*
|
|
* Semaphore calls don't work on Solaris 5.5.
|
|
*
|
|
* #define TSL_INIT(x) sema_init(x, 1, USYNC_PROCESS, NULL)
|
|
* #define TSL_SET(x) (sema_wait(x) == 0)
|
|
* #define TSL_UNSET(x) sema_post(x)
|
|
*/
|
|
#define TSL_INIT(x)
|
|
#define TSL_SET(x) (_lock_try(x))
|
|
#define TSL_UNSET(x) _lock_clear(x)
|
|
#endif
|
|
|
|
#ifdef HAVE_ASSEM_SCO_CC
|
|
#include "sco.cc"
|
|
#endif
|
|
|
|
#ifdef HAVE_ASSEM_SPARC_GCC
|
|
#include "sparc.gcc"
|
|
#endif
|
|
|
|
#ifdef HAVE_ASSEM_UTS4_CC
|
|
#define TSL_INIT(x)
|
|
#define TSL_SET(x) (!uts_lock(x, 1))
|
|
#define TSL_UNSET(x) (*(x) = 0)
|
|
#endif
|
|
|
|
#ifdef HAVE_ASSEM_X86_GCC
|
|
#include "x86.gcc"
|
|
#endif
|
|
|
|
#if defined(_WIN32)
|
|
/* DBDB this needs to be byte-aligned!! */
|
|
#define TSL_INIT(tsl)
|
|
#define TSL_SET(tsl) (!InterlockedExchange((PLONG)tsl, 1))
|
|
#define TSL_UNSET(tsl) (*(tsl) = 0)
|
|
#endif
|
|
|
|
#ifdef macintosh
|
|
/* Mac spinlocks are simple because we cannot possibly be preempted. */
|
|
#define TSL_INIT(tsl)
|
|
#define TSL_SET(tsl) (*(tsl) = 1)
|
|
#define TSL_UNSET(tsl) (*(tsl) = 0)
|
|
#endif
|
|
|
|
#endif /* HAVE_SPINLOCKS */
|
|
|
|
/*
|
|
* __db_mutex_init --
|
|
* Initialize a DB mutex structure.
|
|
*
|
|
* PUBLIC: void __db_mutex_init __P((db_mutex_t *, off_t));
|
|
*/
|
|
void
|
|
__db_mutex_init(mp, off)
|
|
db_mutex_t *mp;
|
|
off_t off;
|
|
{
|
|
#ifdef DEBUG
|
|
if ((ALIGNTYPE)mp & (MUTEX_ALIGNMENT - 1)) {
|
|
(void)fprintf(stderr,
|
|
"MUTEX ERROR: mutex NOT %d-byte aligned!\n",
|
|
MUTEX_ALIGNMENT);
|
|
abort();
|
|
}
|
|
#endif
|
|
memset(mp, 0, sizeof(db_mutex_t));
|
|
|
|
#ifdef HAVE_SPINLOCKS
|
|
TSL_INIT(&mp->tsl_resource);
|
|
mp->spins = __os_spin();
|
|
#else
|
|
mp->off = off;
|
|
#endif
|
|
}
|
|
|
|
#define MS(n) ((n) * 1000) /* Milliseconds to micro-seconds. */
|
|
#define SECOND (MS(1000)) /* A second's worth of micro-seconds. */
|
|
|
|
/*
|
|
* __db_mutex_lock
|
|
* Lock on a mutex, logically blocking if necessary.
|
|
*
|
|
* PUBLIC: int __db_mutex_lock __P((db_mutex_t *, int));
|
|
*/
|
|
int
|
|
__db_mutex_lock(mp, fd)
|
|
db_mutex_t *mp;
|
|
int fd;
|
|
{
|
|
u_long usecs;
|
|
|
|
#ifdef HAVE_SPINLOCKS
|
|
int nspins;
|
|
|
|
for (usecs = MS(10);;) {
|
|
/* Try and acquire the uncontested resource lock for N spins. */
|
|
for (nspins = mp->spins; nspins > 0; --nspins)
|
|
if (TSL_SET(&mp->tsl_resource)) {
|
|
#ifdef DEBUG
|
|
if (mp->pid != 0) {
|
|
(void)fprintf(stderr,
|
|
"MUTEX ERROR: __db_mutex_lock: lock currently locked\n");
|
|
abort();
|
|
}
|
|
mp->pid = getpid();
|
|
#endif
|
|
if (usecs == MS(10))
|
|
++mp->mutex_set_nowait;
|
|
else
|
|
++mp->mutex_set_wait;
|
|
return (0);
|
|
}
|
|
|
|
/* Yield the processor; wait 10ms initially, up to 1 second. */
|
|
if (__db_yield == NULL || __db_yield() != 0) {
|
|
(void)__db_sleep(0, usecs);
|
|
if ((usecs <<= 1) > SECOND)
|
|
usecs = SECOND;
|
|
}
|
|
}
|
|
/* NOTREACHED */
|
|
|
|
#else /* !HAVE_SPINLOCKS */
|
|
struct flock k_lock;
|
|
pid_t mypid;
|
|
int locked;
|
|
|
|
/* Initialize the lock. */
|
|
k_lock.l_whence = SEEK_SET;
|
|
k_lock.l_start = mp->off;
|
|
k_lock.l_len = 1;
|
|
|
|
for (locked = 0, mypid = getpid();;) {
|
|
/*
|
|
* Wait for the lock to become available; wait 10ms initially,
|
|
* up to 1 second.
|
|
*/
|
|
for (usecs = MS(10); mp->pid != 0;)
|
|
if (__db_yield == NULL || __db_yield() != 0) {
|
|
(void)__db_sleep(0, usecs);
|
|
if ((usecs <<= 1) > SECOND)
|
|
usecs = SECOND;
|
|
}
|
|
|
|
/* Acquire an exclusive kernel lock. */
|
|
k_lock.l_type = F_WRLCK;
|
|
if (fcntl(fd, F_SETLKW, &k_lock))
|
|
return (1);
|
|
|
|
/* If the resource tsl is still available, it's ours. */
|
|
if (mp->pid == 0) {
|
|
locked = 1;
|
|
mp->pid = mypid;
|
|
}
|
|
|
|
/* Release the kernel lock. */
|
|
k_lock.l_type = F_UNLCK;
|
|
if (fcntl(fd, F_SETLK, &k_lock))
|
|
return (1);
|
|
|
|
/*
|
|
* If we got the resource tsl we're done.
|
|
*
|
|
* !!!
|
|
* We can't check to see if the lock is ours, because we may
|
|
* be trying to block ourselves in the lock manager, and so
|
|
* the holder of the lock that's preventing us from getting
|
|
* the lock may be us! (Seriously.)
|
|
*/
|
|
if (locked)
|
|
break;
|
|
}
|
|
return (0);
|
|
#endif /* !HAVE_SPINLOCKS */
|
|
}
|
|
|
|
/*
|
|
* __db_mutex_unlock --
|
|
* Release a lock.
|
|
*
|
|
* PUBLIC: int __db_mutex_unlock __P((db_mutex_t *, int));
|
|
*/
|
|
int
|
|
__db_mutex_unlock(mp, fd)
|
|
db_mutex_t *mp;
|
|
int fd;
|
|
{
|
|
#ifdef DEBUG
|
|
if (mp->pid == 0) {
|
|
(void)fprintf(stderr,
|
|
"MUTEX ERROR: __db_mutex_unlock: lock already unlocked\n");
|
|
abort();
|
|
}
|
|
#endif
|
|
|
|
#ifdef HAVE_SPINLOCKS
|
|
#ifdef DEBUG
|
|
mp->pid = 0;
|
|
#endif
|
|
|
|
/* Release the resource tsl. */
|
|
TSL_UNSET(&mp->tsl_resource);
|
|
#else
|
|
/*
|
|
* Release the resource tsl. We don't have to acquire any locks
|
|
* because processes trying to acquire the lock are checking for
|
|
* a pid of 0, not a specific value.
|
|
*/
|
|
mp->pid = 0;
|
|
#endif
|
|
return (0);
|
|
}
|