glibc/db2/include/shqueue.h
Ulrich Drepper a5a0310d8e Update.
1997-09-30 18:03  Ulrich Drepper  <drepper@cygnus.com>

	* Makerules: Undo last change.
	* csu/Makefile: Define before-compile at the right place.

	* aclocal.m4: Remove a.out file created by assembler test.

	* set-init.c: Find set-hooks.h using <...>.

	Update to db 2.3.10.
	* db2/Makefile: Update.
	* db2/db.h: Likewise.
	* db2/db_185.h: Likewise.
	* db2/db_int.h: Likewise.
	* db2/btree/bt_close.c: Likewise.
	* db2/btree/bt_conv.c: Likewise.
	* db2/btree/bt_cursor.c: Likewise.
	* db2/btree/bt_put.c: Likewise.
	* db2/btree/bt_rec.c: Likewise.
	* db2/btree/bt_recno.c: Likewise.
	* db2/btree/btree.src: Likewise.
	* db2/btree/btree_auto.c: Likewise.
	* db2/clib/getlong.c: Likewise.
	* db2/db/db.c: Likewise.
	* db2/db/db_auto.c: Likewise.
	* db2/db/db_conv.c: Likewise.
	* db2/db/db_pr.c: Likewise.
	* db2/db/db_ret.c: Likewise.
	* db2/db/db_thread.c: Likewise.
	* db2/hash/hash.c: Likewise.
	* db2/hash/hash_auto.c: Likewise.
	* db2/hash/hash_conv.c: Likewise.
	* db2/hash/hash_dup.c: Likewise.
	* db2/hash/hash_func.c: Likewise.
	* db2/hash/hash_page.c: Likewise.
	* db2/hash/hash_rec.c: Likewise.
	* db2/include/btree.h: Likewise.
	* db2/include/btree_ext.h: Likewise.
	* db2/include/db.h.src: Likewise.
	* db2/include/db_185.h.src: Likewise.
	* db2/include/db_cxx.h: Likewise.
	* db2/include/db_ext.h: Likewise.
	* db2/include/db_int.h.src: Likewise.
	* db2/include/db_page.h: Likewise.
	* db2/include/db_shash.h: Likewise.
	* db2/include/lock.h: Likewise.
	* db2/include/log.h: Likewise.
	* db2/include/log_ext.h: Likewise.
	* db2/include/mp.h: Likewise.
	* db2/include/shqueue.h: Likewise.
	* db2/include/txn.h: Likewise.
	* db2/lock/lock.c: Likewise.
	* db2/lock/lock_deadlock.c: Likewise.
	* db2/log/log.c: Likewise.
	* db2/log/log_archive.c: Likewise.
	* db2/log/log_auto.c: Likewise.
	* db2/log/log_get.c: Likewise.
	* db2/log/log_put.c: Likewise.
	* db2/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_fset.c: Likewise.
	* db2/mp/mp_open.c: Likewise.
	* db2/mutex/mutex.c: Likewise.
	* db2/os/db_os_dir.c: Likewise.
	* db2/progs/db_checkpoint/db_checkpoint.c: Likewise.
	* db2/progs/db_deadlock/db_deadlock.c: Likewise.
	* db2/progs/db_dump185/db_dump185.c: Likewise.
	* db2/progs/db_load/db_load.c: Likewise.
	* db2/progs/db_recover/db_recover.c: Likewise.
	* db2/txn/txn.c: Likewise.
	* db2/txn/txn_auto.c: Likewise.

	* elf/link.h: Define struct libname_list outside struct link_map
	to not confuse C++ compilers.

	* include/features.h: Recognize _XOPEN_SOURCE == 500 and set
	__USE_UNIX98.
	* manual/creature.texi: Explain this.

	* libc.map: Add new functions.

	* libio/Makefile (routines): Add fseeko and ftello.
	* libio/ftello.c: New file.
	* libio/fseeko.c: New file.
	* libio/stdio.h: Add prototypes for new functions.
	* manual/stdio.texi: Document fseeko and ftello.

	* posix/Makefile (routines): Add pread and pwrite.
	* sysdeps/posix/pread.c: New file.
	* sysdeps/posix/pwrite.c: New file.
	* sysdeps/stub/pread.c: New file.
	* sysdeps/stub/pwrite.c: New file.
	* posix/unistd.h: Add prototypes for pread and pwrite.
	Pretty print header.
	Define gid_t, uid_t, off_t, pid_t if __USE_UNIX98.
	Declare ctermid and cuserid if __USE_UNIX98.
	(swab): Change to take void * arguments.
	* string/swab.c: Change parameter to void *.
	* posix/sys/types: Define gid_t, uid_t, off_t, pid_t only if not
	already happened.
	* manual/llio.texi: Document pread and pwrite.

	* string/strings.h: Don't simply include string.h.  Define BSD
	functions according to Unix98.
	* stdlib/tst-strtol.c: Include <string.h> not <strings.h>.
	* sunrpc/clnt_simp.c: Likewise.

	* malloc/Makefile (aux): Add set-freeres.
	* malloc/mtrace.c: Define function release_libc_mem which calls the
	__libc_subfreeres handler.
	(mtrace): Register release_libc_mem.
	* malloc/set-freeres.c: New file.

	* intl/dcgettext.c: Define free_mem function and add to
	__libc_subfreeres list.
	* intl/finddomain.c: Likewise.
	* intl/gettextP.h (struct loaded_domain): Add new fields use_mmap
	and mmap_size.  Add prototype for _nl_unloaded_domain.
	* intl/loadmsgcat.c: Define new function _nl_unload_domain.
	(_nl_load_domain): Store informaiton about mmap use and file size.
	* intl/localealias.c (read_alias_file): Optimize locale alias file
	reading by avoid frequen mallocs.
	Define free_mem function and add to __libc_subfreeres list.

	* locale/localeinfo.h: Make a difference between MAX_USAGE_COUNT and
	undeletable.
	Add prototype for _nl_unload_locale.
	* locale/C-collate: Mark data as undeletable by using UNDELETABLE.
	* locale/C-ctype: Likewise.
	* locale/C-messages: Likewise.
	* locale/C-monetary: Likewise.
	* locale/C-numeric: Likewise.
	* locale/C-time: Likewise.
	* locale/findlocale.c (_nl_find_locale, _nl_remove_locale): Handle
	MAX_USAGE_COUNT and UNDELETABLE.
	(free_mem): New function.  Add it to __libc_subfreeres list.
	* locale/loadlocale.c: Define _nl_unload_locale function.

	* misc/hsearch.c: Register hdestroy in __libc_subfreeres list.

	* stdlib/fmtmsg.c (addseverity): Handle illegal severity arguments
	correctly
	Define free_mem function and add to __libc_subfreeres list.

	* locale/programs/localedef.c (options): short form os verbose is v.
	Reported by Andreas Jaeger.

	* misc/sys/select.h: Define pselect only is __USE_POSIX since this
	header is used in some others as well for historical reasons.

	* resolv/resolv.h: Include <netinet/in.h> to make self-contained.

	* string/bits/string2.h: Add missing braces and optimize strcmp a
	bit more.
	* sysdeps/i386/i486/bits/string.h: Likewise.

	* sunrpc/rpc/auth_des.h: Include rpc/auth.h to be self-contained.
	Pretty print.

	* sysdeps/mach/hurd/cthreads.c: Add copyright text.

	* sysdeps/unix/sysv/linux/syscalls.list: Correct prctl entry.

	* sysdeps/unix/sysv/linux/sys/mman.h: Get definition of size_t.

	* time/time.h: Pretty print.

1997-09-29  Paul Eggert  <eggert@twinsun.com>

	* time/strftime.c: Synchronize with GNU Emacs strftime.c.
	(HAVE_MEMCPY): Define if emacs is defined and HAVE_BCOPY isn't.
	(gmtime_r, localtime_r): Undef before defining.
	(iso_week_days): Use __inline__, not inline.

1997-09-27  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* sysdeps/m68k/fpu/bits/mathinline.h: Rename exp2{,l,f} to
	__ieee754_exp2{,l,f}.
	* sysdeps/m68k/fpu/s_exp2.c: Likewise.
	* sysdeps/m68k/fpu/s_exp2l.c: Likewise.
	* sysdeps/m68k/fpu/s_exp2f.c: Likewise.

1997-09-27  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* elf/soinit.c (__EH_FRAME_BEGIN__): Don't make the .eh_frame
	section read-only, it contains relocations.
	* elf/sofini.c (__FRAME_END__): Likewise.

1997-09-29 03:08  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/i386/i486/bits/string.h [__PIC__] (__strspn_cg, __strcspn_cg,
	__strpbrk_cg, __strstr_cg): Optimize even more.  No spill register
	needed.  Patch by NIIBE Yutaka <gniibe@mri.co.jp>.

1997-09-28 08:27  Thorsten Kukuk  <kukuk@vt.uni-paderborn.de>

	* nis/nis_call.c (__do_niscall2): Fix return code, add missing
	  break in switch case.

	* nis/nis_mkdir.c: Fix return codes to match Solaris version.
	* nis/nis_rmdir.c: Likewise.

	* nis/rpcsvc/yp_prot.h: Rename struct keydat to struct keydat_t
	for C++.

1997-09-28 04:32  Ulrich Drepper  <drepper@cygnus.com>

	* configure.in: Fix typo.
	Patch by Zack Weinberg <zack@rabi.phys.columbia.edu>.

1997-09-25 20:14  Philip Blundell  <Philip.Blundell@pobox.com>

	* sysdeps/unix/sysv/linux/scsi/sg.h: New file.
	* sysdeps/unix/sysv/linux/Makefile: Install <scsi/sg.h>.
1997-09-30 17:10:40 +00:00

335 lines
11 KiB
C

/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 1997
* Sleepycat Software. All rights reserved.
*
* @(#)shqueue.h 8.12 (Sleepycat) 9/10/97
*/
#ifndef _SYS_SHQUEUE_H_
#define _SYS_SHQUEUE_H_
/*
* This file defines three types of data structures: lists, tail queues, and
* circular queues, similarly to the include file <sys/queue.h>.
*
* The difference is that this set of macros can be used for structures that
* reside in shared memory that may be mapped at different addresses in each
* process. In most cases, the macros for shared structures exactly mirror
* the normal macros, although the macro calls require an additional type
* parameter, only used by the HEAD and ENTRY macros of the standard macros.
*
* For details on the use of these macros, see the queue(3) manual page.
*/
/*
* Shared list definitions.
*/
#define SH_LIST_HEAD(name) \
struct name { \
ssize_t slh_first; /* first element */ \
}
#define SH_LIST_ENTRY \
struct { \
ssize_t sle_next; /* relative offset next element */ \
ssize_t sle_prev; /* relative offset of prev element */ \
}
/*
* Shared list functions. Since we use relative offsets for pointers,
* 0 is a valid offset. Therefore, we use -1 to indicate end of list.
* The macros ending in "P" return pointers without checking for end
* of list, the others check for end of list and evaluate to either a
* pointer or NULL.
*/
#define SH_LIST_FIRSTP(head, type) \
((struct type *)(((u_int8_t *)(head)) + (head)->slh_first))
#define SH_LIST_FIRST(head, type) \
((head)->slh_first == -1 ? NULL : \
((struct type *)(((u_int8_t *)(head)) + (head)->slh_first)))
#define SH_LIST_NEXTP(elm, field, type) \
((struct type *)(((u_int8_t *)(elm)) + (elm)->field.sle_next))
#define SH_LIST_NEXT(elm, field, type) \
((elm)->field.sle_next == -1 ? NULL : \
((struct type *)(((u_int8_t *)(elm)) + (elm)->field.sle_next)))
#define SH_LIST_PREV(elm, field) \
((ssize_t *)(((u_int8_t *)(elm)) + (elm)->field.sle_prev))
#define SH_PTR_TO_OFF(src, dest) \
((ssize_t)(((u_int8_t *)(dest)) - ((u_int8_t *)(src))))
#define SH_LIST_END(head) NULL
/*
* Take the element's next pointer and calculate what the corresponding
* Prev pointer should be -- basically it is the negation plus the offset
* of the next field in the structure.
*/
#define SH_LIST_NEXT_TO_PREV(elm, field) \
(-(elm)->field.sle_next + SH_PTR_TO_OFF(elm, &(elm)->field.sle_next))
#define SH_LIST_INIT(head) (head)->slh_first = -1
#define SH_LIST_INSERT_AFTER(listelm, elm, field, type) do { \
if ((listelm)->field.sle_next != -1) { \
(elm)->field.sle_next = SH_PTR_TO_OFF(elm, \
SH_LIST_NEXTP(listelm, field, type)); \
SH_LIST_NEXTP(listelm, field, type)->field.sle_prev = \
SH_LIST_NEXT_TO_PREV(elm, field); \
} else \
(elm)->field.sle_next = -1; \
(listelm)->field.sle_next = SH_PTR_TO_OFF(listelm, elm); \
(elm)->field.sle_prev = SH_LIST_NEXT_TO_PREV(listelm, field); \
} while (0)
#define SH_LIST_INSERT_HEAD(head, elm, field, type) do { \
if ((head)->slh_first != -1) { \
(elm)->field.sle_next = \
(head)->slh_first - SH_PTR_TO_OFF(head, elm); \
SH_LIST_FIRSTP(head, type)->field.sle_prev = \
SH_LIST_NEXT_TO_PREV(elm, field); \
} else \
(elm)->field.sle_next = -1; \
(head)->slh_first = SH_PTR_TO_OFF(head, elm); \
(elm)->field.sle_prev = SH_PTR_TO_OFF(elm, &(head)->slh_first); \
} while (0)
#define SH_LIST_REMOVE(elm, field, type) do { \
if ((elm)->field.sle_next != -1) { \
SH_LIST_NEXTP(elm, field, type)->field.sle_prev = \
(elm)->field.sle_prev - (elm)->field.sle_next; \
*SH_LIST_PREV(elm, field) += (elm)->field.sle_next; \
} else \
*SH_LIST_PREV(elm, field) = -1; \
} while (0)
/*
* Shared tail queue definitions.
*/
#define SH_TAILQ_HEAD(name) \
struct name { \
ssize_t stqh_first; /* relative offset of first element */ \
ssize_t stqh_last; /* relative offset of last's next */ \
}
#define SH_TAILQ_ENTRY \
struct { \
ssize_t stqe_next; /* relative offset of next element */ \
ssize_t stqe_prev; /* relative offset of prev's next */ \
}
/*
* Shared tail queue functions.
*/
#define SH_TAILQ_FIRSTP(head, type) \
((struct type *)((u_int8_t *)(head) + (head)->stqh_first))
#define SH_TAILQ_FIRST(head, type) \
((head)->stqh_first == -1 ? NULL : SH_TAILQ_FIRSTP(head, type))
#define SH_TAILQ_NEXTP(elm, field, type) \
((struct type *)((u_int8_t *)(elm) + (elm)->field.stqe_next))
#define SH_TAILQ_NEXT(elm, field, type) \
((elm)->field.stqe_next == -1 ? NULL : SH_TAILQ_NEXTP(elm, field, type))
#define SH_TAILQ_PREVP(elm, field) \
((ssize_t *)((u_int8_t *)(elm) + (elm)->field.stqe_prev))
#define SH_TAILQ_LAST(head) \
((ssize_t *)(((u_int8_t *)(head)) + (head)->stqh_last))
#define SH_TAILQ_NEXT_TO_PREV(elm, field) \
(-(elm)->field.stqe_next + SH_PTR_TO_OFF(elm, &(elm)->field.stqe_next))
#define SH_TAILQ_END(head) NULL
#define SH_TAILQ_INIT(head) { \
(head)->stqh_first = -1; \
(head)->stqh_last = SH_PTR_TO_OFF(head, &(head)->stqh_first); \
}
#define SH_TAILQ_INSERT_HEAD(head, elm, field, type) do { \
if ((head)->stqh_first != -1) { \
(elm)->field.stqe_next = \
(head)->stqh_first - SH_PTR_TO_OFF(head, elm); \
SH_TAILQ_FIRSTP(head, type)->field.stqe_prev = \
SH_TAILQ_NEXT_TO_PREV(elm, field); \
} else { \
(elm)->field.stqe_next = -1; \
(head)->stqh_last = \
SH_PTR_TO_OFF(head, &(elm)->field.stqe_next); \
} \
(head)->stqh_first = SH_PTR_TO_OFF(head, elm); \
(elm)->field.stqe_prev = \
SH_PTR_TO_OFF(elm, &(head)->stqh_first); \
} while (0)
#define SH_TAILQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.stqe_next = -1; \
(elm)->field.stqe_prev = \
-SH_PTR_TO_OFF(head, elm) + (head)->stqh_last; \
if ((head)->stqh_last == \
SH_PTR_TO_OFF((head), &(head)->stqh_first)) \
(head)->stqh_first = SH_PTR_TO_OFF(head, elm); \
else \
*SH_TAILQ_LAST(head) = -(head)->stqh_last + \
SH_PTR_TO_OFF((elm), &(elm)->field.stqe_next) + \
SH_PTR_TO_OFF(head, elm); \
(head)->stqh_last = \
SH_PTR_TO_OFF(head, &((elm)->field.stqe_next)); \
} while (0)
#define SH_TAILQ_INSERT_AFTER(head, listelm, elm, field, type) do { \
if ((listelm)->field.stqe_next != -1) { \
(elm)->field.stqe_next = (listelm)->field.stqe_next - \
SH_PTR_TO_OFF(listelm, elm); \
SH_TAILQ_NEXTP(listelm, field, type)->field.stqe_prev = \
SH_TAILQ_NEXT_TO_PREV(elm, field); \
} else { \
(elm)->field.stqe_next = -1; \
(head)->stqh_last = \
SH_PTR_TO_OFF(head, &elm->field.stqe_next); \
} \
(listelm)->field.stqe_next = SH_PTR_TO_OFF(listelm, elm); \
(elm)->field.stqe_prev = SH_TAILQ_NEXT_TO_PREV(listelm, field); \
} while (0)
#define SH_TAILQ_REMOVE(head, elm, field, type) do { \
if ((elm)->field.stqe_next != -1) { \
SH_TAILQ_NEXTP(elm, field, type)->field.stqe_prev = \
(elm)->field.stqe_prev + \
SH_PTR_TO_OFF(SH_TAILQ_NEXTP(elm, \
field, type), elm); \
*SH_TAILQ_PREVP(elm, field) += elm->field.stqe_next; \
} else { \
(head)->stqh_last = (elm)->field.stqe_prev + \
SH_PTR_TO_OFF(head, elm); \
*SH_TAILQ_PREVP(elm, field) = -1; \
} \
} while (0)
/*
* Shared circular queue definitions.
*/
#define SH_CIRCLEQ_HEAD(name) \
struct name { \
ssize_t scqh_first; /* first element */ \
ssize_t scqh_last; /* last element */ \
}
#define SH_CIRCLEQ_ENTRY \
struct { \
ssize_t scqe_next; /* next element */ \
ssize_t scqe_prev; /* previous element */ \
}
/*
* Shared circular queue functions.
*/
#define SH_CIRCLEQ_FIRSTP(head, type) \
((struct type *)(((u_int8_t *)(head)) + (head)->scqh_first))
#define SH_CIRCLEQ_FIRST(head, type) \
((head)->scqh_first == -1 ? \
(void *)head : SH_CIRCLEQ_FIRSTP(head, type))
#define SH_CIRCLEQ_LASTP(head, type) \
((struct type *)(((u_int8_t *)(head)) + (head)->scqh_last))
#define SH_CIRCLEQ_LAST(head, type) \
((head)->scqh_last == -1 ? (void *)head : SH_CIRCLEQ_LASTP(head, type))
#define SH_CIRCLEQ_NEXTP(elm, field, type) \
((struct type *)(((u_int8_t *)(elm)) + (elm)->field.scqe_next))
#define SH_CIRCLEQ_NEXT(head, elm, field, type) \
((elm)->field.scqe_next == SH_PTR_TO_OFF(elm, head) ? \
(void *)head : SH_CIRCLEQ_NEXTP(elm, field, type))
#define SH_CIRCLEQ_PREVP(elm, field, type) \
((struct type *)(((u_int8_t *)(elm)) + (elm)->field.scqe_prev))
#define SH_CIRCLEQ_PREV(head, elm, field, type) \
((elm)->field.scqe_prev == SH_PTR_TO_OFF(elm, head) ? \
(void *)head : SH_CIRCLEQ_PREVP(elm, field, type))
#define SH_CIRCLEQ_END(head) ((void *)(head))
#define SH_CIRCLEQ_INIT(head) { \
(head)->scqh_first = 0; \
(head)->scqh_last = 0; \
}
#define SH_CIRCLEQ_INSERT_AFTER(head, listelm, elm, field, type) do { \
(elm)->field.scqe_prev = SH_PTR_TO_OFF(elm, listelm); \
(elm)->field.scqe_next = (listelm)->field.scqe_next + \
(elm)->field.scqe_prev; \
if (SH_CIRCLEQ_NEXTP(listelm, field, type) == (void *)head) \
(head)->scqh_last = SH_PTR_TO_OFF(head, elm); \
else \
SH_CIRCLEQ_NEXTP(listelm, \
field, type)->field.scqe_prev = \
SH_PTR_TO_OFF(SH_CIRCLEQ_NEXTP(listelm, \
field, type), elm); \
(listelm)->field.scqe_next = -(elm)->field.scqe_prev; \
} while (0)
#define SH_CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field, type) do { \
(elm)->field.scqe_next = SH_PTR_TO_OFF(elm, listelm); \
(elm)->field.scqe_prev = (elm)->field.scqe_next - \
SH_CIRCLEQ_PREVP(listelm, field, type)->field.scqe_next;\
if (SH_CIRCLEQ_PREVP(listelm, field, type) == (void *)(head)) \
(head)->scqh_first = SH_PTR_TO_OFF(head, elm); \
else \
SH_CIRCLEQ_PREVP(listelm, \
field, type)->field.scqe_next = \
SH_PTR_TO_OFF(SH_CIRCLEQ_PREVP(listelm, \
field, type), elm); \
(listelm)->field.scqe_prev = -(elm)->field.scqe_next; \
} while (0)
#define SH_CIRCLEQ_INSERT_HEAD(head, elm, field, type) do { \
(elm)->field.scqe_prev = SH_PTR_TO_OFF(elm, head); \
(elm)->field.scqe_next = (head)->scqh_first + \
(elm)->field.scqe_prev; \
if ((head)->scqh_last == 0) \
(head)->scqh_last = -(elm)->field.scqe_prev; \
else \
SH_CIRCLEQ_FIRSTP(head, type)->field.scqe_prev = \
SH_PTR_TO_OFF(SH_CIRCLEQ_FIRSTP(head, type), elm); \
(head)->scqh_first = -(elm)->field.scqe_prev; \
} while (0)
#define SH_CIRCLEQ_INSERT_TAIL(head, elm, field, type) do { \
(elm)->field.scqe_next = SH_PTR_TO_OFF(elm, head); \
(elm)->field.scqe_prev = (head)->scqh_last + \
(elm)->field.scqe_next; \
if ((head)->scqh_first == 0) \
(head)->scqh_first = -(elm)->field.scqe_next; \
else \
SH_CIRCLEQ_LASTP(head, type)->field.scqe_next = \
SH_PTR_TO_OFF(SH_CIRCLEQ_LASTP(head, type), elm); \
(head)->scqh_last = -(elm)->field.scqe_next; \
} while (0)
#define SH_CIRCLEQ_REMOVE(head, elm, field, type) do { \
if (SH_CIRCLEQ_NEXTP(elm, field, type) == (void *)(head)) \
(head)->scqh_last += (elm)->field.scqe_prev; \
else \
SH_CIRCLEQ_NEXTP(elm, field, type)->field.scqe_prev += \
(elm)->field.scqe_prev; \
if (SH_CIRCLEQ_PREVP(elm, field, type) == (void *)(head)) \
(head)->scqh_first += (elm)->field.scqe_next; \
else \
SH_CIRCLEQ_PREVP(elm, field, type)->field.scqe_next += \
(elm)->field.scqe_next; \
} while (0)
#endif /* !_SYS_SHQUEUE_H_ */