diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-01-25 17:01:47 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-01-25 17:01:47 +0000 |
commit | af69217fea009d28a9dca78796147a05d3cffb01 (patch) | |
tree | 98fd27434ad1ae66768530dd28b8bde5721e6c5f | |
parent | ac9f45cfd18eeffd6a9fbbcc86e68657c95658a6 (diff) | |
download | glibc-af69217fea009d28a9dca78796147a05d3cffb01.zip glibc-af69217fea009d28a9dca78796147a05d3cffb01.tar.gz glibc-af69217fea009d28a9dca78796147a05d3cffb01.tar.bz2 |
Update.
1998-01-26 00:57 Ulrich Drepper <drepper@cygnus.com>
* db2/Makefile (routines): Add os_alloc.
* db2/db.h: Update from db-2.3.16.
* db2/db_185.h: Likewise.
* db2/db_int.h: Likewise.
* db2/btree/bt_close.c: Likewise.
* db2/btree/bt_cursor.c: Likewise.
* db2/btree/bt_delete.c: Likewise.
* db2/btree/bt_open.c: Likewise.
* db2/btree/bt_page.c: Likewise.
* db2/btree/bt_put.c: Likewise.
* db2/btree/bt_rec.c: Likewise.
* db2/btree/bt_recno.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/common/db_shash.c: Likewise.
* db2/db/db.c: Likewise.
* db2/db/db_auto.c: Likewise.
* db2/db/db_conv.c: Likewise.
* db2/db/db_dispatch.c: Likewise.
* db2/db/db_dup.c: Likewise.
* db2/db/db_pr.c: Likewise.
* db2/db/db_rec.c: Likewise.
* db2/db185/db185.c: Likewise.
* db2/dbm/dbm.c: Likewise.
* db2/hash/hash.c: Likewise.
* db2/hash/hash_auto.c: Likewise.
* db2/hash/hash_dup.c: Likewise.
* db2/hash/hash_page.c: Likewise.
* db2/hash/hash_rec.c: Likewise.
* db2/include/btree_ext.h: Likewise.
* db2/include/clib_ext.h: Likewise.
* db2/include/common_ext.h: Likewise.
* db2/include/db.h.src: Likewise.
* db2/include/db_185.h.src: Likewise.
* db2/include/db_am.h: Likewise.
* db2/include/db_ext.h: Likewise.
* db2/include/db_int.h.src: Likewise.
* db2/include/hash_ext.h: Likewise.
* db2/include/lock_ext.h: Likewise.
* db2/include/log.h: Likewise.
* db2/include/log_auto.h: Likewise.
* db2/include/log_ext.h: Likewise.
* db2/include/mp.h: Likewise.
* db2/include/mp_ext.h: Likewise.
* db2/include/mutex_ext.h: Likewise.
* db2/include/os_ext.h: Likewise.
* db2/include/os_func.h: Likewise.
* db2/include/txn_ext.h: Likewise.
* db2/lock/lock.c: Likewise.
* db2/lock/lock_util.c: Likewise.
* db2/log/log.c: Likewise.
* db2/log/log.src: 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/log/log_rec.c: Likewise.
* db2/log/log_register.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_pr.c: Likewise.
* db2/mp/mp_sync.c: Likewise.
* db2/mutex/mutex.c: Likewise.
* db2/os/os_alloc.c: Likewise.
* db2/os/os_config.c: Likewise.
* db2/os/os_stat.c: Likewise.
* db2/progs/db_checkpoint/db_checkpoint.c: Likewise.
* db2/progs/db_deadlock/db_deadlock.c: Likewise.
* db2/progs/db_load/db_load.c: Likewise.
* db2/progs/db_printlog/db_printlog.c: Likewise.
* db2/progs/db_recover/db_recover.c: Likewise.
* db2/progs/db_stat/db_stat.c: Likewise.
* db2/txn/txn.c: Likewise.
* elf/dl-close.c (_dl_close): Rename inner variable named map to imap.
Unmap memory blocks in reverse order of allocation.
Call munmap with load address added to offset.
Bug reported by Miguel de Icaza.
* locale/programs/ld-collate.c (collate_end_weight): Correctly fill
up weight array.
* localedata/locales/cs_CZ: Update by Michael Mraka
<michael@informatics.muni.cz>.
* misc/sys/syslog.h: Reformat a bit. Don't declare vsyslog unless
__USE_BSD.
* nis/nss_compat/compat-grp.c: Correctly handle buffer overflow while
reading line with fgets.
* nis/nss_compat/compat-pwd.c: Likewise.
* nis/nss_compat/compat-spwd.c: Likewise.
* nss/nss_files/files-XXX.c: Likewise.
* nss/nss_files/files-alias.c: Likewise.
* shadow/fgetspent_r.c: Likewise.
* string/strerror_r.c: Correct comment. Patch by Andreas Jaeger.
* sysdeps/unix/sysv/linux/bits/stat.h: Define _STATBUF_ST_RDEV.
* sysdeps/unix/sysv/linux/alpha/bits/stat.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/stat.h: Likewise.
* sysdeps/unix/sysv/linux/i386/sys/ucontext.h: Allocate room for
FP register content in ucontext_t.
1998-01-22 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sysdeps/libm-ieee754/s_modfl.c (modf): Correct
calculation. Patch by Markus Schoder
<Markus.Schoder@dresdner-bank.de>.
* math/libm-test.c (modf_test): Add more tests for modf.
* sysdeps/unix/sysv/linux/sys/mman.h: Add const to mlock and
munlock according to Unix98.
1998-01-25 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* nss/nss_files/files-network.c (LINE_PARSER): Set n_addrtype to
AF_INET.
1998-01-21 07:22 H.J. Lu <hjl@gnu.org>
* sysdeps/posix/ttyname.c: Handle symbolic links.
* sysdeps/posix/ttyname_r.c: Ditto.
1998-01-25 19:39 Ulrich Drepper <drepper@cygnus.com>
* db2/makedb.c (process_input): Write terminating \0 for value.
(print_database): Simply print value string, don't use length.
1998-01-24 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* nss/nsswitch.c (__nss_configure_lookup): Correct test for early
exit of loop.
1998-01-25 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
* nis/ypclnt.c: Don't set dom_client to NULL, or we will not
close all sockets.
1998-01-25 14:54 Ulrich Drepper <drepper@cygnus.com>
* signal/Makefile (routines): Add sighold, sigrelse, sigignore, and
sigset.
* signal/sighold.c: New file.
* signal/sigrelse.c: New file.
* sysdeps/generic/sigignore.c: New file.
* sysdeps/generic/sigset.c: New file.
* sysdeps/posix/sigignore.c: New file.
* sysdeps/posix/sigset.c: New file.
* signal/signal.h: Add prototypes for new functions.
* sysdeps/unix/sysv/linux/alpha/bits/signum.h: Define SIG_HOLD.
* sysdeps/unix/sysv/linux/bits/signum.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/signum.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/signum.h: Likewise.
1998-01-23 00:16 Tim Waugh <tim@cyberelk.demon.co.uk>
* posix/wordexp.c: Added IFS field-splitting in parameter and
command substitution. Fixed an IFS-related bug that caused an
infinite loop.
1998-01-25 12:38 Ulrich Drepper <drepper@cygnus.com>
* stdlib/Makefile (routines): Add getcontext, setcontext, makecontext,
and swapcontext.
* stdlib/ucontext.h: Correct prototypes.
* sysdeps/generic/getcontext.c: New file.
* sysdeps/generic/setcontext.c: New file.
* sysdeps/generic/makecontext.c: New file.
* sysdeps/generic/swapcontext.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc64/Makefile: Removed.
1998-01-25 04:07 Ulrich Drepper <drepper@cygnus.com>
* resource/sys/resource.h: Remove #include of ulimit.h which is
not allowed by SUSv2 and not available on other systems.
* sysdeps/unix/sysv/linux/ulimit.c: Include ulimit.h.
* streams/Makefile: New file.
* streams/stropts.h: New file.
* sysdeps/generic/bits/stropts.h: New file.
* sysdeps/generic/isastream.c: New file.
* sysdeps/generic/getmsg.c: New file.
* sysdeps/generic/getpmsg.c: New file.
* sysdeps/generic/putmsg.c: New file.
* sysdeps/generic/putpmsg.c: New file.
* sysdeps/generic/fattach.c: New file.
* sysdeps/generic/fdetach.c: New file.
* sysdeps/unix/inet/Subdirs: Add streams.
* sysdeps/generic/bits/types.h: Add definition of __t_scalar_t and
__t_uscalar_t.
* sysdeps/unix/sysv/linux/bits/types.h: Likewise.
* sysdeps/unix/sysv/linux/alpha/bits/types.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/types.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/bits/types.h: Likewise.
* sysdeps/mach/_strerror.c: Follow changes of generic version to
handle small buffers correctly.
1998-01-24 17:31 H.J. Lu <hjl@gnu.org>
* sysdeps/alpha/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE):
Remove the 3rd arg and add declaration for _dl_runtime_resolve
and _dl_runtime_profile.
1998-01-25 02:42 Ulrich Drepper <drepper@cygnus.com>
* include/cpio.h: New file. Mainly copied from GNU cpio.
* posix/Makefile (headers): Add cpio.h.
148 files changed, 3589 insertions, 1275 deletions
@@ -1,3 +1,223 @@ +1998-01-26 00:57 Ulrich Drepper <drepper@cygnus.com> + + * db2/Makefile (routines): Add os_alloc. + * db2/db.h: Update from db-2.3.16. + * db2/db_185.h: Likewise. + * db2/db_int.h: Likewise. + * db2/btree/bt_close.c: Likewise. + * db2/btree/bt_cursor.c: Likewise. + * db2/btree/bt_delete.c: Likewise. + * db2/btree/bt_open.c: Likewise. + * db2/btree/bt_page.c: Likewise. + * db2/btree/bt_put.c: Likewise. + * db2/btree/bt_rec.c: Likewise. + * db2/btree/bt_recno.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/common/db_shash.c: Likewise. + * db2/db/db.c: Likewise. + * db2/db/db_auto.c: Likewise. + * db2/db/db_conv.c: Likewise. + * db2/db/db_dispatch.c: Likewise. + * db2/db/db_dup.c: Likewise. + * db2/db/db_pr.c: Likewise. + * db2/db/db_rec.c: Likewise. + * db2/db185/db185.c: Likewise. + * db2/dbm/dbm.c: Likewise. + * db2/hash/hash.c: Likewise. + * db2/hash/hash_auto.c: Likewise. + * db2/hash/hash_dup.c: Likewise. + * db2/hash/hash_page.c: Likewise. + * db2/hash/hash_rec.c: Likewise. + * db2/include/btree_ext.h: Likewise. + * db2/include/clib_ext.h: Likewise. + * db2/include/common_ext.h: Likewise. + * db2/include/db.h.src: Likewise. + * db2/include/db_185.h.src: Likewise. + * db2/include/db_am.h: Likewise. + * db2/include/db_ext.h: Likewise. + * db2/include/db_int.h.src: Likewise. + * db2/include/hash_ext.h: Likewise. + * db2/include/lock_ext.h: Likewise. + * db2/include/log.h: Likewise. + * db2/include/log_auto.h: Likewise. + * db2/include/log_ext.h: Likewise. + * db2/include/mp.h: Likewise. + * db2/include/mp_ext.h: Likewise. + * db2/include/mutex_ext.h: Likewise. + * db2/include/os_ext.h: Likewise. + * db2/include/os_func.h: Likewise. + * db2/include/txn_ext.h: Likewise. + * db2/lock/lock.c: Likewise. + * db2/lock/lock_util.c: Likewise. + * db2/log/log.c: Likewise. + * db2/log/log.src: 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/log/log_rec.c: Likewise. + * db2/log/log_register.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_pr.c: Likewise. + * db2/mp/mp_sync.c: Likewise. + * db2/mutex/mutex.c: Likewise. + * db2/os/os_alloc.c: Likewise. + * db2/os/os_config.c: Likewise. + * db2/os/os_stat.c: Likewise. + * db2/progs/db_checkpoint/db_checkpoint.c: Likewise. + * db2/progs/db_deadlock/db_deadlock.c: Likewise. + * db2/progs/db_load/db_load.c: Likewise. + * db2/progs/db_printlog/db_printlog.c: Likewise. + * db2/progs/db_recover/db_recover.c: Likewise. + * db2/progs/db_stat/db_stat.c: Likewise. + * db2/txn/txn.c: Likewise. + + * elf/dl-close.c (_dl_close): Rename inner variable named map to imap. + Unmap memory blocks in reverse order of allocation. + Call munmap with load address added to offset. + Bug reported by Miguel de Icaza. + + * locale/programs/ld-collate.c (collate_end_weight): Correctly fill + up weight array. + + * localedata/locales/cs_CZ: Update by Michael Mraka + <michael@informatics.muni.cz>. + + * misc/sys/syslog.h: Reformat a bit. Don't declare vsyslog unless + __USE_BSD. + + * nis/nss_compat/compat-grp.c: Correctly handle buffer overflow while + reading line with fgets. + * nis/nss_compat/compat-pwd.c: Likewise. + * nis/nss_compat/compat-spwd.c: Likewise. + * nss/nss_files/files-XXX.c: Likewise. + * nss/nss_files/files-alias.c: Likewise. + * shadow/fgetspent_r.c: Likewise. + + * string/strerror_r.c: Correct comment. Patch by Andreas Jaeger. + + * sysdeps/unix/sysv/linux/bits/stat.h: Define _STATBUF_ST_RDEV. + * sysdeps/unix/sysv/linux/alpha/bits/stat.h: Likewise. + * sysdeps/unix/sysv/linux/mips/bits/stat.h: Likewise. + + * sysdeps/unix/sysv/linux/i386/sys/ucontext.h: Allocate room for + FP register content in ucontext_t. + +1998-01-22 Andreas Jaeger <aj@arthur.rhein-neckar.de> + + * sysdeps/libm-ieee754/s_modfl.c (modf): Correct + calculation. Patch by Markus Schoder + <Markus.Schoder@dresdner-bank.de>. + + * math/libm-test.c (modf_test): Add more tests for modf. + + * sysdeps/unix/sysv/linux/sys/mman.h: Add const to mlock and + munlock according to Unix98. + +1998-01-25 Andreas Jaeger <aj@arthur.rhein-neckar.de> + + * nss/nss_files/files-network.c (LINE_PARSER): Set n_addrtype to + AF_INET. + +1998-01-21 07:22 H.J. Lu <hjl@gnu.org> + + * sysdeps/posix/ttyname.c: Handle symbolic links. + * sysdeps/posix/ttyname_r.c: Ditto. + +1998-01-25 19:39 Ulrich Drepper <drepper@cygnus.com> + + * db2/makedb.c (process_input): Write terminating \0 for value. + (print_database): Simply print value string, don't use length. + +1998-01-24 Andreas Jaeger <aj@arthur.rhein-neckar.de> + + * nss/nsswitch.c (__nss_configure_lookup): Correct test for early + exit of loop. + +1998-01-25 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> + + * nis/ypclnt.c: Don't set dom_client to NULL, or we will not + close all sockets. + +1998-01-25 14:54 Ulrich Drepper <drepper@cygnus.com> + + * signal/Makefile (routines): Add sighold, sigrelse, sigignore, and + sigset. + * signal/sighold.c: New file. + * signal/sigrelse.c: New file. + * sysdeps/generic/sigignore.c: New file. + * sysdeps/generic/sigset.c: New file. + * sysdeps/posix/sigignore.c: New file. + * sysdeps/posix/sigset.c: New file. + * signal/signal.h: Add prototypes for new functions. + + * sysdeps/unix/sysv/linux/alpha/bits/signum.h: Define SIG_HOLD. + * sysdeps/unix/sysv/linux/bits/signum.h: Likewise. + * sysdeps/unix/sysv/linux/mips/bits/signum.h: Likewise. + * sysdeps/unix/sysv/linux/sparc/bits/signum.h: Likewise. + +1998-01-23 00:16 Tim Waugh <tim@cyberelk.demon.co.uk> + + * posix/wordexp.c: Added IFS field-splitting in parameter and + command substitution. Fixed an IFS-related bug that caused an + infinite loop. + +1998-01-25 12:38 Ulrich Drepper <drepper@cygnus.com> + + * stdlib/Makefile (routines): Add getcontext, setcontext, makecontext, + and swapcontext. + * stdlib/ucontext.h: Correct prototypes. + * sysdeps/generic/getcontext.c: New file. + * sysdeps/generic/setcontext.c: New file. + * sysdeps/generic/makecontext.c: New file. + * sysdeps/generic/swapcontext.c: New file. + * sysdeps/unix/sysv/linux/sparc/sparc64/Makefile: Removed. + +1998-01-25 04:07 Ulrich Drepper <drepper@cygnus.com> + + * resource/sys/resource.h: Remove #include of ulimit.h which is + not allowed by SUSv2 and not available on other systems. + * sysdeps/unix/sysv/linux/ulimit.c: Include ulimit.h. + + * streams/Makefile: New file. + * streams/stropts.h: New file. + * sysdeps/generic/bits/stropts.h: New file. + * sysdeps/generic/isastream.c: New file. + * sysdeps/generic/getmsg.c: New file. + * sysdeps/generic/getpmsg.c: New file. + * sysdeps/generic/putmsg.c: New file. + * sysdeps/generic/putpmsg.c: New file. + * sysdeps/generic/fattach.c: New file. + * sysdeps/generic/fdetach.c: New file. + * sysdeps/unix/inet/Subdirs: Add streams. + * sysdeps/generic/bits/types.h: Add definition of __t_scalar_t and + __t_uscalar_t. + * sysdeps/unix/sysv/linux/bits/types.h: Likewise. + * sysdeps/unix/sysv/linux/alpha/bits/types.h: Likewise. + * sysdeps/unix/sysv/linux/mips/bits/types.h: Likewise. + * sysdeps/unix/sysv/linux/sparc/sparc64/bits/types.h: Likewise. + + * sysdeps/mach/_strerror.c: Follow changes of generic version to + handle small buffers correctly. + +1998-01-24 17:31 H.J. Lu <hjl@gnu.org> + + * sysdeps/alpha/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE): + Remove the 3rd arg and add declaration for _dl_runtime_resolve + and _dl_runtime_profile. + +1998-01-25 02:42 Ulrich Drepper <drepper@cygnus.com> + + * include/cpio.h: New file. Mainly copied from GNU cpio. + * posix/Makefile (headers): Add cpio.h. + 1998-01-24 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * nis/Makefile: Distribute nis_cache2.h, add nis cache functions diff --git a/bits/stropts.h b/bits/stropts.h new file mode 100644 index 0000000..026df21 --- /dev/null +++ b/bits/stropts.h @@ -0,0 +1,211 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _BITS_STROPTS_H +#define _BITS_STROPTS_H 1 + +#include <bits/types.h> + +/* Macros used as `request' argument to `ioctl'. */ +#define I_PUSH 1 /* Push STREAMS module onto top of the current + STREAM, just below the STREAM head. */ +#define I_POP 2 /* Remove STREAMS module from just below the + STREAM head. */ +#define I_LOOK 3 /* Retrieve the name of the module just below + the STREAM head and place it in a character + string. */ +#define I_FLUSH 4 /* Flush all input and/or output. */ +#define I_FLUSHBAND 5 /* Flush only band specified. */ +#define I_SETSIG 6 /* Inform the STREAM head that the process + wants the SIGPOLL signal issued. */ +#define I_GETSIG 7 /* Return the events for which the calling + process is currently registered to be sent + a SIGPOLL signal. */ +#define I_FIND 8 /* Compares the names of all modules currently + present in the STREAM to the name pointed to + by `arg'. */ +#define I_PEEK 9 /* Allows a process to retrieve the information + in the first message on the STREAM head read + queue without taking the message off the + queue. */ +#define I_SRDOPT 10 /* Sets the read mode. */ +#define I_GRDOPT 11 /* Returns the current read mode setting. */ +#define I_NREAD 12 /* Counts the number of data bytes in the data + block in the first message. */ +#define I_FDINSERT 13 /* Create a message from the specified + buffer(s), adds information about another + STREAM, and send the message downstream. */ +#define I_STR 14 /* Construct an internal STREAMS `ioctl' + message and send that message downstream. */ +#define I_SWROPT 15 /* Set the write mode. */ +#define I_GWRSET 16 /* Return the current write mode setting. */ +#define I_SENDFD 17 /* Requests the STREAM associated with `fildes' + to send a message, containing a file + pointer, to the STREAM head at the other end + of a STREAMS pipe. */ +#define I_RECVFD 18 /* Retrieve the file descriptor associated with + the message sent by an I_SENDFD `ioctl' + over a STREAMS pipe. */ +#define I_LIST 19 /* List all the module names on the STREAM, up + to and including the topmost driver name. */ +#define I_ATMARK 20 /* See if the current message on the STREAM + head read queue is "marked" by some module + downstream. */ +#define I_CKBAND 21 /* Check if the message of a given priority + band exists on the STREAM head read + queue. */ +#define I_GETBAND 22 /* Return the priority band of the first + message on the STREAM head read queue. */ +#define I_CANPUT 23 /* Check if a certain band is writable. */ +#define I_SETCLTIME 24 /* Set the time the STREAM head will delay when + a STREAM is closing and there is data on + the write queues. */ +#define I_LINK 25 /* Connect two STREAMs. */ +#define I_UNLINK 26 /* Disconnects the two STREAMs. */ +#define I_PLINK 27 /* Connect two STREAMs with a persistent + link. */ +#define I_PUNLINK 28 /* Disconnect the two STREAMs that were + connected with a persistent link. */ + + +/* Used in `I_LOOK' request. */ +#define FMNAMESZ 255 + +/* Flush options. */ +#define FLUSHR 1 /* Flush read queues. */ +#define FLUSHW 2 /* Flush write queues. */ +#define FLUSHRW 3 /* Flush read and write queues. */ + +/* Possible arguments for `I_SETSIG'. */ +#define S_RDNORM 0x0001 /* A normal message has arrived. */ +#define S_RDBAND 0x0002 /* A message with a non-zero priority has + arrived. */ +#define S_INPUT 0x0004 /* A message, other than a high-priority + message, has arrived. */ +#define S_HIPRI 0x0008 /* A high-priority message is present. */ +#define S_OUTPUT 0x0010 /* The write queue for normal data is no longer + full. */ +#define S_WRNORM S_OUTPUT +#define S_WRBAND 0x0020 /* The write queue for a non-zero priority + band is no longer full. */ +#define S_MSG 0x0040 /* A STREAMS signal message that contains the + SIGPOLL signal reaches the front of the + STREAM head read queue. */ +#define S_ERROR 0x0080 /* Notification of an error condition. */ +#define S_HANGUP 0x0100 /* Notification of a hangup. */ +#define S_BANDURG 0x0200 /* When used in conjunction with S_RDBAND, + SIGURG is generated instead of SIGPOLL when + a priority message reaches the front of the + STREAM head read queue. */ + +/* Option for `I_PEEK'. */ +#define RS_HIPRI 1 /* Only look for high-priority messages. */ + +/* Options for `I_SRDOPT'. */ +#define RDNORM 1 /* Byte-STREAM mode, the default. */ +#define RMSGD 2 /* Message-discard mode. */ +#define RMSGN 3 /* Message-nondiscard mode. */ +#define RPROTNORM 4 /* Fail `read' with EBADMSG if a message + containing a control part is at the front + of the STREAM head read queue. */ +#define RPROTDAT 5 /* Deliver the control part of a message as + data. */ +#define RPROTDIS 6 /* Discard the control part of a message, + delivering any data part. */ + +/* Possible mode for `I_SWROPT'. */ +#define SNDZERO 1 /* Send a zero-length message downstream when a + `write' of 0 bytes occurs. */ + +/* Arguments for `I_ATMARK'. */ +#define ANYMARK 1 /* Check if the message is marked. */ +#define LASTMARK 2 /* Check if the message is the last one marked + on the queue. */ + +/* Argument for `I_UNLINK'. */ +#define MUXID_ALL 1 /* Unlink all STREAMs linked to the STREAM + associated with `fildes'. */ + + +/* Macros for `getmsg', `getpmsg', `putmsg' and `putpmsg'. */ +#define MSG_ANY 1 /* Receive any message. */ +#define MSG_BAND 2 /* Receive message from specified band. */ +#define MSG_HIPRI 3 /* Send/receive high priority message. */ +#define MORECTL 4 /* More control information is left in + message. */ +#define MOREDATA 5 /* More data is left in message. */ + + +/* Structure used for the I_FLUSHBAND ioctl on streams. */ +struct bandinfo + { + unsigned char bi_pri; + int bi_flag; + }; + +struct strbuf + { + int maxlen; /* Maximum buffer length. */ + int len; /* Length of data. */ + char *buf; /* Pointer to buffer. */ + }; + +struct strpeek + { + struct strbuf ctlbuf; + struct strbuf databuf; + __t_uscalar_t flags; + }; + +struct strfdinsert + { + struct strbuf ctlbuf; + struct strbuf databuf; + __t_uscalar_t flags; + int fildes; + int offset; + }; + +struct strioctl + { + int ic_cmd; + int ic_timout; + int ic_len; + char *ic_dp; + }; + +struct strrecvfd + { + int fd; + __uid_t uid; + __gid_t gid; + }; + + +struct str_mlist + { + char l_name[FMNAMESZ + 1]; + }; + +struct str_list + { + int sl_nmods; + struct str_mlist *sl_modlist; + }; + +#endif /* bits/stropts.h */ diff --git a/bits/types.h b/bits/types.h index 5315a09..b985a3a 100644 --- a/bits/types.h +++ b/bits/types.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -111,4 +111,8 @@ typedef __u_quad_t __fsblkcnt64_t; typedef unsigned long int __fsfilcnt_t; typedef __u_quad_t __fsfilcnt64_t; +/* Used in XTI. */ +typedef int __t_scalar_t; +typedef unsigned int __t_uscalar_t; + #endif /* bits/types.h */ diff --git a/db2/Makefile b/db2/Makefile index 0ae06a3..02f1b30 100644 --- a/db2/Makefile +++ b/db2/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. +# Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -58,7 +58,7 @@ libdb-routines := bt_close bt_compare bt_conv bt_cursor bt_delete \ bt_open bt_page bt_put bt_rec bt_recno bt_rsearch bt_search \ bt_split bt_stat btree_auto db db_appinit db_apprec \ db_auto \ - db_byteorder db_conv db_dispatch db_dup db_err db_log2 \ + db_byteorder db_conv db_dispatch db_dup db_err db_log2 os_alloc \ os_abs os_config os_dir os_fid os_fsync os_map os_oflags \ os_open os_rpath os_rw os_seek os_sleep os_stat os_unlink \ os_spin db_overflow db_pr db_rec db_region db_ret db_salloc \ diff --git a/db2/btree/bt_close.c b/db2/btree/bt_close.c index 7dd7139..ecccc9f 100644 --- a/db2/btree/bt_close.c +++ b/db2/btree/bt_close.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_close.c 10.24 (Sleepycat) 9/17/97"; +static const char sccsid[] = "@(#)bt_close.c 10.25 (Sleepycat) 1/6/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -144,7 +144,7 @@ __bam_upstat(dbp) { BTREE *t; BTMETA *meta; - DB_LOCK mlock; + DB_LOCK metalock; db_pgno_t pgno; int flags, ret; @@ -161,7 +161,7 @@ __bam_upstat(dbp) pgno = PGNO_METADATA; /* Lock and retrieve the page. */ - if (__bam_lget(dbp, 0, pgno, DB_LOCK_WRITE, &mlock) != 0) + if (__bam_lget(dbp, 0, pgno, DB_LOCK_WRITE, &metalock) != 0) return; if (__bam_pget(dbp, (PAGE **)&meta, &pgno, 0) == 0) { /* Log the change. */ @@ -178,5 +178,5 @@ __bam_upstat(dbp) } err: (void)memp_fput(dbp->mpf, (PAGE *)meta, flags); - (void)__BT_LPUT(dbp, mlock); + (void)__BT_LPUT(dbp, metalock); } diff --git a/db2/btree/bt_cursor.c b/db2/btree/bt_cursor.c index 47ecd7c..f526c96 100644 --- a/db2/btree/bt_cursor.c +++ b/db2/btree/bt_cursor.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_cursor.c 10.37 (Sleepycat) 11/22/97"; +static const char sccsid[] = "@(#)bt_cursor.c 10.41 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -128,22 +128,25 @@ __bam_c_iclose(dbp, dbc) CURSOR *cp; int ret; - cp = dbc->internal; + /* + * All cursors are queued from the master DB structure. For + * now, discard the DB handle which triggered this call, and + * replace it with the cursor's reference. + */ + dbp = dbc->dbp; /* If a cursor key was deleted, perform the actual deletion. */ + cp = dbc->internal; ret = F_ISSET(cp, C_DELETED) ? __bam_c_physdel(dbp, cp, NULL) : 0; /* Discard any lock if we're not inside a transaction. */ if (cp->lock != LOCK_INVALID) (void)__BT_TLPUT(dbp, cp->lock); - /* - * All cursors are queued from the master DB structure. Remove the - * cursor from that queue. - */ - DB_THREAD_LOCK(dbc->dbp); - TAILQ_REMOVE(&dbc->dbp->curs_queue, dbc, links); - DB_THREAD_UNLOCK(dbc->dbp); + /* Remove the cursor from the queue. */ + DB_THREAD_LOCK(dbp); + TAILQ_REMOVE(&dbp->curs_queue, dbc, links); + DB_THREAD_UNLOCK(dbp); /* Discard the structures. */ FREE(dbc->internal, sizeof(CURSOR)); @@ -452,6 +455,8 @@ __bam_c_rget(dbp, cp, data, flags) db_recno_t recno; int exact, ret; + COMPQUIET(flags, 0); + /* Get the page with the current item on it. */ if ((ret = __bam_pget(dbp, &cp->page, &cp->pgno, 0)) != 0) return (ret); @@ -1086,6 +1091,8 @@ __bam_ovfl_chk(dbp, cp, indx, to_end) /* * __bam_cprint -- * Display the current btree cursor list. + * + * PUBLIC: int __bam_cprint __P((DB *)); */ int __bam_cprint(dbp) @@ -1258,12 +1265,11 @@ __bam_ca_dup(dbp, fpgno, first, fi, tpgno, ti) * __bam_ca_move -- * Adjust the cursors when moving data items to another page. * - * PUBLIC: void __bam_ca_move __P((DB *, BTREE *, db_pgno_t, db_pgno_t)); + * PUBLIC: void __bam_ca_move __P((DB *, db_pgno_t, db_pgno_t)); */ void -__bam_ca_move(dbp, t, fpgno, tpgno) +__bam_ca_move(dbp, fpgno, tpgno) DB *dbp; - BTREE *t; db_pgno_t fpgno, tpgno; { CURSOR *cp; diff --git a/db2/btree/bt_delete.c b/db2/btree/bt_delete.c index dbd1995..baa8a25 100644 --- a/db2/btree/bt_delete.c +++ b/db2/btree/bt_delete.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_delete.c 10.23 (Sleepycat) 11/22/97"; +static const char sccsid[] = "@(#)bt_delete.c 10.25 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -500,7 +500,8 @@ __bam_dpages(dbp, t) db_recno_t rcnt; int ret; - rcnt = 0; /* XXX: Shut the compiler up. */ + COMPQUIET(rcnt, 0); + epg = t->bt_sp; /* @@ -581,7 +582,7 @@ __bam_dpages(dbp, t) ++t->lstat.bt_freed; /* Adjust the cursors. */ - __bam_ca_move(dbp, t, h->pgno, PGNO_ROOT); + __bam_ca_move(dbp, h->pgno, PGNO_ROOT); } /* Release the top page in the subtree. */ diff --git a/db2/btree/bt_open.c b/db2/btree/bt_open.c index 2361f69..dd9f109 100644 --- a/db2/btree/bt_open.c +++ b/db2/btree/bt_open.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_open.c 10.21 (Sleepycat) 10/25/97"; +static const char sccsid[] = "@(#)bt_open.c 10.22 (Sleepycat) 1/6/98"; #endif /* not lint */ /* @@ -265,18 +265,18 @@ __bam_setmeta(dbp, t) { BTMETA *meta; PAGE *root; - DB_LOCK mlock, rlock; + DB_LOCK metalock, rootlock; db_pgno_t pgno; int ret; /* Get, and optionally create the metadata page. */ pgno = PGNO_METADATA; if ((ret = - __bam_lget(dbp, 0, PGNO_METADATA, DB_LOCK_WRITE, &mlock)) != 0) + __bam_lget(dbp, 0, PGNO_METADATA, DB_LOCK_WRITE, &metalock)) != 0) return (ret); if ((ret = __bam_pget(dbp, (PAGE **)&meta, &pgno, DB_MPOOL_CREATE)) != 0) { - (void)__BT_LPUT(dbp, mlock); + (void)__BT_LPUT(dbp, metalock); return (ret); } @@ -290,7 +290,7 @@ __bam_setmeta(dbp, t) t->bt_minkey = meta->minkey; (void)memp_fput(dbp->mpf, (PAGE *)meta, 0); - (void)__BT_LPUT(dbp, mlock); + (void)__BT_LPUT(dbp, metalock); return (0); } @@ -320,10 +320,11 @@ __bam_setmeta(dbp, t) /* Create and initialize a root page. */ pgno = PGNO_ROOT; - if ((ret = __bam_lget(dbp, 0, PGNO_ROOT, DB_LOCK_WRITE, &rlock)) != 0) + if ((ret = + __bam_lget(dbp, 0, PGNO_ROOT, DB_LOCK_WRITE, &rootlock)) != 0) return (ret); if ((ret = __bam_pget(dbp, &root, &pgno, DB_MPOOL_CREATE)) != 0) { - (void)__BT_LPUT(dbp, rlock); + (void)__BT_LPUT(dbp, rootlock); return (ret); } P_INIT(root, dbp->pgsize, PGNO_ROOT, PGNO_INVALID, @@ -348,8 +349,8 @@ __bam_setmeta(dbp, t) ret = EINVAL; /* Release the locks. */ - (void)__BT_LPUT(dbp, mlock); - (void)__BT_LPUT(dbp, rlock); + (void)__BT_LPUT(dbp, metalock); + (void)__BT_LPUT(dbp, rootlock); return (ret); } diff --git a/db2/btree/bt_page.c b/db2/btree/bt_page.c index 7ee74ff..853317e 100644 --- a/db2/btree/bt_page.c +++ b/db2/btree/bt_page.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_page.c 10.5 (Sleepycat) 8/18/97"; +static const char sccsid[] = "@(#)bt_page.c 10.7 (Sleepycat) 1/7/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -75,17 +75,17 @@ __bam_new(dbp, type, pagepp) PAGE **pagepp; { BTMETA *meta; - DB_LOCK mlock; + DB_LOCK metalock; PAGE *h; db_pgno_t pgno; int ret; meta = NULL; h = NULL; - mlock = LOCK_INVALID; + metalock = LOCK_INVALID; pgno = PGNO_METADATA; - if ((ret = __bam_lget(dbp, 0, pgno, DB_LOCK_WRITE, &mlock)) != 0) + if ((ret = __bam_lget(dbp, 0, pgno, DB_LOCK_WRITE, &metalock)) != 0) goto err; if ((ret = __bam_pget(dbp, (PAGE **)&meta, &pgno, 0)) != 0) goto err; @@ -112,7 +112,7 @@ __bam_new(dbp, type, pagepp) } (void)memp_fput(dbp->mpf, (PAGE *)meta, DB_MPOOL_DIRTY); - (void)__BT_TLPUT(dbp, mlock); + (void)__BT_TLPUT(dbp, metalock); P_INIT(h, dbp->pgsize, h->pgno, PGNO_INVALID, PGNO_INVALID, 0, type); *pagepp = h; @@ -122,8 +122,8 @@ err: if (h != NULL) (void)memp_fput(dbp->mpf, h, 0); if (meta != NULL) (void)memp_fput(dbp->mpf, meta, 0); - if (mlock != LOCK_INVALID) - (void)__BT_TLPUT(dbp, mlock); + if (metalock != LOCK_INVALID) + (void)__BT_TLPUT(dbp, metalock); return (ret); } @@ -140,7 +140,7 @@ __bam_free(dbp, h) { BTMETA *meta; DBT ldbt; - DB_LOCK mlock; + DB_LOCK metalock; db_pgno_t pgno; int is_dirty, ret, t_ret; @@ -152,10 +152,10 @@ __bam_free(dbp, h) */ is_dirty = 0; pgno = PGNO_METADATA; - if ((ret = __bam_lget(dbp, 0, pgno, DB_LOCK_WRITE, &mlock)) != 0) + if ((ret = __bam_lget(dbp, 0, pgno, DB_LOCK_WRITE, &metalock)) != 0) goto err; if ((ret = __bam_pget(dbp, (PAGE **)&meta, &pgno, 0)) != 0) { - (void)__BT_TLPUT(dbp, mlock); + (void)__BT_TLPUT(dbp, metalock); goto err; } @@ -168,7 +168,7 @@ __bam_free(dbp, h) dbp->txn, &meta->lsn, 0, dbp->log_fileid, h->pgno, &meta->lsn, &ldbt, meta->free)) != 0) { (void)memp_fput(dbp->mpf, (PAGE *)meta, 0); - (void)__BT_TLPUT(dbp, mlock); + (void)__BT_TLPUT(dbp, metalock); return (ret); } LSN(h) = LSN(meta); @@ -194,7 +194,7 @@ __bam_free(dbp, h) /* Discard the metadata page. */ ret = memp_fput(dbp->mpf, (PAGE *)meta, DB_MPOOL_DIRTY); - if ((t_ret = __BT_TLPUT(dbp, mlock)) != 0) + if ((t_ret = __BT_TLPUT(dbp, metalock)) != 0) ret = t_ret; /* Discard the caller's page reference. */ @@ -213,6 +213,8 @@ err: if ((t_ret = memp_fput(dbp->mpf, h, is_dirty)) != 0 && ret == 0) /* * __bam_lt -- * Print out the list of currently held locks. + * + * PUBLIC: int __bam_lt __P((DB *)); */ int __bam_lt(dbp) diff --git a/db2/btree/bt_put.c b/db2/btree/bt_put.c index 3161b02..87f3fd9 100644 --- a/db2/btree/bt_put.c +++ b/db2/btree/bt_put.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_put.c 10.35 (Sleepycat) 11/22/97"; +static const char sccsid[] = "@(#)bt_put.c 10.38 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -69,8 +69,7 @@ static int __bam_lookup __P((DB *, DBT *, int *)); static int __bam_ndup __P((DB *, PAGE *, u_int32_t)); static int __bam_ovput __P((DB *, PAGE *, u_int32_t, DBT *)); static int __bam_partial __P((DB *, DBT *, PAGE *, u_int32_t, u_int32_t)); -static u_int32_t - __bam_partsize __P((DB *, DBT *, PAGE *, u_int32_t)); +static u_int32_t __bam_partsize __P((DBT *, PAGE *, u_int32_t)); /* * __bam_put -- @@ -446,11 +445,11 @@ __bam_iitem(dbp, hp, indxp, key, data, op, flags) u_int32_t data_size, have_bytes, need_bytes, needed; int bigkey, bigdata, dupadjust, replace, ret; + COMPQUIET(bk, NULL); + t = dbp->internal; h = *hp; indx = *indxp; - - bk = NULL; /* XXX: Shut the compiler up. */ dupadjust = replace = 0; /* @@ -490,7 +489,7 @@ __bam_iitem(dbp, hp, indxp, key, data, op, flags) */ bigkey = LF_ISSET(BI_NEWKEY) && key->size > t->bt_ovflsize; data_size = F_ISSET(data, DB_DBT_PARTIAL) ? - __bam_partsize(dbp, data, h, indx) : data->size; + __bam_partsize(data, h, indx) : data->size; bigdata = data_size > t->bt_ovflsize; needed = 0; @@ -626,7 +625,7 @@ __bam_iitem(dbp, hp, indxp, key, data, op, flags) /* * 5. Delete/re-add the data item. * - * If we're dealing with offpage items, we have to + * If we're dealing with offpage items, we have to * delete and then re-add the item. */ if (bigdata || B_TYPE(bk->type) != B_KEYDATA) { @@ -693,8 +692,7 @@ __bam_iitem(dbp, hp, indxp, key, data, op, flags) * Figure out how much space a partial data item is in total. */ static u_int32_t -__bam_partsize(dbp, data, h, indx) - DB *dbp; +__bam_partsize(data, h, indx) DBT *data; PAGE *h; u_int32_t indx; @@ -1041,7 +1039,8 @@ __bam_partial(dbp, dbt, h, indx, nbytes) int ret; u_int8_t *p; - bo = NULL; /* XXX: Shut the compiler up. */ + COMPQUIET(bo, NULL); + t = dbp->internal; /* We use the record data return memory, it's only a short-term use. */ diff --git a/db2/btree/bt_rec.c b/db2/btree/bt_rec.c index c0b7c8a..90ee137 100644 --- a/db2/btree/bt_rec.c +++ b/db2/btree/bt_rec.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_rec.c 10.17 (Sleepycat) 11/2/97"; +static const char sccsid[] = "@(#)bt_rec.c 10.18 (Sleepycat) 12/15/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -69,10 +69,17 @@ __bam_pg_alloc_recover(logp, dbtp, lsnp, redo, info) */ pgno = PGNO_METADATA; if ((ret = memp_fget(mpf, &pgno, 0, &meta)) != 0) { + /* The metadata page must always exist. */ (void)__db_pgerr(file_dbp, pgno); goto out; } if ((ret = memp_fget(mpf, &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0) { + /* + * We specify creation and check for it later, because this + * operation was supposed to create the page, and even in + * the undo case it's going to get linked onto the freelist + * which we're also fixing up. + */ (void)__db_pgerr(file_dbp, argp->pgno); (void)memp_fput(mpf, meta, 0); goto out; @@ -162,6 +169,15 @@ __bam_pg_free_recover(logp, dbtp, lsnp, redo, info) * we're undoing the operation, we get the page and restore its header. */ if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) { + /* + * We don't automatically create the page. The only way the + * page might not exist is if the alloc never happened, and + * the only way the alloc might never have happened is if we + * are undoing, in which case there's no reason to create the + * page. + */ + if (!redo) + goto done; (void)__db_pgerr(file_dbp, argp->pgno); goto out; } @@ -192,6 +208,7 @@ __bam_pg_free_recover(logp, dbtp, lsnp, redo, info) */ pgno = PGNO_METADATA; if ((ret = memp_fget(mpf, &pgno, 0, &meta)) != 0) { + /* The metadata page must always exist. */ (void)__db_pgerr(file_dbp, pgno); goto out; } @@ -217,7 +234,7 @@ __bam_pg_free_recover(logp, dbtp, lsnp, redo, info) goto out; } - *lsnp = argp->prev_lsn; +done: *lsnp = argp->prev_lsn; ret = 0; out: REC_CLOSE; @@ -389,7 +406,7 @@ __bam_split_recover(logp, dbtp, lsnp, redo, info) * interest only if it wasn't a root split -- inserting a new * page in the tree requires that any following page have its * previous-page pointer updated to our new page. The next - * page had better exist. + * page must exist because we're redoing the operation. */ if (!rootsplit && !IS_ZERO_LSN(argp->nlsn)) { if ((ret = memp_fget(mpf, &argp->npgno, 0, &np)) != 0) { @@ -409,12 +426,14 @@ __bam_split_recover(logp, dbtp, lsnp, redo, info) } else { /* * If the split page is wrong, replace its contents with the - * logged page contents. The split page had better exist. + * logged page contents. If the page doesn't exist, it means + * that the create of the page never happened, nor did any of + * the adds onto the page that caused the split, and there's + * really no undo-ing to be done. */ if ((ret = memp_fget(mpf, &pgno, 0, &pp)) != 0) { - (void)__db_pgerr(file_dbp, pgno); pp = NULL; - goto out; + goto lrundo; } if (log_compare(lsnp, &LSN(pp)) == 0) { memcpy(pp, argp->pg.data, argp->pg.size); @@ -424,13 +443,14 @@ __bam_split_recover(logp, dbtp, lsnp, redo, info) } /* - * If it's a root split and the left child ever existed, put - * it on the free list. (If it's not a root split, we just - * updated the left page -- it's the same as the split page.) - * If the right child ever existed, root split or not, put it - * on the free list. + * If it's a root split and the left child ever existed, update + * its LSN. (If it's not a root split, we've updated the left + * page already -- it's the same as the split page.) If the + * right child ever existed, root split or not, update its LSN. + * The undo of the page allocation(s) will restore them to the + * free list. */ - if ((rootsplit && lp != NULL) || rp != NULL) { +lrundo: if ((rootsplit && lp != NULL) || rp != NULL) { if (rootsplit && lp != NULL && log_compare(lsnp, &LSN(lp)) == 0) { lp->lsn = argp->llsn; @@ -453,14 +473,14 @@ __bam_split_recover(logp, dbtp, lsnp, redo, info) * Finally, undo the next-page link if necessary. This is of * interest only if it wasn't a root split -- inserting a new * page in the tree requires that any following page have its - * previous-page pointer updated to our new page. The next - * page had better exist. + * previous-page pointer updated to our new page. Since it's + * possible that the next-page never existed, we ignore it as + * if there's nothing to undo. */ if (!rootsplit && !IS_ZERO_LSN(argp->nlsn)) { if ((ret = memp_fget(mpf, &argp->npgno, 0, &np)) != 0) { - (void)__db_pgerr(file_dbp, argp->npgno); np = NULL; - goto out; + goto done; } if (log_compare(lsnp, &LSN(np)) == 0) { PREV_PGNO(np) = argp->left; @@ -472,8 +492,8 @@ __bam_split_recover(logp, dbtp, lsnp, redo, info) } } -done: ret = 0; - *lsnp = argp->prev_lsn; +done: *lsnp = argp->prev_lsn; + ret = 0; if (0) { fatal: (void)__db_panic(file_dbp); @@ -525,8 +545,8 @@ __bam_rsplit_recover(logp, dbtp, lsnp, redo, info) /* Fix the root page. */ pgno = PGNO_ROOT; if ((ret = memp_fget(mpf, &pgno, 0, &pagep)) != 0) { + /* The root page must always exist. */ __db_pgerr(file_dbp, pgno); - pagep = NULL; goto out; } modified = 0; @@ -554,10 +574,15 @@ __bam_rsplit_recover(logp, dbtp, lsnp, redo, info) goto out; } - /* Fix the page copied over the root page. */ + /* + * Fix the page copied over the root page. It's possible that the + * page never made it to disk, so if we're undo-ing and the page + * doesn't exist, it's okay and there's nothing further to do. + */ if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) { + if (!redo) + goto done; (void)__db_pgerr(file_dbp, argp->pgno); - pagep = NULL; goto out; } modified = 0; @@ -577,8 +602,8 @@ __bam_rsplit_recover(logp, dbtp, lsnp, redo, info) goto out; } +done: *lsnp = argp->prev_lsn; ret = 0; - *lsnp = argp->prev_lsn; out: REC_CLOSE; } @@ -607,9 +632,11 @@ __bam_adj_recover(logp, dbtp, lsnp, redo, info) REC_PRINT(__bam_adj_print); REC_INTRO(__bam_adj_read); + /* Get the page; if it never existed and we're undoing, we're done. */ if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) { + if (!redo) + goto done; (void)__db_pgerr(file_dbp, argp->pgno); - pagep = NULL; goto out; } @@ -633,8 +660,11 @@ __bam_adj_recover(logp, dbtp, lsnp, redo, info) LSN(pagep) = argp->lsn; modified = 1; } - if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) == 0) - *lsnp = argp->prev_lsn; + if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0) + goto out; + +done: *lsnp = argp->prev_lsn; + ret = 0; if (0) { err: (void)memp_fput(mpf, pagep, 0); @@ -667,9 +697,11 @@ __bam_cadjust_recover(logp, dbtp, lsnp, redo, info) REC_PRINT(__bam_cadjust_print); REC_INTRO(__bam_cadjust_read); + /* Get the page; if it never existed and we're undoing, we're done. */ if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) { + if (!redo) + goto done; (void)__db_pgerr(file_dbp, argp->pgno); - pagep = NULL; goto out; } @@ -708,8 +740,11 @@ __bam_cadjust_recover(logp, dbtp, lsnp, redo, info) LSN(pagep) = argp->lsn; modified = 1; } - if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) == 0) - *lsnp = argp->prev_lsn; + if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0) + goto out; + +done: *lsnp = argp->prev_lsn; + ret = 0; out: REC_CLOSE; } @@ -738,9 +773,11 @@ __bam_cdel_recover(logp, dbtp, lsnp, redo, info) REC_PRINT(__bam_cdel_print); REC_INTRO(__bam_cdel_read); + /* Get the page; if it never existed and we're undoing, we're done. */ if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) { + if (!redo) + goto done; (void)__db_pgerr(file_dbp, argp->pgno); - pagep = NULL; goto out; } @@ -760,8 +797,11 @@ __bam_cdel_recover(logp, dbtp, lsnp, redo, info) LSN(pagep) = argp->lsn; modified = 1; } - if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) == 0) - *lsnp = argp->prev_lsn; + if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0) + goto out; + +done: *lsnp = argp->prev_lsn; + ret = 0; out: REC_CLOSE; } @@ -793,9 +833,11 @@ __bam_repl_recover(logp, dbtp, lsnp, redo, info) REC_PRINT(__bam_repl_print); REC_INTRO(__bam_repl_read); + /* Get the page; if it never existed and we're undoing, we're done. */ if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) { + if (!redo) + goto done; (void)__db_pgerr(file_dbp, argp->pgno); - pagep = NULL; goto out; } bk = GET_BKEYDATA(pagep, argp->indx); @@ -860,8 +902,11 @@ __bam_repl_recover(logp, dbtp, lsnp, redo, info) LSN(pagep) = argp->lsn; modified = 1; } - if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) == 0) - *lsnp = argp->prev_lsn; + if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0) + goto out; + +done: *lsnp = argp->prev_lsn; + ret = 0; if (0) { err: (void)memp_fput(mpf, pagep, 0); diff --git a/db2/btree/bt_recno.c b/db2/btree/bt_recno.c index 5e1cbc4..70ab63b 100644 --- a/db2/btree/bt_recno.c +++ b/db2/btree/bt_recno.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_recno.c 10.22 (Sleepycat) 10/25/97"; +static const char sccsid[] = "@(#)bt_recno.c 10.26 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -72,6 +72,8 @@ __ram_open(dbp, type, dbinfo) RECNO *rp; int ret; + COMPQUIET(type, DB_RECNO); + ret = 0; /* Allocate and initialize the private RECNO structure. */ @@ -402,12 +404,16 @@ __ram_c_iclose(dbp, dbc) DBC *dbc; { /* - * All cursors are queued from the master DB structure. Remove the - * cursor from that queue. + * All cursors are queued from the master DB structure. For + * now, discard the DB handle which triggered this call, and + * replace it with the cursor's reference. */ - DB_THREAD_LOCK(dbc->dbp); - TAILQ_REMOVE(&dbc->dbp->curs_queue, dbc, links); - DB_THREAD_UNLOCK(dbc->dbp); + dbp = dbc->dbp; + + /* Remove the cursor from the queue. */ + DB_THREAD_LOCK(dbp); + TAILQ_REMOVE(&dbp->curs_queue, dbc, links); + DB_THREAD_UNLOCK(dbp); /* Discard the structures. */ FREE(dbc->internal, sizeof(RCURSOR)); @@ -699,6 +705,8 @@ __ram_ca(dbp, recno, op) /* * __ram_cprint -- * Display the current recno cursor list. + * + * PUBLIC: int __ram_cprint __P((DB *)); */ int __ram_cprint(dbp) @@ -844,7 +852,8 @@ __ram_source(dbp, rp, fname) RECNO *rp; const char *fname; { - off_t size; + size_t size; + u_int32_t mbytes, bytes; int oflags, ret; if ((ret = __db_appname(dbp->dbenv, @@ -866,15 +875,17 @@ __ram_source(dbp, rp, fname) * compiler will perpetrate, doing the comparison in a portable way is * flatly impossible. Hope that mmap fails if the file is too large. */ - if ((ret = __db_ioinfo(rp->re_source, rp->re_fd, &size, NULL)) != 0) { + if ((ret = __db_ioinfo(rp->re_source, + rp->re_fd, &mbytes, &bytes, NULL)) != 0) { __db_err(dbp->dbenv, "%s: %s", rp->re_source, strerror(ret)); goto err; } - if (size == 0) { + if (mbytes == 0 && bytes == 0) { F_SET(rp, RECNO_EOF); return (0); } + size = mbytes * MEGABYTE + bytes; if ((ret = __db_map(rp->re_fd, (size_t)size, 1, 1, &rp->re_smap)) != 0) goto err; rp->re_cmap = rp->re_smap; @@ -981,7 +992,7 @@ __ram_writeback(dbp) } memset(pad, rp->re_pad, rp->re_len); } else - pad = NULL; /* XXX: Shut the compiler up. */ + COMPQUIET(pad, NULL); for (keyno = 1;; ++keyno) { switch (ret = dbp->get(dbp, NULL, &key, &data, 0)) { case 0: diff --git a/db2/btree/btree_auto.c b/db2/btree/btree_auto.c index 18b9b34..18bbd5d 100644 --- a/db2/btree/btree_auto.c +++ b/db2/btree/btree_auto.c @@ -182,7 +182,7 @@ __bam_pg_alloc_read(recbuf, argpp) /* * PUBLIC: int __bam_pg_free_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, DBT *, + * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, const DBT *, * PUBLIC: db_pgno_t)); */ int __bam_pg_free_log(logp, txnid, ret_lsnp, flags, @@ -194,7 +194,7 @@ int __bam_pg_free_log(logp, txnid, ret_lsnp, flags, u_int32_t fileid; db_pgno_t pgno; DB_LSN * meta_lsn; - DBT *header; + const DBT *header; db_pgno_t next; { DBT logrec; @@ -354,7 +354,7 @@ __bam_pg_free_read(recbuf, argpp) * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, * PUBLIC: DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *, - * PUBLIC: DBT *)); + * PUBLIC: const DBT *)); */ int __bam_split_log(logp, txnid, ret_lsnp, flags, fileid, left, llsn, right, rlsn, indx, @@ -371,7 +371,7 @@ int __bam_split_log(logp, txnid, ret_lsnp, flags, u_int32_t indx; db_pgno_t npgno; DB_LSN * nlsn; - DBT *pg; + const DBT *pg; { DBT logrec; DB_LSN *lsnp, null_lsn; @@ -560,8 +560,8 @@ __bam_split_read(recbuf, argpp) /* * PUBLIC: int __bam_rsplit_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - * PUBLIC: u_int32_t, db_pgno_t, DBT *, db_pgno_t, - * PUBLIC: DBT *, DB_LSN *)); + * PUBLIC: u_int32_t, db_pgno_t, const DBT *, db_pgno_t, + * PUBLIC: const DBT *, DB_LSN *)); */ int __bam_rsplit_log(logp, txnid, ret_lsnp, flags, fileid, pgno, pgdbt, nrec, rootent, rootlsn) @@ -571,9 +571,9 @@ int __bam_rsplit_log(logp, txnid, ret_lsnp, flags, u_int32_t flags; u_int32_t fileid; db_pgno_t pgno; - DBT *pgdbt; + const DBT *pgdbt; db_pgno_t nrec; - DBT *rootent; + const DBT *rootent; DB_LSN * rootlsn; { DBT logrec; @@ -1215,7 +1215,7 @@ __bam_cdel_read(recbuf, argpp) * PUBLIC: int __bam_repl_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, u_int32_t, - * PUBLIC: u_int32_t, DBT *, DBT *, u_int32_t, + * PUBLIC: u_int32_t, const DBT *, const DBT *, u_int32_t, * PUBLIC: u_int32_t)); */ int __bam_repl_log(logp, txnid, ret_lsnp, flags, @@ -1230,8 +1230,8 @@ int __bam_repl_log(logp, txnid, ret_lsnp, flags, DB_LSN * lsn; u_int32_t indx; u_int32_t isdeleted; - DBT *orig; - DBT *repl; + const DBT *orig; + const DBT *repl; u_int32_t prefix; u_int32_t suffix; { diff --git a/db2/common/db_appinit.c b/db2/common/db_appinit.c index 05fc7cc..4ee9e4f 100644 --- a/db2/common/db_appinit.c +++ b/db2/common/db_appinit.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_appinit.c 10.37 (Sleepycat) 11/25/97"; +static const char sccsid[] = "@(#)db_appinit.c 10.38 (Sleepycat) 1/7/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -69,7 +69,8 @@ db_appinit(db_home, db_config, dbenv, flags) { FILE *fp; int ret; - char *lp, **p, buf[MAXPATHLEN * 2]; + char * const *p; + char *lp, buf[MAXPATHLEN * 2]; /* Validate arguments. */ if (dbenv == NULL) @@ -104,7 +105,7 @@ db_appinit(db_home, db_config, dbenv, flags) goto err; /* Parse the config array. */ - for (p = (char **)db_config; p != NULL && *p != NULL; ++p) + for (p = db_config; p != NULL && *p != NULL; ++p) if ((ret = __db_parse(dbenv, *p)) != 0) goto err; diff --git a/db2/common/db_apprec.c b/db2/common/db_apprec.c index 188c6b9..7a42e13 100644 --- a/db2/common/db_apprec.c +++ b/db2/common/db_apprec.c @@ -11,12 +11,13 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_apprec.c 10.19 (Sleepycat) 11/23/97"; +static const char sccsid[] = "@(#)db_apprec.c 10.23 (Sleepycat) 1/17/98"; #endif #ifndef NO_SYSTEM_INCLUDES #include <sys/types.h> +#include <errno.h> #include <time.h> #include <string.h> #include <stdlib.h> @@ -44,9 +45,9 @@ __db_apprec(dbenv, flags) { DBT data; DB_LOG *lp; - DB_LSN ckp_lsn, first_lsn, lsn, tmp_lsn; + DB_LSN ckp_lsn, first_lsn, lsn; time_t now; - int first_flag, is_thread, ret; + int is_thread, ret; void *txninfo; lp = dbenv->lg_info; @@ -63,73 +64,109 @@ __db_apprec(dbenv, flags) F_CLR(lp, DB_AM_THREAD); /* - * Read forward through the log, opening the appropriate files so that - * we can call recovery routines. In general, we start at the last - * checkpoint prior to the last checkpointed LSN. For catastrophic - * recovery, we begin at the first LSN that appears in any log file - * (log_get figures this out for us when we pass it the DB_FIRST flag). + * Recovery is done in three passes: + * Pass #1: + * Read forward through the log from the last checkpoint to the + * end of the log, opening and closing files so that at the end + * of the log we have the "current" set of files open. + * Pass #2: + * Read backward through the log undoing any uncompleted TXNs. + * If doing catastrophic recovery, we read to the beginning of + * the log, otherwise, to the most recent checkpoint that occurs + * before the most recent checkpoint LSN, which is returned by + * __log_findckp(). During this pass, checkpoint file information + * is ignored, and file openings and closings are undone. + * Pass #3: + * Read forward through the log from the LSN found in pass #2, + * redoing any committed TXNs. During this pass, checkpoint + * file information is ignored, and file openings and closings + * are redone. */ - if (LF_ISSET(DB_RECOVER_FATAL)) - first_flag = DB_FIRST; - else { - if ((ret = __log_findckp(lp, &lsn)) == DB_NOTFOUND) - goto out; - first_flag = DB_SET; - } - /* If we're a threaded application, we have to allocate space. */ + /* + * Find the last checkpoint in the log. This is the point from which + * we want to begin pass #1 (the TXN_OPENFILES pass). + */ memset(&data, 0, sizeof(data)); - if ((ret = log_get(lp, &lsn, &data, first_flag)) != 0) { - __db_err(dbenv, "Failure: unable to get log record"); - if (first_flag == DB_SET) - __db_err(dbenv, "Retrieving LSN %lu %lu", - (u_long)lsn.file, (u_long)lsn.offset); - else - __db_err(dbenv, "Retrieving first LSN"); - goto out; + if ((ret = log_get(lp, &ckp_lsn, &data, DB_CHECKPOINT)) != 0) { + /* + * If we don't find a checkpoint, start from the beginning. + * If that fails, we're done. Note, we require that there + * be log records if we're performing recovery, and fail if + * there aren't. + */ + if ((ret = log_get(lp, &ckp_lsn, &data, DB_FIRST)) != 0) { + __db_err(dbenv, "First log record not found"); + if (ret == DB_NOTFOUND) + ret = EINVAL; + goto out; + } } - first_lsn = lsn; + /* + * Now, ckp_lsn is either the lsn of the last checkpoint or the lsn + * of the first record in the log. Begin the TXN_OPENFILES pass from + * that lsn, and proceed to the end of the log. + */ + lsn = ckp_lsn; for (;;) { ret = __db_dispatch(lp, &data, &lsn, TXN_OPENFILES, txninfo); if (ret != 0 && ret != DB_TXN_CKP) goto msgerr; - if ((ret = - log_get(dbenv->lg_info, &lsn, &data, DB_NEXT)) != 0) { - if (ret != DB_NOTFOUND) - goto out; - break; + if ((ret = log_get(lp, &lsn, &data, DB_NEXT)) != 0) { + if (ret == DB_NOTFOUND) + break; + goto out; } } /* - * Initialize the ckp_lsn to 0,0. If we never find a valid - * checkpoint in the log, then leaving ckp_lsn at 0,0 is correct. + * Pass #2. + * + * Before we can begin pass #2, backward roll phase, we determine how + * far back in the log to recover. If we are doing catastrophic + * recovery, then we go as far back as we have files. If we are + * doing normal recovery, we go as back to the most recent checkpoint + * that occurs before the most recent checkpoint LSN. */ - ZERO_LSN(ckp_lsn); + if (LF_ISSET(DB_RECOVER_FATAL)) { + ZERO_LSN(first_lsn); + } else + if ((ret = __log_findckp(lp, &first_lsn)) == DB_NOTFOUND) { + /* + * If recovery was specified, there must be log files. + * If we don't find one, it's an error. (This should + * have been caught above, when a log_get() of DB_FIRST + * or DB_CHECKPOINT succeeded, but paranoia is good.) + */ + ret = EINVAL; + goto out; + } for (ret = log_get(lp, &lsn, &data, DB_LAST); ret == 0 && log_compare(&lsn, &first_lsn) > 0; - ret = log_get(lp,&lsn, &data, DB_PREV)) { - tmp_lsn = lsn; + ret = log_get(lp, &lsn, &data, DB_PREV)) { ret = __db_dispatch(lp, &data, &lsn, TXN_BACKWARD_ROLL, txninfo); - if (ret == DB_TXN_CKP) { - if (IS_ZERO_LSN(ckp_lsn)) - ckp_lsn = tmp_lsn; - ret = 0; - } else if (ret != 0) - goto msgerr; + if (ret != 0) + if (ret != DB_TXN_CKP) + goto msgerr; + else + ret = 0; } if (ret != 0 && ret != DB_NOTFOUND) goto out; + /* + * Pass #3. + */ for (ret = log_get(lp, &lsn, &data, DB_NEXT); ret == 0; ret = log_get(lp, &lsn, &data, DB_NEXT)) { ret = __db_dispatch(lp, &data, &lsn, TXN_FORWARD_ROLL, txninfo); - if (ret == DB_TXN_CKP) - ret = 0; - else if (ret != 0) - goto msgerr; + if (ret != 0) + if (ret != DB_TXN_CKP) + goto msgerr; + else + ret = 0; } if (ret != DB_NOTFOUND) goto out; @@ -149,7 +186,7 @@ __db_apprec(dbenv, flags) goto out; if (dbenv->db_verbose) { - __db_err(lp->dbenv, "Recovery complete at %s", ctime(&now)); + __db_err(lp->dbenv, "Recovery complete at %.24s", ctime(&now)); __db_err(lp->dbenv, "%s %lu %s [%lu][%lu]", "Maximum transaction id", (u_long)dbenv->tx_info->region->last_txnid, diff --git a/db2/common/db_err.c b/db2/common/db_err.c index 13f2cb5..fc59aad 100644 --- a/db2/common/db_err.c +++ b/db2/common/db_err.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_err.c 10.19 (Sleepycat) 11/9/97"; +static const char sccsid[] = "@(#)db_err.c 10.21 (Sleepycat) 1/13/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -97,7 +97,9 @@ __db_ecursor(a, b, c) DB_TXN *b; DBC **c; { - a = a; b = b; c = c; /* XXX: Shut the compiler up. */ + COMPQUIET(a, NULL); + COMPQUIET(b, NULL); + COMPQUIET(c, NULL); return (EPERM); } @@ -113,7 +115,10 @@ __db_edel(a, b, c, d) DBT *c; int d; { - a = a; b = b; c = c; d = d; /* XXX: Shut the compiler up. */ + COMPQUIET(a, NULL); + COMPQUIET(b, NULL); + COMPQUIET(c, NULL); + COMPQUIET(d, 0); return (EPERM); } @@ -127,7 +132,8 @@ __db_efd(a, b) DB *a; int *b; { - a = a; b = b; /* XXX: Shut the compiler up. */ + COMPQUIET(a, NULL); + COMPQUIET(b, NULL); return (EPERM); } @@ -143,7 +149,11 @@ __db_egp(a, b, c, d, e) DBT *c, *d; int e; { - a = a; b = b; c = c; d = d; e = e; /* XXX: Shut the compiler up. */ + COMPQUIET(a, NULL); + COMPQUIET(b, NULL); + COMPQUIET(c, NULL); + COMPQUIET(d, NULL); + COMPQUIET(e, 0); return (EPERM); } @@ -159,7 +169,10 @@ __db_estat(a, b, c, d) void *(*c) __P((size_t)); int d; { - a = a; b = b; c = c; d = d; /* XXX: Shut the compiler up. */ + COMPQUIET(a, NULL); + COMPQUIET(b, NULL); + COMPQUIET(c, NULL); + COMPQUIET(d, 0); return (EPERM); } @@ -173,7 +186,8 @@ __db_esync(a, b) DB *a; int b; { - a = a; b = b; /* XXX: Shut the compiler up. */ + COMPQUIET(a, NULL); + COMPQUIET(b, 0); return (EPERM); } diff --git a/db2/common/db_region.c b/db2/common/db_region.c index 4fc603a..02d939e 100644 --- a/db2/common/db_region.c +++ b/db2/common/db_region.c @@ -43,7 +43,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_region.c 10.18 (Sleepycat) 11/28/97"; +static const char sccsid[] = "@(#)db_region.c 10.21 (Sleepycat) 1/16/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -168,6 +168,8 @@ __db_rinit(dbenv, rp, fd, size, lock_region) { int ret; + COMPQUIET(dbenv, NULL); + /* * Initialize the common information. * @@ -190,6 +192,12 @@ __db_rinit(dbenv, rp, fd, size, lock_region) * been initialized in which case an attempt to get it could lead to * random behavior. If the version number isn't there (the file size * is too small) or it's 0, we know that the region is being created. + * + * We also make sure to check the return of __db_mutex_lock() here, + * even though we don't usually check elsewhere. This is the first + * lock we attempt to acquire, and if it fails we have to know. (It + * can fail -- SunOS, using fcntl(2) for locking, with an in-memory + * filesystem specified as the database home.) */ __db_mutex_init(&rp->lock, MUTEX_LOCK_OFFSET(rp, &rp->lock)); if (lock_region && (ret = __db_mutex_lock(&rp->lock, fd)) != 0) @@ -219,7 +227,8 @@ __db_ropen(dbenv, appname, path, file, flags, fdp, retp) void *retp; { RLAYOUT *rp; - off_t size1, size2; + size_t size; + u_int32_t mbytes, bytes; int fd, ret; char *name; @@ -251,19 +260,20 @@ __db_ropen(dbenv, appname, path, file, flags, fdp, retp) * flatly impossible. Hope that mmap fails if the file is too large. * */ - if ((ret = __db_ioinfo(name, fd, &size1, NULL)) != 0) { + if ((ret = __db_ioinfo(name, fd, &mbytes, &bytes, NULL)) != 0) { __db_err(dbenv, "%s: %s", name, strerror(ret)); goto err2; } + size = mbytes * MEGABYTE + bytes; /* Check to make sure the first block has been written. */ - if ((size_t)size1 < sizeof(RLAYOUT)) { + if (size < sizeof(RLAYOUT)) { ret = EAGAIN; goto err2; } /* Map in whatever is there. */ - if ((ret = __db_rmap(dbenv, fd, size1, &rp)) != 0) + if ((ret = __db_rmap(dbenv, fd, size, &rp)) != 0) goto err2; /* @@ -284,11 +294,11 @@ __db_ropen(dbenv, appname, path, file, flags, fdp, retp) * getting the size of the file and checking the major version. Check * to make sure we got the entire file. */ - if ((ret = __db_ioinfo(name, fd, &size2, NULL)) != 0) { + if ((ret = __db_ioinfo(name, fd, &mbytes, &bytes, NULL)) != 0) { __db_err(dbenv, "%s: %s", name, strerror(ret)); goto err1; } - if (size1 != size2) { + if (size != mbytes * MEGABYTE + bytes) { ret = EAGAIN; goto err1; } @@ -490,11 +500,9 @@ __db_rgrow(dbenv, fd, incr) int fd; size_t incr; { -#ifdef MMAP_INIT_NEEDED size_t i; -#endif ssize_t nw; - int ret; + int mmap_init_needed, ret; char buf[__DB_VMPAGESIZE]; /* Seek to the end of the region. */ @@ -506,33 +514,42 @@ __db_rgrow(dbenv, fd, incr) /* * Historically, some systems required that all of the bytes of the - * region be written before you could mmap it and access it randomly. + * region be written before it could be mmapped and accessed randomly. + * + * Windows/95 doesn't have that problem, but it leaves file contents + * uninitialized. Win/NT apparently initializes them. */ #ifdef MMAP_INIT_NEEDED - /* Extend the region by writing each new page. */ - for (i = 0; i < incr; i += __DB_VMPAGESIZE) { + mmap_init_needed = 1; +#else + mmap_init_needed = __os_oldwin(); +#endif + if (mmap_init_needed) + /* Extend the region by writing each new page. */ + for (i = 0; i < incr; i += __DB_VMPAGESIZE) { + if ((ret = __db_write(fd, buf, sizeof(buf), &nw)) != 0) + goto err; + if (nw != sizeof(buf)) + goto eio; + } + else { + /* + * Extend the region by writing the last page. + * + * Round off the increment to the next page boundary. + */ + incr += __DB_VMPAGESIZE - 1; + incr -= incr % __DB_VMPAGESIZE; + + /* Write the last page, not the page after the last. */ + if ((ret = + __db_seek(fd, 0, 0, incr - __DB_VMPAGESIZE, SEEK_CUR)) != 0) + goto err; if ((ret = __db_write(fd, buf, sizeof(buf), &nw)) != 0) goto err; if (nw != sizeof(buf)) goto eio; } -#else - /* - * Extend the region by writing the last page. - * - * Round off the increment to the next page boundary. - */ - incr += __DB_VMPAGESIZE - 1; - incr -= incr % __DB_VMPAGESIZE; - - /* Write the last page, not the page after the last. */ - if ((ret = __db_seek(fd, 0, 0, incr - __DB_VMPAGESIZE, SEEK_CUR)) != 0) - goto err; - if ((ret = __db_write(fd, buf, sizeof(buf), &nw)) != 0) - goto err; - if (nw != sizeof(buf)) - goto eio; -#endif return (0); eio: ret = EIO; diff --git a/db2/common/db_shash.c b/db2/common/db_shash.c index 988de8a..ab188f5 100644 --- a/db2/common/db_shash.c +++ b/db2/common/db_shash.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_shash.c 10.3 (Sleepycat) 6/21/97"; +static const char sccsid[] = "@(#)db_shash.c 10.4 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -21,8 +21,8 @@ static const char sccsid[] = "@(#)db_shash.c 10.3 (Sleepycat) 6/21/97"; /* Powers-of-2 and close-by prime number pairs. */ static const struct { - int power; - int prime; + u_int power; + u_int prime; } list[] = { { 64, 67}, { 128, 131}, @@ -39,11 +39,11 @@ static const struct { * __db_tablesize -- * Choose a size for the hash table. * - * PUBLIC: int __db_tablesize __P((int)); + * PUBLIC: int __db_tablesize __P((u_int)); */ int __db_tablesize(n_buckets) - int n_buckets; + u_int n_buckets; { int i; @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)db.h.src 10.97 (Sleepycat) 11/28/97 + * @(#)db.h.src 10.102 (Sleepycat) 1/18/98 */ #ifndef _DB_H_ @@ -73,8 +73,8 @@ #define DB_VERSION_MAJOR 2 #define DB_VERSION_MINOR 3 -#define DB_VERSION_PATCH 14 -#define DB_VERSION_STRING "Sleepycat Software: DB 2.3.14: (11/28/97)" +#define DB_VERSION_PATCH 16 +#define DB_VERSION_STRING "Sleepycat Software: DB 2.3.16: (1/19/98)" typedef u_int32_t db_pgno_t; /* Page number type. */ typedef u_int16_t db_indx_t; /* Page offset type. */ @@ -241,7 +241,7 @@ struct __db_env { DB_LOCKTAB *lk_info; /* Return from lock_open(). */ u_int8_t *lk_conflicts; /* Two dimensional conflict matrix. */ int lk_modes; /* Number of lock modes in table. */ - unsigned int lk_max; /* Maximum number of locks. */ + u_int lk_max; /* Maximum number of locks. */ u_int32_t lk_detect; /* Deadlock detect on every conflict. */ /* Logging. */ @@ -461,7 +461,6 @@ struct __db { #define DB_RE_PAD 0x004000 /* DB_PAD (internal). */ #define DB_RE_RENUMBER 0x008000 /* DB_RENUMBER (internal). */ #define DB_RE_SNAPSHOT 0x010000 /* DB_SNAPSHOT (internal). */ - u_int32_t flags; }; @@ -532,7 +531,7 @@ int db_open __P((const char *, DBTYPE, int, int, DB_ENV *, DB_INFO *, DB **)); int db_value_set __P((int, int)); char *db_version __P((int *, int *, int *)); #if defined(__cplusplus) -}; +} #endif /******************************************************* @@ -611,7 +610,7 @@ int lock_unlink __P((const char *, int, DB_ENV *)); int lock_vec __P((DB_LOCKTAB *, u_int32_t, int, DB_LOCKREQ *, int, DB_LOCKREQ **)); #if defined(__cplusplus) -}; +} #endif /******************************************************* @@ -650,6 +649,8 @@ struct __db_log_stat { u_int32_t st_scount; /* Total writes to the log. */ u_int32_t st_region_wait; /* Region lock granted after wait. */ u_int32_t st_region_nowait; /* Region lock granted without wait. */ + u_int32_t st_cur_file; /* Current log file number. */ + u_int32_t st_cur_offset; /* Current log file offset. */ }; #if defined(__cplusplus) @@ -668,7 +669,7 @@ int log_stat __P((DB_LOG *, DB_LOG_STAT **, void *(*)(size_t))); int log_unlink __P((const char *, int, DB_ENV *)); int log_unregister __P((DB_LOG *, u_int32_t)); #if defined(__cplusplus) -}; +} #endif /******************************************************* @@ -739,7 +740,7 @@ int memp_sync __P((DB_MPOOL *, DB_LSN *)); int memp_trickle __P((DB_MPOOL *, int, int *)); int memp_unlink __P((const char *, int, DB_ENV *)); #if defined(__cplusplus) -}; +} #endif /******************************************************* @@ -790,10 +791,13 @@ int txn_prepare __P((DB_TXN *)); int txn_stat __P((DB_TXNMGR *, DB_TXN_STAT **, void *(*)(size_t))); int txn_unlink __P((const char *, int, DB_ENV *)); #if defined(__cplusplus) -}; +} #endif -#ifdef DB_DBM_HSEARCH +#ifndef DB_DBM_HSEARCH +#define DB_DBM_HSEARCH 0 /* No historic interfaces by default. */ +#endif +#if DB_DBM_HSEARCH != 0 /******************************************************* * Dbm/Ndbm historic interfaces. *******************************************************/ @@ -811,40 +815,74 @@ typedef struct { int dsize; } datum; +/* + * Translate DBM calls into DB calls so that DB doesn't step on the + * application's name space. + * + * The global variables dbrdonly, dirf and pagf were not retained when + * 4BSD replaced the dbm interface with ndbm, and are not support here. + */ +#define dbminit(a) __db_dbm_init(a) +#if !defined(__cplusplus) +#define delete(a) __db_dbm_delete(a) +#endif +#define fetch(a) __db_dbm_fetch(a) +#define firstkey __db_dbm_firstkey +#define nextkey(a) __db_dbm_nextkey(a) +#define store(a, b) __db_dbm_store(a, b) + +/* Prototype the DB calls. */ #if defined(__cplusplus) extern "C" { #endif -int dbminit __P((char *)); -#if !defined(__cplusplus) -int delete __P((datum)); +int __db_dbm_init __P((char *)); +int __db_dbm_delete __P((datum)); +int __db_dbm_dbrdonly __P((void)); +int __db_dbm_dirf __P((void)); +datum __db_dbm_fetch __P((datum)); +datum __db_dbm_firstkey __P((void)); +datum __db_dbm_nextkey __P((datum)); +int __db_dbm_pagf __P((void)); +int __db_dbm_store __P((datum, datum)); +#if defined(__cplusplus) +} #endif -datum fetch __P((datum)); -datum firstkey __P((void)); -datum nextkey __P((datum)); -int store __P((datum, datum)); /* - * !!! - * Don't prototype: - * - * dbm_clearerr(DBM *db); - * dbm_dirfno(DBM *db); - * dbm_error(DBM *db); - * dbm_pagfno(DBM *db); - * dbm_rdonly(DBM *db); - * - * they weren't documented and were historically implemented as #define's. + * Translate NDBM calls into DB calls so that DB doesn't step on the + * application's name space. */ -void dbm_close __P((DBM *)); -int dbm_delete __P((DBM *, datum)); -datum dbm_fetch __P((DBM *, datum)); -datum dbm_firstkey __P((DBM *)); -long dbm_forder __P((DBM *, datum)); -datum dbm_nextkey __P((DBM *)); -DBM *dbm_open __P((const char *, int, int)); -int dbm_store __P((DBM *, datum, datum, int)); +#define dbm_clearerr(a) __db_ndbm_clearerr(a) +#define dbm_close(a) __db_ndbm_close(a) +#define dbm_delete(a, b) __db_ndbm_delete(a, b) +#define dbm_dirfno(a) __db_ndbm_dirfno(a) +#define dbm_error(a) __db_ndbm_error(a) +#define dbm_fetch(a, b) __db_ndbm_fetch(a, b) +#define dbm_firstkey(a) __db_ndbm_firstkey(a) +#define dbm_nextkey(a) __db_ndbm_nextkey(a) +#define dbm_open(a, b, c) __db_ndbm_open(a, b, c) +#define dbm_pagfno(a) __db_ndbm_pagfno(a) +#define dbm_rdonly(a) __db_ndbm_rdonly(a) +#define dbm_store(a, b, c, d) __db_ndbm_store(a, b, c, d) + +/* Prototype the DB calls. */ #if defined(__cplusplus) -}; +extern "C" { +#endif +int __db_ndbm_clearerr __P((DBM *)); +void __db_ndbm_close __P((DBM *)); +int __db_ndbm_delete __P((DBM *, datum)); +int __db_ndbm_dirfno __P((DBM *)); +int __db_ndbm_error __P((DBM *)); +datum __db_ndbm_fetch __P((DBM *, datum)); +datum __db_ndbm_firstkey __P((DBM *)); +datum __db_ndbm_nextkey __P((DBM *)); +DBM *__db_ndbm_open __P((const char *, int, int)); +int __db_ndbm_pagfno __P((DBM *)); +int __db_ndbm_rdonly __P((DBM *)); +int __db_ndbm_store __P((DBM *, datum, datum, int)); +#if defined(__cplusplus) +} #endif /******************************************************* @@ -859,14 +897,23 @@ typedef struct entry { void *data; } ENTRY; +/* + * Translate HSEARCH calls into DB calls so that DB doesn't step on the + * application's name space. + */ +#define hcreate(a) __db_hcreate(a) +#define hdestroy __db_hdestroy +#define hsearch(a, b) __db_hsearch(a, b) + +/* Prototype the DB calls. */ #if defined(__cplusplus) extern "C" { #endif -int hcreate __P((unsigned int)); -void hdestroy __P((void)); -ENTRY *hsearch __P((ENTRY, ACTION)); +int __db_hcreate __P((unsigned int)); +void __db_hdestroy __P((void)); +ENTRY *__db_hsearch __P((ENTRY, ACTION)); #if defined(__cplusplus) -}; +} #endif #endif /* DB_DBM_HSEARCH */ diff --git a/db2/db/db.c b/db2/db/db.c index 50b14eb..8df7634 100644 --- a/db2/db/db.c +++ b/db2/db/db.c @@ -44,7 +44,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db.c 10.44 (Sleepycat) 10/25/97"; +static const char sccsid[] = "@(#)db.c 10.45 (Sleepycat) 12/4/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -110,9 +110,9 @@ db_open(fname, type, flags, mode, dbenv, dbinfo, dbpp) DB_ENV *envp, t_dbenv; DB_PGINFO pginfo; HASHHDR *hashm; - off_t io; size_t cachesize; ssize_t nr; + u_int32_t iopsize; int fd, ftype, need_fileid, restore, ret, retry_cnt, swapped; char *real_name, mbuf[512]; @@ -269,17 +269,17 @@ open_retry: if (LF_ISSET(DB_CREATE)) { * sizes, we limit the default pagesize to 16K. */ if (dbp->pgsize == 0) { - if ((ret = - __db_ioinfo(real_name, fd, NULL, &io)) != 0) { + if ((ret = __db_ioinfo(real_name, + fd, NULL, NULL, &iopsize)) != 0) { __db_err(dbenv, "%s: %s", real_name, strerror(ret)); goto err; } - if (io < 512) - io = 512; - if (io > 16 * 1024) - io = 16 * 1024; - dbp->pgsize = io; + if (iopsize < 512) + iopsize = 512; + if (iopsize > 16 * 1024) + iopsize = 16 * 1024; + dbp->pgsize = iopsize; F_SET(dbp, DB_AM_PGDEF); } diff --git a/db2/db/db_auto.c b/db2/db/db_auto.c index 88bca7b..5d35264 100644 --- a/db2/db/db_auto.c +++ b/db2/db/db_auto.c @@ -20,7 +20,7 @@ * PUBLIC: int __db_addrem_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, u_int32_t, - * PUBLIC: size_t, DBT *, DBT *, DB_LSN *)); + * PUBLIC: size_t, const DBT *, const DBT *, DB_LSN *)); */ int __db_addrem_log(logp, txnid, ret_lsnp, flags, opcode, fileid, pgno, indx, nbytes, hdr, @@ -34,8 +34,8 @@ int __db_addrem_log(logp, txnid, ret_lsnp, flags, db_pgno_t pgno; u_int32_t indx; size_t nbytes; - DBT *hdr; - DBT *dbt; + const DBT *hdr; + const DBT *dbt; DB_LSN * pagelsn; { DBT logrec; @@ -229,7 +229,7 @@ __db_addrem_read(recbuf, argpp) /* * PUBLIC: int __db_split_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, DBT *, + * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, const DBT *, * PUBLIC: DB_LSN *)); */ int __db_split_log(logp, txnid, ret_lsnp, flags, @@ -241,7 +241,7 @@ int __db_split_log(logp, txnid, ret_lsnp, flags, u_int32_t opcode; u_int32_t fileid; db_pgno_t pgno; - DBT *pageimage; + const DBT *pageimage; DB_LSN * pagelsn; { DBT logrec; @@ -400,7 +400,7 @@ __db_split_read(recbuf, argpp) * PUBLIC: int __db_big_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, db_pgno_t, - * PUBLIC: db_pgno_t, DBT *, DB_LSN *, DB_LSN *, + * PUBLIC: db_pgno_t, const DBT *, DB_LSN *, DB_LSN *, * PUBLIC: DB_LSN *)); */ int __db_big_log(logp, txnid, ret_lsnp, flags, @@ -415,7 +415,7 @@ int __db_big_log(logp, txnid, ret_lsnp, flags, db_pgno_t pgno; db_pgno_t prev_pgno; db_pgno_t next_pgno; - DBT *dbt; + const DBT *dbt; DB_LSN * pagelsn; DB_LSN * prevlsn; DB_LSN * nextlsn; @@ -1079,7 +1079,7 @@ __db_addpage_read(recbuf, argpp) /* * PUBLIC: int __db_debug_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - * PUBLIC: DBT *, u_int32_t, DBT *, DBT *, + * PUBLIC: const DBT *, u_int32_t, const DBT *, const DBT *, * PUBLIC: u_int32_t)); */ int __db_debug_log(logp, txnid, ret_lsnp, flags, @@ -1088,10 +1088,10 @@ int __db_debug_log(logp, txnid, ret_lsnp, flags, DB_TXN *txnid; DB_LSN *ret_lsnp; u_int32_t flags; - DBT *op; + const DBT *op; u_int32_t fileid; - DBT *key; - DBT *data; + const DBT *key; + const DBT *data; u_int32_t arg_flags; { DBT logrec; diff --git a/db2/db/db_conv.c b/db2/db/db_conv.c index 8eccc2e..c075df3 100644 --- a/db2/db/db_conv.c +++ b/db2/db/db_conv.c @@ -44,7 +44,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_conv.c 10.7 (Sleepycat) 9/21/97"; +static const char sccsid[] = "@(#)db_conv.c 10.8 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -94,7 +94,7 @@ __db_pgout(pg, pagesize, pp) */ static int __db_convert(pg, pp, pagesize, pgin) - db_pgno_t pg; /* Unused, but left for the future. */ + db_pgno_t pg; void *pp; size_t pagesize; int pgin; @@ -107,6 +107,8 @@ __db_convert(pg, pp, pagesize, pgin) db_indx_t i, len, tmp; u_int8_t *p, *end; + COMPQUIET(pg, 0); + h = pp; if (pgin) { M_32_SWAP(h->lsn.file); diff --git a/db2/db/db_dispatch.c b/db2/db/db_dispatch.c index 4f89d2b..736575a 100644 --- a/db2/db/db_dispatch.c +++ b/db2/db/db_dispatch.c @@ -43,7 +43,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_dispatch.c 10.7 (Sleepycat) 11/23/97"; +static const char sccsid[] = "@(#)db_dispatch.c 10.9 (Sleepycat) 1/17/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -61,6 +61,7 @@ static const char sccsid[] = "@(#)db_dispatch.c 10.7 (Sleepycat) 11/23/97"; #include "db_dispatch.h" #include "db_am.h" #include "common_ext.h" +#include "log_auto.h" /* * Data structures to manage the DB dispatch table. The dispatch table @@ -113,7 +114,8 @@ __db_dispatch(logp, db, lsnp, redo, info) * seen it, then we call the appropriate recovery routine * in "abort mode". */ - if (__db_txnlist_find(info, txnid) == DB_NOTFOUND) + if (rectype == DB_log_register || + __db_txnlist_find(info, txnid) == DB_NOTFOUND) return ((dispatch_table[rectype])(logp, db, lsnp, TXN_UNDO, info)); break; @@ -122,7 +124,8 @@ __db_dispatch(logp, db, lsnp, redo, info) * In the forward pass, if we haven't seen the transaction, * do nothing, else recovery it. */ - if (__db_txnlist_find(info, txnid) != DB_NOTFOUND) + if (rectype == DB_log_register || + __db_txnlist_find(info, txnid) != DB_NOTFOUND) return ((dispatch_table[rectype])(logp, db, lsnp, TXN_REDO, info)); break; @@ -258,6 +261,8 @@ __db_txnlist_find(listp, txnid) /* * __db_txnlist_print -- * Print out the transaction list. + * + * PUBLIC: void __db_txnlist_print __P((void *)); */ void __db_txnlist_print(listp) diff --git a/db2/db/db_dup.c b/db2/db/db_dup.c index faeefa0..59dfb85 100644 --- a/db2/db/db_dup.c +++ b/db2/db/db_dup.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_dup.c 10.10 (Sleepycat) 10/25/97"; +static const char sccsid[] = "@(#)db_dup.c 10.11 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -369,14 +369,13 @@ __db_dsplit(dbp, hp, indxp, size, newfunc) * __db_ditem -- * Remove an item from a page. * - * PUBLIC: int __db_ditem __P((DB *, PAGE *, int, u_int32_t)); + * PUBLIC: int __db_ditem __P((DB *, PAGE *, u_int32_t, u_int32_t)); */ int __db_ditem(dbp, pagep, indx, nbytes) DB *dbp; PAGE *pagep; - int indx; - u_int32_t nbytes; + u_int32_t indx, nbytes; { DBT ldbt; db_indx_t cnt, offset; diff --git a/db2/db/db_pr.c b/db2/db/db_pr.c index 6b6171a..1135a9e 100644 --- a/db2/db/db_pr.c +++ b/db2/db/db_pr.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_pr.c 10.19 (Sleepycat) 11/2/97"; +static const char sccsid[] = "@(#)db_pr.c 10.20 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -81,7 +81,7 @@ __db_dump(dbp, name, all) { FILE *fp, *save_fp; - save_fp = NULL; /* XXX: Shut the compiler up. */ + COMPQUIET(save_fp, NULL); if (set_psize == PSIZE_BOUNDARY) __db_psize(dbp->mpf); diff --git a/db2/db/db_rec.c b/db2/db/db_rec.c index 2c9ca9a..48e09e6 100644 --- a/db2/db/db_rec.c +++ b/db2/db/db_rec.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_rec.c 10.10 (Sleepycat) 11/2/97"; +static const char sccsid[] = "@(#)db_rec.c 10.12 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -87,8 +87,8 @@ __db_addrem_recover(logp, dbtp, lsnp, redo, info) } else if ((cmp_n == 0 && !redo && argp->opcode == DB_ADD_DUP) || (cmp_p == 0 && redo && argp->opcode == DB_REM_DUP)) { /* Need to undo an add, or redo a delete. */ - if ((ret = __db_ditem(file_dbp, pagep, argp->indx, - argp->nbytes)) != 0) + if ((ret = __db_ditem(file_dbp, + pagep, argp->indx, argp->nbytes)) != 0) goto out; change = DB_MPOOL_DIRTY; } @@ -585,6 +585,9 @@ __db_debug_recover(logp, dbtp, lsnp, redo, info) __db_debug_args *argp; int ret; + COMPQUIET(redo, 0); + COMPQUIET(logp, NULL); + REC_PRINT(__db_debug_print); REC_NOOP_INTRO(__db_debug_read); @@ -612,6 +615,9 @@ __db_noop_recover(logp, dbtp, lsnp, redo, info) __db_noop_args *argp; int ret; + COMPQUIET(redo, 0); + COMPQUIET(logp, NULL); + REC_PRINT(__db_noop_print); REC_NOOP_INTRO(__db_noop_read); diff --git a/db2/db185/db185.c b/db2/db185/db185.c index 1affdcd..7f6a16d 100644 --- a/db2/db185/db185.c +++ b/db2/db185/db185.c @@ -119,7 +119,7 @@ __dbopen(file, oflags, mode, type, openinfo) */ if (file != NULL) { if (oflags & O_CREAT && __db_exists(file, NULL) != 0) - (void)__os_close(open(file, oflags, mode)); + (void)__os_close(__os_open(file, oflags, mode)); dbinfop->re_source = (char *)file; file = NULL; } diff --git a/db2/db_185.h b/db2/db_185.h index b6a4d0a..f3b02c7 100644 --- a/db2/db_185.h +++ b/db2/db_185.h @@ -36,7 +36,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)db_185.h.src 8.4 (Sleepycat) 9/16/97 + * @(#)db_185.h.src 8.5 (Sleepycat) 1/15/98 */ #ifndef _DB_185_H_ @@ -76,8 +76,8 @@ * XXX * SGI/IRIX already has a pgno_t. */ -#ifdef sgi -#define pgno_t db_pgno_t +#ifdef sgi +#define pgno_t db_pgno_t #endif #define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ @@ -174,6 +174,6 @@ DB *__dbopen __P((const char *, int, int, DBTYPE, const void *)); DB *dbopen __P((const char *, int, int, DBTYPE, const void *)); #if defined(__cplusplus) -}; +} #endif #endif /* !_DB_185_H_ */ diff --git a/db2/db_int.h b/db2/db_int.h index 2146072..eacd3f9 100644 --- a/db2/db_int.h +++ b/db2/db_int.h @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)db_int.h.src 10.37 (Sleepycat) 11/25/97 + * @(#)db_int.h.src 10.41 (Sleepycat) 1/8/98 */ #ifndef _DB_INTERNAL_H_ @@ -18,14 +18,22 @@ /******************************************************* * General purpose constants and macros. *******************************************************/ -#define UINT32_T_MAX 0xffffffff /* Maximum 32 bit unsigned. */ #define UINT16_T_MAX 0xffff /* Maximum 16 bit unsigned. */ +#define UINT32_T_MAX 0xffffffff /* Maximum 32 bit unsigned. */ #define DB_MIN_PGSIZE 0x000200 /* Minimum page size. */ #define DB_MAX_PGSIZE 0x010000 /* Maximum page size. */ #define DB_MINCACHE 10 /* Minimum cached pages */ +#define MEGABYTE 1048576 + +/* + * If we are unable to determine the underlying filesystem block size, use + * 8K on the grounds that most OS's use less than 8K as their VM page size. + */ +#define DB_DEF_IOSIZE (8 * 1024) + /* * Aligning items to particular sizes or in pages or memory. ALIGNP is a * separate macro, as we've had to cast the pointer to different integral @@ -109,6 +117,9 @@ typedef struct __fn { #undef DB_LINE #define DB_LINE "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" +/* Unused, or not-used-yet variable. "Shut that bloody compiler up!" */ +#define COMPQUIET(n, v) (n) = (v) + /******************************************************* * Files. *******************************************************/ @@ -155,18 +166,22 @@ typedef unsigned char tsl_t; /* * The offset of a mutex in memory. + * + * !!! + * Not an off_t, so backing file offsets MUST be less than 4Gb. See the + * off field of the db_mutex_t as well. */ -#define MUTEX_LOCK_OFFSET(a, b) ((off_t)((u_int8_t *)b - (u_int8_t *)a)) +#define MUTEX_LOCK_OFFSET(a, b) ((u_int32_t)((u_int8_t *)b - (u_int8_t *)a)) typedef struct _db_mutex_t { #ifdef HAVE_SPINLOCKS - tsl_t tsl_resource; /* Resource test and set. */ + tsl_t tsl_resource; /* Resource test and set. */ #ifdef DEBUG - u_long pid; /* Lock holder: 0 or process pid. */ + u_long pid; /* Lock holder: 0 or process pid. */ #endif #else - off_t off; /* Backing file offset. */ - u_long pid; /* Lock holder: 0 or process pid. */ + u_int32_t off; /* Backing file offset. */ + u_long pid; /* Lock holder: 0 or process pid. */ #endif u_int32_t spins; /* Spins before block. */ u_int32_t mutex_set_wait; /* Granted after wait. */ diff --git a/db2/dbm/dbm.c b/db2/dbm/dbm.c index bd7c7a6..81f4bba 100644 --- a/db2/dbm/dbm.c +++ b/db2/dbm/dbm.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)dbm.c 10.7 (Sleepycat) 11/25/97"; +static const char sccsid[] = "@(#)dbm.c 10.10 (Sleepycat) 1/16/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -59,18 +59,12 @@ static const char sccsid[] = "@(#)dbm.c 10.7 (Sleepycat) 11/25/97"; #include <string.h> #endif -#define DB_DBM_HSEARCH +#define DB_DBM_HSEARCH 1 #include "db_int.h" #include "db_page.h" #include "hash.h" -/* Provide prototypes here since there are none in db.h. */ -int dbm_clearerr __P((DBM *)); -int dbm_dirfno __P((DBM *)); -int dbm_error __P((DBM *)); -int dbm_pagfno __P((DBM *)); - /* * * This package provides dbm and ndbm compatible interfaces to DB. @@ -82,7 +76,7 @@ static DBM *__cur_db; static void __db_no_open __P((void)); int -dbminit(file) +__db_dbm_init(file) char *file; { if (__cur_db != NULL) @@ -94,9 +88,10 @@ dbminit(file) return (0); return (-1); } +weak_alias (__db_dbm_init, dbminit) datum -fetch(key) +__db_dbm_fetch(key) datum key; { datum item; @@ -108,9 +103,10 @@ fetch(key) } return (dbm_fetch(__cur_db, key)); } +weak_alias (__db_dbm_fetch, fetch) datum -firstkey() +__db_dbm_firstkey() { datum item; @@ -121,13 +117,17 @@ firstkey() } return (dbm_firstkey(__cur_db)); } +#undef firstkey +weak_alias (__db_dbm_firstkey, firstkey) datum -nextkey(key) +__db_dbm_nextkey(key) datum key; { datum item; + COMPQUIET(key.dsize, 0); + if (__cur_db == NULL) { __db_no_open(); item.dptr = 0; @@ -135,9 +135,10 @@ nextkey(key) } return (dbm_nextkey(__cur_db)); } +weak_alias (__db_dbm_nextkey, nextkey) int -delete(key) +__db_dbm_delete(key) datum key; { int ret; @@ -151,9 +152,10 @@ delete(key) ret = (((DB *)__cur_db)->sync)((DB *)__cur_db, 0); return (ret); } +weak_alias (__db_dbm_delete, delete) int -store(key, dat) +__db_dbm_store(key, dat) datum key, dat; { int ret; @@ -167,6 +169,7 @@ store(key, dat) ret = (((DB *)__cur_db)->sync)((DB *)__cur_db, 0); return (ret); } +weak_alias (__db_dbm_store, store) static void __db_no_open() @@ -185,7 +188,7 @@ __db_no_open() * NULL on failure */ DBM * -dbm_open(file, oflags, mode) +__db_ndbm_open(file, oflags, mode) const char *file; int oflags, mode; { @@ -215,17 +218,19 @@ dbm_open(file, oflags, mode) return (NULL); return ((DBM *)dbp); } +weak_alias (__db_ndbm_open, dbm_open) /* * Returns: * Nothing. */ void -dbm_close(db) +__db_ndbm_close(db) DBM *db; { (void)db->close(db, 0); } +weak_alias (__db_ndbm_close, dbm_close) /* * Returns: @@ -233,7 +238,7 @@ dbm_close(db) * NULL on failure */ datum -dbm_fetch(db, key) +__db_ndbm_fetch(db, key) DBM *db; datum key; { @@ -255,6 +260,7 @@ dbm_fetch(db, key) } return (data); } +weak_alias (__db_ndbm_fetch, dbm_fetch) /* * Returns: @@ -262,7 +268,7 @@ dbm_fetch(db, key) * NULL on failure */ datum -dbm_firstkey(db) +__db_ndbm_firstkey(db) DBM *db; { DBT _key, _data; @@ -289,6 +295,7 @@ dbm_firstkey(db) } return (key); } +weak_alias (__db_ndbm_firstkey, dbm_firstkey) /* * Returns: @@ -296,7 +303,7 @@ dbm_firstkey(db) * NULL on failure */ datum -dbm_nextkey(db) +__db_ndbm_nextkey(db) DBM *db; { DBC *cp; @@ -322,6 +329,7 @@ dbm_nextkey(db) } return (key); } +weak_alias (__db_ndbm_nextkey, dbm_nextkey) /* * Returns: @@ -329,7 +337,7 @@ dbm_nextkey(db) * <0 failure */ int -dbm_delete(db, key) +__db_ndbm_delete(db, key) DBM *db; datum key; { @@ -348,6 +356,7 @@ dbm_delete(db, key) } return (ret); } +weak_alias (__db_ndbm_delete, dbm_delete) /* * Returns: @@ -356,7 +365,7 @@ dbm_delete(db, key) * 1 if DBM_INSERT and entry exists */ int -dbm_store(db, key, data, flags) +__db_ndbm_store(db, key, data, flags) DBM *db; datum key, data; int flags; @@ -372,9 +381,10 @@ dbm_store(db, key, data, flags) return (db->put((DB *)db, NULL, &_key, &_data, (flags == DBM_INSERT) ? DB_NOOVERWRITE : 0)); } +weak_alias (__db_ndbm_store, dbm_store) int -dbm_error(db) +__db_ndbm_error(db) DBM *db; { HTAB *hp; @@ -382,9 +392,10 @@ dbm_error(db) hp = (HTAB *)db->internal; return (hp->local_errno); } +weak_alias (__db_ndbm_error, dbm_error) int -dbm_clearerr(db) +__db_ndbm_clearerr(db) DBM *db; { HTAB *hp; @@ -393,6 +404,19 @@ dbm_clearerr(db) hp->local_errno = 0; return (0); } +weak_alias (__db_ndbm_clearerr, dbm_clearerr) + +/* + * Returns: + * 1 if read-only + * 0 if not read-only + */ +int +__db_ndbm_rdonly(db) + DBM *db; +{ + return (F_ISSET((DB *)db, DB_AM_RDONLY) ? 1 : 0); +} /* * XXX @@ -401,7 +425,7 @@ dbm_clearerr(db) * and picked one to use at random. */ int -dbm_dirfno(db) +__db_ndbm_dirfno(db) DBM *db; { int fd; @@ -409,9 +433,10 @@ dbm_dirfno(db) (void)db->fd(db, &fd); return (fd); } +weak_alias (__db_ndbm_dirfno, dbm_dirfno) int -dbm_pagfno(db) +__db_ndbm_pagfno(db) DBM *db; { int fd; @@ -419,3 +444,4 @@ dbm_pagfno(db) (void)db->fd(db, &fd); return (fd); } +weak_alias (__db_ndbm_pagfno, dbm_pagfno) diff --git a/db2/hash/hash.c b/db2/hash/hash.c index c084953..5193ece 100644 --- a/db2/hash/hash.c +++ b/db2/hash/hash.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)hash.c 10.33 (Sleepycat) 11/2/97"; +static const char sccsid[] = "@(#)hash.c 10.36 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -731,7 +731,7 @@ __ham_c_del(cursor, flags) } else /* Case 1 */ F_SET(hcp, H_DELETED); if (chg_pgno != PGNO_INVALID) - __ham_c_update(hashp, hcp, chg_pgno, 0, 0, 1); + __ham_c_update(hcp, chg_pgno, 0, 0, 1); } else if (F_ISSET(hcp, H_ISDUP)) { /* on page */ if (hcp->dup_off == 0 && DUP_SIZE(hcp->dup_len) == LEN_HDATA(hcp->pagep, hashp->hdr->pagesize, hcp->bndx)) @@ -747,7 +747,7 @@ __ham_c_del(cursor, flags) ret = __ham_replpair(hashp, hcp, &repldbt, 0); hcp->dup_tlen -= DUP_SIZE(hcp->dup_len); F_SET(hcp, H_DELETED); - __ham_c_update(hashp, hcp, hcp->pgno, + __ham_c_update(hcp, hcp->pgno, DUP_SIZE(hcp->dup_len), 0, 1); } @@ -1009,9 +1009,9 @@ __ham_expand_table(hashp) * if the next doubling is going to be big (more than 8 * pages), we have some extra pages around. */ - if (hashp->hdr->max_bucket + 1 >= 8 && + if (hashp->hdr->max_bucket + 1 >= 8 && hashp->hdr->spares[hashp->hdr->ovfl_point] < - hashp->hdr->spares[hashp->hdr->ovfl_point - 1] + + hashp->hdr->spares[hashp->hdr->ovfl_point - 1] + hashp->hdr->ovfl_point + 1) __ham_init_ovflpages(hashp); } @@ -1347,17 +1347,15 @@ __ham_init_dbt(dbt, size, bufp, sizep) * added (add == 1) or deleted (add == 0). * dup indicates if the addition occurred into a duplicate set. * - * PUBLIC: void __ham_c_update __P((HTAB *, - * PUBLIC: HASH_CURSOR *, db_pgno_t, u_int32_t, int, int)); + * PUBLIC: void __ham_c_update + * PUBLIC: __P((HASH_CURSOR *, db_pgno_t, u_int32_t, int, int)); */ void -__ham_c_update(hashp, hcp, chg_pgno, len, add, dup) - HTAB *hashp; +__ham_c_update(hcp, chg_pgno, len, add, is_dup) HASH_CURSOR *hcp; db_pgno_t chg_pgno; u_int32_t len; - int add; - int dup; + int add, is_dup; { DBC *cp; HTAB *hp; @@ -1365,22 +1363,21 @@ __ham_c_update(hashp, hcp, chg_pgno, len, add, dup) int page_deleted; /* - * Regular adds are always at the end of a given page, - * so we never have to adjust anyone's cursor after - * a regular add. + * Regular adds are always at the end of a given page, so we never + * have to adjust anyone's cursor after a regular add. */ - if (!dup && add) + if (!is_dup && add) return; /* * Determine if a page was deleted. If this is a regular update - * (i.e., not dup) then the deleted page's number will be that in + * (i.e., not is_dup) then the deleted page's number will be that in * chg_pgno, and the pgno in the cursor will be different. If this * was an onpage-duplicate, then the same conditions apply. If this * was an off-page duplicate, then we need to verify if hcp->dpgno * is the same (no delete) or different (delete) than chg_pgno. */ - if (!dup || hcp->dpgno == PGNO_INVALID) + if (!is_dup || hcp->dpgno == PGNO_INVALID) page_deleted = chg_pgno != PGNO_INVALID && chg_pgno != hcp->pgno; else @@ -1397,17 +1394,18 @@ __ham_c_update(hashp, hcp, chg_pgno, len, add, dup) lcp = (HASH_CURSOR *)cp->internal; - if (!dup && lcp->pgno != chg_pgno) - continue; - - if (dup && F_ISSET(hcp, H_DELETED) && lcp->pgno != chg_pgno) + if (!is_dup && lcp->pgno != chg_pgno) continue; - if (dup && !F_ISSET(hcp, H_DELETED) && lcp->dpgno != chg_pgno) - continue; + if (is_dup) { + if (F_ISSET(hcp, H_DELETED) && lcp->pgno != chg_pgno) + continue; + if (!F_ISSET(hcp, H_DELETED) && lcp->dpgno != chg_pgno) + continue; + } if (page_deleted) { - if (dup) { + if (is_dup) { lcp->dpgno = hcp->dpgno; lcp->dndx = hcp->dndx; } else { @@ -1419,11 +1417,11 @@ __ham_c_update(hashp, hcp, chg_pgno, len, add, dup) continue; } - if (!dup && lcp->bndx > hcp->bndx) + if (!is_dup && lcp->bndx > hcp->bndx) lcp->bndx--; - else if (!dup && lcp->bndx == hcp->bndx) + else if (!is_dup && lcp->bndx == hcp->bndx) F_SET(lcp, H_DELETED); - else if (dup && lcp->bndx == hcp->bndx) { + else if (is_dup && lcp->bndx == hcp->bndx) { /* Assign dpgno in case there was page conversion. */ lcp->dpgno = hcp->dpgno; if (add && lcp->dndx >= hcp->dndx ) diff --git a/db2/hash/hash_auto.c b/db2/hash/hash_auto.c index 787ee04..830ea46 100644 --- a/db2/hash/hash_auto.c +++ b/db2/hash/hash_auto.c @@ -21,7 +21,7 @@ * PUBLIC: int __ham_insdel_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, u_int32_t, - * PUBLIC: DB_LSN *, DBT *, DBT *)); + * PUBLIC: DB_LSN *, const DBT *, const DBT *)); */ int __ham_insdel_log(logp, txnid, ret_lsnp, flags, opcode, fileid, pgno, ndx, pagelsn, key, @@ -35,8 +35,8 @@ int __ham_insdel_log(logp, txnid, ret_lsnp, flags, db_pgno_t pgno; u_int32_t ndx; DB_LSN * pagelsn; - DBT *key; - DBT *data; + const DBT *key; + const DBT *data; { DBT logrec; DB_LSN *lsnp, null_lsn; @@ -555,7 +555,7 @@ __ham_splitmeta_read(recbuf, argpp) /* * PUBLIC: int __ham_splitdata_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, DBT *, + * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, const DBT *, * PUBLIC: DB_LSN *)); */ int __ham_splitdata_log(logp, txnid, ret_lsnp, flags, @@ -567,7 +567,7 @@ int __ham_splitdata_log(logp, txnid, ret_lsnp, flags, u_int32_t fileid; u_int32_t opcode; db_pgno_t pgno; - DBT *pageimage; + const DBT *pageimage; DB_LSN * pagelsn; { DBT logrec; @@ -726,7 +726,7 @@ __ham_splitdata_read(recbuf, argpp) * PUBLIC: int __ham_replace_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, * PUBLIC: u_int32_t, db_pgno_t, u_int32_t, DB_LSN *, - * PUBLIC: int32_t, DBT *, DBT *, u_int32_t)); + * PUBLIC: int32_t, const DBT *, const DBT *, u_int32_t)); */ int __ham_replace_log(logp, txnid, ret_lsnp, flags, fileid, pgno, ndx, pagelsn, off, olditem, @@ -740,8 +740,8 @@ int __ham_replace_log(logp, txnid, ret_lsnp, flags, u_int32_t ndx; DB_LSN * pagelsn; int32_t off; - DBT *olditem; - DBT *newitem; + const DBT *olditem; + const DBT *newitem; u_int32_t makedup; { DBT logrec; @@ -1279,7 +1279,7 @@ __ham_ovfl_read(recbuf, argpp) * PUBLIC: int __ham_copypage_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, - * PUBLIC: DB_LSN *, db_pgno_t, DB_LSN *, DBT *)); + * PUBLIC: DB_LSN *, db_pgno_t, DB_LSN *, const DBT *)); */ int __ham_copypage_log(logp, txnid, ret_lsnp, flags, fileid, pgno, pagelsn, next_pgno, nextlsn, nnext_pgno, @@ -1295,7 +1295,7 @@ int __ham_copypage_log(logp, txnid, ret_lsnp, flags, DB_LSN * nextlsn; db_pgno_t nnext_pgno; DB_LSN * nnextlsn; - DBT *page; + const DBT *page; { DBT logrec; DB_LSN *lsnp, null_lsn; diff --git a/db2/hash/hash_dup.c b/db2/hash/hash_dup.c index 22444e4..f8b0adb 100644 --- a/db2/hash/hash_dup.c +++ b/db2/hash/hash_dup.c @@ -42,7 +42,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)hash_dup.c 10.8 (Sleepycat) 10/14/97"; +static const char sccsid[] = "@(#)hash_dup.c 10.10 (Sleepycat) 1/8/98"; #endif /* not lint */ /* @@ -182,7 +182,7 @@ __ham_add_dup(hashp, hcp, nval, flags) ret = __ham_replpair(hashp, hcp, &tmp_val, 0); if (ret == 0) ret = __ham_dirty_page(hashp, hcp->pagep); - __ham_c_update(hashp, hcp, hcp->pgno, tmp_val.size, 1, 1); + __ham_c_update(hcp, hcp->pgno, tmp_val.size, 1, 1); return (ret); } @@ -227,7 +227,7 @@ __ham_add_dup(hashp, hcp, nval, flags) ret = __db_dput(hashp->dbp, nval, &hcp->dpagep, &hcp->dndx, __ham_overflow_page); hcp->pgno = PGNO(hcp->pagep); - __ham_c_update(hashp, hcp, hcp->pgno, nval->size, 1, 1); + __ham_c_update(hcp, hcp->pgno, nval->size, 1, 1); return (ret); } @@ -325,9 +325,9 @@ __ham_dup_convert(hashp, hcp) } static int -__ham_make_dup(notdup, dup, bufp, sizep) +__ham_make_dup(notdup, duplicate, bufp, sizep) const DBT *notdup; - DBT *dup; + DBT *duplicate; void **bufp; u_int32_t *sizep; { @@ -337,22 +337,22 @@ __ham_make_dup(notdup, dup, bufp, sizep) item_size = (db_indx_t)notdup->size; tsize = DUP_SIZE(item_size); - if ((ret = __ham_init_dbt(dup, tsize, bufp, sizep)) != 0) + if ((ret = __ham_init_dbt(duplicate, tsize, bufp, sizep)) != 0) return (ret); - dup->dlen = 0; - dup->flags = notdup->flags; - F_SET(dup, DB_DBT_PARTIAL); + duplicate->dlen = 0; + duplicate->flags = notdup->flags; + F_SET(duplicate, DB_DBT_PARTIAL); - p = dup->data; + p = duplicate->data; memcpy(p, &item_size, sizeof(db_indx_t)); p += sizeof(db_indx_t); memcpy(p, notdup->data, notdup->size); p += notdup->size; memcpy(p, &item_size, sizeof(db_indx_t)); - dup->doff = 0; - dup->dlen = notdup->size; + duplicate->doff = 0; + duplicate->dlen = notdup->size; return (0); } diff --git a/db2/hash/hash_page.c b/db2/hash/hash_page.c index 0a12c14..09a4a0c 100644 --- a/db2/hash/hash_page.c +++ b/db2/hash/hash_page.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)hash_page.c 10.29 (Sleepycat) 11/2/97"; +static const char sccsid[] = "@(#)hash_page.c 10.31 (Sleepycat) 1/8/98"; #endif /* not lint */ /* @@ -720,7 +720,7 @@ __ham_del_pair(hashp, cursorp, reclaim_page) chg_pgno = cursorp->pgno; ret = __ham_dirty_page(hashp, p); } - __ham_c_update(hashp, cursorp, chg_pgno, 0, 0, 0); + __ham_c_update(cursorp, chg_pgno, 0, 0, 0); /* * Since we just deleted a pair from the master page, anything @@ -1131,7 +1131,8 @@ __ham_add_el(hashp, hcp, key, val, type) const DBT *key, *val; int type; { - DBT *pkey, *pdata, key_dbt, data_dbt; + const DBT *pkey, *pdata; + DBT key_dbt, data_dbt; DB_LSN new_lsn; HOFFPAGE doff, koff; db_pgno_t next_pgno; @@ -1200,7 +1201,7 @@ __ham_add_el(hashp, hcp, key, val, type) pkey = &key_dbt; key_type = H_OFFPAGE; } else { - pkey = (DBT *)key; + pkey = key; key_type = H_KEYDATA; } @@ -1215,7 +1216,7 @@ __ham_add_el(hashp, hcp, key, val, type) pdata = &data_dbt; data_type = H_OFFPAGE; } else { - pdata = (DBT *)val; + pdata = val; data_type = type; } @@ -1593,7 +1594,7 @@ __ham_init_ovflpages(hp) db_pgno_t last_pgno, new_pgno; u_int32_t i, curpages, numpages; - curpages = hp->hdr->spares[hp->hdr->ovfl_point] - + curpages = hp->hdr->spares[hp->hdr->ovfl_point] - hp->hdr->spares[hp->hdr->ovfl_point - 1]; numpages = hp->hdr->ovfl_point + 1 - curpages; diff --git a/db2/hash/hash_rec.c b/db2/hash/hash_rec.c index d239e3d..0950825 100644 --- a/db2/hash/hash_rec.c +++ b/db2/hash/hash_rec.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)hash_rec.c 10.14 (Sleepycat) 11/2/97"; +static const char sccsid[] = "@(#)hash_rec.c 10.15 (Sleepycat) 12/4/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -811,7 +811,7 @@ out: if (getmeta) /* * __ham_copypage_recover -- * Recovery function for copypage. - * + * * PUBLIC: int __ham_copypage_recover * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); */ diff --git a/db2/include/btree_ext.h b/db2/include/btree_ext.h index 46f2227..9c34c8c 100644 --- a/db2/include/btree_ext.h +++ b/db2/include/btree_ext.h @@ -1,4 +1,6 @@ /* DO NOT EDIT: automatically built by dist/distrib. */ +#ifndef _btree_ext_h_ +#define _btree_ext_h_ int __bam_close __P((DB *)); int __bam_sync __P((DB *, int)); int __bam_cmp __P((DB *, const DBT *, EPG *)); @@ -11,11 +13,12 @@ int __bam_cursor __P((DB *, DB_TXN *, DBC **)); int __bam_c_iclose __P((DB *, DBC *)); int __bam_get __P((DB *, DB_TXN *, DBT *, DBT *, int)); int __bam_ovfl_chk __P((DB *, CURSOR *, u_int32_t, int)); +int __bam_cprint __P((DB *)); int __bam_ca_delete __P((DB *, db_pgno_t, u_int32_t, CURSOR *, int)); void __bam_ca_di __P((DB *, db_pgno_t, u_int32_t, int)); void __bam_ca_dup __P((DB *, db_pgno_t, u_int32_t, u_int32_t, db_pgno_t, u_int32_t)); -void __bam_ca_move __P((DB *, BTREE *, db_pgno_t, db_pgno_t)); +void __bam_ca_move __P((DB *, db_pgno_t, db_pgno_t)); void __bam_ca_replace __P((DB *, db_pgno_t, u_int32_t, ca_replace_arg)); void __bam_ca_split __P((DB *, @@ -29,6 +32,7 @@ int __bam_open __P((DB *, DBTYPE, DB_INFO *)); int __bam_bdup __P((DB *, DB *)); int __bam_new __P((DB *, u_int32_t, PAGE **)); int __bam_free __P((DB *, PAGE *)); +int __bam_lt __P((DB *)); int __bam_lget __P((DB *, int, db_pgno_t, db_lockmode_t, DB_LOCK *)); int __bam_lput __P((DB *, DB_LOCK)); int __bam_pget __P((DB *, PAGE **, db_pgno_t *, int)); @@ -57,6 +61,7 @@ int __ram_cursor __P((DB *, DB_TXN *, DBC **)); int __ram_close __P((DB *)); int __ram_c_iclose __P((DB *, DBC *)); void __ram_ca __P((DB *, db_recno_t, ca_recno_arg)); +int __ram_cprint __P((DB *)); int __ram_getno __P((DB *, const DBT *, db_recno_t *, int)); int __ram_snapshot __P((DB *)); int __bam_rsearch __P((DB *, db_recno_t *, u_int, int, int *)); @@ -82,7 +87,7 @@ int __bam_pg_alloc_print int __bam_pg_alloc_read __P((void *, __bam_pg_alloc_args **)); int __bam_pg_free_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - u_int32_t, db_pgno_t, DB_LSN *, DBT *, + u_int32_t, db_pgno_t, DB_LSN *, const DBT *, db_pgno_t)); int __bam_pg_free_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); @@ -91,14 +96,14 @@ int __bam_split_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *, - DBT *)); + const DBT *)); int __bam_split_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); int __bam_split_read __P((void *, __bam_split_args **)); int __bam_rsplit_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - u_int32_t, db_pgno_t, DBT *, db_pgno_t, - DBT *, DB_LSN *)); + u_int32_t, db_pgno_t, const DBT *, db_pgno_t, + const DBT *, DB_LSN *)); int __bam_rsplit_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); int __bam_rsplit_read __P((void *, __bam_rsplit_args **)); @@ -125,10 +130,11 @@ int __bam_cdel_read __P((void *, __bam_cdel_args **)); int __bam_repl_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_pgno_t, DB_LSN *, u_int32_t, - u_int32_t, DBT *, DBT *, u_int32_t, + u_int32_t, const DBT *, const DBT *, u_int32_t, u_int32_t)); int __bam_repl_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); int __bam_repl_read __P((void *, __bam_repl_args **)); int __bam_init_print __P((DB_ENV *)); int __bam_init_recover __P((DB_ENV *)); +#endif /* _btree_ext_h_ */ diff --git a/db2/include/clib_ext.h b/db2/include/clib_ext.h index 91e4a13..eb982bf 100644 --- a/db2/include/clib_ext.h +++ b/db2/include/clib_ext.h @@ -1,4 +1,6 @@ /* DO NOT EDIT: automatically built by dist/distrib. */ +#ifndef _clib_ext_h_ +#define _clib_ext_h_ #ifdef __STDC__ void err __P((int eval, const char *, ...)); #else @@ -63,3 +65,4 @@ char *strsep __P((char **, const char *)); #ifndef HAVE_VSNPRINTF int vsnprintf(); #endif +#endif /* _clib_ext_h_ */ diff --git a/db2/include/common_ext.h b/db2/include/common_ext.h index 29bc9aa..b362c9c 100644 --- a/db2/include/common_ext.h +++ b/db2/include/common_ext.h @@ -1,4 +1,6 @@ /* DO NOT EDIT: automatically built by dist/distrib. */ +#ifndef _common_ext_h_ +#define _common_ext_h_ int __db_appname __P((DB_ENV *, APPNAME, const char *, const char *, int *, char **)); int __db_apprec __P((DB_ENV *, int)); @@ -38,5 +40,6 @@ void __db_shalloc_free __P((void *, void *)); size_t __db_shalloc_count __P((void *)); size_t __db_shsizeof __P((void *)); void __db_shalloc_dump __P((FILE *, void *)); -int __db_tablesize __P((int)); +int __db_tablesize __P((u_int)); void __db_hashinit __P((void *, int)); +#endif /* _common_ext_h_ */ diff --git a/db2/include/db.h.src b/db2/include/db.h.src index 654eb16..ebdaa27 100644 --- a/db2/include/db.h.src +++ b/db2/include/db.h.src @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)db.h.src 10.97 (Sleepycat) 11/28/97 + * @(#)db.h.src 10.102 (Sleepycat) 1/18/98 */ #ifndef _DB_H_ @@ -73,8 +73,8 @@ #define DB_VERSION_MAJOR 2 #define DB_VERSION_MINOR 3 -#define DB_VERSION_PATCH 14 -#define DB_VERSION_STRING "Sleepycat Software: DB 2.3.14: (11/28/97)" +#define DB_VERSION_PATCH 16 +#define DB_VERSION_STRING "Sleepycat Software: DB 2.3.16: (1/19/98)" typedef u_int32_t db_pgno_t; /* Page number type. */ typedef u_int16_t db_indx_t; /* Page offset type. */ @@ -241,7 +241,7 @@ struct __db_env { DB_LOCKTAB *lk_info; /* Return from lock_open(). */ u_int8_t *lk_conflicts; /* Two dimensional conflict matrix. */ int lk_modes; /* Number of lock modes in table. */ - unsigned int lk_max; /* Maximum number of locks. */ + u_int lk_max; /* Maximum number of locks. */ u_int32_t lk_detect; /* Deadlock detect on every conflict. */ /* Logging. */ @@ -461,7 +461,6 @@ struct __db { #define DB_RE_PAD 0x004000 /* DB_PAD (internal). */ #define DB_RE_RENUMBER 0x008000 /* DB_RENUMBER (internal). */ #define DB_RE_SNAPSHOT 0x010000 /* DB_SNAPSHOT (internal). */ - u_int32_t flags; }; @@ -532,7 +531,7 @@ int db_open __P((const char *, DBTYPE, int, int, DB_ENV *, DB_INFO *, DB **)); int db_value_set __P((int, int)); char *db_version __P((int *, int *, int *)); #if defined(__cplusplus) -}; +} #endif /******************************************************* @@ -611,7 +610,7 @@ int lock_unlink __P((const char *, int, DB_ENV *)); int lock_vec __P((DB_LOCKTAB *, u_int32_t, int, DB_LOCKREQ *, int, DB_LOCKREQ **)); #if defined(__cplusplus) -}; +} #endif /******************************************************* @@ -650,6 +649,8 @@ struct __db_log_stat { u_int32_t st_scount; /* Total writes to the log. */ u_int32_t st_region_wait; /* Region lock granted after wait. */ u_int32_t st_region_nowait; /* Region lock granted without wait. */ + u_int32_t st_cur_file; /* Current log file number. */ + u_int32_t st_cur_offset; /* Current log file offset. */ }; #if defined(__cplusplus) @@ -668,7 +669,7 @@ int log_stat __P((DB_LOG *, DB_LOG_STAT **, void *(*)(size_t))); int log_unlink __P((const char *, int, DB_ENV *)); int log_unregister __P((DB_LOG *, u_int32_t)); #if defined(__cplusplus) -}; +} #endif /******************************************************* @@ -739,7 +740,7 @@ int memp_sync __P((DB_MPOOL *, DB_LSN *)); int memp_trickle __P((DB_MPOOL *, int, int *)); int memp_unlink __P((const char *, int, DB_ENV *)); #if defined(__cplusplus) -}; +} #endif /******************************************************* @@ -790,10 +791,13 @@ int txn_prepare __P((DB_TXN *)); int txn_stat __P((DB_TXNMGR *, DB_TXN_STAT **, void *(*)(size_t))); int txn_unlink __P((const char *, int, DB_ENV *)); #if defined(__cplusplus) -}; +} #endif -#ifdef DB_DBM_HSEARCH +#ifndef DB_DBM_HSEARCH +#define DB_DBM_HSEARCH 0 /* No historic interfaces by default. */ +#endif +#if DB_DBM_HSEARCH != 0 /******************************************************* * Dbm/Ndbm historic interfaces. *******************************************************/ @@ -811,40 +815,74 @@ typedef struct { int dsize; } datum; +/* + * Translate DBM calls into DB calls so that DB doesn't step on the + * application's name space. + * + * The global variables dbrdonly, dirf and pagf were not retained when + * 4BSD replaced the dbm interface with ndbm, and are not support here. + */ +#define dbminit(a) __db_dbm_init(a) +#if !defined(__cplusplus) +#define delete(a) __db_dbm_delete(a) +#endif +#define fetch(a) __db_dbm_fetch(a) +#define firstkey __db_dbm_firstkey +#define nextkey(a) __db_dbm_nextkey(a) +#define store(a, b) __db_dbm_store(a, b) + +/* Prototype the DB calls. */ #if defined(__cplusplus) extern "C" { #endif -int dbminit __P((char *)); -#if !defined(__cplusplus) -int delete __P((datum)); +int __db_dbm_init __P((char *)); +int __db_dbm_delete __P((datum)); +int __db_dbm_dbrdonly __P((void)); +int __db_dbm_dirf __P((void)); +datum __db_dbm_fetch __P((datum)); +datum __db_dbm_firstkey __P((void)); +datum __db_dbm_nextkey __P((datum)); +int __db_dbm_pagf __P((void)); +int __db_dbm_store __P((datum, datum)); +#if defined(__cplusplus) +} #endif -datum fetch __P((datum)); -datum firstkey __P((void)); -datum nextkey __P((datum)); -int store __P((datum, datum)); /* - * !!! - * Don't prototype: - * - * dbm_clearerr(DBM *db); - * dbm_dirfno(DBM *db); - * dbm_error(DBM *db); - * dbm_pagfno(DBM *db); - * dbm_rdonly(DBM *db); - * - * they weren't documented and were historically implemented as #define's. + * Translate NDBM calls into DB calls so that DB doesn't step on the + * application's name space. */ -void dbm_close __P((DBM *)); -int dbm_delete __P((DBM *, datum)); -datum dbm_fetch __P((DBM *, datum)); -datum dbm_firstkey __P((DBM *)); -long dbm_forder __P((DBM *, datum)); -datum dbm_nextkey __P((DBM *)); -DBM *dbm_open __P((const char *, int, int)); -int dbm_store __P((DBM *, datum, datum, int)); +#define dbm_clearerr(a) __db_ndbm_clearerr(a) +#define dbm_close(a) __db_ndbm_close(a) +#define dbm_delete(a, b) __db_ndbm_delete(a, b) +#define dbm_dirfno(a) __db_ndbm_dirfno(a) +#define dbm_error(a) __db_ndbm_error(a) +#define dbm_fetch(a, b) __db_ndbm_fetch(a, b) +#define dbm_firstkey(a) __db_ndbm_firstkey(a) +#define dbm_nextkey(a) __db_ndbm_nextkey(a) +#define dbm_open(a, b, c) __db_ndbm_open(a, b, c) +#define dbm_pagfno(a) __db_ndbm_pagfno(a) +#define dbm_rdonly(a) __db_ndbm_rdonly(a) +#define dbm_store(a, b, c, d) __db_ndbm_store(a, b, c, d) + +/* Prototype the DB calls. */ #if defined(__cplusplus) -}; +extern "C" { +#endif +int __db_ndbm_clearerr __P((DBM *)); +void __db_ndbm_close __P((DBM *)); +int __db_ndbm_delete __P((DBM *, datum)); +int __db_ndbm_dirfno __P((DBM *)); +int __db_ndbm_error __P((DBM *)); +datum __db_ndbm_fetch __P((DBM *, datum)); +datum __db_ndbm_firstkey __P((DBM *)); +datum __db_ndbm_nextkey __P((DBM *)); +DBM *__db_ndbm_open __P((const char *, int, int)); +int __db_ndbm_pagfno __P((DBM *)); +int __db_ndbm_rdonly __P((DBM *)); +int __db_ndbm_store __P((DBM *, datum, datum, int)); +#if defined(__cplusplus) +} #endif /******************************************************* @@ -859,14 +897,23 @@ typedef struct entry { void *data; } ENTRY; +/* + * Translate HSEARCH calls into DB calls so that DB doesn't step on the + * application's name space. + */ +#define hcreate(a) __db_hcreate(a) +#define hdestroy __db_hdestroy +#define hsearch(a, b) __db_hsearch(a, b) + +/* Prototype the DB calls. */ #if defined(__cplusplus) extern "C" { #endif -int hcreate __P((unsigned int)); -void hdestroy __P((void)); -ENTRY *hsearch __P((ENTRY, ACTION)); +int __db_hcreate __P((unsigned int)); +void __db_hdestroy __P((void)); +ENTRY *__db_hsearch __P((ENTRY, ACTION)); #if defined(__cplusplus) -}; +} #endif #endif /* DB_DBM_HSEARCH */ diff --git a/db2/include/db_185.h.src b/db2/include/db_185.h.src index 3fbca8b..a88eb4e 100644 --- a/db2/include/db_185.h.src +++ b/db2/include/db_185.h.src @@ -36,7 +36,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)db_185.h.src 8.4 (Sleepycat) 9/16/97 + * @(#)db_185.h.src 8.5 (Sleepycat) 1/15/98 */ #ifndef _DB_185_H_ @@ -173,6 +173,6 @@ extern "C" { DB *dbopen __P((const char *, int, int, DBTYPE, const void *)); #if defined(__cplusplus) -}; +} #endif #endif /* !_DB_185_H_ */ diff --git a/db2/include/db_am.h b/db2/include/db_am.h index 0ea24be..304e3fd 100644 --- a/db2/include/db_am.h +++ b/db2/include/db_am.h @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)db_am.h 10.7 (Sleepycat) 10/25/97 + * @(#)db_am.h 10.8 (Sleepycat) 1/8/98 */ #ifndef _DB_AM_H #define _DB_AM_H @@ -79,7 +79,7 @@ (void)func(logp, dbtp, lsnp, redo, info); #else #define REC_PRINT(func) \ - info = info; /* XXX: Shut the compiler up. */ + COMPQUIET(info, NULL); #endif #include "db_auto.h" diff --git a/db2/include/db_ext.h b/db2/include/db_ext.h index 15eeaf5..122d8f1 100644 --- a/db2/include/db_ext.h +++ b/db2/include/db_ext.h @@ -1,16 +1,18 @@ /* DO NOT EDIT: automatically built by dist/distrib. */ +#ifndef _db_ext_h_ +#define _db_ext_h_ int __db_pgerr __P((DB *, db_pgno_t)); int __db_pgfmt __P((DB *, db_pgno_t)); int __db_addrem_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, u_int32_t, db_pgno_t, u_int32_t, - size_t, DBT *, DBT *, DB_LSN *)); + size_t, const DBT *, const DBT *, DB_LSN *)); int __db_addrem_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); int __db_addrem_read __P((void *, __db_addrem_args **)); int __db_split_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - u_int32_t, u_int32_t, db_pgno_t, DBT *, + u_int32_t, u_int32_t, db_pgno_t, const DBT *, DB_LSN *)); int __db_split_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); @@ -18,7 +20,7 @@ int __db_split_read __P((void *, __db_split_args **)); int __db_big_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, u_int32_t, db_pgno_t, db_pgno_t, - db_pgno_t, DBT *, DB_LSN *, DB_LSN *, + db_pgno_t, const DBT *, DB_LSN *, DB_LSN *, DB_LSN *)); int __db_big_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); @@ -45,7 +47,7 @@ int __db_addpage_print int __db_addpage_read __P((void *, __db_addpage_args **)); int __db_debug_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - DBT *, u_int32_t, DBT *, DBT *, + const DBT *, u_int32_t, const DBT *, const DBT *, u_int32_t)); int __db_debug_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); @@ -65,13 +67,14 @@ int __db_add_recovery __P((DB_ENV *, int __db_txnlist_init __P((void *)); int __db_txnlist_add __P((void *, u_int32_t)); int __db_txnlist_find __P((void *, u_int32_t)); +void __db_txnlist_print __P((void *)); void __db_txnlist_end __P((void *)); int __db_dput __P((DB *, DBT *, PAGE **, db_indx_t *, int (*)(DB *, u_int32_t, PAGE **))); int __db_drem __P((DB *, PAGE **, u_int32_t, int (*)(DB *, PAGE *))); int __db_dend __P((DB *, db_pgno_t, PAGE **)); - int __db_ditem __P((DB *, PAGE *, int, u_int32_t)); + int __db_ditem __P((DB *, PAGE *, u_int32_t, u_int32_t)); int __db_pitem __P((DB *, PAGE *, u_int32_t, u_int32_t, DBT *, DBT *)); int __db_relink __P((DB *, PAGE *, PAGE **, int)); @@ -113,3 +116,4 @@ int __db_retcopy __P((DBT *, void *, u_int32_t, void **, u_int32_t *, void *(*)(size_t))); int __db_gethandle __P((DB *, int (*)(DB *, DB *), DB **)); int __db_puthandle __P((DB *)); +#endif /* _db_ext_h_ */ diff --git a/db2/include/db_int.h.src b/db2/include/db_int.h.src index 03a882f..48790d6 100644 --- a/db2/include/db_int.h.src +++ b/db2/include/db_int.h.src @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)db_int.h.src 10.37 (Sleepycat) 11/25/97 + * @(#)db_int.h.src 10.41 (Sleepycat) 1/8/98 */ #ifndef _DB_INTERNAL_H_ @@ -18,14 +18,22 @@ /******************************************************* * General purpose constants and macros. *******************************************************/ -#define UINT32_T_MAX 0xffffffff /* Maximum 32 bit unsigned. */ #define UINT16_T_MAX 0xffff /* Maximum 16 bit unsigned. */ +#define UINT32_T_MAX 0xffffffff /* Maximum 32 bit unsigned. */ #define DB_MIN_PGSIZE 0x000200 /* Minimum page size. */ #define DB_MAX_PGSIZE 0x010000 /* Maximum page size. */ #define DB_MINCACHE 10 /* Minimum cached pages */ +#define MEGABYTE 1048576 + +/* + * If we are unable to determine the underlying filesystem block size, use + * 8K on the grounds that most OS's use less than 8K as their VM page size. + */ +#define DB_DEF_IOSIZE (8 * 1024) + /* * Aligning items to particular sizes or in pages or memory. ALIGNP is a * separate macro, as we've had to cast the pointer to different integral @@ -109,6 +117,9 @@ typedef struct __fn { #undef DB_LINE #define DB_LINE "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" +/* Unused, or not-used-yet variable. "Shut that bloody compiler up!" */ +#define COMPQUIET(n, v) (n) = (v) + /******************************************************* * Files. *******************************************************/ @@ -155,18 +166,22 @@ typedef struct __fn { /* * The offset of a mutex in memory. + * + * !!! + * Not an off_t, so backing file offsets MUST be less than 4Gb. See the + * off field of the db_mutex_t as well. */ -#define MUTEX_LOCK_OFFSET(a, b) ((off_t)((u_int8_t *)b - (u_int8_t *)a)) +#define MUTEX_LOCK_OFFSET(a, b) ((u_int32_t)((u_int8_t *)b - (u_int8_t *)a)) typedef struct _db_mutex_t { #ifdef HAVE_SPINLOCKS - tsl_t tsl_resource; /* Resource test and set. */ + tsl_t tsl_resource; /* Resource test and set. */ #ifdef DEBUG - u_long pid; /* Lock holder: 0 or process pid. */ + u_long pid; /* Lock holder: 0 or process pid. */ #endif #else - off_t off; /* Backing file offset. */ - u_long pid; /* Lock holder: 0 or process pid. */ + u_int32_t off; /* Backing file offset. */ + u_long pid; /* Lock holder: 0 or process pid. */ #endif u_int32_t spins; /* Spins before block. */ u_int32_t mutex_set_wait; /* Granted after wait. */ diff --git a/db2/include/hash_ext.h b/db2/include/hash_ext.h index 5abbb27..9b97d35 100644 --- a/db2/include/hash_ext.h +++ b/db2/include/hash_ext.h @@ -1,17 +1,19 @@ /* DO NOT EDIT: automatically built by dist/distrib. */ +#ifndef _hash_ext_h_ +#define _hash_ext_h_ int __ham_open __P((DB *, DB_INFO *)); int __ham_close __P((DB *)); int __ham_c_iclose __P((DB *, DBC *)); int __ham_expand_table __P((HTAB *)); u_int32_t __ham_call_hash __P((HTAB *, u_int8_t *, int32_t)); int __ham_init_dbt __P((DBT *, u_int32_t, void **, u_int32_t *)); -void __ham_c_update __P((HTAB *, - HASH_CURSOR *, db_pgno_t, u_int32_t, int, int)); +void __ham_c_update + __P((HASH_CURSOR *, db_pgno_t, u_int32_t, int, int)); int __ham_hdup __P((DB *, DB *)); int __ham_insdel_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, u_int32_t, db_pgno_t, u_int32_t, - DB_LSN *, DBT *, DBT *)); + DB_LSN *, const DBT *, const DBT *)); int __ham_insdel_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); int __ham_insdel_read __P((void *, __ham_insdel_args **)); @@ -31,7 +33,7 @@ int __ham_splitmeta_print int __ham_splitmeta_read __P((void *, __ham_splitmeta_args **)); int __ham_splitdata_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - u_int32_t, u_int32_t, db_pgno_t, DBT *, + u_int32_t, u_int32_t, db_pgno_t, const DBT *, DB_LSN *)); int __ham_splitdata_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); @@ -39,7 +41,7 @@ int __ham_splitdata_read __P((void *, __ham_splitdata_args **)); int __ham_replace_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_pgno_t, u_int32_t, DB_LSN *, - int32_t, DBT *, DBT *, u_int32_t)); + int32_t, const DBT *, const DBT *, u_int32_t)); int __ham_replace_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); int __ham_replace_read __P((void *, __ham_replace_args **)); @@ -61,7 +63,7 @@ int __ham_ovfl_read __P((void *, __ham_ovfl_args **)); int __ham_copypage_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, - DB_LSN *, db_pgno_t, DB_LSN *, DBT *)); + DB_LSN *, db_pgno_t, DB_LSN *, const DBT *)); int __ham_copypage_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); int __ham_copypage_read __P((void *, __ham_copypage_args **)); @@ -128,3 +130,4 @@ int __ham_ovfl_recover int __ham_copypage_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); int __ham_stat __P((DB *, FILE *)); +#endif /* _hash_ext_h_ */ diff --git a/db2/include/lock_ext.h b/db2/include/lock_ext.h index 0d0ba14..d983b29 100644 --- a/db2/include/lock_ext.h +++ b/db2/include/lock_ext.h @@ -1,8 +1,14 @@ /* DO NOT EDIT: automatically built by dist/distrib. */ +#ifndef _lock_ext_h_ +#define _lock_ext_h_ +void __lock_dump_region __P((DB_LOCKTAB *, u_int)); +int __lock_is_locked + __P((DB_LOCKTAB *, u_int32_t, DBT *, db_lockmode_t)); int __lock_getobj __P((DB_LOCKTAB *, - u_int32_t, DBT *, u_int32_t type, DB_LOCKOBJ **)); -int __lock_cmp __P((DBT *, DB_LOCKOBJ *)); + u_int32_t, const DBT *, u_int32_t type, DB_LOCKOBJ **)); +int __lock_cmp __P((const DBT *, DB_LOCKOBJ *)); int __lock_locker_cmp __P((u_int32_t, DB_LOCKOBJ *)); -int __lock_ohash __P((DBT *)); +int __lock_ohash __P((const DBT *)); u_int32_t __lock_locker_hash __P((u_int32_t)); u_int32_t __lock_lhash __P((DB_LOCKOBJ *)); +#endif /* _lock_ext_h_ */ diff --git a/db2/include/log.h b/db2/include/log.h index 405daf4..4e27b03 100644 --- a/db2/include/log.h +++ b/db2/include/log.h @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)log.h 10.16 (Sleepycat) 11/9/97 + * @(#)log.h 10.19 (Sleepycat) 1/17/98 */ #ifndef _LOG_H_ @@ -15,15 +15,13 @@ struct __hdr; typedef struct __hdr HDR; struct __log; typedef struct __log LOG; struct __log_persist; typedef struct __log_persist LOGP; -#define MEGABYTE (1024 * 1024) - #define MAXLFNAME 99999 /* Maximum log file name. */ #define LFNAME "log.%05d" /* Log file name template. */ /* Default log name. */ #define DB_DEFAULT_LOG_FILE "__db_log.share" -#define DEFAULT_MAX (10 * 1048576) /* 10 Mb. */ +#define DEFAULT_MAX (10 * MEGABYTE) /* 10 Mb. */ /* Macros to lock/unlock the region and threads. */ #define LOCK_LOGTHREAD(dblp) \ @@ -125,7 +123,7 @@ struct __log { /* * The s_lsn LSN is the last LSN that we know is on disk, not just - * written, by synced. + * written, but synced. */ DB_LSN s_lsn; /* LSN of the last sync. */ @@ -166,6 +164,11 @@ struct __fname { size_t name_off; /* Name offset. */ }; +/* File open/close register log record opcodes. */ +#define LOG_CHECKPOINT 1 /* Checkpoint: file name/id dump. */ +#define LOG_CLOSE 2 /* File close. */ +#define LOG_OPEN 3 /* File open. */ + #include "log_auto.h" #include "log_ext.h" #endif /* _LOG_H_ */ diff --git a/db2/include/log_auto.h b/db2/include/log_auto.h index 820aac6..5717e14 100644 --- a/db2/include/log_auto.h +++ b/db2/include/log_auto.h @@ -8,20 +8,11 @@ typedef struct _log_register_args { u_int32_t type; DB_TXN *txnid; DB_LSN prev_lsn; + u_int32_t opcode; DBT name; DBT uid; u_int32_t id; DBTYPE ftype; } __log_register_args; - -#define DB_log_unregister (DB_log_BEGIN + 2) - -typedef struct _log_unregister_args { - u_int32_t type; - DB_TXN *txnid; - DB_LSN prev_lsn; - u_int32_t id; -} __log_unregister_args; - #endif diff --git a/db2/include/log_ext.h b/db2/include/log_ext.h index c32d1d6..8640b13 100644 --- a/db2/include/log_ext.h +++ b/db2/include/log_ext.h @@ -1,18 +1,15 @@ /* DO NOT EDIT: automatically built by dist/distrib. */ -int __log_find __P((DB_LOG *, int *)); +#ifndef _log_ext_h_ +#define _log_ext_h_ +int __log_find __P((DB_LOG *, int, int *)); int __log_valid __P((DB_LOG *, LOG *, int)); int __log_register_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - DBT *, DBT *, u_int32_t, DBTYPE)); + u_int32_t, const DBT *, const DBT *, u_int32_t, + DBTYPE)); int __log_register_print __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); int __log_register_read __P((void *, __log_register_args **)); -int __log_unregister_log - __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - u_int32_t)); -int __log_unregister_print - __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); -int __log_unregister_read __P((void *, __log_unregister_args **)); int __log_init_print __P((DB_ENV *)); int __log_init_recover __P((DB_ENV *)); int __log_findckp __P((DB_LOG *, DB_LSN *)); @@ -21,9 +18,8 @@ int __log_put __P((DB_LOG *, DB_LSN *, const DBT *, int)); int __log_name __P((DB_LOG *, int, char **)); int __log_register_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); -int __log_unregister_recover - __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); int __log_add_logid __P((DB_LOG *, DB *, u_int32_t)); int __db_fileid_to_db __P((DB_LOG *, DB **, u_int32_t)); void __log_close_files __P((DB_LOG *)); void __log_rem_logid __P((DB_LOG *, u_int32_t)); +#endif /* _log_ext_h_ */ diff --git a/db2/include/mp.h b/db2/include/mp.h index f108246..4efbf9b 100644 --- a/db2/include/mp.h +++ b/db2/include/mp.h @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)mp.h 10.22 (Sleepycat) 11/28/97 + * @(#)mp.h 10.25 (Sleepycat) 1/8/98 */ struct __bh; typedef struct __bh BH; @@ -41,13 +41,17 @@ struct __mpoolfile; typedef struct __mpoolfile MPOOLFILE; * Acquire the region lock. * Find the buffer header. * Increment the reference count (guarantee the buffer stays). - * If the BH_LOCKED flag is set (I/O is going on): - * Release the region lock. - * Request the buffer lock. - * The I/O will complete... - * Acquire the buffer lock. - * Release the buffer lock. - * Acquire the region lock. + * While the BH_LOCKED flag is set (I/O is going on) { + * Release the region lock. + * Explicitly yield the processor if it's not the first pass + * through this loop, otherwise, we can simply spin because + * we'll be simply switching between the two locks. + * Request the buffer lock. + * The I/O will complete... + * Acquire the buffer lock. + * Release the buffer lock. + * Acquire the region lock. + * } * Return the buffer. * * Reading/writing a buffer: @@ -57,12 +61,16 @@ struct __mpoolfile; typedef struct __mpoolfile MPOOLFILE; * Set the BH_LOCKED flag. * Acquire the buffer lock (guaranteed not to block). * Release the region lock. - * Do the I/O and/or initialize buffer contents. + * Do the I/O and/or initialize the buffer contents. + * Release the buffer lock. + * At this point, the buffer lock is available, but the logical + * operation (flagged by BH_LOCKED) is not yet completed. For + * this reason, among others, threads checking the BH_LOCKED flag + * must loop around their test. * Acquire the region lock. * Clear the BH_LOCKED flag. * Release the region lock. - * Release the buffer lock. - * If reading, return the buffer. + * Return/discard the buffer. * * Pointers to DB_MPOOL, MPOOL, DB_MPOOLFILE and MPOOLFILE structures are not * reacquired when a region lock is reacquired because they couldn't have been @@ -70,7 +78,8 @@ struct __mpoolfile; typedef struct __mpoolfile MPOOLFILE; */ #define LOCKINIT(dbmp, mutexp) \ if (F_ISSET(dbmp, MP_LOCKHANDLE | MP_LOCKREGION)) \ - (void)__db_mutex_init(mutexp, (dbmp)->fd) + (void)__db_mutex_init(mutexp, \ + MUTEX_LOCK_OFFSET((dbmp)->maddr, mutexp)) #define LOCKHANDLE(dbmp, mutexp) \ if (F_ISSET(dbmp, MP_LOCKHANDLE)) \ diff --git a/db2/include/mp_ext.h b/db2/include/mp_ext.h index b78b342..1928820 100644 --- a/db2/include/mp_ext.h +++ b/db2/include/mp_ext.h @@ -1,4 +1,6 @@ /* DO NOT EDIT: automatically built by dist/distrib. */ +#ifndef _mp_ext_h_ +#define _mp_ext_h_ int __memp_bhwrite __P((DB_MPOOL *, MPOOLFILE *, BH *, int *, int *)); int __memp_pgread __P((DB_MPOOLFILE *, BH *, int)); @@ -14,3 +16,4 @@ int __memp_ralloc __P((DB_MPOOL *, size_t, size_t *, void *)); int __memp_ropen __P((DB_MPOOL *, const char *, size_t, int, int)); int __memp_rclose __P((DB_MPOOL *)); +#endif /* _mp_ext_h_ */ diff --git a/db2/include/mutex_ext.h b/db2/include/mutex_ext.h index cb2d488..f0e68f3 100644 --- a/db2/include/mutex_ext.h +++ b/db2/include/mutex_ext.h @@ -1,4 +1,7 @@ /* DO NOT EDIT: automatically built by dist/distrib. */ -void __db_mutex_init __P((db_mutex_t *, off_t)); +#ifndef _mutex_ext_h_ +#define _mutex_ext_h_ +void __db_mutex_init __P((db_mutex_t *, u_int32_t)); int __db_mutex_lock __P((db_mutex_t *, int)); int __db_mutex_unlock __P((db_mutex_t *, int)); +#endif /* _mutex_ext_h_ */ diff --git a/db2/include/os_ext.h b/db2/include/os_ext.h index 2edf2e2..9c66a24 100644 --- a/db2/include/os_ext.h +++ b/db2/include/os_ext.h @@ -1,8 +1,11 @@ /* DO NOT EDIT: automatically built by dist/distrib. */ +#ifndef _os_ext_h_ +#define _os_ext_h_ int __db_abspath __P((const char *)); void *__db_calloc __P((size_t, size_t)); void *__db_malloc __P((size_t)); void *__db_realloc __P((void *, size_t)); +int __os_oldwin __P((void)); int __os_dirlist __P((const char *, char ***, int *)); void __os_dirfree __P((char **, int)); int __db_fileid __P((DB_ENV *, const char *, int, u_int8_t *)); @@ -19,5 +22,7 @@ int __os_seek __P((int, size_t, db_pgno_t, u_long, int)); int __os_sleep __P((u_long, u_long)); int __os_spin __P((void)); int __os_exists __P((const char *, int *)); -int __os_ioinfo __P((const char *, int, off_t *, off_t *)); +int __os_ioinfo + __P((const char *, int, u_int32_t *, u_int32_t *, u_int32_t *)); int __db_unlink __P((const char *)); +#endif /* _os_ext_h_ */ diff --git a/db2/include/os_func.h b/db2/include/os_func.h index 54b64ff..b825fed 100644 --- a/db2/include/os_func.h +++ b/db2/include/os_func.h @@ -4,7 +4,7 @@ * Copyright (c) 1997 * Sleepycat Software. All rights reserved. * - * @(#)os_func.h 10.4 (Sleepycat) 11/28/97 + * @(#)os_func.h 10.5 (Sleepycat) 12/4/97 */ /* Calls which can be replaced by the application. */ @@ -17,8 +17,8 @@ struct __db_jumptab { __P((const char *, int *)); void (*db_free) __P((void *)); /* DB_FUNC_FREE */ int (*db_fsync) __P((int)); /* DB_FUNC_FSYNC */ - int (*db_ioinfo) /* DB_FUNC_IOINFO */ - __P((const char *, int, off_t *, off_t *)); + int (*db_ioinfo) __P((const char *, /* DB_FUNC_IOINFO */ + int, u_int32_t *, u_int32_t *, u_int32_t *)); void *(*db_malloc) __P((size_t)); /* DB_FUNC_MALLOC */ int (*db_map) /* DB_FUNC_MAP */ __P((int, size_t, int, int, void **)); diff --git a/db2/include/txn_ext.h b/db2/include/txn_ext.h index 9b617bb..7d694f0 100644 --- a/db2/include/txn_ext.h +++ b/db2/include/txn_ext.h @@ -1,4 +1,6 @@ /* DO NOT EDIT: automatically built by dist/distrib. */ +#ifndef _txn_ext_h_ +#define _txn_ext_h_ int __txn_regop_log __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t)); @@ -16,3 +18,4 @@ int __txn_init_recover __P((DB_ENV *)); int __txn_regop_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); int __txn_ckp_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); +#endif /* _txn_ext_h_ */ diff --git a/db2/lock/lock.c b/db2/lock/lock.c index 9b1cbc8..0846d3c 100644 --- a/db2/lock/lock.c +++ b/db2/lock/lock.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)lock.c 10.41 (Sleepycat) 11/28/97"; +static const char sccsid[] = "@(#)lock.c 10.43 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -79,14 +79,15 @@ __lock_create(path, mode, dbenv) u_int maxlocks; u_int32_t i; int fd, lock_modes, nelements, ret; - u_int8_t *conflicts, *curaddr; + const u_int8_t *conflicts; + u_int8_t *curaddr; maxlocks = dbenv == NULL || dbenv->lk_max == 0 ? DB_LOCK_DEFAULT_N : dbenv->lk_max; lock_modes = dbenv == NULL || dbenv->lk_modes == 0 ? DB_LOCK_RW_N : dbenv->lk_modes; conflicts = dbenv == NULL || dbenv->lk_conflicts == NULL ? - (u_int8_t *)db_rw_conflicts : dbenv->lk_conflicts; + db_rw_conflicts : dbenv->lk_conflicts; if ((ret = __db_rcreate(dbenv, DB_APP_NONE, path, DB_DEFAULT_LOCK_FILE, mode, @@ -666,8 +667,7 @@ __lock_get_internal(lt, locker, flags, obj, lock_mode, lockp) newl->holder = locker; newl->refcount = 1; - if ((ret = - __lock_getobj(lt, 0, (DBT *)obj, DB_LOCK_OBJTYPE, &sh_obj)) != 0) + if ((ret = __lock_getobj(lt, 0, obj, DB_LOCK_OBJTYPE, &sh_obj)) != 0) return (ret); lrp = lt->region; /* getobj might have grown */ @@ -955,10 +955,15 @@ __lock_grow_region(lt, which, howmuch) } #ifdef DEBUG +/* + * __lock_dump_region -- + * + * PUBLIC: void __lock_dump_region __P((DB_LOCKTAB *, u_int)); + */ void __lock_dump_region(lt, flags) DB_LOCKTAB *lt; - unsigned long flags; + u_int flags; { struct __db_lock *lp; DB_LOCKOBJ *op; @@ -1096,6 +1101,12 @@ __lock_dump_object(lt, op) } } +/* + * __lock_is_locked -- + * + * PUBLIC: int __lock_is_locked + * PUBLIC: __P((DB_LOCKTAB *, u_int32_t, DBT *, db_lockmode_t)); + */ int __lock_is_locked(lt, locker, dbt, mode) DB_LOCKTAB *lt; @@ -1135,7 +1146,7 @@ __lock_printlock(lt, lp, ispgno) db_pgno_t pgno; size_t obj; u_int8_t *ptr; - char *mode, *stat; + const char *mode, *status; switch (lp->mode) { case DB_LOCK_IREAD: @@ -1162,32 +1173,32 @@ __lock_printlock(lt, lp, ispgno) } switch (lp->status) { case DB_LSTAT_ABORTED: - stat = "ABORT"; + status = "ABORT"; break; case DB_LSTAT_ERR: - stat = "ERROR"; + status = "ERROR"; break; case DB_LSTAT_FREE: - stat = "FREE"; + status = "FREE"; break; case DB_LSTAT_HELD: - stat = "HELD"; + status = "HELD"; break; case DB_LSTAT_NOGRANT: - stat = "NONE"; + status = "NONE"; break; case DB_LSTAT_WAITING: - stat = "WAIT"; + status = "WAIT"; break; case DB_LSTAT_PENDING: - stat = "PENDING"; + status = "PENDING"; break; default: - stat = "UNKNOWN"; + status = "UNKNOWN"; break; } printf("\t%lx\t%s\t%lu\t%s\t", - (u_long)lp->holder, mode, (u_long)lp->refcount, stat); + (u_long)lp->holder, mode, (u_long)lp->refcount, status); lockobj = (DB_LOCKOBJ *)((u_int8_t *)lp + lp->obj); ptr = SH_DBT_PTR(&lockobj->lockobj); @@ -1202,7 +1213,6 @@ __lock_printlock(lt, lp, ispgno) printf("\n"); } } - #endif static int @@ -1239,13 +1249,13 @@ __lock_count_objs(lrp) /* * PUBLIC: int __lock_getobj __P((DB_LOCKTAB *, - * PUBLIC: u_int32_t, DBT *, u_int32_t type, DB_LOCKOBJ **)); + * PUBLIC: u_int32_t, const DBT *, u_int32_t type, DB_LOCKOBJ **)); */ int __lock_getobj(lt, locker, dbt, type, objp) DB_LOCKTAB *lt; u_int32_t locker, type; - DBT *dbt; + const DBT *dbt; DB_LOCKOBJ **objp; { DB_LOCKREGION *lrp; diff --git a/db2/lock/lock_util.c b/db2/lock/lock_util.c index 4063849..6c1e30f 100644 --- a/db2/lock/lock_util.c +++ b/db2/lock/lock_util.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)lock_util.c 10.4 (Sleepycat) 7/22/97"; +static const char sccsid[] = "@(#)lock_util.c 10.5 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -35,11 +35,11 @@ static const char sccsid[] = "@(#)lock_util.c 10.4 (Sleepycat) 7/22/97"; * that it just returns true on equal and 0 on not-equal. Therefore this * cannot be used as a sort function; its purpose is to be used as a * hash comparison function. - * PUBLIC: int __lock_cmp __P((DBT *, DB_LOCKOBJ *)); + * PUBLIC: int __lock_cmp __P((const DBT *, DB_LOCKOBJ *)); */ int __lock_cmp(dbt, lock_obj) - DBT *dbt; + const DBT *dbt; DB_LOCKOBJ *lock_obj; { void *obj_data; @@ -69,11 +69,11 @@ __lock_locker_cmp(locker, lock_obj) } /* - * PUBLIC: int __lock_ohash __P((DBT *)); + * PUBLIC: int __lock_ohash __P((const DBT *)); */ int __lock_ohash(dbt) - DBT *dbt; + const DBT *dbt; { return (__ham_func5(dbt->data, dbt->size)); } diff --git a/db2/log/log.c b/db2/log/log.c index a9bf7a9..8013d42 100644 --- a/db2/log/log.c +++ b/db2/log/log.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)log.c 10.34 (Sleepycat) 11/28/97"; +static const char sccsid[] = "@(#)log.c 10.39 (Sleepycat) 1/17/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -203,28 +203,21 @@ __log_recover(dblp) * Find a log file. If none exist, we simply return, leaving * everything initialized to a new log. */ - if ((ret = __log_find(dblp, &cnt)) != 0) + if ((ret = __log_find(dblp, 0, &cnt)) != 0) return (ret); if (cnt == 0) return (0); - /* We have a log file name, find the last one. */ - while (cnt < MAXLFNAME) - if (__log_valid(dblp, lp, ++cnt) != 0) { - --cnt; - break; - } - /* * We have the last useful log file and we've loaded any persistent * information. Pretend that the log is larger than it can possibly - * be, and read this file, looking for a checkpoint and its end. + * be, and read the last file, looking for the last checkpoint and + * the log's end. */ - dblp->c_lsn.file = cnt; - dblp->c_lsn.offset = 0; - lsn = dblp->c_lsn; lp->lsn.file = cnt + 1; lp->lsn.offset = 0; + lsn.file = cnt; + lsn.offset = 0; /* Set the cursor. Shouldn't fail, leave error messages on. */ memset(&dbt, 0, sizeof(dbt)); @@ -264,9 +257,8 @@ __log_recover(dblp) * one in the last log file. Start searching. */ while (!found_checkpoint && cnt > 1) { - dblp->c_lsn.file = --cnt; - dblp->c_lsn.offset = 0; - lsn = dblp->c_lsn; + lsn.file = --cnt; + lsn.offset = 0; /* Set the cursor. Shouldn't fail, leave error messages on. */ if ((ret = __log_get(dblp, &lsn, &dbt, DB_SET, 0)) != 0) @@ -288,36 +280,35 @@ __log_recover(dblp) } /* If we never find a checkpoint, that's okay, just 0 it out. */ - if (!found_checkpoint) { - lp->c_lsn.file = 1; - lp->c_lsn.offset = 0; - } + if (!found_checkpoint) + ZERO_LSN(lp->c_lsn); __db_err(dblp->dbenv, "Recovering the log: last valid LSN: file: %lu offset %lu", (u_long)lp->lsn.file, (u_long)lp->lsn.offset); - /* Reset the cursor. */ - ZERO_LSN(dblp->c_lsn); - return (0); } /* * __log_find -- - * Try to find a log file. + * Try to find a log file. If find_first is set, valp will contain + * the number of the first log file, else it will contain the number of + * the last log file. * - * PUBLIC: int __log_find __P((DB_LOG *, int *)); + * PUBLIC: int __log_find __P((DB_LOG *, int, int *)); */ int -__log_find(dblp, valp) +__log_find(dblp, find_first, valp) DB_LOG *dblp; - int *valp; + int find_first, *valp; { int cnt, fcnt, logval, ret; const char *dir; char **names, *p, *q; + *valp = 0; + /* Find the directory name. */ if ((ret = __log_name(dblp, 1, &p)) != 0) return (ret); @@ -340,21 +331,29 @@ __log_find(dblp, valp) * Search for a valid log file name, return a value of 0 on * failure. */ - *valp = 0; for (cnt = fcnt, logval = 0; --cnt >= 0;) if (strncmp(names[cnt], "log.", sizeof("log.") - 1) == 0) { logval = atoi(names[cnt] + 4); if (logval != 0 && - __log_valid(dblp, dblp->lp, logval) == 0) { - *valp = logval; + __log_valid(dblp, dblp->lp, logval) == 0) break; - } } /* Discard the list. */ __db_dirfree(names, fcnt); - return (ret); + /* We have a valid log file, find either the first or last one. */ + if (find_first) { + for (; logval > 0; --logval) + if (__log_valid(dblp, dblp->lp, logval - 1) != 0) + break; + } else + for (; logval < MAXLFNAME; ++logval) + if (__log_valid(dblp, dblp->lp, logval + 1) != 0) + break; + *valp = logval; + + return (0); } /* @@ -508,6 +507,10 @@ log_stat(dblp, gspp, db_malloc) (*gspp)->st_region_nowait = lp->rlayout.lock.mutex_set_nowait; (*gspp)->st_region_wait = lp->rlayout.lock.mutex_set_wait; + + (*gspp)->st_cur_file = lp->lsn.file; + (*gspp)->st_cur_offset = lp->lsn.offset; + UNLOCK_LOGREGION(dblp); return (0); diff --git a/db2/log/log.src b/db2/log/log.src index 9f48291..f3d9f32 100644 --- a/db2/log/log.src +++ b/db2/log/log.src @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)log.src 10.3 (Sleepycat) 8/20/97 + * @(#)log.src 10.4 (Sleepycat) 1/17/98 * * This is the source file used to create the logging functions for the * log package. Each access method (or set of routines wishing to register @@ -40,14 +40,11 @@ */ PREFIX log -/* Used for registering new name/id translations. */ +/* Used for registering name/id translations at open or close. */ BEGIN register +ARG opcode u_int32_t lu DBT name DBT s DBT uid DBT s ARG id u_int32_t lu ARG ftype DBTYPE lx END - -BEGIN unregister -ARG id u_int32_t lu -END diff --git a/db2/log/log_archive.c b/db2/log/log_archive.c index 0248e28..91ae5ab 100644 --- a/db2/log/log_archive.c +++ b/db2/log/log_archive.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)log_archive.c 10.29 (Sleepycat) 11/12/97"; +static const char sccsid[] = "@(#)log_archive.c 10.30 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -49,7 +49,7 @@ log_archive(dblp, listp, flags, db_malloc) int array_size, n, ret; char **array, **arrayp, *name, *p, *pref, buf[MAXPATHLEN]; - fnum = 0; /* XXX: Shut the compiler up. */ + COMPQUIET(fnum, 0); #define OKFLAGS (DB_ARCH_ABS | DB_ARCH_DATA | DB_ARCH_LOG) if (flags != 0) { diff --git a/db2/log/log_auto.c b/db2/log/log_auto.c index 61626b0..2fe1783 100644 --- a/db2/log/log_auto.c +++ b/db2/log/log_auto.c @@ -20,16 +20,18 @@ /* * PUBLIC: int __log_register_log * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - * PUBLIC: DBT *, DBT *, u_int32_t, DBTYPE)); + * PUBLIC: u_int32_t, const DBT *, const DBT *, u_int32_t, + * PUBLIC: DBTYPE)); */ int __log_register_log(logp, txnid, ret_lsnp, flags, - name, uid, id, ftype) + opcode, name, uid, id, ftype) DB_LOG *logp; DB_TXN *txnid; DB_LSN *ret_lsnp; u_int32_t flags; - DBT *name; - DBT *uid; + u_int32_t opcode; + const DBT *name; + const DBT *uid; u_int32_t id; DBTYPE ftype; { @@ -49,6 +51,7 @@ int __log_register_log(logp, txnid, ret_lsnp, flags, } else lsnp = &txnid->last_lsn; logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN) + + sizeof(opcode) + sizeof(u_int32_t) + (name == NULL ? 0 : name->size) + sizeof(u_int32_t) + (uid == NULL ? 0 : uid->size) + sizeof(id) @@ -63,6 +66,8 @@ int __log_register_log(logp, txnid, ret_lsnp, flags, bp += sizeof(txn_num); memcpy(bp, lsnp, sizeof(DB_LSN)); bp += sizeof(DB_LSN); + memcpy(bp, &opcode, sizeof(opcode)); + bp += sizeof(opcode); if (name == NULL) { zero = 0; memcpy(bp, &zero, sizeof(u_int32_t)); @@ -129,6 +134,7 @@ __log_register_print(notused1, dbtp, lsnp, notused3, notused4) (u_long)argp->txnid->txnid, (u_long)argp->prev_lsn.file, (u_long)argp->prev_lsn.offset); + printf("\topcode: %lu\n", (u_long)argp->opcode); printf("\tname: "); for (i = 0; i < argp->name.size; i++) { c = ((char *)argp->name.data)[i]; @@ -177,6 +183,8 @@ __log_register_read(recbuf, argpp) bp += sizeof(argp->txnid->txnid); memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN)); bp += sizeof(DB_LSN); + memcpy(&argp->opcode, bp, sizeof(argp->opcode)); + bp += sizeof(argp->opcode); memcpy(&argp->name.size, bp, sizeof(u_int32_t)); bp += sizeof(u_int32_t); argp->name.data = bp; @@ -194,124 +202,6 @@ __log_register_read(recbuf, argpp) } /* - * PUBLIC: int __log_unregister_log - * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, - * PUBLIC: u_int32_t)); - */ -int __log_unregister_log(logp, txnid, ret_lsnp, flags, - id) - DB_LOG *logp; - DB_TXN *txnid; - DB_LSN *ret_lsnp; - u_int32_t flags; - u_int32_t id; -{ - DBT logrec; - DB_LSN *lsnp, null_lsn; - u_int32_t rectype, txn_num; - int ret; - u_int8_t *bp; - - rectype = DB_log_unregister; - txn_num = txnid == NULL ? 0 : txnid->txnid; - if (txnid == NULL) { - null_lsn.file = 0; - null_lsn.offset = 0; - lsnp = &null_lsn; - } else - lsnp = &txnid->last_lsn; - logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN) - + sizeof(id); - if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL) - return (ENOMEM); - - bp = logrec.data; - memcpy(bp, &rectype, sizeof(rectype)); - bp += sizeof(rectype); - memcpy(bp, &txn_num, sizeof(txn_num)); - bp += sizeof(txn_num); - memcpy(bp, lsnp, sizeof(DB_LSN)); - bp += sizeof(DB_LSN); - memcpy(bp, &id, sizeof(id)); - bp += sizeof(id); -#ifdef DEBUG - if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size) - fprintf(stderr, "Error in log record length"); -#endif - ret = __log_put(logp, ret_lsnp, (DBT *)&logrec, flags); - if (txnid != NULL) - txnid->last_lsn = *ret_lsnp; - __db_free(logrec.data); - return (ret); -} - -/* - * PUBLIC: int __log_unregister_print - * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); - */ -int -__log_unregister_print(notused1, dbtp, lsnp, notused3, notused4) - DB_LOG *notused1; - DBT *dbtp; - DB_LSN *lsnp; - int notused3; - void *notused4; -{ - __log_unregister_args *argp; - u_int32_t i; - int c, ret; - - i = 0; - c = 0; - notused1 = NULL; - notused3 = 0; - notused4 = NULL; - - if ((ret = __log_unregister_read(dbtp->data, &argp)) != 0) - return (ret); - printf("[%lu][%lu]log_unregister: rec: %lu txnid %lx prevlsn [%lu][%lu]\n", - (u_long)lsnp->file, - (u_long)lsnp->offset, - (u_long)argp->type, - (u_long)argp->txnid->txnid, - (u_long)argp->prev_lsn.file, - (u_long)argp->prev_lsn.offset); - printf("\tid: %lu\n", (u_long)argp->id); - printf("\n"); - __db_free(argp); - return (0); -} - -/* - * PUBLIC: int __log_unregister_read __P((void *, __log_unregister_args **)); - */ -int -__log_unregister_read(recbuf, argpp) - void *recbuf; - __log_unregister_args **argpp; -{ - __log_unregister_args *argp; - u_int8_t *bp; - - argp = (__log_unregister_args *)__db_malloc(sizeof(__log_unregister_args) + - sizeof(DB_TXN)); - if (argp == NULL) - return (ENOMEM); - argp->txnid = (DB_TXN *)&argp[1]; - bp = recbuf; - memcpy(&argp->type, bp, sizeof(argp->type)); - bp += sizeof(argp->type); - memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid)); - bp += sizeof(argp->txnid->txnid); - memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN)); - bp += sizeof(DB_LSN); - memcpy(&argp->id, bp, sizeof(argp->id)); - bp += sizeof(argp->id); - *argpp = argp; - return (0); -} - -/* * PUBLIC: int __log_init_print __P((DB_ENV *)); */ int @@ -323,9 +213,6 @@ __log_init_print(dbenv) if ((ret = __db_add_recovery(dbenv, __log_register_print, DB_log_register)) != 0) return (ret); - if ((ret = __db_add_recovery(dbenv, - __log_unregister_print, DB_log_unregister)) != 0) - return (ret); return (0); } @@ -341,9 +228,6 @@ __log_init_recover(dbenv) if ((ret = __db_add_recovery(dbenv, __log_register_recover, DB_log_register)) != 0) return (ret); - if ((ret = __db_add_recovery(dbenv, - __log_unregister_recover, DB_log_unregister)) != 0) - return (ret); return (0); } diff --git a/db2/log/log_get.c b/db2/log/log_get.c index 2d1512c..ab6f624 100644 --- a/db2/log/log_get.c +++ b/db2/log/log_get.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)log_get.c 10.22 (Sleepycat) 11/22/97"; +static const char sccsid[] = "@(#)log_get.c 10.24 (Sleepycat) 1/17/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -122,7 +122,7 @@ __log_get(dblp, alsn, dbt, flags, silent) nlsn = dblp->c_lsn; switch (flags) { case DB_CHECKPOINT: - nlsn = dblp->lp->c_lsn; + nlsn = lp->c_lsn; if (IS_ZERO_LSN(nlsn)) { __db_err(dblp->dbenv, "log_get: unable to find checkpoint record: no checkpoint set."); @@ -138,26 +138,18 @@ __log_get(dblp, alsn, dbt, flags, silent) } /* FALLTHROUGH */ case DB_FIRST: /* Find the first log record. */ - /* - * Find any log file. Note, we may have only entered records - * in the buffer, and not yet written a log file. - */ - if ((ret = __log_find(dblp, &cnt)) != 0) { - __db_err(dblp->dbenv, - "log_get: unable to find the first record: no log files found."); + /* Find the first log file. */ + if ((ret = __log_find(dblp, 1, &cnt)) != 0) goto err2; - } - /* If there's anything in the buffer, it belongs to file 1. */ + /* + * We may have only entered records in the buffer, and not + * yet written a log file. If no log files were found and + * there's anything in the buffer, it belongs to file 1. + */ if (cnt == 0) cnt = 1; - /* Now go backwards to find the smallest one. */ - for (; cnt > 1; --cnt) - if (__log_valid(dblp, NULL, cnt) != 0) { - ++cnt; - break; - } nlsn.file = cnt; nlsn.offset = 0; break; diff --git a/db2/log/log_put.c b/db2/log/log_put.c index 42fec88..65a3990 100644 --- a/db2/log/log_put.c +++ b/db2/log/log_put.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)log_put.c 10.22 (Sleepycat) 11/12/97"; +static const char sccsid[] = "@(#)log_put.c 10.24 (Sleepycat) 1/17/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -82,8 +82,7 @@ __log_put(dblp, lsn, dbt, flags) const DBT *dbt; int flags; { - DBT t; - DBT fid_dbt; + DBT fid_dbt, t; DB_LSN r_unused; FNAME *fnp; LOG *lp; @@ -156,13 +155,15 @@ __log_put(dblp, lsn, dbt, flags) for (fnp = SH_TAILQ_FIRST(&dblp->lp->fq, __fname); fnp != NULL; fnp = SH_TAILQ_NEXT(fnp, q, __fname)) { + memset(&t, 0, sizeof(t)); t.data = R_ADDR(dblp, fnp->name_off); t.size = strlen(t.data) + 1; memset(&fid_dbt, 0, sizeof(fid_dbt)); fid_dbt.data = R_ADDR(dblp, fnp->fileid_off); fid_dbt.size = DB_FILE_ID_LEN; - if ((ret = __log_register_log(dblp, NULL, &r_unused, - 0, &t, &fid_dbt, fnp->id, fnp->s_type)) != 0) + if ((ret = __log_register_log(dblp, NULL, &r_unused, 0, + LOG_CHECKPOINT, &t, &fid_dbt, fnp->id, fnp->s_type)) + != 0) return (ret); } } @@ -280,7 +281,7 @@ __log_flush(dblp, lsn) /* * If the LSN is less than the last-sync'd LSN, we're done. Note, - * the last-sync LSN saved in s_lsn is the LSN of the first byte + * the last-sync LSN saved in s_lsn is the LSN of the first byte * we absolutely know has been written to disk, so the test is <=. */ if (lsn->file < lp->s_lsn.file || diff --git a/db2/log/log_rec.c b/db2/log/log_rec.c index 92b8203..69334f8 100644 --- a/db2/log/log_rec.c +++ b/db2/log/log_rec.c @@ -40,7 +40,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)log_rec.c 10.14 (Sleepycat) 10/25/97"; +static const char sccsid[] = "@(#)log_rec.c 10.16 (Sleepycat) 1/17/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -80,73 +80,53 @@ __log_register_recover(logp, dbtp, lsnp, redo, info) #ifdef DEBUG_RECOVER __log_register_print(logp, dbtp, lsnp, redo, info); #endif - info = info; /* XXX: Shut the compiler up. */ - lsnp = lsnp; + COMPQUIET(info, NULL); + COMPQUIET(lsnp, NULL); F_SET(logp, DB_AM_RECOVER); if ((ret = __log_register_read(dbtp->data, &argp)) != 0) goto out; - ret = __log_open_file(logp, - argp->uid.data, argp->name.data, argp->ftype, argp->id); - if (ret == ENOENT) { - if (redo == TXN_OPENFILES) - __db_err(logp->dbenv, - "warning: file %s not found", argp->name.data); - ret = 0; - } - -out: F_CLR(logp, DB_AM_RECOVER); - if (argp != NULL) - __db_free(argp); - return (ret); -} - -/* - * PUBLIC: int __log_unregister_recover - * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); - */ -int -__log_unregister_recover(logp, dbtp, lsnp, redo, info) - DB_LOG *logp; - DBT *dbtp; - DB_LSN *lsnp; - int redo; - void *info; -{ - __log_unregister_args *argp; - int ret; - -#ifdef DEBUG_RECOVER - __log_unregister_print(logp, dbtp, lsnp, redo, info); -#endif - info = info; /* XXX: Shut the compiler up. */ - lsnp = lsnp; - - if (redo == TXN_OPENFILES || - redo == TXN_BACKWARD_ROLL || redo == TXN_UNDO) - return (0); - - F_SET(logp, DB_AM_RECOVER); - if ((ret = __log_unregister_read(dbtp->data, &argp)) != 0) - goto out; - - /* - * If the file is deleted, then we can just ignore this close. - * Otherwise, we'd better have a valid dbp that we should either - * close or whose reference count should be decremented. - */ - LOCK_LOGTHREAD(logp); - if (logp->dbentry[argp->id].dbp == NULL) { - if (!logp->dbentry[argp->id].deleted) - ret = EINVAL; - } else if (--logp->dbentry[argp->id].refcount == 0) { - ret = logp->dbentry[argp->id].dbp->close( - logp->dbentry[argp->id].dbp, 0); - logp->dbentry[argp->id].dbp = NULL; + if ((argp->opcode == LOG_CHECKPOINT && redo == TXN_OPENFILES) || + (argp->opcode == LOG_OPEN && + (redo == TXN_REDO || redo == TXN_OPENFILES || + redo == TXN_FORWARD_ROLL)) || + (argp->opcode == LOG_CLOSE && + (redo == TXN_UNDO || redo == TXN_BACKWARD_ROLL))) { + /* + * If we are redoing an open or undoing a close, then we need + * to open a file. + */ + ret = __log_open_file(logp, + argp->uid.data, argp->name.data, argp->ftype, argp->id); + if (ret == ENOENT) { + if (redo == TXN_OPENFILES) + __db_err(logp->dbenv, + "warning: file %s not found", + argp->name.data); + ret = 0; + } + } else if (argp->opcode != LOG_CHECKPOINT) { + /* + * If we are redoing a close or undoing an open, then we need + * to close the file. + * + * If the file is deleted, then we can just ignore this close. + * Otherwise, we'd better have a valid dbp that we should either + * close or whose reference count should be decremented. + */ + LOCK_LOGTHREAD(logp); + if (logp->dbentry[argp->id].dbp == NULL) { + if (!logp->dbentry[argp->id].deleted) + ret = EINVAL; + } else if (--logp->dbentry[argp->id].refcount == 0) { + ret = logp->dbentry[argp->id].dbp->close( + logp->dbentry[argp->id].dbp, 0); + logp->dbentry[argp->id].dbp = NULL; + } + UNLOCK_LOGTHREAD(logp); } - UNLOCK_LOGTHREAD(logp); out: F_CLR(logp, DB_AM_RECOVER); if (argp != NULL) diff --git a/db2/log/log_register.c b/db2/log/log_register.c index 2dab361..9907d6e 100644 --- a/db2/log/log_register.c +++ b/db2/log/log_register.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)log_register.c 10.12 (Sleepycat) 9/29/97"; +static const char sccsid[] = "@(#)log_register.c 10.14 (Sleepycat) 1/19/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -35,8 +35,7 @@ log_register(dblp, dbp, name, type, idp) DBTYPE type; u_int32_t *idp; { - DBT r_name; - DBT fid_dbt; + DBT fid_dbt, r_name; DB_LSN r_unused; FNAME *fnp; size_t len; @@ -75,10 +74,7 @@ log_register(dblp, dbp, name, type, idp) R_ADDR(dblp, fnp->fileid_off), DB_FILE_ID_LEN)) { ++fnp->ref; fid = fnp->id; - if (!F_ISSET(dblp, DB_AM_RECOVER) && - (ret = __log_add_logid(dblp, dbp, fid) != 0)) - goto err; - goto ret1; + goto found; } } @@ -107,7 +103,7 @@ log_register(dblp, dbp, name, type, idp) SH_TAILQ_INSERT_HEAD(&dblp->lp->fq, fnp, q, __fname); inserted = 1; - /* Log the registry. */ +found: /* Log the registry. */ if (!F_ISSET(dblp, DB_AM_RECOVER)) { r_name.data = (void *)name; /* XXX: Yuck! */ r_name.size = strlen(name) + 1; @@ -115,7 +111,7 @@ log_register(dblp, dbp, name, type, idp) fid_dbt.data = dbp->lock.fileid; fid_dbt.size = DB_FILE_ID_LEN; if ((ret = __log_register_log(dblp, NULL, &r_unused, - 0, &r_name, &fid_dbt, fid, type)) != 0) + 0, LOG_OPEN, &r_name, &fid_dbt, fid, type)) != 0) goto err; if ((ret = __log_add_logid(dblp, dbp, fid)) != 0) goto err; @@ -136,7 +132,7 @@ err: /* __db_shalloc_free(dblp->addr, fnp); } -ret1: UNLOCK_LOGREGION(dblp); + UNLOCK_LOGREGION(dblp); if (fullname != NULL) FREES(fullname); @@ -155,6 +151,7 @@ log_unregister(dblp, fid) DB_LOG *dblp; u_int32_t fid; { + DBT fid_dbt, r_name; DB_LSN r_unused; FNAME *fnp; int ret; @@ -162,11 +159,6 @@ log_unregister(dblp, fid) ret = 0; LOCK_LOGREGION(dblp); - /* Unlog the registry. */ - if (!F_ISSET(dblp, DB_AM_RECOVER) && - (ret = __log_unregister_log(dblp, NULL, &r_unused, 0, fid)) != 0) - return (ret); - /* Find the entry in the log. */ for (fnp = SH_TAILQ_FIRST(&dblp->lp->fq, __fname); fnp != NULL; fnp = SH_TAILQ_NEXT(fnp, q, __fname)) @@ -178,17 +170,31 @@ log_unregister(dblp, fid) goto ret1; } - /* If more than 1 reference, decrement the reference and return. */ - if (fnp->ref > 1) { - --fnp->ref; - goto ret1; + /* Unlog the registry. */ + if (!F_ISSET(dblp, DB_AM_RECOVER)) { + memset(&r_name, 0, sizeof(r_name)); + r_name.data = R_ADDR(dblp, fnp->name_off); + r_name.size = strlen(r_name.data) + 1; + memset(&fid_dbt, 0, sizeof(fid_dbt)); + fid_dbt.data = R_ADDR(dblp, fnp->fileid_off); + fid_dbt.size = DB_FILE_ID_LEN; + if ((ret = __log_register_log(dblp, NULL, &r_unused, + 0, LOG_CLOSE, &r_name, &fid_dbt, fid, fnp->s_type)) != 0) + goto ret1; } - /* Free the unique file information, name and structure. */ - __db_shalloc_free(dblp->addr, R_ADDR(dblp, fnp->fileid_off)); - __db_shalloc_free(dblp->addr, R_ADDR(dblp, fnp->name_off)); - SH_TAILQ_REMOVE(&dblp->lp->fq, fnp, q, __fname); - __db_shalloc_free(dblp->addr, fnp); + /* + * If more than 1 reference, just decrement the reference and return. + * Otherwise, free the unique file information, name and structure. + */ + if (fnp->ref > 1) + --fnp->ref; + else { + __db_shalloc_free(dblp->addr, R_ADDR(dblp, fnp->fileid_off)); + __db_shalloc_free(dblp->addr, R_ADDR(dblp, fnp->name_off)); + SH_TAILQ_REMOVE(&dblp->lp->fq, fnp, q, __fname); + __db_shalloc_free(dblp->addr, fnp); + } /* * Remove from the process local table. If this operation is taking @@ -199,6 +205,5 @@ log_unregister(dblp, fid) __log_rem_logid(dblp, fid); ret1: UNLOCK_LOGREGION(dblp); - return (ret); } diff --git a/db2/makedb.c b/db2/makedb.c index 6c9d0a1..d782103 100644 --- a/db2/makedb.c +++ b/db2/makedb.c @@ -233,7 +233,7 @@ print_version (FILE *stream, struct argp_state *state) Copyright (C) %s Free Software Foundation, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "1996, 1997"); +"), "1996, 1997, 1998"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } @@ -303,7 +303,7 @@ process_input (input, inname, output, to_lowercase, be_quiet) ++cp; val.data = cp; - val.size = &line[n] - cp; + val.size = (&line[n] - cp) + 1; /* Store the value. */ status = output->put (output, &key, &val, R_NOOVERWRITE); @@ -349,7 +349,7 @@ print_database (db) no_more = db->seq (db, &key, &val, R_FIRST); while (!no_more) { - printf ("%.*s %.*s\n", (int) key.size, (char *) key.data, (int) val.size, + printf ("%.*s %s\n", (int) key.size, (char *) key.data, (char *) val.data); no_more = db->seq (db, &key, &val, R_NEXT); diff --git a/db2/mp/mp_bh.c b/db2/mp/mp_bh.c index 578abed..c23abdd 100644 --- a/db2/mp/mp_bh.c +++ b/db2/mp/mp_bh.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_bh.c 10.23 (Sleepycat) 11/26/97"; +static const char sccsid[] = "@(#)mp_bh.c 10.28 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -193,30 +193,28 @@ __memp_pgread(dbmfp, bhp, can_create) /* Call any pgin function. */ pgin: ret = mfp->ftype == 0 ? 0 : __memp_pg(dbmfp, bhp, 1); - /* Reacquire the region lock. */ + /* Unlock the buffer and reacquire the region lock. */ +err: UNLOCKBUFFER(dbmp, bhp); LOCKREGION(dbmp); - /* If the pgin function succeeded, the data is now valid. */ - if (ret == 0) + /* + * If no errors occurred, the data is now valid, clear the BH_TRASH + * flag; regardless, clear the lock bit and let other threads proceed. + */ + F_CLR(bhp, BH_LOCKED); + if (ret == 0) { F_CLR(bhp, BH_TRASH); - /* Update the statistics. */ - if (can_create) { - ++dbmp->mp->stat.st_page_create; - ++mfp->stat.st_page_create; - } else { - ++dbmp->mp->stat.st_page_in; - ++mfp->stat.st_page_in; - } - - if (0) { -err: LOCKREGION(dbmp); + /* Update the statistics. */ + if (can_create) { + ++dbmp->mp->stat.st_page_create; + ++mfp->stat.st_page_create; + } else { + ++dbmp->mp->stat.st_page_in; + ++mfp->stat.st_page_in; + } } - /* Release the buffer. */ - F_CLR(bhp, BH_LOCKED); - UNLOCKBUFFER(dbmp, bhp); - return (ret); } @@ -240,7 +238,7 @@ __memp_pgwrite(dbmfp, bhp, restartp, wrotep) MPOOLFILE *mfp; size_t pagesize; ssize_t nw; - int callpgin, ret; + int callpgin, ret, syncfail; const char *fail; dbmp = dbmfp->dbmp; @@ -255,8 +253,32 @@ __memp_pgwrite(dbmfp, bhp, restartp, wrotep) callpgin = 0; pagesize = mfp->stat.st_pagesize; - F_SET(bhp, BH_LOCKED); + /* + * Check the dirty bit -- this buffer may have been written since we + * decided to write it. + */ + if (!F_ISSET(bhp, BH_DIRTY)) { + if (wrotep != NULL) + *wrotep = 1; + return (0); + } + LOCKBUFFER(dbmp, bhp); + + /* + * If there were two writers, we may have just been waiting while the + * other writer completed I/O on this buffer. Check the dirty bit one + * more time. + */ + if (!F_ISSET(bhp, BH_DIRTY)) { + UNLOCKBUFFER(dbmp, bhp); + + if (wrotep != NULL) + *wrotep = 1; + return (0); + } + + F_SET(bhp, BH_LOCKED); UNLOCKREGION(dbmp); if (restartp != NULL) @@ -272,8 +294,9 @@ __memp_pgwrite(dbmfp, bhp, restartp, wrotep) goto err; /* - * Call any pgout function. We set the callpgin flag so that on - * error we flag that the contents of the buffer may be trash. + * Call any pgout function. We set the callpgin flag so that we flag + * that the contents of the buffer will need to be passed through pgin + * before they are reused. */ if (mfp->ftype == 0) ret = 0; @@ -307,7 +330,7 @@ __memp_pgwrite(dbmfp, bhp, restartp, wrotep) * between the failing clauses to __db_lseek and __db_write and * this ret != 0. */ - fail = NULL; + COMPQUIET(fail, NULL); goto syserr; } @@ -320,18 +343,20 @@ __memp_pgwrite(dbmfp, bhp, restartp, wrotep) if (wrotep != NULL) *wrotep = 1; - /* Reacquire the region lock. */ + /* Unlock the buffer and reacquire the region lock. */ + UNLOCKBUFFER(dbmp, bhp); LOCKREGION(dbmp); - /* Clean up the flags based on a successful write. */ - F_SET(bhp, BH_CALLPGIN); + /* + * Clean up the flags based on a successful write. + * + * If we rewrote the page, it will need processing by the pgin + * routine before reuse. + */ + if (callpgin) + F_SET(bhp, BH_CALLPGIN); F_CLR(bhp, BH_DIRTY | BH_LOCKED); - ++mp->stat.st_page_clean; - --mp->stat.st_page_dirty; - - UNLOCKBUFFER(dbmp, bhp); - /* * If we write a buffer for which a checkpoint is waiting, update * the count of pending buffers (both in the mpool as a whole and @@ -344,23 +369,36 @@ __memp_pgwrite(dbmfp, bhp, restartp, wrotep) * * XXX: * We ignore errors from the sync -- it makes no sense to return an - * error to the calling process, so set a flag causing the sync to - * be retried later. - * - * If the buffer we wrote has a LSN larger than the current largest - * we've written for this checkpoint, update the saved value. + * error to the calling process, so set a flag causing the checkpoint + * to be retried later. */ if (F_ISSET(bhp, BH_WRITE)) { + if (mfp->lsn_cnt == 1) { + UNLOCKREGION(dbmp); + syncfail = __db_fsync(dbmfp->fd) != 0; + LOCKREGION(dbmp); + if (syncfail) + F_SET(mp, MP_LSN_RETRY); + + } + + F_CLR(bhp, BH_WRITE); + + /* + * If the buffer just written has a larger LSN than the current + * max LSN written for this checkpoint, update the saved value. + */ if (log_compare(&lsn, &mp->lsn) > 0) mp->lsn = lsn; - F_CLR(bhp, BH_WRITE); --mp->lsn_cnt; - - if (--mfp->lsn_cnt == 0 && __db_fsync(dbmfp->fd) != 0) - F_SET(mp, MP_LSN_RETRY); + --mfp->lsn_cnt; } + /* Update the page clean/dirty statistics. */ + ++mp->stat.st_page_clean; + --mp->stat.st_page_dirty; + /* Update I/O statistics. */ ++mp->stat.st_page_out; ++mfp->stat.st_page_out; @@ -370,11 +408,20 @@ __memp_pgwrite(dbmfp, bhp, restartp, wrotep) syserr: __db_err(dbenv, "%s: %s failed for page %lu", __memp_fn(dbmfp), fail, (u_long)bhp->pgno); -err: UNLOCKBUFFER(dbmp, bhp); +err: /* Unlock the buffer and reacquire the region lock. */ + UNLOCKBUFFER(dbmp, bhp); LOCKREGION(dbmp); + + /* + * Clean up the flags based on a failure. + * + * The page remains dirty but we remove our lock. If we rewrote the + * page, it will need processing by the pgin routine before reuse. + */ if (callpgin) F_SET(bhp, BH_CALLPGIN); F_CLR(bhp, BH_LOCKED); + return (ret); } diff --git a/db2/mp/mp_fget.c b/db2/mp/mp_fget.c index 1010751..f5955c4 100644 --- a/db2/mp/mp_fget.c +++ b/db2/mp/mp_fget.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_fget.c 10.32 (Sleepycat) 11/26/97"; +static const char sccsid[] = "@(#)mp_fget.c 10.33 (Sleepycat) 12/2/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -272,8 +272,17 @@ found: /* Increment the reference count. */ * discarded we know the buffer can't move and its contents * can't change. */ - if (F_ISSET(bhp, BH_LOCKED)) { + for (cnt = 0; F_ISSET(bhp, BH_LOCKED); ++cnt) { UNLOCKREGION(dbmp); + + /* + * Sleep so that we don't simply spin, switching locks. + * (See the comment in include/mp.h.) + */ + if (cnt != 0 && + (__db_yield == NULL || __db_yield() != 0)) + __db_sleep(0, 1); + LOCKBUFFER(dbmp, bhp); /* Waiting for I/O to finish... */ UNLOCKBUFFER(dbmp, bhp); diff --git a/db2/mp/mp_fopen.c b/db2/mp/mp_fopen.c index bdc4713..0f41122 100644 --- a/db2/mp/mp_fopen.c +++ b/db2/mp/mp_fopen.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_fopen.c 10.32 (Sleepycat) 11/26/97"; +static const char sccsid[] = "@(#)mp_fopen.c 10.37 (Sleepycat) 1/18/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -28,8 +28,8 @@ static const char sccsid[] = "@(#)mp_fopen.c 10.32 (Sleepycat) 11/26/97"; #include "common_ext.h" static int __memp_mf_close __P((DB_MPOOL *, DB_MPOOLFILE *)); -static int __memp_mf_open __P((DB_MPOOL *, DB_MPOOLFILE *, - const char *, int, size_t, off_t, int, DBT *, u_int8_t *, MPOOLFILE **)); +static int __memp_mf_open __P((DB_MPOOL *, const char *, + int, size_t, db_pgno_t, int, DBT *, u_int8_t *, MPOOLFILE **)); /* * memp_fopen -- @@ -84,7 +84,9 @@ __memp_fopen(dbmp, mfp, path, { DB_ENV *dbenv; DB_MPOOLFILE *dbmfp; - off_t size; + db_pgno_t last_pgno; + size_t size; + u_int32_t mbytes, bytes; int ret; u_int8_t idbuf[DB_FILE_ID_LEN]; char *rpath; @@ -120,6 +122,7 @@ __memp_fopen(dbmp, mfp, path, goto err; } size = 0; + last_pgno = 0; } else { /* Get the real name for this file and open it. */ if ((ret = __db_appname(dbenv, @@ -133,17 +136,20 @@ __memp_fopen(dbmp, mfp, path, } /* Don't permit files that aren't a multiple of the pagesize. */ - if ((ret = __db_ioinfo(rpath, dbmfp->fd, &size, NULL)) != 0) { + if ((ret = __db_ioinfo(rpath, + dbmfp->fd, &mbytes, &bytes, NULL)) != 0) { __db_err(dbenv, "%s: %s", rpath, strerror(ret)); goto err; } - if (size % pagesize) { + if (bytes % pagesize) { __db_err(dbenv, "%s: file size not a multiple of the pagesize", rpath); ret = EINVAL; goto err; } + size = mbytes * MEGABYTE + bytes; + last_pgno = size == 0 ? 0 : (size - 1) / pagesize; /* * Get the file id if we weren't given one. Generated file id's @@ -155,6 +161,7 @@ __memp_fopen(dbmp, mfp, path, goto err; fileid = idbuf; } + FREES(rpath); } /* @@ -166,8 +173,8 @@ __memp_fopen(dbmp, mfp, path, LOCKREGION(dbmp); if (mfp == NULL) - ret = __memp_mf_open(dbmp, dbmfp, path, - ftype, pagesize, size, lsn_offset, pgcookie, fileid, &mfp); + ret = __memp_mf_open(dbmp, path, ftype, + pagesize, last_pgno, lsn_offset, pgcookie, fileid, &mfp); else { ++mfp->ref; ret = 0; @@ -216,7 +223,7 @@ __memp_fopen(dbmp, mfp, path, if (LF_ISSET(DB_NOMMAP)) F_CLR(mfp, MP_CAN_MMAP); if (size > (dbenv == NULL || dbenv->mp_mmapsize == 0 ? - DB_MAXMMAPSIZE : (off_t)dbenv->mp_mmapsize)) + DB_MAXMMAPSIZE : dbenv->mp_mmapsize)) F_CLR(mfp, MP_CAN_MMAP); } dbmfp->addr = NULL; @@ -253,14 +260,13 @@ err: /* * Open an MPOOLFILE. */ static int -__memp_mf_open(dbmp, dbmfp, path, - ftype, pagesize, size, lsn_offset, pgcookie, fileid, retp) +__memp_mf_open(dbmp, path, + ftype, pagesize, last_pgno, lsn_offset, pgcookie, fileid, retp) DB_MPOOL *dbmp; - DB_MPOOLFILE *dbmfp; const char *path; int ftype, lsn_offset; size_t pagesize; - off_t size; + db_pgno_t last_pgno; DBT *pgcookie; u_int8_t *fileid; MPOOLFILE **retp; @@ -314,7 +320,7 @@ __memp_mf_open(dbmp, dbmfp, path, * it away. */ mfp->stat.st_pagesize = pagesize; - mfp->last_pgno = size == 0 ? 0 : (size - 1) / mfp->stat.st_pagesize; + mfp->last_pgno = last_pgno; F_SET(mfp, MP_CAN_MMAP); if (ISTEMPORARY) diff --git a/db2/mp/mp_fput.c b/db2/mp/mp_fput.c index 38e86b8..335ee9f 100644 --- a/db2/mp/mp_fput.c +++ b/db2/mp/mp_fput.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_fput.c 10.16 (Sleepycat) 11/26/97"; +static const char sccsid[] = "@(#)mp_fput.c 10.17 (Sleepycat) 12/20/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -105,7 +105,7 @@ memp_fput(dbmfp, pgaddr, flags) #ifdef DEBUG if (bhp->ref == 0) { __db_err(dbmp->dbenv, - "Internal error: bhp->ref on page %lu went negative.", + "Unpinned page returned: reference count on page %lu went negative.", (u_long)bhp->pgno); abort(); } diff --git a/db2/mp/mp_pr.c b/db2/mp/mp_pr.c index 6ff1131..13a6c62 100644 --- a/db2/mp/mp_pr.c +++ b/db2/mp/mp_pr.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_pr.c 10.20 (Sleepycat) 11/26/97"; +static const char sccsid[] = "@(#)mp_pr.c 10.21 (Sleepycat) 1/6/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -25,8 +25,6 @@ static const char sccsid[] = "@(#)mp_pr.c 10.20 (Sleepycat) 11/26/97"; #include "db_shash.h" #include "mp.h" -void __memp_debug __P((DB_MPOOL *, FILE *, int)); - static void __memp_pbh __P((FILE *, DB_MPOOL *, BH *, int)); static void __memp_pdbmf __P((FILE *, DB_MPOOLFILE *, int)); static void __memp_pmf __P((FILE *, MPOOLFILE *, int)); diff --git a/db2/mp/mp_sync.c b/db2/mp/mp_sync.c index 47a7f2e..6d16cf3 100644 --- a/db2/mp/mp_sync.c +++ b/db2/mp/mp_sync.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_sync.c 10.17 (Sleepycat) 11/26/97"; +static const char sccsid[] = "@(#)mp_sync.c 10.19 (Sleepycat) 12/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -39,7 +39,7 @@ memp_sync(dbmp, lsnp) DB_ENV *dbenv; MPOOL *mp; MPOOLFILE *mfp; - int ar_cnt, cnt, nalloc, next, notused, ret, wrote; + int ar_cnt, cnt, nalloc, next, ret, wrote; dbenv = dbmp->dbenv; @@ -180,32 +180,28 @@ memp_sync(dbmp, lsnp) /* Write the buffer. */ mfp = R_ADDR(dbmp, bharray[next]->mf_offset); - ret = - __memp_bhwrite(dbmp, mfp, bharray[next], ¬used, &wrote); + ret = __memp_bhwrite(dbmp, mfp, bharray[next], NULL, &wrote); /* Release the buffer. */ --bharray[next]->ref; /* If there's an error, release the rest of the buffers. */ if (ret != 0 || !wrote) { - while (++next < ar_cnt) - --bharray[next]->ref; - - if (ret != 0) - goto err; - /* * Any process syncing the shared memory buffer pool * had better be able to write to any underlying file. * Be understanding, but firm, on this point. */ - if (!wrote) { + if (ret == 0) { __db_err(dbenv, "%s: unable to flush page: %lu", __memp_fns(dbmp, mfp), (u_long)bharray[next]->pgno); ret = EPERM; - goto err; } + + while (++next < ar_cnt) + --bharray[next]->ref; + goto err; } } ret = mp->lsn_cnt ? DB_INCOMPLETE : 0; @@ -242,7 +238,7 @@ memp_fsync(dbmfp) BH *bhp, **bharray; DB_MPOOL *dbmp; size_t mf_offset; - int ar_cnt, cnt, nalloc, next, pincnt, notused, ret, wrote; + int ar_cnt, cnt, nalloc, next, pincnt, ret, wrote; dbmp = dbmfp->dbmp; @@ -333,7 +329,7 @@ memp_fsync(dbmfp) } /* Write the buffer. */ - ret = __memp_pgwrite(dbmfp, bharray[next], ¬used, &wrote); + ret = __memp_pgwrite(dbmfp, bharray[next], NULL, &wrote); /* Release the buffer. */ --bharray[next]->ref; @@ -379,7 +375,7 @@ memp_trickle(dbmp, pct, nwrotep) MPOOL *mp; MPOOLFILE *mfp; u_long total; - int notused, ret, wrote; + int ret, wrote; mp = dbmp->mp; if (nwrotep != NULL) @@ -423,8 +419,7 @@ loop: total = mp->stat.st_page_clean + mp->stat.st_page_dirty; if (F_ISSET(mfp, MP_TEMP)) continue; - if ((ret = - __memp_bhwrite(dbmp, mfp, bhp, ¬used, &wrote)) != 0) + if ((ret = __memp_bhwrite(dbmp, mfp, bhp, NULL, &wrote)) != 0) goto err; /* diff --git a/db2/mutex/mutex.c b/db2/mutex/mutex.c index 6e87c5f..6dca323 100644 --- a/db2/mutex/mutex.c +++ b/db2/mutex/mutex.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mutex.c 10.29 (Sleepycat) 11/25/97"; +static const char sccsid[] = "@(#)mutex.c 10.32 (Sleepycat) 1/16/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -105,12 +105,12 @@ static const char sccsid[] = "@(#)mutex.c 10.29 (Sleepycat) 11/25/97"; * __db_mutex_init -- * Initialize a DB mutex structure. * - * PUBLIC: void __db_mutex_init __P((db_mutex_t *, off_t)); + * PUBLIC: void __db_mutex_init __P((db_mutex_t *, u_int32_t)); */ void __db_mutex_init(mp, off) db_mutex_t *mp; - off_t off; + u_int32_t off; { #ifdef DEBUG if ((ALIGNTYPE)mp & (MUTEX_ALIGNMENT - 1)) { @@ -123,6 +123,8 @@ __db_mutex_init(mp, off) memset(mp, 0, sizeof(db_mutex_t)); #ifdef HAVE_SPINLOCKS + COMPQUIET(off, 0); + TSL_INIT(&mp->tsl_resource); mp->spins = __os_spin(); #else @@ -149,6 +151,8 @@ __db_mutex_lock(mp, fd) #ifdef HAVE_SPINLOCKS int nspins; + COMPQUIET(fd, 0); + for (usecs = MS(10);;) { /* Try and acquire the uncontested resource lock for N spins. */ for (nspins = mp->spins; nspins > 0; --nspins) @@ -202,7 +206,7 @@ __db_mutex_lock(mp, fd) /* Acquire an exclusive kernel lock. */ k_lock.l_type = F_WRLCK; if (fcntl(fd, F_SETLKW, &k_lock)) - return (1); + return (errno); /* If the resource tsl is still available, it's ours. */ if (mp->pid == 0) { @@ -213,7 +217,7 @@ __db_mutex_lock(mp, fd) /* Release the kernel lock. */ k_lock.l_type = F_UNLCK; if (fcntl(fd, F_SETLK, &k_lock)) - return (1); + return (errno); /* * If we got the resource tsl we're done. @@ -251,6 +255,8 @@ __db_mutex_unlock(mp, fd) #endif #ifdef HAVE_SPINLOCKS + COMPQUIET(fd, 0); + #ifdef DEBUG mp->pid = 0; #endif diff --git a/db2/os/os_alloc.c b/db2/os/os_alloc.c new file mode 100644 index 0000000..27abffb --- /dev/null +++ b/db2/os/os_alloc.c @@ -0,0 +1,75 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 1997 + * Sleepycat Software. All rights reserved. + */ + +#include "config.h" + +#ifndef lint +static const char sccsid[] = "@(#)os_alloc.c 10.1 (Sleepycat) 12/1/97"; +#endif /* not lint */ + +#ifndef NO_SYSTEM_INCLUDES +#include <sys/types.h> + +#include <errno.h> +#include <string.h> +#endif + +#include "db_int.h" + +/* + * XXX + * Correct for systems that return NULL when you allocate 0 bytes of memory. + * There are several places in DB where we allocate the number of bytes held + * by the key/data item, and it can be 0. Correct here so that malloc never + * returns a NULL for that reason (which behavior is permitted by ANSI). We + * could make these calls macros on non-Alpha architectures (that's where we + * saw the problem), but it's probably not worth the autoconf complexity. + */ +/* + * __db_calloc -- + * The calloc(3) function for DB. + * + * PUBLIC: void *__db_calloc __P((size_t, size_t)); + */ +void * +__db_calloc(num, size) + size_t num, size; +{ + void *p; + + size *= num; + if ((p = __db_jump.db_malloc(size == 0 ? 1 : size)) != NULL) + memset(p, 0, size); + return (p); +} + +/* + * __db_malloc -- + * The malloc(3) function for DB. + * + * PUBLIC: void *__db_malloc __P((size_t)); + */ +void * +__db_malloc(size) + size_t size; +{ + return (__db_jump.db_malloc(size == 0 ? 1 : size)); +} + +/* + * __db_realloc -- + * The realloc(3) function for DB. + * + * PUBLIC: void *__db_realloc __P((void *, size_t)); + */ +void * +__db_realloc(ptr, size) + void *ptr; + size_t size; +{ + return (__db_jump.db_realloc(ptr, size == 0 ? 1 : size)); +} diff --git a/db2/os/os_config.c b/db2/os/os_config.c index ecb4f1c..7a89ba5 100644 --- a/db2/os/os_config.c +++ b/db2/os/os_config.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_config.c 10.9 (Sleepycat) 11/28/97"; +static const char sccsid[] = "@(#)os_config.c 10.12 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -20,6 +20,22 @@ static const char sccsid[] = "@(#)os_config.c 10.9 (Sleepycat) 11/28/97"; #include "db_int.h" /* + * __os_oldwin -- + * Return if Windows 95 (as opposed to Windows NT). + * + * PUBLIC: int __os_oldwin __P((void)); + */ +int +__os_oldwin() +{ +#ifdef _WIN32 + return ((GetVersion() & 0x80000000) != 0); +#else + return (0); +#endif +} + +/* * XXX * We provide our own extern declarations so that we don't collide with * systems that get them wrong, e.g., SunOS. @@ -41,7 +57,6 @@ imported extern char *strdup __P((const char *)); imported extern void *realloc __P((void *, size_t)); imported extern int unlink __P((const char *)); imported extern ssize_t write __P((int, const void *, size_t)); -imported extern void *memset __P((void *, int, size_t)); /* * __db_jump -- @@ -110,8 +125,8 @@ db_jump_set(func, which) __db_jump.db_fsync = (int (*) __P((int)))func; break; case DB_FUNC_IOINFO: - __db_jump.db_ioinfo = - (int (*) __P((const char *, int, off_t *, off_t *)))func; + __db_jump.db_ioinfo = (int (*) __P((const char *, + int, u_int32_t *, u_int32_t *, u_int32_t *)))func; break; case DB_FUNC_MALLOC: __db_jump.db_malloc = (void *(*) __P((size_t)))func; @@ -178,55 +193,3 @@ db_value_set(value, which) } return (0); } - -/* - * XXX - * Correct for systems that return NULL when you allocate 0 bytes of memory. - * There are several places in DB where we allocate the number of bytes held - * by the key/data item, and it can be 0. Correct here so that malloc never - * returns a NULL for that reason. - */ -/* - * __db_calloc -- - * The calloc(3) function for DB. - * - * PUBLIC: void *__db_calloc __P((size_t, size_t)); - */ -void * -__db_calloc(num, size) - size_t num, size; -{ - void *p; - - size *= num; - if ((p = __db_jump.db_malloc(size == 0 ? 1 : size)) != NULL) - memset(p, 0, size); - return (p); -} - -/* - * __db_malloc -- - * The malloc(3) function for DB. - * - * PUBLIC: void *__db_malloc __P((size_t)); - */ -void * -__db_malloc(size) - size_t size; -{ - return (__db_jump.db_malloc(size == 0 ? 1 : size)); -} - -/* - * __db_realloc -- - * The realloc(3) function for DB. - * - * PUBLIC: void *__db_realloc __P((void *, size_t)); - */ -void * -__db_realloc(ptr, size) - void *ptr; - size_t size; -{ - return (__db_jump.db_realloc(ptr, size == 0 ? 1 : size)); -} diff --git a/db2/os/os_stat.c b/db2/os/os_stat.c index ee84ab0..73600b6 100644 --- a/db2/os/os_stat.c +++ b/db2/os/os_stat.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_stat.c 10.8 (Sleepycat) 10/25/97"; +static const char sccsid[] = "@(#)os_stat.c 10.11 (Sleepycat) 1/8/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -47,34 +47,35 @@ __os_exists(path, isdirp) * Return file size and I/O size; abstracted to make it easier * to replace. * - * PUBLIC: int __os_ioinfo __P((const char *, int, off_t *, off_t *)); + * PUBLIC: int __os_ioinfo + * PUBLIC: __P((const char *, int, u_int32_t *, u_int32_t *, u_int32_t *)); */ int -__os_ioinfo(path, fd, sizep, iop) +__os_ioinfo(path, fd, mbytesp, bytesp, iosizep) const char *path; int fd; - off_t *sizep, *iop; + u_int32_t *mbytesp, *bytesp, *iosizep; { struct stat sb; + COMPQUIET(path, NULL); + if (fstat(fd, &sb) == -1) return (errno); /* Return the size of the file. */ - if (sizep != NULL) - *sizep = sb.st_size; + if (mbytesp != NULL) + *mbytesp = sb.st_size / MEGABYTE; + if (bytesp != NULL) + *bytesp = sb.st_size % MEGABYTE; - /* - * Return the underlying filesystem blocksize, if available. Default - * to 8K on the grounds that most OS's use less than 8K as their VM - * page size. - */ + /* Return the underlying filesystem blocksize, if available. */ #ifdef HAVE_ST_BLKSIZE - if (iop != NULL) - *iop = sb.st_blksize; + if (iosizep != NULL) + *iosizep = sb.st_blksize; #else - if (iop != NULL) - *iop = 8 * 1024; + if (iosizep != NULL) + *iosizep = DB_DEF_IOSIZE; #endif return (0); } diff --git a/db2/progs/db_checkpoint/db_checkpoint.c b/db2/progs/db_checkpoint/db_checkpoint.c index b2a692b..3157a52 100644 --- a/db2/progs/db_checkpoint/db_checkpoint.c +++ b/db2/progs/db_checkpoint/db_checkpoint.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_checkpoint.c 10.12 (Sleepycat) 9/4/97"; +static const char sccsid[] = "@(#)db_checkpoint.c 10.14 (Sleepycat) 1/17/98"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -46,7 +46,6 @@ void siginit __P((void)); void usage __P((void)); int interrupted; -time_t now; /* Checkpoint time. */ const char *progname = "db_checkpoint"; /* Program name. */ @@ -203,7 +202,7 @@ logpid(fname, is_open) } (void)time(&now); fprintf(fp, - "%s: %lu %s", progname, (u_long)getpid(), ctime(&now)); + "%.24s: %lu %s", progname, (u_long)getpid(), ctime(&now)); fclose(fp); } else (void)remove(fname); diff --git a/db2/progs/db_deadlock/db_deadlock.c b/db2/progs/db_deadlock/db_deadlock.c index 473e5b9..97fa8ca 100644 --- a/db2/progs/db_deadlock/db_deadlock.c +++ b/db2/progs/db_deadlock/db_deadlock.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_deadlock.c 10.16 (Sleepycat) 10/14/97"; +static const char sccsid[] = "@(#)db_deadlock.c 10.17 (Sleepycat) 1/15/98"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -192,7 +192,7 @@ logpid(fname, is_open) } (void)time(&now); fprintf(fp, - "%s: %lu %s", progname, (u_long)getpid(), ctime(&now)); + "%.24s: %lu %s", progname, (u_long)getpid(), ctime(&now)); fclose(fp); } else (void)remove(fname); diff --git a/db2/progs/db_load/db_load.c b/db2/progs/db_load/db_load.c index 6597f10..afa5730 100644 --- a/db2/progs/db_load/db_load.c +++ b/db2/progs/db_load/db_load.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_load.c 10.14 (Sleepycat) 10/19/97"; +static const char sccsid[] = "@(#)db_load.c 10.15 (Sleepycat) 12/29/97"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -51,11 +51,11 @@ main(argc, argv) extern int optind; DB *dbp; DBT key, data; - DBTYPE argtype, headertype; + DBTYPE argtype, dbtype; DB_ENV *dbenv; DB_INFO dbinfo; db_recno_t recno; - int ch, pflag; + int ch, no_header, pflag; char **clist, **clp, *home; /* Allocate enough room for configuration arguments. */ @@ -63,8 +63,9 @@ main(argc, argv) err(1, NULL); home = NULL; - argtype = DB_UNKNOWN; - while ((ch = getopt(argc, argv, "c:f:h:t:")) != EOF) + no_header = 0; + argtype = dbtype = DB_UNKNOWN; + while ((ch = getopt(argc, argv, "c:f:h:Tt:")) != EOF) switch (ch) { case 'c': *clp++ = optarg; @@ -76,6 +77,9 @@ main(argc, argv) case 'h': home = optarg; break; + case 'T': + no_header = pflag = 1; + break; case 't': if (strcmp(optarg, "btree") == 0) { argtype = DB_BTREE; @@ -85,6 +89,10 @@ main(argc, argv) argtype = DB_HASH; break; } + if (strcmp(optarg, "recno") == 0) { + argtype = DB_RECNO; + break; + } usage(); /* NOTREACHED */ case '?': @@ -101,21 +109,31 @@ main(argc, argv) dbenv = db_init(home); memset(&dbinfo, 0, sizeof(DB_INFO)); - /* Read the header. */ - rheader(&headertype, &pflag, &dbinfo); + /* + * Read the header. If there isn't any header, we're expecting flat + * text, set the pflag appropriately. + */ + if (no_header) + dbtype = argtype; + else { + rheader(&dbtype, &pflag, &dbinfo); + if (argtype != DB_UNKNOWN) { + /* Conversion to/from recno is prohibited. */ + if ((dbtype == DB_RECNO && argtype != DB_RECNO) || + (argtype == DB_RECNO && dbtype != DB_RECNO)) + errx(1, + "databases of type recno may not be converted"); + dbtype = argtype; + } + } + if (dbtype == DB_UNKNOWN) + errx(1, "no database type specified"); /* Apply command-line configuration changes. */ configure(&dbinfo, clist); - /* Conversion to/from recno is prohibited. */ - if (argtype != DB_UNKNOWN) { - if (headertype == DB_RECNO) - errx(1, "databases of type recno may not be converted"); - headertype = argtype; - } - /* Open the DB file. */ - if ((errno = db_open(argv[0], headertype, DB_CREATE | DB_TRUNCATE, + if ((errno = db_open(argv[0], dbtype, DB_CREATE | DB_TRUNCATE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, dbenv, &dbinfo, &dbp)) != 0) err(1, "%s", argv[0]); @@ -133,7 +151,7 @@ main(argc, argv) } /* Get each key/data pair and add them to the database. */ - if (headertype == DB_RECNO) { + if (dbtype == DB_RECNO) { key.data = &recno; key.size = sizeof(recno); for (recno = 1;; ++recno) { @@ -273,8 +291,11 @@ rheader(dbtypep, pflagp, dbinfop) *pflagp = 0; for (lineno = 1;; ++lineno) { + /* If we don't see the expected information, it's an error. */ if (fscanf(stdin, "%[^=]=%s\n", name, value) != 2) errx(1, "line %lu: unexpected format", lineno); + + /* Check for the end of the header lines. */ if (strcmp(name, "HEADER") == 0) break; @@ -455,6 +476,6 @@ void usage() { (void)fprintf(stderr, -"usage: db_load [-c name=value] [-f file] [-h home] [-t btree | hash] db_file\n"); +"usage: db_load [-T]\n\t[-c name=value] [-f file] [-h home] [-t btree | hash] db_file\n"); exit(1); } diff --git a/db2/progs/db_printlog/db_printlog.c b/db2/progs/db_printlog/db_printlog.c index 6bbd118..24554bc 100644 --- a/db2/progs/db_printlog/db_printlog.c +++ b/db2/progs/db_printlog/db_printlog.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_printlog.c 10.10 (Sleepycat) 8/27/97"; +static const char sccsid[] = "@(#)db_printlog.c 10.11 (Sleepycat) 1/8/98"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -150,7 +150,8 @@ void onint(signo) int signo; { - signo = 1; /* XXX: Shut the compiler up. */ + COMPQUIET(signo, 0); + interrupted = 1; } diff --git a/db2/progs/db_recover/db_recover.c b/db2/progs/db_recover/db_recover.c index 5a39d32..f902fed 100644 --- a/db2/progs/db_recover/db_recover.c +++ b/db2/progs/db_recover/db_recover.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_recover.c 10.16 (Sleepycat) 10/28/97"; +static const char sccsid[] = "@(#)db_recover.c 10.17 (Sleepycat) 1/15/98"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -73,7 +73,7 @@ main(argc, argv) dbenv = db_init(home, flags, verbose); if (verbose) { - __db_err(dbenv, "Recovery complete at %s", ctime(&now)); + __db_err(dbenv, "Recovery complete at %.24s", ctime(&now)); __db_err(dbenv, "%s %lu %s [%lu][%lu]", "Maximum transaction id", (u_long)dbenv->tx_info->region->last_txnid, diff --git a/db2/progs/db_stat/db_stat.c b/db2/progs/db_stat/db_stat.c index b1f1615..5295f01 100644 --- a/db2/progs/db_stat/db_stat.c +++ b/db2/progs/db_stat/db_stat.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_stat.c 8.26 (Sleepycat) 11/2/97"; +static const char sccsid[] = "@(#)db_stat.c 8.30 (Sleepycat) 1/8/98"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -31,9 +31,6 @@ static const char sccsid[] = "@(#)db_stat.c 8.26 (Sleepycat) 11/2/97"; #undef stat -#define MB 1048576 -#define DIVIDER "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" - typedef enum { T_NOTSET, T_DB, T_LOG, T_MPOOL, T_TXN } test_t; void btree_stats __P((DB *)); @@ -232,6 +229,8 @@ void hash_stats(dbp) DB *dbp; { + COMPQUIET(dbp, NULL); + return; } @@ -251,8 +250,9 @@ log_stats(dbenv) printf("%#lx\tLog magic number.\n", (u_long)sp->st_magic); printf("%lu\tLog version number.\n", (u_long)sp->st_version); printf("%#o\tLog file mode.\n", sp->st_mode); - if (sp->st_lg_max % MB == 0) - printf("%luMb\tLog file size.\n", (u_long)sp->st_lg_max / MB); + if (sp->st_lg_max % MEGABYTE == 0) + printf("%luMb\tLog file size.\n", + (u_long)sp->st_lg_max / MEGABYTE); else if (sp->st_lg_max % 1024 == 0) printf("%luKb\tLog file size.\n", (u_long)sp->st_lg_max / 1024); else @@ -263,6 +263,8 @@ log_stats(dbenv) (u_long)sp->st_wc_mbytes, (u_long)sp->st_wc_bytes); printf("%lu\tTotal log file writes.\n", (u_long)sp->st_wcount); printf("%lu\tTotal log file flushes.\n", (u_long)sp->st_scount); + printf("%lu\tCurrent log file number.\n", (u_long)sp->st_cur_file); + printf("%lu\tCurrent log file offset.\n", (u_long)sp->st_cur_offset); printf("%lu\tThe number of region locks granted without waiting.\n", (u_long)sp->st_region_nowait); printf("%lu\tThe number of region locks granted after waiting.\n", @@ -325,7 +327,7 @@ mpool_stats(dbenv) (u_long)gsp->st_region_wait); for (; fsp != NULL && *fsp != NULL; ++fsp) { - printf("%s\n", DIVIDER); + printf("%s\n", DB_LINE); printf("%s\n", (*fsp)->file_name); printf("%lu\tPage size.\n", (u_long)(*fsp)->st_pagesize); printf("%lu\tRequested pages found in the cache", @@ -513,7 +515,8 @@ void onint(signo) int signo; { - signo = 1; /* XXX: Shut the compiler up. */ + COMPQUIET(signo, 0); + interrupted = 1; } diff --git a/db2/txn/txn.c b/db2/txn/txn.c index e7a1798..2a2e3da 100644 --- a/db2/txn/txn.c +++ b/db2/txn/txn.c @@ -43,7 +43,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)txn.c 10.37 (Sleepycat) 11/28/97"; +static const char sccsid[] = "@(#)txn.c 10.39 (Sleepycat) 1/8/98"; #endif /* not lint */ @@ -205,7 +205,12 @@ retry1: if ((ret = __db_ropen(dbenv, DB_APP_NONE, path, DEFAULT_TXN_FILE, LOCK_TXNREGION(tmgrp); if ((ret = __db_shalloc(tmgrp->mem, sizeof(db_mutex_t), MUTEX_ALIGNMENT, &tmgrp->mutexp)) == 0) - __db_mutex_init(tmgrp->mutexp, -1); + /* + * Since we only get here if threading is turned on, we + * know that we have spinlocks, so the offset is going + * to be ignored. We put 0 here as a valid placeholder. + */ + __db_mutex_init(tmgrp->mutexp, 0); UNLOCK_TXNREGION(tmgrp); if (ret != 0) goto out; @@ -735,8 +740,7 @@ __txn_grow_region(tp) DB_TXNMGR *tp; { size_t incr; - off_t mutex_offset; - u_int32_t oldmax; + u_int32_t mutex_offset, oldmax; u_int8_t *curaddr; int ret; diff --git a/elf/dl-close.c b/elf/dl-close.c index 9467385..2854573 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -1,5 +1,5 @@ /* Close a shared object opened by `_dl_open'. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -74,25 +74,25 @@ _dl_close (struct link_map *map) it are gone. */ for (i = 0; i < map->l_nsearchlist; ++i) { - struct link_map *map = list[i]; - if (map->l_opencount == 0 && map->l_type == lt_loaded) + struct link_map *imap = list[i]; + if (imap->l_opencount == 0 && imap->l_type == lt_loaded) { /* That was the last reference, and this was a dlopen-loaded object. We can unmap it. */ const ElfW(Phdr) *ph; - if (map->l_info[DT_FINI]) + if (imap->l_info[DT_FINI]) /* Call its termination function. */ - (*(void (*) (void)) ((void *) map->l_addr + - map->l_info[DT_FINI]->d_un.d_ptr)) (); + (*(void (*) (void)) ((void *) imap->l_addr + + imap->l_info[DT_FINI]->d_un.d_ptr)) (); - if (map->l_global) + if (imap->l_global) { /* This object is in the global scope list. Remove it. */ struct link_map **tail = _dl_global_scope_end; do --tail; - while (*tail != map); + while (*tail != imap); --_dl_global_scope_end; memcpy (tail, tail + 1, _dl_global_scope_end - tail); _dl_global_scope_end[0] = NULL; @@ -100,24 +100,26 @@ _dl_close (struct link_map *map) } /* Unmap the segments. */ - for (ph = map->l_phdr; ph < &map->l_phdr[map->l_phnum]; ++ph) + for (ph = imap->l_phdr + (imap->l_phnum - 1); + ph >= imap->l_phdr; --ph) if (ph->p_type == PT_LOAD) { ElfW(Addr) mapstart = ph->p_vaddr & ~(ph->p_align - 1); ElfW(Addr) mapend = ((ph->p_vaddr + ph->p_memsz + ph->p_align - 1) & ~(ph->p_align - 1)); - __munmap ((caddr_t) mapstart, mapend - mapstart); + __munmap ((caddr_t) (imap->l_addr + mapstart), + mapend - mapstart); } /* Finally, unlink the data structure and free it. */ - if (map->l_prev) - map->l_prev->l_next = map->l_next; - if (map->l_next) - map->l_next->l_prev = map->l_prev; - if (map->l_searchlist) - free (map->l_searchlist); - free (map); + if (imap->l_prev) + imap->l_prev->l_next = imap->l_next; + if (imap->l_next) + imap->l_next->l_prev = imap->l_prev; + if (imap->l_searchlist) + free (imap->l_searchlist); + free (imap); } } diff --git a/include/cpio.h b/include/cpio.h new file mode 100644 index 0000000..0364e8a --- /dev/null +++ b/include/cpio.h @@ -0,0 +1,76 @@ +/* Extended cpio format from POSIX.1. + This file is part of the GNU C Library. + Copyright (C) 1992, 1998 Free Software Foundation, Inc. + + NOTE: The canonical source of this file is maintained with the GNU cpio. + Bugs can be reported to bug-glibc@gnu.org. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _CPIO_H +#define _CPIO_H 1 + +/* A cpio archive consists of a sequence of files. + Each file has a 76 byte header, + a variable length, NUL terminated filename, + and variable length file data. + A header for a filename "TRAILER!!!" indicates the end of the archive. */ + +/* All the fields in the header are ISO 646 (approximately ASCII) strings + of octal numbers, left padded, not NUL terminated. + + Field Name Length in Bytes Notes + c_magic 6 must be "070707" + c_dev 6 + c_ino 6 + c_mode 6 see below for value + c_uid 6 + c_gid 6 + c_nlink 6 + c_rdev 6 only valid for chr and blk special files + c_mtime 11 + c_namesize 6 count includes terminating NUL in pathname + c_filesize 11 must be 0 for FIFOs and directories */ + +/* Value for the field `c_magic'. */ +#define MAGIC "070707" + +/* Values for c_mode, OR'd together: */ + +#define C_IRUSR 000400 +#define C_IWUSR 000200 +#define C_IXUSR 000100 +#define C_IRGRP 000040 +#define C_IWGRP 000020 +#define C_IXGRP 000010 +#define C_IROTH 000004 +#define C_IWOTH 000002 +#define C_IXOTH 000001 + +#define C_ISUID 004000 +#define C_ISGID 002000 +#define C_ISVTX 001000 + +#define C_ISBLK 060000 +#define C_ISCHR 020000 +#define C_ISDIR 040000 +#define C_ISFIFO 010000 +#define C_ISSOCK 0140000 +#define C_ISLNK 0120000 +#define C_ISCTG 0110000 +#define C_ISREG 0100000 + +#endif /* cpio.h */ diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c index f01b1f6..9c591f6 100644 --- a/locale/programs/ld-collate.c +++ b/locale/programs/ld-collate.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. @@ -1889,7 +1889,7 @@ collate_end_weight (struct linereader *lr, struct localedef_t *locale) || collate->kind == undefined); /* Fill in the missing weights. */ - while (collate->weight_idx++ < collate->nrules) + while (++collate->weight_idx < collate->nrules) { collate->weight[collate->nweight++] = pelem->this_weight; ++collate->weight_cnt[collate->weight_idx]; diff --git a/math/libm-test.c b/math/libm-test.c index efb89f7..13f7cf3 100644 --- a/math/libm-test.c +++ b/math/libm-test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1997. @@ -1707,6 +1707,13 @@ modf_test (void) check ("modf (-2.5, &x) returns -0.5", result, -0.5); check ("modf (-2.5, &x) sets x to -2", intpart, -2); + result = FUNC(modf) (20, &intpart); + check ("modf (20, &x) returns 0", result, 0); + check ("modf (20, &x) sets x to 20", intpart, 20); + + result = FUNC(modf) (21, &intpart); + check ("modf (21, &x) returns 0", result, 0); + check ("modf (21, &x) sets x to 21", intpart, 21); } diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h index aff5456..8394d27 100644 --- a/misc/sys/syslog.h +++ b/misc/sys/syslog.h @@ -36,6 +36,11 @@ #ifndef _SYS_SYSLOG_H #define _SYS_SYSLOG_H 1 +#include <features.h> +#define __need___va_list +#include <stdarg.h> + + #define _PATH_LOG "/dev/log" /* @@ -165,11 +170,6 @@ CODE facilitynames[] = #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ #define LOG_PERROR 0x20 /* log to stderr as well */ -#define __need___va_list -#include <stdarg.h> - -#include <sys/cdefs.h> - __BEGIN_DECLS /* Close desriptor used to write to system logger. */ @@ -185,9 +185,11 @@ extern int setlogmask __P ((int __mask)); /* Generate a log message using FMT string and option arguments. */ extern void syslog __P ((int __pri, __const char *__fmt, ...)); +#ifdef __USE_BSD /* Generate a log message using FMT and using arguments pointed to by AP. */ extern void vsyslog __P ((int __pri, __const char *__fmt, __gnuc_va_list __ap)); +#endif __END_DECLS diff --git a/nis/nis_cache.c b/nis/nis_cache.c new file mode 100644 index 0000000..a0e1130 --- /dev/null +++ b/nis/nis_cache.c @@ -0,0 +1,94 @@ +/* Copyright (c) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <rpcsvc/nis.h> +#include "nis_intern.h" + +#include "nis_cache2.h" + +static struct timeval TIMEOUT = { 25, 0 }; + +directory_obj * +__nis_cache_search (const_nis_name name, u_long flags, cache2_info *cinfo) +{ + XDR xdrs; + CLIENT *clnt; + struct sockaddr_in clnt_saddr; + directory_obj *obj = NULL; + fs_result fsres; + int clnt_sock; + + cinfo->server_used = -1; + cinfo->current_ep = -1; + cinfo->class = -1; + + memset (&clnt_saddr, '\0', sizeof clnt_saddr); + clnt_saddr.sin_family = AF_INET; + clnt_saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); + clnt_sock = RPC_ANYSOCK; + clnt = clnttcp_create (&clnt_saddr, CACHEPROG, CACHE_VER_1, + &clnt_sock, 0, 0); + if (clnt == NULL) + return NULL; + + memset (&fsres, 0, sizeof (fsres)); + if (flags & MASTER_ONLY) + { + if (clnt_call (clnt, NIS_CACHE_FIND_MASTER, (xdrproc_t) xdr_wrapstring, + (caddr_t) &name, (xdrproc_t) xdr_fs_result, + (caddr_t) &fsres, TIMEOUT) != RPC_SUCCESS) + { + clnt_destroy (clnt); + close (clnt_sock); + return NULL; + } + } + else + { + if (clnt_call (clnt, NIS_CACHE_FIND_SERVER, (xdrproc_t) xdr_wrapstring, + (caddr_t) &name, (xdrproc_t) xdr_fs_result, + (caddr_t) &fsres, TIMEOUT) != RPC_SUCCESS) + { + clnt_destroy (clnt); + close (clnt_sock); + return NULL; + } + } + + clnt_destroy (clnt); + close (clnt_sock); + + if (fsres.status != NIS_SUCCESS) + return NULL; + + obj = calloc (1, sizeof (directory_obj)); + if (obj == NULL) + return NULL; + + xdrmem_create (&xdrs, fsres.dir_data.dir_data_val, + fsres.dir_data.dir_data_len, XDR_DECODE); + xdr_directory_obj (&xdrs, obj); + xdr_destroy (&xdrs); + + cinfo->server_used = fsres.server_used; + cinfo->current_ep = fsres.current_ep; + cinfo->class = fsres.class; + + return obj; +} diff --git a/nis/nis_cache2.h b/nis/nis_cache2.h new file mode 100644 index 0000000..55f0109 --- /dev/null +++ b/nis/nis_cache2.h @@ -0,0 +1,93 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _NIS_CACHE2_H_RPCGEN +#define _NIS_CACHE2_H_RPCGEN + +#include <rpc/rpc.h> + +#include <rpcsvc/nis.h> + +struct fs_result { + nis_error status; + long class; + struct { + u_int dir_data_len; + char *dir_data_val; + } dir_data; + long server_used; + long current_ep; +}; +typedef struct fs_result fs_result; +#ifdef __cplusplus +extern "C" bool_t xdr_fs_result(XDR *, fs_result*); +#elif __STDC__ +extern bool_t xdr_fs_result(XDR *, fs_result*); +#else /* Old Style C */ +bool_t xdr_fs_result(); +#endif /* Old Style C */ + + +struct fs_request { + nis_name name; + long old_class; +}; +typedef struct fs_request fs_request; +#ifdef __cplusplus +extern "C" bool_t xdr_fs_request(XDR *, fs_request*); +#elif __STDC__ +extern bool_t xdr_fs_request(XDR *, fs_request*); +#else /* Old Style C */ +bool_t xdr_fs_request(); +#endif /* Old Style C */ + + +#define CACHEPROG ((u_long)600100301) +#define CACHE_VER_1 ((u_long)1) + +#ifdef __cplusplus +#define NIS_CACHE_READ_COLDSTART ((u_long)1) +extern "C" void * nis_cache_read_coldstart_1(void *, CLIENT *); +extern "C" void * nis_cache_read_coldstart_1_svc(void *, struct svc_req *); +#define NIS_CACHE_FIND_MASTER ((u_long)2) +extern "C" fs_result * nis_cache_find_master_1(char **, CLIENT *); +extern "C" fs_result * nis_cache_find_master_1_svc(char **, struct svc_req *); +#define NIS_CACHE_FIND_SERVER ((u_long)3) +extern "C" fs_result * nis_cache_find_server_1(char **, CLIENT *); +extern "C" fs_result * nis_cache_find_server_1_svc(char **, struct svc_req *); +#define NIS_CACHE_NEXT_SERVER ((u_long)4) +extern "C" fs_result * nis_cache_next_server_1(fs_request *, CLIENT *); +extern "C" fs_result * nis_cache_next_server_1_svc(fs_request *, struct svc_req *); + +#elif __STDC__ +#define NIS_CACHE_READ_COLDSTART ((u_long)1) +extern void * nis_cache_read_coldstart_1(void *, CLIENT *); +extern void * nis_cache_read_coldstart_1_svc(void *, struct svc_req *); +#define NIS_CACHE_FIND_MASTER ((u_long)2) +extern fs_result * nis_cache_find_master_1(char **, CLIENT *); +extern fs_result * nis_cache_find_master_1_svc(char **, struct svc_req *); +#define NIS_CACHE_FIND_SERVER ((u_long)3) +extern fs_result * nis_cache_find_server_1(char **, CLIENT *); +extern fs_result * nis_cache_find_server_1_svc(char **, struct svc_req *); +#define NIS_CACHE_NEXT_SERVER ((u_long)4) +extern fs_result * nis_cache_next_server_1(fs_request *, CLIENT *); +extern fs_result * nis_cache_next_server_1_svc(fs_request *, struct svc_req *); + +#else /* Old Style C */ +#define NIS_CACHE_READ_COLDSTART ((u_long)1) +extern void * nis_cache_read_coldstart_1(); +extern void * nis_cache_read_coldstart_1_svc(); +#define NIS_CACHE_FIND_MASTER ((u_long)2) +extern fs_result * nis_cache_find_master_1(); +extern fs_result * nis_cache_find_master_1_svc(); +#define NIS_CACHE_FIND_SERVER ((u_long)3) +extern fs_result * nis_cache_find_server_1(); +extern fs_result * nis_cache_find_server_1_svc(); +#define NIS_CACHE_NEXT_SERVER ((u_long)4) +extern fs_result * nis_cache_next_server_1(); +extern fs_result * nis_cache_next_server_1_svc(); +#endif /* Old Style C */ + +#endif /* !_NIS_CACHE2_H_RPCGEN */ diff --git a/nis/nis_cache2_xdr.c b/nis/nis_cache2_xdr.c new file mode 100644 index 0000000..b988f3f --- /dev/null +++ b/nis/nis_cache2_xdr.c @@ -0,0 +1,43 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#include <rpc/types.h> +#include <rpc/xdr.h> + +#include "nis_cache2.h" +#include <rpcsvc/nis.h> + +bool_t +xdr_fs_result(XDR *xdrs, fs_result *objp) +{ + if (!xdr_nis_error(xdrs, &objp->status)) { + return FALSE; + } + if (!xdr_long(xdrs, &objp->class)) { + return FALSE; + } + if (!xdr_bytes(xdrs, (char **)&objp->dir_data.dir_data_val, (u_int *)&objp->dir_data.dir_data_len, ~0)) { + return FALSE; + } + if (!xdr_long(xdrs, &objp->server_used)) { + return FALSE; + } + if (!xdr_long(xdrs, &objp->current_ep)) { + return FALSE; + } + return TRUE; +} + +bool_t +xdr_fs_request(XDR *xdrs, fs_request *objp) +{ + if (!xdr_nis_name(xdrs, &objp->name)) { + return FALSE; + } + if (!xdr_long(xdrs, &objp->old_class)) { + return FALSE; + } + return TRUE; +} diff --git a/nis/nss_compat/compat-grp.c b/nis/nss_compat/compat-grp.c index 4b873d6..dab1b5e 100644 --- a/nis/nss_compat/compat-grp.c +++ b/nis/nss_compat/compat-grp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996. @@ -458,17 +458,15 @@ getgrent_next_file (struct group *result, ent_t *ent, do { fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; p = fgets (buffer, buflen, ent->stream); - if (p == NULL) + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') { - if (feof (ent->stream)) - return NSS_STATUS_NOTFOUND; - else - { - fsetpos (ent->stream, &pos); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } + fsetpos (ent->stream, &pos); + *errnop = ERANGE; + return NSS_STATUS_TRYAGAIN; } /* Terminate the line for any case. */ @@ -600,17 +598,15 @@ internal_getgrnam_r (const char *name, struct group *result, ent_t *ent, do { fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; p = fgets (buffer, buflen, ent->stream); - if (p == NULL) + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') { - if (feof (ent->stream)) - return NSS_STATUS_NOTFOUND; - else - { - fsetpos (ent->stream, &pos); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } + fsetpos (ent->stream, &pos); + *errnop = ERANGE; + return NSS_STATUS_TRYAGAIN; } /* Terminate the line for any case. */ @@ -794,17 +790,15 @@ internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent, do { fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; p = fgets (buffer, buflen, ent->stream); - if (p == NULL) + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') { - if (feof (ent->stream)) - return NSS_STATUS_NOTFOUND; - else - { - fsetpos (ent->stream, &pos); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } + fsetpos (ent->stream, &pos); + *errnop = ERANGE; + return NSS_STATUS_TRYAGAIN; } /* Terminate the line for any case. */ diff --git a/nis/nss_compat/compat-pwd.c b/nis/nss_compat/compat-pwd.c index 8a1c424..5bfff17 100644 --- a/nis/nss_compat/compat-pwd.c +++ b/nis/nss_compat/compat-pwd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996. @@ -810,17 +810,15 @@ getpwent_next_file (struct passwd *result, ent_t *ent, do { fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; p = fgets (buffer, buflen, ent->stream); - if (p == NULL) + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') { - if (feof (ent->stream)) - return NSS_STATUS_NOTFOUND; - else - { - fsetpos (ent->stream, &pos); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } + fsetpos (ent->stream, &pos); + *errnop = ERANGE; + return NSS_STATUS_TRYAGAIN; } /* Terminate the line for any case. */ @@ -1023,17 +1021,15 @@ internal_getpwnam_r (const char *name, struct passwd *result, ent_t *ent, do { fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; p = fgets (buffer, buflen, ent->stream); - if (p == NULL) + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') { - if (feof (ent->stream)) - return NSS_STATUS_NOTFOUND; - else - { - fsetpos (ent->stream, &pos); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } + fsetpos (ent->stream, &pos); + *errnop = ERANGE; + return NSS_STATUS_TRYAGAIN; } /* Terminate the line for any case. */ @@ -1306,17 +1302,15 @@ internal_getpwuid_r (uid_t uid, struct passwd *result, ent_t *ent, do { fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; p = fgets (buffer, buflen, ent->stream); - if (p == NULL) + if (p == NULL && feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + if (p == NULL || buffer[buflen - 1] != '\xff') { - if (feof (ent->stream)) - return NSS_STATUS_NOTFOUND; - else - { - fsetpos (ent->stream, &pos); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } + fsetpos (ent->stream, &pos); + *errnop = ERANGE; + return NSS_STATUS_TRYAGAIN; } /* Terminate the line for any case. */ diff --git a/nis/nss_compat/compat-spwd.c b/nis/nss_compat/compat-spwd.c index 83db856..816e9c1 100644 --- a/nis/nss_compat/compat-spwd.c +++ b/nis/nss_compat/compat-spwd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996. @@ -761,12 +761,16 @@ getspent_next_file (struct spwd *result, ent_t *ent, do { fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; p = fgets (buffer, buflen, ent->stream); - if (p == NULL) + if (p == NULL && feof (ent->stream)) return NSS_STATUS_NOTFOUND; - - /* Terminate the line for any case. */ - buffer[buflen - 1] = '\0'; + if (p == NULL || buffer[buflen - 1] != '\xff') + { + fsetpos (ent->stream, &pos); + *errnop = ERANGE; + return NSS_STATUS_TRYAGAIN; + } /* Skip leading blanks. */ while (isspace (*p)) @@ -965,12 +969,16 @@ internal_getspnam_r (const char *name, struct spwd *result, ent_t *ent, do { fgetpos (ent->stream, &pos); + buffer[buflen - 1] = '\xff'; p = fgets (buffer, buflen, ent->stream); - if (p == NULL) + if (p == NULL && feof (ent->stream)) return NSS_STATUS_NOTFOUND; - - /* Terminate the line for any case. */ - buffer[buflen - 1] = '\0'; + if (p == NULL || buffer[buflen - 1] != '\xff') + { + fsetpos (ent->stream, &pos); + *errnop = ERANGE; + return NSS_STATUS_TRYAGAIN; + } /* Skip leading blanks. */ while (isspace (*p)) diff --git a/nis/ypclnt.c b/nis/ypclnt.c index f07f0c6..c661ee3 100644 --- a/nis/ypclnt.c +++ b/nis/ypclnt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996. @@ -78,8 +78,6 @@ __yp_bind (const char *domain, dom_binding **ypdb) ysd->dom_socket = -1; ysd->dom_vers = -1; } - else - ysd->dom_client = NULL; try = 0; diff --git a/nss/nss_files/files-XXX.c b/nss/nss_files/files-XXX.c index e3261ed..6933986 100644 --- a/nss/nss_files/files-XXX.c +++ b/nss/nss_files/files-XXX.c @@ -1,5 +1,5 @@ /* Common code for file-based databases in nss_files module. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -179,7 +179,7 @@ internal_getent (struct STRUCTURE *result, do { /* Terminate the line so that we can test for overflow. */ - data->linebuffer[linebuflen - 1] = '\0'; + data->linebuffer[linebuflen - 1] = '\xff'; p = fgets (data->linebuffer, linebuflen, stream); if (p == NULL) @@ -189,7 +189,7 @@ internal_getent (struct STRUCTURE *result, H_ERRNO_SET (HOST_NOT_FOUND); return NSS_STATUS_NOTFOUND; } - else if (data->linebuffer[linebuflen - 1] != '\0') + else if (data->linebuffer[linebuflen - 1] != '\xff') { /* The line is too long. Give the user the opportunity to enlarge the buffer. */ diff --git a/nss/nss_files/files-alias.c b/nss/nss_files/files-alias.c index 84d771d..66f3d3ad 100644 --- a/nss/nss_files/files-alias.c +++ b/nss/nss_files/files-alias.c @@ -150,12 +150,12 @@ get_next_alias (const char *match, struct aliasent *result, /* Read the first line. It must contain the alias name and possibly some alias names. */ - first_unused[room_left - 1] = '\0'; + first_unused[room_left - 1] = '\xff'; line = fgets (first_unused, room_left, stream); if (line == NULL) /* Nothing to read. */ break; - else if (first_unused[room_left - 1] != '\0') + else if (first_unused[room_left - 1] != '\xff') { /* The line is too long for our buffer. */ no_more_room: @@ -244,11 +244,11 @@ get_next_alias (const char *match, struct aliasent *result, { while (! feof (listfile)) { - first_unused[room_left - 1] = '\0'; + first_unused[room_left - 1] = '\xff'; line = fgets (first_unused, room_left, listfile); if (line == NULL) break; - if (first_unused[room_left - 1] != '\0') + if (first_unused[room_left - 1] != '\xff') { free (old_line); goto no_more_room; @@ -344,9 +344,9 @@ get_next_alias (const char *match, struct aliasent *result, /* The just read character is a white space and so can be ignored. */ - first_unused[room_left - 1] = '\0'; + first_unused[room_left - 1] = '\xff'; line = fgets (first_unused, room_left, stream); - if (first_unused[room_left - 1] != '\0') + if (first_unused[room_left - 1] != '\xff') goto no_more_room; cp = strpbrk (line, "#\n"); if (cp != NULL) diff --git a/nss/nss_files/files-network.c b/nss/nss_files/files-network.c index 8180d46..59cf012 100644 --- a/nss/nss_files/files-network.c +++ b/nss/nss_files/files-network.c @@ -38,6 +38,7 @@ LINE_PARSER STRING_FIELD (addr, isspace, 1); result->n_net = inet_network (addr); + result->n_addrtype = AF_INET; }) diff --git a/posix/Makefile b/posix/Makefile index b8fbbd2..2d69711 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. +# Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -26,7 +26,7 @@ headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \ bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h \ bits/local_lim.h tar.h bits/utsname.h bits/confname.h \ bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \ - bits/sched.h re_comp.h wait.h bits/environments.h + bits/sched.h re_comp.h wait.h bits/environments.h cpio.h distribute := confstr.h TESTS TESTS2C.sed testcases.h \ globtest.c globtest.sh diff --git a/posix/wordexp.c b/posix/wordexp.c index 42b22ec..abd55a5 100644 --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -1,5 +1,5 @@ /* POSIX.2 wordexp implementation. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Tim Waugh <tim@cyberelk.demon.co.uk>. @@ -51,11 +51,13 @@ /* Some forward declarations */ static int parse_dollars (char **word, size_t *word_length, size_t *max_length, const char *words, size_t *offset, int flags, - wordexp_t *pwordexp) + wordexp_t *pwordexp, const char *ifs, + const char *ifs_white) internal_function; static int parse_backtick (char **word, size_t *word_length, size_t *max_length, const char *words, - size_t *offset, int flags, wordexp_t *pwordexp) + size_t *offset, int flags, wordexp_t *pwordexp, + const char *ifs, const char *ifs_white) internal_function; static int eval_expr (char *expr, int *result) internal_function; @@ -315,7 +317,7 @@ static int internal_function parse_glob (char **word, size_t *word_length, size_t *max_length, const char *words, size_t *offset, int flags, - wordexp_t *pwordexp, char *ifs) + wordexp_t *pwordexp, const char *ifs, const char *ifs_white) { /* We are poised just after a '*' or a '{'. */ int error; @@ -332,7 +334,7 @@ parse_glob (char **word, size_t *word_length, size_t *max_length, case '$': error = parse_dollars (word, word_length, max_length, words, offset, - flags, pwordexp); + flags, pwordexp, ifs, ifs_white); if (error) return error; @@ -583,8 +585,8 @@ parse_arith (char **word, size_t *word_length, size_t *max_length, { case '$': error = parse_dollars (&expr, &expr_length, &expr_maxlen, - words, offset, flags, NULL); - /* The NULL here is to tell parse_dollars not to + words, offset, flags, NULL, NULL, NULL); + /* The first NULL here is to tell parse_dollars not to * split the fields. */ if (error) @@ -597,8 +599,8 @@ parse_arith (char **word, size_t *word_length, size_t *max_length, case '`': (*offset)++; error = parse_backtick (&expr, &expr_length, &expr_maxlen, - words, offset, flags, NULL); - /* The NULL here is to tell parse_backtick not to + words, offset, flags, NULL, NULL, NULL); + /* The first NULL here is to tell parse_backtick not to * split the fields. */ if (error) @@ -696,20 +698,15 @@ parse_arith (char **word, size_t *word_length, size_t *max_length, static int internal_function exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length, - int flags, wordexp_t *pwordexp) + int flags, wordexp_t *pwordexp, const char *ifs, + const char *ifs_white) { int fildes[2]; int bufsize = 128; int buflen; - int state = 0; int i; char *buffer; pid_t pid; - /* 'state' is: - * 0 until first non-(whitespace-ifs) - * 1 after a non-ifs - * 2 after non-(whitespace-ifs) - */ /* Don't fork() unless necessary */ if (!comm || !*comm) @@ -775,49 +772,99 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length, close (fildes[0]); return 0; } - - /* Not quoted - split fields. - * NB. This isn't done properly yet. - */ - while (1) + else + /* Not quoted - split fields */ { - if ((buflen = read (fildes[0], buffer, bufsize)) < 1) - { - if (__waitpid (pid, NULL, WNOHANG) == 0) - continue; - if ((read (fildes[0], buffer, bufsize)) < 1) - break; - } + int copying = 0; + /* 'copying' is: + * 0 when searching for first character in a field not IFS white space + * 1 when copying the text of a field + * 2 when searching for possible non-whitespace IFS + */ - for (i = 0; i < buflen; ++i) + while (1) { - /* What if these aren't field separators? FIX */ - if (buffer[i] == ' ' || buffer[i] == '\t' || buffer[i] == '\n') + if ((buflen = read (fildes[0], buffer, bufsize)) < 1) { - if (state != 0) - state = 2; - continue; + if (__waitpid (pid, NULL, WNOHANG) == 0) + continue; + if ((read (fildes[0], buffer, bufsize)) < 1) + break; } - if (state == 2) + for (i = 0; i < buflen; ++i) { - /* End of word */ - if (w_addword (pwordexp, *word) == WRDE_NOSPACE) + if (strchr (ifs, buffer[i]) != NULL) { - close (fildes[0]); - return WRDE_NOSPACE; - } + /* Current character is IFS */ + if (strchr (ifs_white, buffer[i]) == NULL) + { + /* Current character is IFS but not whitespace */ + if (copying == 2) + { + /* current character + * | + * V + * eg: text<space><comma><space>moretext + * + * So, strip whitespace IFS (like at the start) + */ + copying = 0; + continue; + } + + copying = 0; + /* fall through and delimit field.. */ + } + else + { + /* Current character is IFS white space */ - *word = NULL; - *word_length = 0; - } + /* If not copying a field, ignore it */ + if (copying != 1) + continue; - state = 1; - *word = w_addchar (*word, word_length, max_length, buffer[i]); - if (*word == NULL) - { - close (fildes[0]); - return WRDE_NOSPACE; + /* End of field (search for non-IFS afterwards) */ + copying = 2; + } + + /* First IFS white space, or IFS non-whitespace. + * Delimit the field. */ + if (!*word) + { + /* This field is null, so make it an empty string */ + *word = w_addchar (*word, word_length, max_length, 0); + if (*word == NULL) + { + close (fildes[0]); + return WRDE_NOSPACE; + } + } + + if (w_addword (pwordexp, *word) == WRDE_NOSPACE) + { + /* Should do __waitpid? */ + close (fildes[0]); + return WRDE_NOSPACE; + } + + *word = NULL; + *word_length = 0; + *max_length = 0; + /* fall back round the loop.. */ + } + else + { + /* Not IFS character */ + copying = 1; + *word = w_addchar (*word, word_length, max_length, + buffer[i]); + if (*word == NULL) + { + close (fildes[0]); + return WRDE_NOSPACE; + } + } } } } @@ -828,7 +875,8 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length, static int parse_comm (char **word, size_t *word_length, size_t *max_length, - const char *words, size_t *offset, int flags, wordexp_t *pwordexp) + const char *words, size_t *offset, int flags, wordexp_t *pwordexp, + const char *ifs, const char *ifs_white) { /* We are poised just after "$(" */ int paren_depth = 1; @@ -846,7 +894,7 @@ parse_comm (char **word, size_t *word_length, size_t *max_length, { /* Go -- give script to the shell */ error = exec_comm (comm, word, word_length, max_length, flags, - pwordexp); + pwordexp, ifs, ifs_white); free (comm); return error; } @@ -877,7 +925,8 @@ parse_comm (char **word, size_t *word_length, size_t *max_length, static int internal_function parse_param (char **word, size_t *word_length, size_t *max_length, - const char *words, size_t *offset, int flags, wordexp_t *pwordexp) + const char *words, size_t *offset, int flags, wordexp_t *pwordexp, + const char *ifs, const char *ifs_white) { /* We are poised just after "$" */ enum remove_pattern_enum @@ -1264,8 +1313,65 @@ envsubst: /* Quoted - no field split */ *word = w_addstr (*word, word_length, max_length, value); else - /* Should field-split here - FIX */ - *word = w_addstr (*word, word_length, max_length, value); + { + /* Need to field-split */ + char *field_begin = value; + int seen_nonws_ifs = 0; + + do + { + char *field_end = field_begin; + char *field; + char *next_field; + char ch; + + /* Skip IFS whitespace before the field */ + while (*field_begin && strchr (ifs_white, *field_begin) != NULL) + field_begin++; + + if (!seen_nonws_ifs && *field_begin == 0) + /* Nothing but whitespace */ + return 0; + + /* Search for the end of the field */ + field_end = field_begin; + while (*field_end && strchr (ifs, *field_end) == NULL) + field_end++; + + /* Set up pointer to the character after end of field */ + ch = *field_end; + next_field = ch ? field_end : NULL; + + /* Skip whitespace IFS after the field */ + while (next_field && *next_field && strchr (ifs_white, *next_field)) + next_field++; + + /* Skip at most one non-whitespace IFS character after the field */ + seen_nonws_ifs = 0; + if (next_field && *next_field && strchr (ifs, *next_field)) + { + seen_nonws_ifs = 1; + next_field++; + } + + /* Null-terminate it and make a copy */ + *field_end = 0; + field = __strdup (field_begin); + if (field == NULL) + goto no_space; + + /* Tag the field onto the word list */ + if (w_addword (pwordexp, field) == WRDE_NOSPACE) + return WRDE_NOSPACE; + + *word = NULL; + *word_length = *max_length = 0; + + field_begin = next_field; + } while (seen_nonws_ifs || (field_begin && *field_begin)); + + return 0; + } return *word ? 0 : WRDE_NOSPACE; @@ -1292,7 +1398,7 @@ static int internal_function parse_dollars (char **word, size_t *word_length, size_t *max_length, const char *words, size_t *offset, int flags, - wordexp_t *pwordexp) + wordexp_t *pwordexp, const char *ifs, const char *ifs_white) { /* We are poised _at_ "$" */ switch (words[1 + *offset]) @@ -1317,7 +1423,7 @@ parse_dollars (char **word, size_t *word_length, size_t *max_length, (*offset) += 2; return parse_comm (word, word_length, max_length, words, offset, flags, - pwordexp); + pwordexp, ifs, ifs_white); case '[': (*offset) += 2; @@ -1329,14 +1435,14 @@ parse_dollars (char **word, size_t *word_length, size_t *max_length, default: ++(*offset); /* parse_param needs to know if "{" is there */ return parse_param (word, word_length, max_length, words, offset, flags, - pwordexp); + pwordexp, ifs, ifs_white); } } static int parse_backtick (char **word, size_t *word_length, size_t *max_length, const char *words, size_t *offset, int flags, - wordexp_t *pwordexp) + wordexp_t *pwordexp, const char *ifs, const char *ifs_white) { /* We are poised just after "`" */ int error; @@ -1352,7 +1458,7 @@ parse_backtick (char **word, size_t *word_length, size_t *max_length, case '`': /* Go -- give the script to the shell */ error = exec_comm (comm, word, word_length, max_length, flags, - pwordexp); + pwordexp, ifs, ifs_white); free (comm); return error; @@ -1414,8 +1520,8 @@ parse_dquote (char **word, size_t *word_length, size_t *max_length, case '$': error = parse_dollars (word, word_length, max_length, words, offset, - flags, NULL); - /* The NULL here is to tell parse_dollars not to + flags, NULL, NULL, NULL); + /* The first NULL here is to tell parse_dollars not to * split the fields. */ if (error) @@ -1429,8 +1535,8 @@ parse_dquote (char **word, size_t *word_length, size_t *max_length, ++(*offset); error = parse_backtick (word, word_length, max_length, words, - offset, flags, NULL); - /* The NULL here is to tell parse_backtick not to + offset, flags, NULL, NULL, NULL); + /* The first NULL here is to tell parse_backtick not to * split the fields. */ if (error) @@ -1527,25 +1633,33 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags) ifs = getenv ("IFS"); if (!ifs) - ifs = strcpy (ifs_white, " \t\n"); + /* NULL IFS means no field-splitting is to be performed */ + ifs = strcpy (ifs_white, ""); else { char *ifsch = ifs; char *whch = ifs_white; + /* Start off with no whitespace IFS characters */ + ifs_white[0] = '\0'; + while (*ifsch != '\0') - if ((*ifsch == ' ') || (*ifsch == '\t') || (*ifsch == '\n')) - { - /* White space IFS. See first whether it is already in our - collection. */ - char *runp = ifs_white; + { + if ((*ifsch == ' ') || (*ifsch == '\t') || (*ifsch == '\n')) + { + /* Whitespace IFS. See first whether it is already in our + collection. */ + char *runp = ifs_white; - while (runp < whch && *runp != '\0' && *runp != *ifsch) - ++runp; + while (runp < whch && *runp != '\0' && *runp != *ifsch) + ++runp; - if (runp == whch) - *whch++ = *ifsch; - } + if (runp == whch) + *whch++ = *ifsch; + } + + ifsch++; + } *whch = '\0'; } @@ -1578,7 +1692,7 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags) case '$': error = parse_dollars (&word, &word_length, &max_length, words, - &words_offset, flags, pwordexp); + &words_offset, flags, pwordexp, ifs, ifs_white); if (error) goto do_error; @@ -1591,7 +1705,8 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags) ++words_offset; error = parse_backtick (&word, &word_length, &max_length, words, - &words_offset, flags, pwordexp); + &words_offset, flags, pwordexp, ifs, + ifs_white); if (error) goto do_error; @@ -1630,7 +1745,7 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags) case '*': case '{': error = parse_glob (&word, &word_length, &max_length, words, - &words_offset, flags, pwordexp, ifs); + &words_offset, flags, pwordexp, ifs, ifs_white); if (error) goto do_error; @@ -1670,6 +1785,7 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags) word = NULL; word_length = 0; + max_length = 0; break; } diff --git a/resource/sys/resource.h b/resource/sys/resource.h index 488612f..1599f05 100644 --- a/resource/sys/resource.h +++ b/resource/sys/resource.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1994, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1994, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,9 +24,6 @@ /* Get the system-dependent definitions of structures and bit values. */ #include <bits/resource.h> -/* Get the definitions for the `ulimit' function. */ -#include <ulimit.h> - __BEGIN_DECLS /* Put the soft and hard limits for RESOURCE in *RLIMITS. diff --git a/shadow/fgetspent_r.c b/shadow/fgetspent_r.c index 8c4638d..fafa89a 100644 --- a/shadow/fgetspent_r.c +++ b/shadow/fgetspent_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -41,12 +41,18 @@ __fgetspent_r (FILE *stream, struct spwd *resbuf, char *buffer, size_t buflen, do { + buffer[buflen] = '\xff'; p = fgets (buffer, buflen, stream); - if (p == NULL) + if (p == NULL && feof (stream)) { *result = NULL; return errno; } + if (p == NULL || buffer[buflen] != '\xff') + { + *result = NULL; + return errno = ERANGE; + } /* Skip leading blanks. */ while (isspace (*p)) diff --git a/signal/Makefile b/signal/Makefile index 29aeea5..0642f75 100644 --- a/signal/Makefile +++ b/signal/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. +# Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -33,7 +33,8 @@ routines := signal raise killpg \ sigreturn \ siggetmask sysv_signal \ sigisempty sigandset sigorset \ - allocrtsig sigtimedwait sigwaitinfo sigqueue + allocrtsig sigtimedwait sigwaitinfo sigqueue \ + sighold sigrelse sigignore sigset tests := tst-signal diff --git a/signal/sighold.c b/signal/sighold.c new file mode 100644 index 0000000..d2cb537 --- /dev/null +++ b/signal/sighold.c @@ -0,0 +1,39 @@ +/* Add SIG to the calling process' signal mask. + Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <signal.h> + +int +sighold (sig) + int sig; +{ + sigset_t set; + + /* Retrieve current signal set. */ + if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0) + return -1; + + /* Add the specified signal. */ + if (sigaddset (&set, sig) < 0) + return -1; + + /* Set the new mask. */ + return __sigprocmask (SIG_SETMASK, &set, NULL); +} diff --git a/signal/signal.h b/signal/signal.h index 589b870..864a49b 100644 --- a/signal/signal.h +++ b/signal/signal.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,94,95,96,97,98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -345,6 +345,23 @@ extern int sigaltstack __P ((__const struct sigaltstack *__ss, #endif /* signal.h included and use BSD or X/Open Unix. */ +#if defined _SIGNAL_H && defined __USE_UNIX98 +/* Simplified interface for signal management. */ + +/* Add SIG to the calling process' signal mask. */ +extern int sighold __P ((int __sig)); + +/* Remove SIG from the calling process' signal mask. */ +extern int sigrelse __P ((int __sig)); + +/* Set the disposition of SIG to SIG_IGN. */ +extern int sigignore __P ((int __sig)); + +/* Set the disposition of SIG. */ +extern __sighandler_t sigset __P ((int __sig, __sighandler_t __disp)); +#endif + + /* The following functions are used internally in the C library and in other code which need deep insights. */ diff --git a/signal/sigrelse.c b/signal/sigrelse.c new file mode 100644 index 0000000..44e1001 --- /dev/null +++ b/signal/sigrelse.c @@ -0,0 +1,39 @@ +/* Remove SIG from the calling process' signal mask. + Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <signal.h> + +int +sigrelse (sig) + int sig; +{ + sigset_t set; + + /* Retrieve current signal set. */ + if (sigprocmask (SIG_SETMASK, NULL, &set) < 0) + return -1; + + /* Remove the specified signal. */ + if (sigdelset (&set, sig) < 0) + return -1; + + /* Set the new mask. */ + return sigprocmask (SIG_SETMASK, &set, NULL); +} diff --git a/stdlib/Makefile b/stdlib/Makefile index 2d297e5..99236c5 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. +# Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -46,7 +46,8 @@ routines := \ system canonicalize \ a64l l64a \ rpmatch strfmon strfmon_l getsubopt xpg_basename fmtmsg \ - strtoimax strtoumax wcstoimax wcstoumax + strtoimax strtoumax wcstoimax wcstoumax \ + getcontext setcontext makecontext swapcontext distribute := exit.h grouping.h abort-instr.h tests := tst-strtol tst-strtod testmb testrand testsort testdiv \ diff --git a/stdlib/ucontext.h b/stdlib/ucontext.h index 2fd6576..d99e95e 100644 --- a/stdlib/ucontext.h +++ b/stdlib/ucontext.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1997 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -32,11 +32,11 @@ __BEGIN_DECLS extern int getcontext __P ((ucontext_t *__ucp)); /* Set user context from information of variable pointed to by UCP. */ -extern int setcontext __P ((ucontext_t *__ucp)); +extern int setcontext __P ((__const ucontext_t *__ucp)); /* Save current context in context variable pointed to by OUCP and set context from variable pointed to by UCP. */ -extern int swapcontext __P ((ucontext_t *__oucp, ucontext_t *__ucp)); +extern int swapcontext __P ((ucontext_t *__oucp, __const ucontext_t *__ucp)); /* Manipulate user context UCP to continue with calling functions FUNC and the ARGC-1 parameters following ARGC when the context is used @@ -44,7 +44,7 @@ extern int swapcontext __P ((ucontext_t *__oucp, ucontext_t *__ucp)); We cannot say anything about the parameters FUNC takes; `void' is as good as any other choice. */ -extern void makecontext __P ((ucontext_t *__ucp, void (*__func) __P ((void)), +extern void makecontext __P ((ucontext_t *__ucp, void (*__func) (void), int __argc, ...)); __END_DECLS diff --git a/streams/Makefile b/streams/Makefile new file mode 100644 index 0000000..c4c1190 --- /dev/null +++ b/streams/Makefile @@ -0,0 +1,27 @@ +# Copyright (C) 1998 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If +# not, write to the Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# +# Makefile for streams. +# +subdir := streams + +headers = stropts.h bits/stropts.h +routines = isastream getmsg getpmsg putmsg putpmsg fattach fdetach + +include ../Rules diff --git a/streams/stropts.h b/streams/stropts.h new file mode 100644 index 0000000..52d0a04 --- /dev/null +++ b/streams/stropts.h @@ -0,0 +1,67 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _STROPTS_H +#define _STROPTS_H 1 + +#include <features.h> +#include <bits/types.h> + +/* Get system specific contants. */ +#include <bits/stropts.h> + + +__BEGIN_DECLS + +/* Test whether FILDES is associated with a STREAM-based file. */ +extern int isastream __P ((int __fildes)); + +/* Receive next message from a STREAMS file. */ +extern int getmsg __P ((int __fildes, struct strbuf *__ctlptr, + struct strbuf *__dataptr, int *__flagsp)); + +/* Receive next message from a STREAMS file, with *FLAGSP allowing to + control which message. */ +extern int getpmsg __P ((int __fildes, struct strbuf *__ctlptr, + struct strbuf *__dataptr, int *__bandp, + int *__flagsp)); + +/* Perform the I/O control operation specified by REQUEST on FD. + One argument may follow; its presence and type depend on REQUEST. + Return value depends on REQUEST. Usually -1 indicates error. */ +extern int ioctl __P ((int __fd, unsigned long int __request, ...)); + +/* Send a message on a STREAM. */ +extern int putmsg __P ((int __fildes, __const struct strbuf *__ctlptr, + __const struct strbuf *__dataptr, int __flags)); + +/* Send a message on a STREAM to the BAND. */ +extern int putpmsg __P ((int __fildes, __const struct strbuf *__ctlptr, + __const struct strbuf *__dataptr, int __band, + int __flags)); + +/* Attach a STREAMS-based file descriptor FILDES to a file PATH in the + file system name space. */ +extern int fattach __P ((int __fildes, __const char *__path)); + +/* Detach a name PATH from a STREAMS-based file descriptor. */ +extern int fdetach __P ((__const char *__path)); + +__END_DECLS + +#endif /* stropts.h */ diff --git a/string/strerror_r.c b/string/strerror_r.c index 6a43a55..fc96744 100644 --- a/string/strerror_r.c +++ b/string/strerror_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1991, 93, 94, 95, 96, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,8 +21,8 @@ extern char *_strerror_internal __P ((int, char *, size_t)); -/* Return a string describing the errno code in ERRNUM. At most BUFLEN - characters of the result will be placed in STRERRBUF. */ +/* Return a string describing the errno code in ERRNUM. If a temporary + buffer is required, at most BUFLEN bytes of BUF will be used. */ char * __strerror_r (int errnum, char *buf, size_t buflen) { diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h index cd4f86a..e42ed3d 100644 --- a/sysdeps/alpha/dl-machine.h +++ b/sysdeps/alpha/dl-machine.h @@ -1,5 +1,5 @@ /* Machine-dependent ELF dynamic relocation inline functions. Alpha version. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Richard Henderson <rth@tamu.edu>. @@ -205,7 +205,9 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) #else #define ELF_MACHINE_RUNTIME_TRAMPOLINE \ TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup, imb); \ - strong_alias (_dl_runtime_resolve, _dl_runtime_profile, #nop); + extern void _dl_runtime_resolve (void); \ + extern void _dl_runtime_profile (void); \ + strong_alias (_dl_runtime_resolve, _dl_runtime_profile); #endif /* Initial entry point code for the dynamic linker. diff --git a/sysdeps/generic/bits/stropts.h b/sysdeps/generic/bits/stropts.h new file mode 100644 index 0000000..026df21 --- /dev/null +++ b/sysdeps/generic/bits/stropts.h @@ -0,0 +1,211 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _BITS_STROPTS_H +#define _BITS_STROPTS_H 1 + +#include <bits/types.h> + +/* Macros used as `request' argument to `ioctl'. */ +#define I_PUSH 1 /* Push STREAMS module onto top of the current + STREAM, just below the STREAM head. */ +#define I_POP 2 /* Remove STREAMS module from just below the + STREAM head. */ +#define I_LOOK 3 /* Retrieve the name of the module just below + the STREAM head and place it in a character + string. */ +#define I_FLUSH 4 /* Flush all input and/or output. */ +#define I_FLUSHBAND 5 /* Flush only band specified. */ +#define I_SETSIG 6 /* Inform the STREAM head that the process + wants the SIGPOLL signal issued. */ +#define I_GETSIG 7 /* Return the events for which the calling + process is currently registered to be sent + a SIGPOLL signal. */ +#define I_FIND 8 /* Compares the names of all modules currently + present in the STREAM to the name pointed to + by `arg'. */ +#define I_PEEK 9 /* Allows a process to retrieve the information + in the first message on the STREAM head read + queue without taking the message off the + queue. */ +#define I_SRDOPT 10 /* Sets the read mode. */ +#define I_GRDOPT 11 /* Returns the current read mode setting. */ +#define I_NREAD 12 /* Counts the number of data bytes in the data + block in the first message. */ +#define I_FDINSERT 13 /* Create a message from the specified + buffer(s), adds information about another + STREAM, and send the message downstream. */ +#define I_STR 14 /* Construct an internal STREAMS `ioctl' + message and send that message downstream. */ +#define I_SWROPT 15 /* Set the write mode. */ +#define I_GWRSET 16 /* Return the current write mode setting. */ +#define I_SENDFD 17 /* Requests the STREAM associated with `fildes' + to send a message, containing a file + pointer, to the STREAM head at the other end + of a STREAMS pipe. */ +#define I_RECVFD 18 /* Retrieve the file descriptor associated with + the message sent by an I_SENDFD `ioctl' + over a STREAMS pipe. */ +#define I_LIST 19 /* List all the module names on the STREAM, up + to and including the topmost driver name. */ +#define I_ATMARK 20 /* See if the current message on the STREAM + head read queue is "marked" by some module + downstream. */ +#define I_CKBAND 21 /* Check if the message of a given priority + band exists on the STREAM head read + queue. */ +#define I_GETBAND 22 /* Return the priority band of the first + message on the STREAM head read queue. */ +#define I_CANPUT 23 /* Check if a certain band is writable. */ +#define I_SETCLTIME 24 /* Set the time the STREAM head will delay when + a STREAM is closing and there is data on + the write queues. */ +#define I_LINK 25 /* Connect two STREAMs. */ +#define I_UNLINK 26 /* Disconnects the two STREAMs. */ +#define I_PLINK 27 /* Connect two STREAMs with a persistent + link. */ +#define I_PUNLINK 28 /* Disconnect the two STREAMs that were + connected with a persistent link. */ + + +/* Used in `I_LOOK' request. */ +#define FMNAMESZ 255 + +/* Flush options. */ +#define FLUSHR 1 /* Flush read queues. */ +#define FLUSHW 2 /* Flush write queues. */ +#define FLUSHRW 3 /* Flush read and write queues. */ + +/* Possible arguments for `I_SETSIG'. */ +#define S_RDNORM 0x0001 /* A normal message has arrived. */ +#define S_RDBAND 0x0002 /* A message with a non-zero priority has + arrived. */ +#define S_INPUT 0x0004 /* A message, other than a high-priority + message, has arrived. */ +#define S_HIPRI 0x0008 /* A high-priority message is present. */ +#define S_OUTPUT 0x0010 /* The write queue for normal data is no longer + full. */ +#define S_WRNORM S_OUTPUT +#define S_WRBAND 0x0020 /* The write queue for a non-zero priority + band is no longer full. */ +#define S_MSG 0x0040 /* A STREAMS signal message that contains the + SIGPOLL signal reaches the front of the + STREAM head read queue. */ +#define S_ERROR 0x0080 /* Notification of an error condition. */ +#define S_HANGUP 0x0100 /* Notification of a hangup. */ +#define S_BANDURG 0x0200 /* When used in conjunction with S_RDBAND, + SIGURG is generated instead of SIGPOLL when + a priority message reaches the front of the + STREAM head read queue. */ + +/* Option for `I_PEEK'. */ +#define RS_HIPRI 1 /* Only look for high-priority messages. */ + +/* Options for `I_SRDOPT'. */ +#define RDNORM 1 /* Byte-STREAM mode, the default. */ +#define RMSGD 2 /* Message-discard mode. */ +#define RMSGN 3 /* Message-nondiscard mode. */ +#define RPROTNORM 4 /* Fail `read' with EBADMSG if a message + containing a control part is at the front + of the STREAM head read queue. */ +#define RPROTDAT 5 /* Deliver the control part of a message as + data. */ +#define RPROTDIS 6 /* Discard the control part of a message, + delivering any data part. */ + +/* Possible mode for `I_SWROPT'. */ +#define SNDZERO 1 /* Send a zero-length message downstream when a + `write' of 0 bytes occurs. */ + +/* Arguments for `I_ATMARK'. */ +#define ANYMARK 1 /* Check if the message is marked. */ +#define LASTMARK 2 /* Check if the message is the last one marked + on the queue. */ + +/* Argument for `I_UNLINK'. */ +#define MUXID_ALL 1 /* Unlink all STREAMs linked to the STREAM + associated with `fildes'. */ + + +/* Macros for `getmsg', `getpmsg', `putmsg' and `putpmsg'. */ +#define MSG_ANY 1 /* Receive any message. */ +#define MSG_BAND 2 /* Receive message from specified band. */ +#define MSG_HIPRI 3 /* Send/receive high priority message. */ +#define MORECTL 4 /* More control information is left in + message. */ +#define MOREDATA 5 /* More data is left in message. */ + + +/* Structure used for the I_FLUSHBAND ioctl on streams. */ +struct bandinfo + { + unsigned char bi_pri; + int bi_flag; + }; + +struct strbuf + { + int maxlen; /* Maximum buffer length. */ + int len; /* Length of data. */ + char *buf; /* Pointer to buffer. */ + }; + +struct strpeek + { + struct strbuf ctlbuf; + struct strbuf databuf; + __t_uscalar_t flags; + }; + +struct strfdinsert + { + struct strbuf ctlbuf; + struct strbuf databuf; + __t_uscalar_t flags; + int fildes; + int offset; + }; + +struct strioctl + { + int ic_cmd; + int ic_timout; + int ic_len; + char *ic_dp; + }; + +struct strrecvfd + { + int fd; + __uid_t uid; + __gid_t gid; + }; + + +struct str_mlist + { + char l_name[FMNAMESZ + 1]; + }; + +struct str_list + { + int sl_nmods; + struct str_mlist *sl_modlist; + }; + +#endif /* bits/stropts.h */ diff --git a/sysdeps/generic/bits/types.h b/sysdeps/generic/bits/types.h index 5315a09..b985a3a 100644 --- a/sysdeps/generic/bits/types.h +++ b/sysdeps/generic/bits/types.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -111,4 +111,8 @@ typedef __u_quad_t __fsblkcnt64_t; typedef unsigned long int __fsfilcnt_t; typedef __u_quad_t __fsfilcnt64_t; +/* Used in XTI. */ +typedef int __t_scalar_t; +typedef unsigned int __t_uscalar_t; + #endif /* bits/types.h */ diff --git a/sysdeps/generic/fattach.c b/sysdeps/generic/fattach.c new file mode 100644 index 0000000..2c9abab --- /dev/null +++ b/sysdeps/generic/fattach.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stropts.h> + +int +fattach (fildes, path) + int fildes; + const char *path; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (fattach) +#include <stub-tag.h> diff --git a/sysdeps/generic/fdetach.c b/sysdeps/generic/fdetach.c new file mode 100644 index 0000000..2a15d57 --- /dev/null +++ b/sysdeps/generic/fdetach.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stropts.h> + +int +fdetach (path) + const char *path; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (fdetach) +#include <stub-tag.h> diff --git a/sysdeps/generic/getcontext.c b/sysdeps/generic/getcontext.c new file mode 100644 index 0000000..ce59b49 --- /dev/null +++ b/sysdeps/generic/getcontext.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <ucontext.h> + +int +getcontext (ucp) + ucontext_t *ucp; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (getcontext) +#include <stub-tag.h> diff --git a/sysdeps/generic/getmsg.c b/sysdeps/generic/getmsg.c new file mode 100644 index 0000000..119b50c --- /dev/null +++ b/sysdeps/generic/getmsg.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stropts.h> + +int +getmsg (fildes, ctlptr, dataptr, flagsp) + int fildes; + struct strbuf *ctlptr; + struct strbuf *dataptr; + int *flagsp; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (getmsg) +#include <stub-tag.h> diff --git a/sysdeps/generic/getpmsg.c b/sysdeps/generic/getpmsg.c new file mode 100644 index 0000000..c35c03c --- /dev/null +++ b/sysdeps/generic/getpmsg.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stropts.h> + +int +getpmsg (fildes, ctlptr, dataptr, bandp, flagsp) + int fildes; + struct strbuf *ctlptr; + struct strbuf *dataptr; + int *bandp; + int *flagsp; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (getpmsg) +#include <stub-tag.h> diff --git a/sysdeps/generic/isastream.c b/sysdeps/generic/isastream.c new file mode 100644 index 0000000..4e59580 --- /dev/null +++ b/sysdeps/generic/isastream.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stropts.h> + +int +isastream (fildes) + int fildes; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (isastream) +#include <stub-tag.h> diff --git a/sysdeps/generic/makecontext.c b/sysdeps/generic/makecontext.c new file mode 100644 index 0000000..16ed5b0 --- /dev/null +++ b/sysdeps/generic/makecontext.c @@ -0,0 +1,30 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <ucontext.h> + +void +makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) +{ + __set_errno (ENOSYS); +} + + +stub_warning (makecontext) +#include <stub-tag.h> diff --git a/sysdeps/generic/putmsg.c b/sysdeps/generic/putmsg.c new file mode 100644 index 0000000..3d4f0d1 --- /dev/null +++ b/sysdeps/generic/putmsg.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stropts.h> + +int +putmsg (fildes, ctlptr, dataptr, flags) + int fildes; + const struct strbuf *ctlptr; + const struct strbuf *dataptr; + int flags; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (putmsg) +#include <stub-tag.h> diff --git a/sysdeps/generic/putpmsg.c b/sysdeps/generic/putpmsg.c new file mode 100644 index 0000000..767f39b --- /dev/null +++ b/sysdeps/generic/putpmsg.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stropts.h> + +int +putpmsg (fildes, ctlptr, dataptr, band, flags) + int fildes; + const struct strbuf *ctlptr; + const struct strbuf *dataptr; + int band; + int flags; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (putpmsg) +#include <stub-tag.h> diff --git a/sysdeps/generic/setcontext.c b/sysdeps/generic/setcontext.c new file mode 100644 index 0000000..d6965fa --- /dev/null +++ b/sysdeps/generic/setcontext.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <ucontext.h> + +int +setcontext (ucp) + const ucontext_t *ucp; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (setcontext) +#include <stub-tag.h> diff --git a/sysdeps/generic/sigignore.c b/sysdeps/generic/sigignore.c new file mode 100644 index 0000000..04fe9569 --- /dev/null +++ b/sysdeps/generic/sigignore.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <signal.h> + + +/* Set the disposition for SIG to SIG_IGN. */ +int +sigignore (sig) + int sig; +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (sigignore) +#include <stub-tag.h> diff --git a/sysdeps/generic/sigset.c b/sysdeps/generic/sigset.c new file mode 100644 index 0000000..ed2d2dd --- /dev/null +++ b/sysdeps/generic/sigset.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <signal.h> + + +/* Set the disposition for SIG. */ +__sighandler_t +sigset (sig, disp) + int sig; + __sighandler_t disp; +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (sigset) +#include <stub-tag.h> diff --git a/sysdeps/generic/swapcontext.c b/sysdeps/generic/swapcontext.c new file mode 100644 index 0000000..6a414d7 --- /dev/null +++ b/sysdeps/generic/swapcontext.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <ucontext.h> + +int +swapcontext (oucp, ucp) + ucontext_t *oucp; + const ucontext_t *ucp; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (swapcontext) +#include <stub-tag.h> diff --git a/sysdeps/libm-ieee754/s_modfl.c b/sysdeps/libm-ieee754/s_modfl.c index 324fe9f..5f2b4b5 100644 --- a/sysdeps/libm-ieee754/s_modfl.c +++ b/sysdeps/libm-ieee754/s_modfl.c @@ -53,7 +53,7 @@ static long double one = 1.0; SET_LDOUBLE_WORDS(*iptr,se&0x8000,0,0); /* *iptr = +-0 */ return x; } else { - i = (0xffffffff)>>j0; + i = (0x7fffffff)>>j0; if(((i0&i)|i1)==0) { /* x is integral */ *iptr = x; SET_LDOUBLE_WORDS(x,se&0x8000,0,0); /* return +-0 */ @@ -71,7 +71,7 @@ static long double one = 1.0; SET_LDOUBLE_WORDS(x,se&0x8000,0,0); /* return +-0 */ return x; } else { /* fraction part in low x */ - i = ((u_int32_t)(0xffffffff))>>(j0-20); + i = ((u_int32_t)(0x7fffffff))>>(j0-32); if((i1&i)==0) { /* x is integral */ *iptr = x; INSERT_WORDS(x,se&0x8000,0); /* return +-0 */ diff --git a/sysdeps/mach/_strerror.c b/sysdeps/mach/_strerror.c index 4db1e74..7bca7e8 100644 --- a/sysdeps/mach/_strerror.c +++ b/sysdeps/mach/_strerror.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -20,7 +20,8 @@ #include <string.h> #include <mach/error.h> #include <errorlib.h> -#include "../stdio-common/_itoa.h" +#include <sys/param.h> +#include <stdio-common/_itoa.h> /* It is critical here that we always use the `dcgettext' function for the message translation. Since <libintl.h> only defines the macro @@ -49,12 +50,27 @@ _strerror_internal (int errnum, char *buf, size_t buflen) if (system > err_max_system || ! __mach_error_systems[system].bad_sub) { + /* Buffer we use to print the number in. For a maximum size for + `int' of 8 bytes we never need more than 20 digits. */ + char numbuf[21]; const char *unk = _("Error in unknown error system: "); const size_t unklen = strlen (unk); - char *p = buf + buflen; - *--p = '\0'; - p = _itoa (errnum, p, 16, 1); - return memcpy (p - unklen, unk, unklen); + char *p, *q; + + numbuf[20] = '\0'; + p = _itoa_word (errnum, &numbuf[20], 16, 1); + + /* Now construct the result while taking care for the destination + buffer size. */ + q = __mempcpy (buf, unk, MIN (unklen, buflen)); + if (unklen < buflen) + __stpncpy (q, p, buflen - unklen); + + /* Terminate the string in any case. */ + if (buflen > 0) + buf[buflen - 1] = '\0'; + + return buf; } es = &__mach_error_systems[system]; @@ -64,15 +80,37 @@ _strerror_internal (int errnum, char *buf, size_t buflen) if (code >= es->subsystem[sub].max_code) { + /* Buffer we use to print the number in. For a maximum size for + `int' of 8 bytes we never need more than 20 digits. */ + char numbuf[21]; const char *unk = _("Unknown error "); const size_t unklen = strlen (unk); - char *p = buf + buflen; + char *p, *q; size_t len = strlen (es->subsystem[sub].subsys_name); - *--p = '\0'; - p = _itoa (errnum, p, 16, 1); - *p-- = ' '; - p = memcpy (p - len, es->subsystem[sub].subsys_name, len); - return memcpy (p - unklen, unk, unklen); + + numbuf[20] = '\0'; + p = _itoa_word (errnum, &numbuf[20], 10, 0); + + /* Now construct the result while taking care for the destination + buffer size. */ + q = __mempcpy (buf, unk, MIN (unklen, buflen)); + if (unklen < buflen) + { + q = __mempcpy (q, es->subsystem[sub].subsys_name, + MIN (len, buflen - unklen)); + if (unklen + len < buflen) + { + *q++ = ' '; + if (unklen + len + 1 < buflen) + __stpncpy (q, p, buflen - unklen - len - 1); + } + } + + /* Terminate the string in any case. */ + if (buflen > 0) + buf[buflen - 1] = '\0'; + + return buf; } return (char *) _(es->subsystem[sub].codes[code]); diff --git a/sysdeps/posix/sigignore.c b/sysdeps/posix/sigignore.c new file mode 100644 index 0000000..f24aca7 --- /dev/null +++ b/sysdeps/posix/sigignore.c @@ -0,0 +1,36 @@ +/* Set the disposition of SIG to SIG_IGN. + Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <signal.h> + +int +sigignore (sig) + int sig; +{ + struct sigaction act; + + act.sa_handler = SIG_IGN; + if (__sigemptyset (&act.sa_mask) < 0) + return -1; + act.sa_flags = 0; + + return __sigaction (sig, &act, NULL); +} diff --git a/sysdeps/posix/sigset.c b/sysdeps/posix/sigset.c new file mode 100644 index 0000000..4bd3bf3 --- /dev/null +++ b/sysdeps/posix/sigset.c @@ -0,0 +1,66 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <signal.h> + + +/* Set the disposition for SIG. */ +__sighandler_t +sigset (sig, disp) + int sig; + __sighandler_t disp; +{ + struct sigaction act, oact; + + /* Handle SIG_HOLD first. */ + if (disp == SIG_HOLD) + { + sigset_t set; + + /* Retrieve current signal set. */ + if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0) + return SIG_ERR; + + /* Add the specified signal. */ + if (sigaddset (&set, sig) < 0) + return SIG_ERR; + + /* Set the new mask. */ + if (__sigprocmask (SIG_SETMASK, &set, NULL) < 0) + return SIG_ERR; + + return SIG_HOLD; + } + + /* Check signal extents to protect __sigismember. */ + if (disp == SIG_ERR || sig < 1 || sig >= NSIG) + { + __set_errno (EINVAL); + return SIG_ERR; + } + + act.sa_handler = disp; + if (__sigemptyset (&act.sa_mask) < 0) + return SIG_ERR; + act.sa_flags = 0; + if (__sigaction (sig, &act, &oact) < 0) + return SIG_ERR; + + return oact.sa_handler; +} diff --git a/sysdeps/posix/ttyname.c b/sysdeps/posix/ttyname.c index a4e4f30..6a046ea 100644 --- a/sysdeps/posix/ttyname.c +++ b/sysdeps/posix/ttyname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 96, 97, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,36 +28,34 @@ char *__ttyname = NULL; -/* Return the pathname of the terminal FD is open on, or NULL on errors. - The returned storage is good only until the next call to this function. */ -char * -ttyname (fd) +static char * getttyname __P ((int fd, dev_t mydev, ino_t myino, + int save, int *dostat)) internal_function; + +static char * +internal_function +getttyname (fd, mydev, myino, save, dostat) int fd; + dev_t mydev; + ino_t myino; + int save; + int *dostat; { static const char dev[] = "/dev"; static char *name; static size_t namelen = 0; struct stat st; - dev_t mydev; - ino_t myino; DIR *dirstream; struct dirent *d; - int save = errno; - - if (!__isatty (fd)) - return NULL; - - if (fstat (fd, &st) < 0) - return NULL; - mydev = st.st_dev; - myino = st.st_ino; dirstream = opendir (dev); if (dirstream == NULL) - return NULL; + { + *dostat = -1; + return NULL; + } while ((d = readdir (dirstream)) != NULL) - if ((ino_t) d->d_fileno == myino) + if ((ino_t) d->d_fileno == myino || *dostat) { size_t dlen = _D_ALLOC_NAMLEN (d); if (sizeof (dev) + dlen > namelen) @@ -67,6 +65,7 @@ ttyname (fd) name = malloc (namelen); if (! name) { + *dostat = -1; /* Perhaps it helps to free the directory stream buffer. */ (void) closedir (dirstream); return NULL; @@ -74,7 +73,13 @@ ttyname (fd) *((char *) __mempcpy (name, dev, sizeof (dev) - 1)) = '/'; } (void) __mempcpy (&name[sizeof (dev)], d->d_name, dlen); - if (stat (name, &st) == 0 && st.st_dev == mydev) + if (stat (name, &st) == 0 +#ifdef _STATBUF_ST_RDEV + && S_ISCHR (st.st_mode) && st.st_rdev == mydev +#else + && (ino_t) d->d_fileno == myino && st.st_dev == mydev +#endif + ) { (void) closedir (dirstream); __ttyname = name; @@ -87,3 +92,39 @@ ttyname (fd) __set_errno (save); return NULL; } + +/* Return the pathname of the terminal FD is open on, or NULL on errors. + The returned storage is good only until the next call to this function. */ +char * +ttyname (fd) + int fd; +{ + struct stat st; + int dostat = 0; + char *name; + int save = errno; + + if (!__isatty (fd)) + return NULL; + + if (fstat (fd, &st) < 0) + return NULL; + +#ifdef _STATBUF_ST_RDEV + name = getttyname (fd, st.st_rdev, st.st_ino, save, &dostat); +#else + name = getttyname (fd, st.st_dev, st.st_ino, save, &dostat); +#endif + + if (!name && dostat != -1) + { + dostat = 1; +#ifdef _STATBUF_ST_RDEV + name = getttyname (fd, st.st_rdev, st.st_ino, save, &dostat); +#else + name = getttyname (fd, st.st_dev, st.st_ino, save, &dostat); +#endif + } + + return name; +} diff --git a/sysdeps/posix/ttyname_r.c b/sysdeps/posix/ttyname_r.c index b3a15d1..ad747ad 100644 --- a/sysdeps/posix/ttyname_r.c +++ b/sysdeps/posix/ttyname_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 93, 95, 96, 97 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 95, 96, 97, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -30,58 +30,43 @@ # define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif -/* Store at most BUFLEN character of the pathname of the terminal FD is - open on in BUF. Return 0 on success, otherwise an error number. */ -int -__ttyname_r (fd, buf, buflen) +static const char dev[] = "/dev"; + +static int getttyname_r __P ((int fd, char *buf, size_t buflen, + dev_t mydev, ino_t myino, int save, + int *dostat)) internal_function; + +static int +internal_function +getttyname_r (fd, buf, buflen, mydev, myino, save, dostat) int fd; char *buf; size_t buflen; + dev_t mydev; + ino_t myino; + int save; + int *dostat; { - static const char dev[] = "/dev"; struct stat st; - dev_t mydev; - ino_t myino; DIR *dirstream; struct dirent *d; - int save = errno; - - /* Test for the absolute minimal size. This makes life easier inside - the loop. */ - if (buflen < (int) (sizeof (dev) + 1)) - { - __set_errno (ERANGE); - return ERANGE; - } - - if (!__isatty (fd)) - { - __set_errno (ENOTTY); - return ENOTTY; - } - - if (fstat (fd, &st) < 0) - return errno; - mydev = st.st_dev; - myino = st.st_ino; dirstream = opendir (dev); if (dirstream == NULL) - return errno; - - /* Prepare the result buffer. */ - memcpy (buf, dev, sizeof (dev) - 1); - buf[sizeof (dev) - 1] = '/'; - buflen -= sizeof (dev); + { + *dostat = -1; + return errno; + } while ((d = readdir (dirstream)) != NULL) - if ((ino_t) d->d_fileno == myino) + if ((ino_t) d->d_fileno == myino || *dostat) { char *cp; size_t needed = _D_EXACT_NAMLEN (d) + 1; if (needed > buflen) { + *dostat = -1; (void) closedir (dirstream); __set_errno (ERANGE); return ERANGE; @@ -90,7 +75,13 @@ __ttyname_r (fd, buf, buflen) cp = __stpncpy (&buf[sizeof (dev)], d->d_name, needed); cp[0] = '\0'; - if (stat (buf, &st) == 0 && st.st_dev == mydev) + if (stat (buf, &st) == 0 +#ifdef _STATBUF_ST_RDEV + && S_ISCHR (st.st_mode) && st.st_rdev == mydev +#else + && (ino_t) d->d_fileno == myino && st.st_dev == mydev +#endif + ) { (void) closedir (dirstream); __set_errno (save); @@ -104,4 +95,69 @@ __ttyname_r (fd, buf, buflen) refers to a TTY but no entry in /dev has this inode. */ return ENOTTY; } + +/* Store at most BUFLEN character of the pathname of the terminal FD is + open on in BUF. Return 0 on success, otherwise an error number. */ +int +__ttyname_r (fd, buf, buflen) + int fd; + char *buf; + size_t buflen; +{ + struct stat st; + int dostat = 0; + int save = errno; + int ret; + + /* Test for the absolute minimal size. This makes life easier inside + the loop. */ + if (!buf) + { + __set_errno (EINVAL); + return EINVAL; + } + + if (buflen < (int) (sizeof (dev) + 1)) + { + __set_errno (ERANGE); + return ERANGE; + } + + if (!__isatty (fd)) + { + __set_errno (ENOTTY); + return ENOTTY; + } + + if (fstat (fd, &st) < 0) + return errno; + + /* Prepare the result buffer. */ + memcpy (buf, dev, sizeof (dev) - 1); + buf[sizeof (dev) - 1] = '/'; + buflen -= sizeof (dev); + +#ifdef _STATBUF_ST_RDEV + ret = getttyname_r (fd, buf, buflen, st.st_rdev, st.st_ino, save, + &dostat); +#else + ret = getttyname_r (fd, buf, buflen, st.st_dev, st.st_ino, save, + &dostat); +#endif + + if (ret && dostat != -1) + { + dostat = 1; +#ifdef _STATBUF_ST_RDEV + ret = getttyname_r (fd, buf, buflen, st.st_rdev, st.st_ino, + save, &dostat); +#else + ret = getttyname_r (fd, buf, buflen, st.st_dev, st.st_ino, + save, &dostat); +#endif + } + + return ret; +} + weak_alias (__ttyname_r, ttyname_r) diff --git a/sysdeps/unix/inet/Subdirs b/sysdeps/unix/inet/Subdirs index 647ec6a..0dc102b 100644 --- a/sysdeps/unix/inet/Subdirs +++ b/sysdeps/unix/inet/Subdirs @@ -3,3 +3,4 @@ resolv hesiod sunrpc nis +streams diff --git a/sysdeps/unix/sysv/linux/alpha/bits/signum.h b/sysdeps/unix/sysv/linux/alpha/bits/signum.h index ac5c34c..6b1399e 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/signum.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/signum.h @@ -1,5 +1,5 @@ /* Signal number definitions. Linux/Alpha version. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,6 +24,10 @@ #define SIG_DFL ((__sighandler_t) 0) /* Default action. */ #define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */ +#ifdef __USE_UNIX98 +# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */ +#endif + /* * Linux/AXP has different signal numbers that Linux/i386: I'm trying * to make it OSF/1 binary compatible, at least for normal binaries. diff --git a/sysdeps/unix/sysv/linux/alpha/bits/stat.h b/sysdeps/unix/sysv/linux/alpha/bits/stat.h index 319ff96..cb4ab78 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/stat.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/stat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -84,7 +84,9 @@ struct stat64 }; #endif -#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */ +/* Tell code we have these members. */ +#define _STATBUF_ST_BLKSIZE +#define _STATBUF_ST_RDEV /* Encoding of the file mode. */ diff --git a/sysdeps/unix/sysv/linux/alpha/bits/types.h b/sysdeps/unix/sysv/linux/alpha/bits/types.h index 9033fdb..70b7d72 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/types.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/types.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -103,4 +103,8 @@ typedef struct __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS]; } __fd_set; +/* Used in XTI. */ +typedef int __t_scalar_t; +typedef unsigned int __t_uscalar_t; + #endif /* bits/types.h */ diff --git a/sysdeps/unix/sysv/linux/bits/signum.h b/sysdeps/unix/sysv/linux/bits/signum.h index f625f46..1054f9a 100644 --- a/sysdeps/unix/sysv/linux/bits/signum.h +++ b/sysdeps/unix/sysv/linux/bits/signum.h @@ -1,5 +1,5 @@ /* Signal number definitions. Linux version. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,6 +24,10 @@ #define SIG_DFL ((__sighandler_t) 0) /* Default action. */ #define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */ +#ifdef __USE_UNIX98 +# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */ +#endif + /* Signals. */ #define SIGHUP 1 /* Hangup (POSIX). */ diff --git a/sysdeps/unix/sysv/linux/bits/stat.h b/sysdeps/unix/sysv/linux/bits/stat.h index 18432fd..c175668 100644 --- a/sysdeps/unix/sysv/linux/bits/stat.h +++ b/sysdeps/unix/sysv/linux/bits/stat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -98,7 +98,9 @@ struct stat64 }; #endif -#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */ +/* Tell code we have these members. */ +#define _STATBUF_ST_BLKSIZE +#define _STATBUF_ST_RDEV /* Encoding of the file mode. */ diff --git a/sysdeps/unix/sysv/linux/bits/types.h b/sysdeps/unix/sysv/linux/bits/types.h index 723e0ff..68cbf8c 100644 --- a/sysdeps/unix/sysv/linux/bits/types.h +++ b/sysdeps/unix/sysv/linux/bits/types.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -127,4 +127,8 @@ typedef __u_long __ino64_t; /* Type of file sizes and offsets. */ typedef __loff_t __off64_t; +/* Used in XTI. */ +typedef int __t_scalar_t; +typedef unsigned int __t_uscalar_t; + #endif /* bits/types.h */ diff --git a/sysdeps/unix/sysv/linux/i386/sys/ucontext.h b/sysdeps/unix/sysv/linux/i386/sys/ucontext.h index ccc32b6..f8c8e26 100644 --- a/sysdeps/unix/sysv/linux/i386/sys/ucontext.h +++ b/sysdeps/unix/sysv/linux/i386/sys/ucontext.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1997 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -101,6 +101,7 @@ typedef struct ucontext stack_t uc_stack; mcontext_t uc_mcontext; __sigset_t uc_sigmask; + struct _fpstate __fpregs_mem; } ucontext_t; #endif /* sys/ucontext.h */ diff --git a/sysdeps/unix/sysv/linux/mips/bits/signum.h b/sysdeps/unix/sysv/linux/mips/bits/signum.h index 5254a2b..c30abe3 100644 --- a/sysdeps/unix/sysv/linux/mips/bits/signum.h +++ b/sysdeps/unix/sysv/linux/mips/bits/signum.h @@ -1,5 +1,5 @@ /* Signal number definitions. Linux version. - Copyright (C) 1995, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,6 +24,10 @@ #define __need_signums #include <asm/signal.h> +#ifdef __USE_UNIX98 +# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */ +#endif + #endif /* <signal.h> included. */ #define __need__nsig diff --git a/sysdeps/unix/sysv/linux/mips/bits/stat.h b/sysdeps/unix/sysv/linux/mips/bits/stat.h index cd586d4..3bcf1a9 100644 --- a/sysdeps/unix/sysv/linux/mips/bits/stat.h +++ b/sysdeps/unix/sysv/linux/mips/bits/stat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -112,7 +112,9 @@ struct stat64 }; #endif -#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */ +/* Tell code we have these members. */ +#define _STATBUF_ST_BLKSIZE +#define _STATBUF_ST_RDEV /* Encoding of the file mode. */ diff --git a/sysdeps/unix/sysv/linux/mips/bits/types.h b/sysdeps/unix/sysv/linux/mips/bits/types.h index 56075d1..1d72de0 100644 --- a/sysdeps/unix/sysv/linux/mips/bits/types.h +++ b/sysdeps/unix/sysv/linux/mips/bits/types.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -127,4 +127,8 @@ typedef __u_long __ino64_t; /* Type of file sizes and offsets. */ typedef __loff_t __off64_t; +/* Used in XTI. */ +typedef int __t_scalar_t; +typedef unsigned int __t_uscalar_t; + #endif /* bits/types.h */ diff --git a/sysdeps/unix/sysv/linux/sparc/bits/signum.h b/sysdeps/unix/sysv/linux/sparc/bits/signum.h index 3437c16..fae3826 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/signum.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/signum.h @@ -1,5 +1,5 @@ /* Signal number definitions. Linux/SPARC version. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,6 +24,10 @@ #define SIG_DFL ((__sighandler_t) 0) /* Default action. */ #define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */ +#ifdef __USE_UNIX98 +# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */ +#endif + /* * Linux/SPARC has different signal numbers that Linux/i386: I'm trying * to make it OSF/1 binary compatible, at least for normal binaries. diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/Makefile b/sysdeps/unix/sysv/linux/sparc/sparc64/Makefile deleted file mode 100644 index c4d8322..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -ifeq ($(subdir),misc) -sysdep_headers += ucontext.h -sysdep_routines += getcontext setcontext -endif diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/bits/types.h b/sysdeps/unix/sysv/linux/sparc/sparc64/bits/types.h index 5ee6c0e..5c77f9a 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/bits/types.h +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/bits/types.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -113,4 +113,8 @@ typedef __u_quad_t __fsblkcnt64_t; typedef unsigned long int __fsfilcnt_t; typedef __u_quad_t __fsfilcnt64_t; +/* Used in XTI. */ +typedef int __t_scalar_t; +typedef unsigned int __t_uscalar_t; + #endif /* bits/types.h */ diff --git a/sysdeps/unix/sysv/linux/sys/mman.h b/sysdeps/unix/sysv/linux/sys/mman.h index 70f95d0..92cc3d2 100644 --- a/sysdeps/unix/sysv/linux/sys/mman.h +++ b/sysdeps/unix/sysv/linux/sys/mman.h @@ -1,5 +1,5 @@ /* Definitions for POSIX-style memory management. Linux version. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -91,10 +91,10 @@ extern int munlockall __P ((void)); /* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to be memory resident. */ -extern int mlock __P ((__ptr_t __addr, size_t __len)); +extern int mlock __P ((__const __ptr_t __addr, size_t __len)); /* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN). */ -extern int munlock __P ((__ptr_t __addr, size_t __len)); +extern int munlock __P ((__const __ptr_t __addr, size_t __len)); #ifdef __USE_MISC /* Remap pages mapped by the range [ADDR,ADDR+OLD_LEN) to new length diff --git a/sysdeps/unix/sysv/linux/ulimit.c b/sysdeps/unix/sysv/linux/ulimit.c index 58ff111..2d9e86a 100644 --- a/sysdeps/unix/sysv/linux/ulimit.c +++ b/sysdeps/unix/sysv/linux/ulimit.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,6 +19,7 @@ #include <errno.h> #include <stdarg.h> #include <sysdep.h> +#include <ulimit.h> #include <unistd.h> #include <sys/resource.h> |