Author: jonathan
Date: 2005-07-15 10:26:58 -0400 (Fri, 15 Jul 2005)
New Revision: 241
Added:
vendor/
vendor/stdutil/
vendor/stdutil/current/
vendor/stdutil/current/Makefile
vendor/stdutil/current/README
vendor/stdutil/current/STDUTIL_LICENSE
vendor/stdutil/current/bin/
vendor/stdutil/current/docs/
vendor/stdutil/current/docs/html/
vendor/stdutil/current/docs/html/index.html
vendor/stdutil/current/docs/html/std.html
vendor/stdutil/current/docs/html/std_it.html
vendor/stdutil/current/docs/html/stdarr.html
vendor/stdutil/current/docs/html/stdcarr.html
vendor/stdutil/current/docs/html/stddll.html
vendor/stdutil/current/docs/html/stdhash.html
vendor/stdutil/current/docs/html/stdutil_title.gif
vendor/stdutil/current/docs/index.html
vendor/stdutil/current/docs/man/
vendor/stdutil/current/docs/man/std_it.3thr
vendor/stdutil/current/docs/man/stdarr.3thr
vendor/stdutil/current/docs/man/stdcarr.3thr
vendor/stdutil/current/docs/man/stddll.3thr
vendor/stdutil/current/docs/man/stdhash.3thr
vendor/stdutil/current/lib/
vendor/stdutil/current/src/
vendor/stdutil/current/src/Makefile.in
vendor/stdutil/current/src/configure
vendor/stdutil/current/src/configure.in
vendor/stdutil/current/src/stdarr.c
vendor/stdutil/current/src/stdcarr.c
vendor/stdutil/current/src/stddll.c
vendor/stdutil/current/src/stderror.c
vendor/stdutil/current/src/stdfd.c
vendor/stdutil/current/src/stdhash.c
vendor/stdutil/current/src/stdit.c
vendor/stdutil/current/src/stdskl.c
vendor/stdutil/current/src/stdtest/
vendor/stdutil/current/src/stdtest/stdarr_test.c
vendor/stdutil/current/src/stdtest/stdcarr_test.c
vendor/stdutil/current/src/stdtest/stddll_test.c
vendor/stdutil/current/src/stdtest/stdhash_test.c
vendor/stdutil/current/src/stdthread.c
vendor/stdutil/current/src/stdtime.c
vendor/stdutil/current/src/stdutil.c
vendor/stdutil/current/src/stdutil/
vendor/stdutil/current/src/stdutil/private/
vendor/stdutil/current/src/stdutil/private/stdarch.h
vendor/stdutil/current/src/stdutil/private/stdarch.h.in
vendor/stdutil/current/src/stdutil/private/stdarr_p.h
vendor/stdutil/current/src/stdutil/private/stdcarr_p.h
vendor/stdutil/current/src/stdutil/private/stddll_p.h
vendor/stdutil/current/src/stdutil/private/stdhash_p.h
vendor/stdutil/current/src/stdutil/private/stdit_p.h
vendor/stdutil/current/src/stdutil/private/stdskl_p.h
vendor/stdutil/current/src/stdutil/private/stdthread_p.h
vendor/stdutil/current/src/stdutil/stdarr.h
vendor/stdutil/current/src/stdutil/stdcarr.h
vendor/stdutil/current/src/stdutil/stddefines.h
vendor/stdutil/current/src/stdutil/stddll.h
vendor/stdutil/current/src/stdutil/stderror.h
vendor/stdutil/current/src/stdutil/stdfd.h
vendor/stdutil/current/src/stdutil/stdhash.h
vendor/stdutil/current/src/stdutil/stdit.h
vendor/stdutil/current/src/stdutil/stdskl.h
vendor/stdutil/current/src/stdutil/stdthread.h
vendor/stdutil/current/src/stdutil/stdtime.h
vendor/stdutil/current/src/stdutil/stdutil.h
Log:
Importing initial stdutil 1.0.0beta1 vendor release
Added: vendor/stdutil/current/Makefile
===================================================================
--- vendor/stdutil/current/Makefile 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/Makefile 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,11 @@
+stdutil: src/Makefile
+ cd src; make
+
+src/Makefile:
+ cd src; ./configure
+
+clean: src/Makefile
+ cd src; make clean
+
+distclean: src/Makefile
+ cd src; make distclean
Added: vendor/stdutil/current/README
===================================================================
--- vendor/stdutil/current/README 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/README 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,65 @@
+This is the v0.9.1 (July 2001) distribution of the stdutil library.
+
+Note, that for v1.0.0 I intend to pretty much destroy any backward
+compatability, as I have a growing distaste for my naming conventions
+and function/type names. So just be warned, you may want to wait
+for that version -- although it could be several months before I
+get around to and finish it.
+
+Changes since v0.9.0 (Nov 2000):
+
+Wrote more documentation on the data structures, including an HTML
+interface. Changed build system to be a bit more autoconf'ish.
+Rearranged structure of distribution a little.
+
+DESCRIPTION:
+
+The stdutil library is a toolkit of C data structures and functions.
+
+LICENSE:
+
+The license for use of the stdutil library or its code is contained in
+the file STDUTIL_LICENSE found in the root of this distribution.
+
+DOCUMENTATION:
+
+Simply open up index.html with a browser or visit
+http://www.cnds.jhu.edu/software/stdutil or look directly at the man
+pages contained in the man/ directory.
+
+BUILDING:
+
+To build this library run make in the root of this distribution. This
+will build stdutil.a and several test programs and place them,
+respectively, in the bin and lib directories of this distribution.
+
+*** Anybody who wants to contribute a more complex build and install
+setup, please feel free, as this is not one of my strong points. ***
+
+To build a checked or debug version of the library edit src/Makefile.in
+before running make. There you can uncomment definitions for the
+variables STD_USE_EXCEPTIONS, STD_CONSTRUCT_CHECKS, STD_BOUNDS_CHECKS
+and STD_SAFE_CHECKS. The effects of these different variables is either
+self-evident or described in Makefile.in.
+
+INSTALLING:
+
+Feel free to move the library and documentation to your standard system
+directories. Then go into the src directory and do a recursive copy of
+the _DIRECTORY_ stdutil into a standard include path (e.g. cp -r
+src/stdutil /usr/include).
+
+LINKING:
+
+Just make sure the include files are available and link with
+libstdutil.a.
+
+PROBLEMS:
+
+Please report bugs and/or bug fixes to [email protected] with a
+gdb compatible core (if possible) and any information that could help
+me fix the problem in my distributions.
+
+Enjoy,
+John Schultz <[email protected]>
+July 2001
Added: vendor/stdutil/current/STDUTIL_LICENSE
===================================================================
--- vendor/stdutil/current/STDUTIL_LICENSE 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/STDUTIL_LICENSE 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,49 @@
+/* Copyright (c) 2000, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ *
+ * This license is equivalent to the BSD license as of July 23, 1999.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * (1) Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * (2) Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * (3) Neither the name of The Johns Hopkins University nor the names
+ * of the contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission. To acquire such permission, write to:
+ *
+ * Director, The Center for Networking and Distributed Systems
+ * Department of Computer Science
+ * The Johns Hopkins University
+ * 3400 N. Charles St., MD 21218
+ *
+ * or email [email protected].
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
Added: vendor/stdutil/current/docs/html/index.html
===================================================================
--- vendor/stdutil/current/docs/html/index.html 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/html/index.html 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,35 @@
+<html>
+<head><title>Stdutil Documentation</title></head>
+
+<body bgcolor="#FFFFFF">
+
+<!--#include virtual="/includes/header-a" -->
+
+<a href="http://www.cnds.jhu.edu/software/stdutil"><img src="stdutil_title.gif" alt="Stdutil Library" border=0></a>
+
+<!--#include virtual="/includes/header-b" -->
+
+<font size=+2><b>C/C++ Documentation</b></font><br><br>
+
+The following documents the interface to the stdutil C library. Or you can look directly at the <a href="../src">src</a>.
+
+<ol>
+<li>The <a href="stdarr.html">stdarr</a> array data structure declared in <a href="../src/stdutil/stdarr.h">stdarr.h</a>.
+<li>The <a href="stdcarr.html">stdcarr</a> circular array data structure declared in <a href="../src/stdutil/stdcarr.h">stdcarr.h</a>.
+<li>The <a href="stddll.html">stddll</a> doubly linked list data structure declared in <a href="../src/stdutil/stddll.h">stddll.h</a>.
+<li>The <a href="stdhash.html">stdhash</a> dictionary data structure declared in <a href="../src/stdutil/stdhash.h">stdhash.h</a>.
+<li>The <a href="std_it.html">std_it</a> generic iterator type, with specific declarations in the above .h files.
+</ol>
+
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+
+<!--#include virtual="/includes/footer" -->
+
+</body></html>
Added: vendor/stdutil/current/docs/html/std.html
===================================================================
--- vendor/stdutil/current/docs/html/std.html 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/html/std.html 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,19 @@
+<HTML><HEAD><TITLE>Manpage of FL_version</TITLE>
+</HEAD>
+
+<body bgcolor="#FFFFFF">
+
+<!--#include virtual="/includes/header-a" -->
+
+<a href="http://www.cnds.jhu.edu/software/stdutil">
+<img src="stdutil_title.gif" alt="Stdutil Library" border=0>
+</a>
+
+<!--#include virtual="/includes/header-b" -->
+
+
+
+<!--#include virtual="/includes/footer" -->
+
+</BODY>
+</HTML>
Added: vendor/stdutil/current/docs/html/std_it.html
===================================================================
--- vendor/stdutil/current/docs/html/std_it.html 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/html/std_it.html 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,268 @@
+<HTML><HEAD><TITLE>Manpage of FL_version</TITLE>
+</HEAD>
+
+<body bgcolor="#FFFFFF">
+
+<!--#include virtual="/includes/header-a" -->
+
+<a href="http://www.cnds.jhu.edu/software/stdutil">
+<img src="stdutil_title.gif" alt="Stdutil Library" border=0>
+</a>
+
+<!--#include virtual="/includes/header-b" -->
+
+<H1>STD_IT</H1>
+Section: User Manuals (3)<BR>Updated: NOV 2000<BR>
+<HR>
+
+<H2>NAME</H2>
+
+<P>
+std_it, std_it_val, std_it_equals, std_it_is_begin, std_it_is_end, std_it_seek_begin, std_it_seek_end, std_it_next, std_it_advance, std_it_prev, std_it_retreat, std_it_offset, std_it_compare - basic operations provided by stdutil iterators.
+<P>
+<H2>SYNOPSIS</H2>
+
+<P>
+<B>void *std_it_val(const std_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdbool std_it_equals(const std_it *</B><I>it1</I><B>, const std_it *</B><I>it2</I><B>);</B>
+
+<P>
+<B>stdbool std_it_is_begin(const std_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdbool std_it_is_end(const std_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>std_it *std_it_seek_begin(std_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>std_it *std_it_seek_end(std_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>std_it *std_it_next(std_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>std_it *std_it_advance(std_it *</B><I>it</I><B>, size_t </B><I>num_advance</I><B>);</B>
+
+<P>
+<B>std_it *std_it_prev(std_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>std_it *std_it_retreat(std_it *</B><I>it</I><B>, size_t </B><I>num_retreat</I><B>);</B>
+
+<P>
+<B>std_it *std_it_offset(std_it *</B><I>it</I><B>, stdssize_t </B><I>offset</I><B>);</B>
+
+<P>
+<B>stdssize_t std_it_compare(const std_it *</B><I>it1</I><B>, const std_it *</B><I>it2</I><B>);</B>
+
+<P>
+<H2>DESCRIPTION</H2>
+
+<P>
+A std_it is an abstract type that describes several iterator types
+defined by the stdutil library (e.g. - stdarr_it, stdcarr_it,
+stddll_it and stdhash_it). An iterator is a common design pattern used
+to represent a sequence of values contained in a data structure. The
+main purpose of an iterator is to allow for unique iteration through
+all of the values contained within a data structure. However,
+iterators can also be used in many other operations as well.
+<P>
+Any data structure that supports unique iteration through all of its
+values defines a sequence on those values at the time of iteration. If
+the structure S contains n values, then each contained value in S can
+be uniquely associated with an integer rank in the range [0, n), which
+is equal to the number of values in S that precede it in the
+sequence.
+<P>
+For the stdutil library, multiple iterations on the same data
+structure instance that occur without intervening structural
+operations on that instance see the same rank sequence of values.
+Furthermore, many stdutil data structures define precise semantics on
+how iterators and the rank sequence of the structure are affected by
+structural changes (see each structure's documentation).
+<P>
+The stdutil is modeled loosely after C++'s STL library, which uses
+iterators extensively. In both the stdutil and STL libraries there are
+three types of iterators: forward, bi-directional and random-access
+iterators. See each stdutil data structure's documentation for what
+type of iterator it provides.
+<P>
+A forward iterator allows some basic operations and tests, but in
+general only allows the iterator to move forward (increasing rank) in
+the data structure's sequence. A simple singly linked list should only
+provide a forward iterator, for example. A bi-directional iterator is
+a forward iterator, but also allows the iterator to move backwards
+(decreasing rank) in the structure's sequence. A simple doubly-linked
+list should provide a bi-directional iterator, for example. A
+random-access iterator is a bi-directional iterator that allows for
+arbitrary offset and comparison of sequence ranks. A tightly packed
+array of values should provide a random-access iterator, for example.
+<P>
+A data structure's iterator implementation should attempt to support
+the broadest class it can, while maintaing expected O(1) space and
+time overhead for each of its basic operations (next, previous and
+offset, respectively).
+<P>
+In the stdutil library, an iterator must be correctly initialized by a
+data structure instance before it can legally be used. All operations
+on that iterator are then done in the context of the initializing
+instance. The results of using an iterator initialized by one instance
+with another instance are undefined. Likewise, the results of calling
+iterator functions (such as
+<B>std_it_compare</B>)
+
+on iterators initialized by different structure instances are
+undefined.
+<P>
+<H2>FORWARD ITERATORS</H2>
+
+<P>
+A forward iterator is the most restricted class of iterator and
+supports the following operations in expected O(1) space and time.
+<P>
+<B>std_it_val</B>
+
+returns a pointer to the value to which this iterator is currently
+referencing.
+<P>
+<B>std_it_equals</B>
+
+returns stdtrue if the two iterators are referencing the same value.
+<P>
+<B>std_it_is_begin</B>
+
+returns stdtrue if the iterator is referencing the beginning of the
+sequence. The beginning of a sequence is defined as the first value in
+the sequence or the end of the sequence if it is empty.
+<P>
+<B>std_it_is_end</B>
+
+returns stdtrue if the iterator is referencing the end of the
+sequence. The end of a sequence is defined as one position past the
+last value contained in the sequence (rank n). It is illegal to call
+<B>std_it_val</B>
+
+on the end of sequence.
+<P>
+<B>std_it_seek_begin</B>
+
+sets the iterator to reference the beginning of the sequence.
+<P>
+<B>std_it_seek_end</B>
+
+sets the iterator to reference the end of the sequence.
+<P>
+<B>std_it_next</B>
+
+advances the iterator forward one position in the sequence.
+<P>
+<B>std_it_advance</B>
+
+advances the iterator forward
+<I>num_advance</I>
+
+positions in the sequence. This operation should execute in O(1) space
+and
+O(<I>num_advance</I>)
+
+time.
+<P>
+<H2>BI-DIRECTIONAL ITERATORS</H2>
+
+<P>
+A bi-directional iterator is a forward iterator that also supports the
+following operations in expected O(1) space and time.
+<P>
+<B>std_it_prev</B>
+
+retreats the iterator back one position in the sequence.
+<P>
+<B>std_it_retreat</B>
+
+retreats the iterator back
+<I>num_retreat</I>
+
+positions in the sequence. This operation should execute in O(1) space
+and
+O(<I>num_retreat</I>)
+
+time.
+<P>
+<H2>RANDOM-ACCESS ITERATORS</H2>
+
+<P>
+A random-access iterator is a bi-directional iterator that supports
+the following operations in expected O(1) space and time.
+<P>
+<B>std_it_offset</B>
+
+offsets the iterator
+<I>offset</I>
+
+positions forward in the sequence. If
+<I>offset</I>
+
+is negative, then it retreats the iterator that many positions.
+<P>
+<B>std_it_compare</B>
+
+compares two iterators and returns the offset in sequence rank needed
+to move from
+<I>it2</I>
+
+to
+<I>it1</I>.
+
+For example, say
+<I>it1</I>
+
+is referencing the value with rank 2 and
+<I>it2</I>
+
+is referencing the value with rank 5, then
+<B>std_it_compare</B>
+
+(<I>it1</I>, <I>it2</I>)
+
+would return -3.
+<P>
+<H2>RETURN VALUES</H2>
+
+<P>
+When called legally, none of the above functions can fail. Most of the
+functions' return values are described in the SYNOPSIS. The functions
+that return std_it *'s return the
+<I>it</I>
+
+passed to them to allow for function composition.
+<P>
+<H2>NOTES</H2>
+
+<P>
+For performance reasons, by default the stdutil library does no usage
+checking. It assumes the programmer knows what s/he is doing and
+doesn't want additional overhead incurred from sanity checks.
+<P>
+However, the library can be built will several types of checks,
+including bounds and initialization checks that can catch many common
+programming mistakes. See the README file included with the stdutil
+library distribution to see how to create such a "checked" or debug
+library.
+<P>
+<H2>AUTHOR</H2>
+
+<P>
+John Schultz <<A HREF="mailto:[email protected]">[email protected]</A>>
+<P>
+<H2>SEE ALSO</H2>
+
+<P>
+stdarr, stdcarr, stddll, stdhash
+
+<!--#include virtual="/includes/footer" -->
+
+</BODY>
+</HTML>
Added: vendor/stdutil/current/docs/html/stdarr.html
===================================================================
--- vendor/stdutil/current/docs/html/stdarr.html 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/html/stdarr.html 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,481 @@
+<HTML><HEAD><TITLE>Manpage of FL_version</TITLE>
+</HEAD>
+
+<body bgcolor="#FFFFFF">
+
+<!--#include virtual="/includes/header-a" -->
+
+<a href="http://www.cnds.jhu.edu/software/stdutil">
+<img src="stdutil_title.gif" alt="Stdutil Library" border=0>
+</a>
+
+<!--#include virtual="/includes/header-b" -->
+
+<H1>STDARR</H1>
+Section: User Manuals (3)<BR>Updated: NOV 2000<BR>
+<HR>
+
+<H2>NAME</H2>
+
+<P>
+stdarr, stdarr_construct, stdarr_copy_construct, stdarr_destruct, stdarr_size, stdarr_empty, stdarr_high_capacity, stdarr_low_capacity, stdarr_get_auto_alloc, stdarr_set_auto_alloc, stdarr_push_back, stdarr_pop_back, stdarr_multi_push_back, stdarr_multi_pop_back, stdarr_insert, stdarr_erase, stdarr_repeat_insert, stdarr_multi_insert, stdarr_multi_erase, stdarr_resize, stdarr_clear, stdarr_set_capacity, stdarr_reserve, stdarr_shrink_fit, stdarr_begin, stdarr_end, stdarr_last, stdarr_get, stdarr_max_size, stdarr_val_size - operations on a stdarr, a resizable array data structure
+<P>
+<H2>SYNOPSIS</H2>
+
+<P>
+<B>#include <stdutil/stdarr.h></B>
+
+<P>
+<B>stdarr </B><I>array</I><B> = STDARR_STATIC_CONSTRUCT(sizeof_val);</B>
+
+<P>
+<B>int stdarr_construct(stdarr *</B><I>arr</I><B>, size_t </B><I>sizeof_val</I><B>);</B>
+
+<P>
+<B>int stdarr_copy_construct(stdarr *</B><I>dst</I><B>, const stdarr *</B><I>src</I><B>);</B>
+
+<P>
+<B>void stdarr_destruct(stdarr *</B><I>arr</I><B>);</B>
+
+<P>
+<B>size_t stdarr_size(const stdarr *</B><I>arr</I><B>);</B>
+
+<P>
+<B>stdbool stdarr_empty(const stdarr *</B><I>arr</I><B>);</B>
+
+<P>
+<B>size_t stdarr_high_capacity(const stdarr *</B><I>arr</I><B>);</B>
+
+<P>
+<B>size_t stdarr_low_capacity(const stdarr *</B><I>arr</I><B>);</B>
+
+<P>
+<B>stdbool stdarr_get_auto_alloc(const stdarr *</B><I>arr</I><B>);</B>
+
+<P>
+<B>void stdarr_set_auto_alloc(stdarr *</B><I>arr</I><B>, stdbool </B><I>use_auto_alloc</I><B>);</B>
+
+<P>
+<B>int stdarr_push_back(stdarr *</B><I>arr</I><B>, const void *</B><I>val</I><B>);</B>
+
+<P>
+<B>int stdarr_pop_back(stdarr *</B><I>arr</I><B>);</B>
+
+<P>
+<B>int stdarr_multi_push_back(stdarr *</B><I>arr</I><B>, const void *</B><I>vals</I><B>, size_t </B><I>num_push</I><B>);</B>
+
+<P>
+<B>int stdarr_multi_pop_back(stdarr *</B><I>arr</I><B>, size_t </B><I>num_pop</I><B>);</B>
+
+<P>
+<B>stdarr_it *stdarr_insert(stdarr_it *</B><I>it</I><B>, const void *</B><I>val</I><B>);</B>
+
+<P>
+<B>stdarr_it *stdarr_erase(stdarr_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdarr_it *stdarr_repeat_insert(stdarr_it *</B><I>it</I><B>, const void *</B><I>val</I><B>, size_t </B><I>num_times</I><B>);</B>
+
+<P>
+<B>stdarr_it *stdarr_multi_insert(stdarr_it *</B><I>it</I><B>, const void *</B><I>vals</I><B>, size_t </B><I>num_insert</I><B>);</B>
+
+<P>
+<B>stdarr_it *stdarr_multi_erase(stdarr_it *</B><I>it</I><B>, size_t </B><I>num_erase</I><B>);</B>
+
+<P>
+<B>int stdarr_resize(stdarr *</B><I>arr</I><B>, size_t </B><I>num_elems</I><B>);</B>
+
+<P>
+<B>int stdarr_clear(stdarr *</B><I>arr</I><B>);</B>
+
+<P>
+<B>int stdarr_set_capacity(stdarr *</B><I>arr</I><B> , size_t </B><I>num_elems</I><B>);</B>
+
+<P>
+<B>int stdarr_reserve(stdarr *</B><I>arr</I><B>, size_t </B><I>num_elems</I><B>);</B>
+
+<P>
+<B>int stdarr_shrink_fit(stdarr *</B><I>arr</I><B>);</B>
+
+<P>
+<B>stdarr_it *stdarr_begin(const stdarr *</B><I>arr</I><B>, stdarr_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdarr_it *stdarr_end(const stdarr *</B><I>arr</I><B>, stdarr_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdarr_it *stdarr_last(const stdarr *</B><I>arr</I><B>, stdarr_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdarr_it *stdarr_get(const stdarr *</B><I>arr</I><B>, stdarr_it *</B><I>it</I><B>, size_t </B><I>elem_num</I><B>);</B>
+
+<P>
+<B>size_t stdarr_max_size(const stdarr *</B><I>arr</I><B>);</B>
+
+<P>
+<B>size_t stdarr_val_size(const stdarr *</B><I>arr</I><B>);</B>
+
+<P>
+<H2>DESCRIPTION</H2>
+
+<P>
+stdarr is a generic data structure that contains, by value, a user
+defined sequence of same sized values. The values can be referenced in
+constant O(1) time by their 0-based rank in the sequence. This data
+structure is the equivalent of a resizable array or vector in other
+languages. This structure is well suited to applications where
+references to arbitrary points in a user defined sequence often occur.
+<P>
+Before a stdarr can legally be used it must be successfully
+initialized.
+<B>STDARR_STATIC_CONSTRUCT(</B><I>sizeof_val</I><B>)</B>
+
+is a macro that initializes the assigned stdarr at definition to
+contain values of size
+<I>sizeof_val</I>
+
+bytes.
+<B>stdarr_construct</B>
+
+dynamically initializes the stdarr object pointed to by
+<I>arr</I>
+
+to contain values of size
+<I>sizeof_val</I>
+
+bytes. Arrays initialized using either of these methods initially
+contain no values.
+<B>stdarr_copy_construct</B>
+
+makes
+<I>dst</I>
+
+contain a clone (copy by value) of the sequence of values that the
+successfully initialized
+<I>src</I>
+
+array contains. The cloned array has the same operational parameters
+(i.e. - sizeof_val, auto_alloc) as the source array. It is illegal to
+call a constructor on an already successfully constructed stdarr --
+doing so will cause memory leaks at best. When an array is no longer
+in use its memory should be released by calling
+<B>stdarr_destruct</B>
+
+on it. Once a stdarr has been destructed it must be initialized again
+before being legally used.
+<P>
+<B>stdarr_size</B>
+
+indicates the current number of values contained in the array.
+<B>stdarr_empty</B>
+
+indicates whether or not the array contains no values.
+<P>
+In order to support constant time access to any value, stdarr
+allocates a contiguous block of memory in which it stores its sequence
+of values. When a rank is referenced (see stdarr_get), an offset
+from the base address of the allocated memory is calculated, which
+gives the address of the value. Because of this block memory scheme,
+when too many values are inserted to fit into the allocated memory,
+the stdarr must allocate a new block of memory to contain the sequence
+and move its sequence there.
+<P>
+Reallocating and copying a sequence of values is an expensive linear
+O(n) time operation, where n is the number of values in the array. In
+order to minimize the frequency of these operations, stdarr defaults
+to using an auto-allocation mechanism that handles memory
+allocation. When this mechanism is active, it allocates more memory
+than the array currently needs so that every insertion and deletion
+does not result in a reallocation. If the mechanism is active, then
+<B>stdarr_high_capacity</B>
+
+indicates the maximum number of values the array can contain before
+being reallocated and
+<B>stdarr_low_capacity</B>
+
+indicates the minimum number of values the array can contain before
+<B>possibly</B>
+
+being reallocated. If the size of the array always remains between
+these two numbers, then the array will never be reallocated by the
+auto-allocation mechanism.
+<P>
+Oftentimes the programmer will want to control the allocation of the
+array's memory manually. For this reason, the programmer can activate
+or deactivate the auto-allocation mechanism by passing, respectively,
+<I>stdtrue</I>
+
+or
+<I>stdfalse</I>
+
+to
+<B>stdarr_set_auto_alloc</B>.
+
+The programmer can query if the auto-allocation mechanism is currently
+active by calling
+<B>stdarr_get_auto_alloc</B>.
+
+While the auto-allocation mechanism is disabled, the current memory
+allocation of the array is fixed and no size affecting operations
+(insert, pop, resize, etc.) will result in reallocations. In this
+case, it is the user's responsibility to ensure that there is enough
+memory to contain the values stored in the array.
+<B>stdarr_high_capacity</B>
+
+indicates the maximum number of values an array can legally contain in
+its current allocation.
+<P>
+Because stdarr stores its values in contiguous memory it provides
+fast stack operations (push and pop) onto the end of the
+sequence. Push operations run in linear O(m) time, where m is the
+number of elements being pushed. Pop operations run in constant O(1)
+time. If a stack operation causes an auto-reallocation then it runs in
+linear O(n) time.
+<B>stdarr_push_back</B>
+
+pushes the referenced value onto the end of the array.
+<B>stdarr_pop_back</B>
+
+pops the last value off of the end of the array.
+<B>stdarr_multi_push_back </B>
+
+appends an array of
+<I>num_push</I>
+
+values onto the end of the stdarr.
+<B>stdarr_multi_pop_back</B>
+
+pops the last
+<I>num_pop</I>
+
+values off of the end of the array.
+<P>
+Because stdarr stores its values in contiguous memory it provides
+slow list operations (insert and erase) on the sequence in worst case
+linear O(n) time. These functions are very expensive and are only
+provided as a convenience. If the user performs list operations often,
+then another data structure (such as stddll) should probably be
+considered.
+<B>stdarr_insert</B>
+
+inserts the referenced value into the sequence immediately before the
+value that the iterator
+<I>it</I>
+
+references. The passed iterator is set to point at the inserted
+value. All of the old values after the insertion point have their
+rank in the sequence incremented by one.
+<B>stdarr_multi_insert</B>
+
+inserts an array of
+<I>num_insert </I>
+
+values into the array immediately before the value that the iterator
+<I>it </I>
+
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their rank in the sequence incremented by
+<I>num_insert</I>.
+
+<B>stdarr_repeat_insert</B>
+
+inserts the referenced value into the sequence
+<I>num_times</I>
+
+times immediately before the value that
+<I>it</I>
+
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their rank in the sequence incremented by
+<I>num_times</I>.
+
+<P>
+<B>stdarr_erase</B>
+
+erases the value that
+<I>it</I>
+
+references. All of the remaining values after the erased value have
+their rank in the sequence decremented by one. The passed iterator is
+set to point at the value that shifted into the erased position, or
+end if none.
+<B>stdarr_multi_erase</B>
+
+erases the contiguous increasing subsequence of
+<I>num_erase</I>
+
+values starting at and including the rank/value that
+<I>it</I>
+
+references. All of the remaining values after the erased subsequence
+have their rank in the sequence decremented by
+<I>num_erase</I>.
+
+The passed iterator is set to point at the value that shifted into the
+beginning position of the erased subsequence, or end if none. All of
+the list operations return a pointer to the passed iterator to allow
+for function composition.
+<P>
+Stdarr also has several resizing and capacity (allocation) features.
+<B>stdarr_resize</B>
+
+resizes the array to contain
+<I>num_elems</I>
+
+values. If
+<I>num_elems</I>
+
+is smaller than the current size of the array, then this will truncate
+the sequence to only contain the first
+<I>num_elems</I>
+
+values in the array. If
+<I>num_elems</I>
+
+is larger than the current size of the array, then additional
+uninitialized values will be added to the end of the sequence of
+values.
+<B>stdarr_clear</B>
+
+deletes all of the values contained in the sequence.
+<B>stdarr_set_capacity</B>
+
+sets the high capacity of the array to be
+<I>num_elems</I>,
+
+which will usually require a re-allocation. This function is often
+used when the user has turned off the auto-allocation mechanism and
+wants to set the size of memory allocated to the array manually.
+<B>stdarr_reserve</B>
+
+reserves enough memory space to contain
+<I>num_elems</I>
+
+values; if the auto-allocation mechanism is disabled this function
+has the same effect as
+<B>stdarr_set_capacity</B>.
+
+<B>stdarr_shrink_fit</B>
+
+makes the capacity of the array the same as the size of the array so
+that there is no unused allocated memory. This operation will usually
+require a re-allocation.
+<P>
+stdarr, like the other stdutil data structures, has several methods
+for getting iterators that reference particular values in its
+sequence. stdarr provides random-access iterators (see std_it).
+<B>stdarr_begin</B>
+
+sets the iterator
+<I>it</I>
+
+to reference the first or 0th value of the array, or, if the array is
+empty to reference the end of the array.
+<B>stdarr_end</B>
+
+sets the iterator to reference the end of the array. The end of the
+array is one past the last value contained in the array and has a
+sequence rank of n.
+<B>stdarr_last</B>
+
+sets the iterator to reference the nth value in the sequence (rank of
+n-1). It is illegal to call stdarr_last on an empty array.
+<B>stdarr_get</B>
+
+sets the iterator to reference the value with rank
+<I>elem_num </I>
+
+or end if
+<I>elem_num </I>
+
+is n.
+<I>elem_num</I>
+
+must be less than or equal to n. All of these functions return
+pointers to the passed iterator to allow function composition. All of
+these functions work in constant O(1) time.
+<P>
+<B>stdarr_max_size</B>
+
+returns the absolute maximum number of values of a particular size an
+array can hold. As an array's size approaches this number (within a
+small multiplicative factor) the auto-allocation mechanism may begin
+to fail because it tries to allocate too much memory. If an array
+needs to be able to hold somewhere around this many values, then the
+user should disable the auto-allocation mechanism and manually control
+the capacity of the array.
+<P>
+<B>stdarr_val_size</B>
+
+returns the size, in bytes, of the value type this array is currently
+containing.
+<P>
+<H2>RETURN VALUES</H2>
+
+<P>
+Most of the functions' return values are described in the SYNOPSIS and
+cannot fail. However, the constructors and functions that potentially
+affect the capacity of the array can fail. If such a function returns
+an int, then it returns zero on success and non-zero on failure. If
+such a function returns a stdarr_it *, then it returns non-zero on
+success and null(0) on failure. Whenever any stdarr function fails it
+has no side effects.
+<P>
+<H2>ERRORS</H2>
+
+<P>
+The constructor functions can return the following error codes:
+<DL COMPACT><DT><DD>
+<DL COMPACT>
+<DT><B>STD_ILLEGAL_PARAM </B>
+
+<DD>
+the sizeof the value type was zero.
+<P>
+<DT><B>STD_MEM_FAILURE</B>
+
+<DD>
+a memory allocation failure occurred.
+</DL></DL>
+
+<P>
+Functions that potentially affect the capacity of the array and return
+an int, return the following error codes on error:
+<DL COMPACT><DT><DD>
+<DL COMPACT>
+<DT><B>STD_MEM_FAILURE</B>
+
+<DD>
+a memory allocation failure occurred.
+</DL></DL>
+
+<P>
+<H2>NOTES</H2>
+
+<P>
+For performance reasons, by default the stdutil library does no usage
+checking. It assumes the programmer knows what s/he is doing and
+doesn't want additional overhead incurred from sanity checks.
+<P>
+However, the library can be built will several types of checks,
+including bounds and initialization checks that can catch many common
+programming mistakes. See the README file included with the stdutil
+library distribution to see how to create such a "checked" or debug
+library.
+<P>
+<H2>AUTHOR</H2>
+
+<P>
+John Schultz <<A HREF="mailto:[email protected]">[email protected]</A>>
+<P>
+<H2>SEE ALSO</H2>
+
+<P>
+std_it, stdcarr, stddll
+
+<!--#include virtual="/includes/footer" -->
+
+</BODY>
+</HTML>
Added: vendor/stdutil/current/docs/html/stdcarr.html
===================================================================
--- vendor/stdutil/current/docs/html/stdcarr.html 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/html/stdcarr.html 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,524 @@
+<HTML><HEAD><TITLE>Manpage of FL_version</TITLE>
+</HEAD>
+
+<body bgcolor="#FFFFFF">
+
+<!--#include virtual="/includes/header-a" -->
+
+<a href="http://www.cnds.jhu.edu/software/stdutil">
+<img src="stdutil_title.gif" alt="Stdutil Library" border=0>
+</a>
+
+<!--#include virtual="/includes/header-b" -->
+
+<H1>STDCARR</H1>
+Section: User Manuals (3)<BR>Updated: NOV 2000<BR>
+<HR>
+
+<H2>NAME</H2>
+
+<P>
+stdcarr, stdcarr_construct, stdcarr_copy_construct, stdcarr_destruct, stdcarr_size, stdcarr_empty, stdcarr_high_capacity, stdcarr_low_capacity, stdcarr_get_auto_alloc, stdcarr_set_auto_alloc, stdcarr_push_front, stdcarr_pop_front, stdcarr_push_back, stdcarr_pop_back, stdcarr_multi_push_front, stdcarr_multi_pop_front, stdcarr_multi_push_back, stdcarr_multi_pop_back, stdcarr_insert, stdcarr_erase, stdcarr_repeat_insert, stdcarr_multi_insert, stdcarr_multi_erase, stdcarr_resize, stdcarr_clear, stdcarr_set_capacity, stdcarr_reserve, stdcarr_shrink_fit, stdcarr_begin, stdcarr_end, stdcarr_last, stdcarr_get, stdcarr_max_size, stdcarr_val_size - operations on a stdcarr, a resizable circular array data structure
+<P>
+<H2>SYNOPSIS</H2>
+
+<P>
+<B>#include <stdutil/stdcarr.h></B>
+
+<P>
+<B>stdcarr </B><I>carray</I><B> = STDCARR_STATIC_CONSTRUCT(sizeof_val);</B>
+
+<P>
+<B>int stdcarr_construct(stdcarr *</B><I>carr</I><B>, size_t </B><I>sizeof_val</I><B>);</B>
+
+<P>
+<B>int stdcarr_copy_construct(stdcarr *</B><I>dst</I><B>, const stdcarr *</B><I>src</I><B>);</B>
+
+<P>
+<B>void stdcarr_destruct(stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<B>size_t stdcarr_size(const stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<B>stdbool stdcarr_empty(const stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<B>size_t stdcarr_high_capacity(const stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<B>size_t stdcarr_low_capacity(const stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<B>stdbool stdcarr_get_auto_alloc(const stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<B>void stdcarr_set_auto_alloc(stdcarr *</B><I>carr</I><B>, stdbool </B><I>use_auto_alloc</I><B>);</B>
+
+<P>
+<B>int stdcarr_push_front(stdcarr *</B><I>carr</I><B>, const void *</B><I>val</I><B>);</B>
+
+<P>
+<B>int stdcarr_pop_front(stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<B>int stdcarr_push_back(stdcarr *</B><I>carr</I><B>, const void *</B><I>val</I><B>);</B>
+
+<P>
+<B>int stdcarr_pop_back(stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<B>int stdcarr_multi_push_front(stdcarr *</B><I>carr</I><B>, const void *</B><I>vals</I><B>, size_t </B><I>num_push</I><B>);</B>
+
+<P>
+<B>int stdcarr_multi_pop_front(stdcarr *</B><I>carr</I><B>, size_t </B><I>num_pop</I><B>);</B>
+
+<P>
+<B>int stdcarr_multi_push_back(stdcarr *</B><I>carr</I><B>, const void *</B><I>vals</I><B>, size_t </B><I>num_push</I><B>);</B>
+
+<P>
+<B>int stdcarr_multi_pop_back(stdcarr *</B><I>carr</I><B>, size_t </B><I>num_pop</I><B>);</B>
+
+<P>
+<B>stdcarr_it *stdcarr_insert(stdcarr_it *</B><I>it</I><B>, const void *</B><I>val</I><B>);</B>
+
+<P>
+<B>stdcarr_it *stdcarr_erase(stdcarr_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdcarr_it *stdcarr_repeat_insert(stdcarr_it *</B><I>it</I><B>, const void *</B><I>val</I><B>, size_t </B><I>num_times</I><B>);</B>
+
+<P>
+<B>stdcarr_it *stdcarr_multi_insert(stdcarr_it *</B><I>it</I><B>, const void *</B><I>vals</I><B>, size_t </B><I>num_insert</I><B>);</B>
+
+<P>
+<B>stdcarr_it *stdcarr_multi_erase(stdcarr_it *</B><I>it</I><B>, size_t </B><I>num_erase</I><B>);</B>
+
+<P>
+<B>int stdcarr_resize(stdcarr *</B><I>carr</I><B>, size_t </B><I>num_elems</I><B>);</B>
+
+<P>
+<B>int stdcarr_clear(stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<B>int stdcarr_set_capacity(stdcarr *</B><I>carr</I><B> , size_t </B><I>num_elems</I><B>);</B>
+
+<P>
+<B>int stdcarr_reserve(stdcarr *</B><I>carr</I><B>, size_t </B><I>num_elems</I><B>);</B>
+
+<P>
+<B>int stdcarr_shrink_fit(stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<B>stdcarr_it *stdcarr_begin(const stdcarr *</B><I>carr</I><B>, stdcarr_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdcarr_it *stdcarr_end(const stdcarr *</B><I>carr</I><B>, stdcarr_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdcarr_it *stdcarr_last(const stdcarr *</B><I>carr</I><B>, stdcarr_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdcarr_it *stdcarr_get(const stdcarr *</B><I>carr</I><B>, stdcarr_it *</B><I>it</I><B>, size_t </B><I>elem_num</I><B>);</B>
+
+<P>
+<B>size_t stdcarr_max_size(const stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<B>size_t stdcarr_val_size(const stdcarr *</B><I>carr</I><B>);</B>
+
+<P>
+<H2>DESCRIPTION</H2>
+
+<P>
+stdcarr is a generic data structure that contains, by value, a user
+defined sequence of same sized values. The values can be referenced in
+constant O(1) time by their 0-based rank in the sequence. This data
+structure is the equivalent of a resizable circular array or circular
+vector in other languages. This structure is well suited to
+applications where references to arbitrary points in a user defined
+sequence often occur.
+<P>
+This data structure is closely related to the stdarr. The main
+differences between these structures are: (1) most operations should
+work slightly faster on a stdarr, and (2) stdcarr provides
+expected constant O(1) time push and pop operations on both ends of
+the array, while a stdarr only provides those operations on the end
+of the array. Obviously stdcarr supports any type of queuing
+application
+<B>much </B>
+
+better than stdarr.
+<P>
+Before a stdcarr can legally be used it must be successfully
+initialized.
+<B>STDCARR_STATIC_CONSTRUCT(</B><I>sizeof_val</I><B>)</B>
+
+is a macro that initializes the assigned stdcarr at definition to
+contain values of size
+<I>sizeof_val</I>
+
+bytes.
+<B>stdcarr_construct</B>
+
+dynamically initializes the stdcarr object pointed to by
+<I>carr</I>
+
+to contain values of size
+<I>sizeof_val</I>
+
+bytes. Arrays initialized using either of these methods initially
+contain no values.
+<B>stdcarr_copy_construct</B>
+
+makes
+<I>dst</I>
+
+contain a clone (copy by value) of the sequence of values that the
+successfully initialized
+<I>src</I>
+
+array contains. The cloned array has the same operational parameters
+(i.e. - sizeof_val, auto_alloc) as the source array. It is illegal to
+call a constructor on an already successfully constructed stdcarr --
+doing so will cause memory leaks at best. When an array is no longer
+in use its memory should be released by calling
+<B>stdcarr_destruct</B>
+
+on it. Once a stdcarr has been destructed it must be successfully
+initialized again before being legally used.
+<P>
+<B>stdcarr_size</B>
+
+indicates the current number of values contained in the array.
+<B>stdcarr_empty</B>
+
+indicates whether or not the array contains no values.
+<P>
+In order to support constant time access to any value, stdcarr
+allocates a contiguous block of memory in which it stores its sequence
+of values. When a rank is referenced (see stdcarr_get), an offset from
+the arbitrary beginning address of the stored values is calculated
+modulo the size of the allocated memory, which gives the address of
+the value. Because of this block memory scheme, when too many values
+are inserted to fit into the allocated memory, the stdcarr must
+allocate a new block of memory to contain the sequence and move its
+sequence there.
+<P>
+Reallocating and copying a sequence of values is an expensive linear
+O(n) time operation, where n is the number of values contained. In
+order to minimize the frequency of these operations, stdcarr defaults
+to using an auto-allocation mechanism that handles memory
+allocation. When this mechanism is active, it allocates more memory
+than the array currently needs so that every insertion and deletion
+does not result in a reallocation. If the mechanism is active, then
+<B>stdcarr_high_capacity</B>
+
+indicates the maximum number of values the array can contain before
+being reallocated and
+<B>stdcarr_low_capacity</B>
+
+indicates the minimum number of values the array can contain before
+<B>possibly</B>
+
+being reallocated. If the size of the array always remains between
+these two numbers, then the array will never be reallocated by the
+auto-allocation mechanism.
+<P>
+Oftentimes the programmer will want to control the allocation of the
+array's memory manually. For this reason, the programmer can activate
+or deactivate the auto-allocation mechanism by passing, respectively,
+<I>stdtrue</I>
+
+or
+<I>stdfalse</I>
+
+to
+<B>stdcarr_set_auto_alloc</B>.
+
+The programmer can query if the auto-allocation mechanism is currently
+active by calling
+<B>stdcarr_get_auto_alloc</B>.
+
+While the auto-allocation mechanism is disabled, the current memory
+allocation of the array is fixed and no size affecting operations
+(insert, pop, resize, etc.) will result in reallocations. In this
+case, it is the user's responsibility to ensure that there is enough
+memory to contain the values stored in the array.
+<B>stdcarr_high_capacity</B>
+
+indicates the maximum number of values an array can legally contain in
+its current allocation.
+<P>
+Because stdcarr stores its values in contiguous memory it provides
+fast stack operations (push and pop) onto both the beginning and the
+end of the sequence. Push operations run in O(m) time, where m is the
+number of elements being pushed. Pop operations run in constant O(1)
+time. If a stack operation causes an auto-reallocation it runs in
+linear O(n) time.
+<B>stdcarr_push_front</B>
+
+pushes the referenced value onto the beginning of the array.
+<B>stdcarr_pop_front</B>
+
+pops the first element off of the front of the array.
+<B>stdcarr_push_back</B>
+
+pushes the referenced value onto the end of the array.
+<B>stdcarr_pop_back</B>
+
+pops the last value off of the end of the array.
+<B>stdcarr_multi_push_front</B>
+
+prepends an array of
+<I>num_push</I>
+
+values onto the beginning of the stdcarr.
+<B>stdcarr_multi_pop_front</B>
+
+pops the first
+<I>num_pop</I>
+
+values off of the beginning of the array.
+<B>stdcarr_multi_push_back </B>
+
+appends an array of
+<I>num_push</I>
+
+values onto the end of the stdcarr.
+<B>stdcarr_multi_pop_back</B>
+
+pops the last
+<I>num_erase</I>
+
+values off of the end of the array.
+<P>
+Because stdcarr stores its values in contiguous memory it provides
+slow list operations (insert and erase) on the sequence in worst
+case linear O(n) time. These functions are very expensive and are only
+provided as a convenience. If the user needs to do list operations
+often, then another data structure (such as stddll) should probably be
+considered.
+<B>stdcarr_insert</B>
+
+inserts the referenced value into the sequence immediately before the
+value that the iterator
+<I>it</I>
+
+references. The passed iterator is set to point at the inserted
+value. All of the old values after the insertion point have their
+rank in the sequence incremented by one.
+<B>stdcarr_multi_insert</B>
+
+inserts an array of
+<I>num_insert </I>
+
+values into the array immediately before the value that the iterator
+<I>it </I>
+
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their rank in the sequence incremented by
+<I>num_insert</I>.
+
+<B>stdcarr_repeat_insert</B>
+
+inserts the referenced value into the sequence
+<I>num_times</I>
+
+times immediately before the value that
+<I>it</I>
+
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their rank in the sequence incremented by
+<I>num_times</I>.
+
+<P>
+<B>stdcarr_erase</B>
+
+erases the value that
+<I>it</I>
+
+references. All of the remaining values after the erased value have
+their rank in the sequence decremented by one. The passed iterator is
+set to point at the value that shifted into the erased position, or
+end if none.
+<B>stdcarr_multi_erase</B>
+
+erases the contiguous increasing subsequence of
+<I>num_erase</I>
+
+values starting at and including the rank/value that
+<I>it</I>
+
+references. All of the remaining values after the erased subsequence
+have their rank in the sequence decremented by
+<I>num_erase</I>.
+
+The passed iterator is set to point at the value that shifted into the
+beginning position of the erased subsequence, or end if none. All of
+the list operations return a pointer to the passed iterator to allow
+for function composition.
+<P>
+Stdcarr also has several resizing and capacity (allocation) features.
+<B>stdcarr_resize</B>
+
+resizes the array to contain
+<I>num_elems</I>
+
+values. If
+<I>num_elems</I>
+
+is smaller than the current size of the array, then this will truncate
+the sequence to only contain the first
+<I>num_elems</I>
+
+values in the array. If
+<I>num_elems</I>
+
+is larger than the current size of the array, then additional
+uninitialized values will be added to the end of the sequence of
+values.
+<B>stdcarr_clear</B>
+
+deletes all of the values contained in the sequence.
+<B>stdcarr_set_capacity</B>
+
+sets the high capacity of the array to be
+<I>num_elems</I>,
+
+which will usually require a reallocation. This function is often
+used when the user has turned off the auto-allocation mechanism and
+wants to set the size of memory allocated to the array manually.
+<B>stdcarr_reserve</B>
+
+reserves enough memory space to contain
+<I>num_elems</I>
+
+values; if the auto-allocation mechanism is disabled this function
+has the same effect as
+<B>stdcarr_set_capacity</B>.
+
+<B>stdcarr_shrink_fit</B>
+
+makes the capacity of the array the same as the size of the array so
+that there is no unused allocated memory. This operation will usually
+require a re-allocation.
+<P>
+stdcarr, like the other stdutil data structures, has several methods
+for getting iterators that reference particular values in its
+sequence. stdcarr provides random-access iterators (see std_it).
+<B>stdcarr_begin</B>
+
+sets the iterator
+<I>it</I>
+
+to reference the first or 0th value of the array, or, if the array is
+empty to reference the end of the array.
+<B>stdcarr_end</B>
+
+sets the iterator to reference the end of the array. The end of the
+array is one past the last value contained in the array and has an
+rank of n.
+<B>stdcarr_last</B>
+
+sets the iterator to reference the nth value in the sequence (rank of
+n-1). It is illegal to call stdcarr_last on an empty array.
+<B>stdcarr_get</B>
+
+sets the iterator to reference the value with rank
+<I>elem_num </I>
+
+or end if
+<I>elem_num</I>
+
+is n.
+<I>elem_num</I>
+
+must be less than or equal to n. All of these functions return
+pointers to the passed iterator to allow function composition. All of
+these functions work in constant O(1) time.
+<P>
+<B>stdcarr_max_size</B>
+
+returns the absolute maximum number of values of a particular size an
+array can hold. As an array's size approaches this number (within a
+small multiplicative factor) the auto-allocation mechanism may begin
+to fail because it tries to allocate too much memory. If an array
+needs to be able to hold somewhere around this many values, then the
+user should disable the auto-allocation mechanism and manually control
+the capacity of the array.
+<P>
+<B>stdcarr_val_size</B>
+
+returns the size, in bytes, of the value type this array is currently
+containing.
+<P>
+<H2>RETURN VALUES</H2>
+
+<P>
+Most of the functions' return values are described in the SYNOPSIS and
+cannot fail. However, the constructors and functions that potentially
+affect the capacity of the array can fail. If such a function returns
+an int, then it returns zero on success and non-zero on failure. If
+such a function returns a stdcarr_it *, then it returns non-zero on
+success and null(0) on failure. Whenever any stdcarr function fails it
+has no side effects.
+<P>
+<H2>ERRORS</H2>
+
+<P>
+The constructor functions can return the following error codes:
+<DL COMPACT><DT><DD>
+<DL COMPACT>
+<DT><B>STD_ILLEGAL_PARAM </B>
+
+<DD>
+the sizeof the value type was zero.
+<P>
+<DT><B>STD_MEM_FAILURE</B>
+
+<DD>
+a memory allocation failure occurred.
+</DL></DL>
+
+<P>
+Functions that potentially affect the capacity of the array and return
+an int, return the following error codes on error:
+<DL COMPACT><DT><DD>
+<DL COMPACT>
+<DT><B>STD_MEM_FAILURE</B>
+
+<DD>
+a memory allocation failure occurred.
+</DL></DL>
+
+<P>
+<H2>NOTES</H2>
+
+<P>
+For performance reasons, by default the stdutil library does no usage
+checking. It assumes the programmer knows what s/he is doing and
+doesn't want additional overhead incurred from sanity checks.
+<P>
+However, the library can be built will several types of checks,
+including bounds and initialization checks that can catch many common
+programming mistakes. See the README file included with the stdutil
+library distribution to see how to create such a "checked" or debug
+library.
+<P>
+<H2>AUTHOR</H2>
+
+<P>
+John Schultz <<A HREF="mailto:[email protected]">[email protected]</A>>
+<P>
+<H2>SEE ALSO</H2>
+
+<P>
+std_it, stdarr, stddll
+
+<!--#include virtual="/includes/footer" -->
+
+</BODY>
+</HTML>
Added: vendor/stdutil/current/docs/html/stddll.html
===================================================================
--- vendor/stdutil/current/docs/html/stddll.html 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/html/stddll.html 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,401 @@
+<HTML><HEAD><TITLE>Manpage of FL_version</TITLE>
+</HEAD>
+
+<body bgcolor="#FFFFFF">
+
+<!--#include virtual="/includes/header-a" -->
+
+<a href="http://www.cnds.jhu.edu/software/stdutil">
+<img src="stdutil_title.gif" alt="Stdutil Library" border=0>
+</a>
+
+<!--#include virtual="/includes/header-b" -->
+
+<H1>STDDLL</H1>
+Section: User Manuals (3)<BR>Updated: NOV 2000<BR>
+<HR>
+
+<H2>NAME</H2>
+
+<P>
+stddll, stddll_construct, stddll_copy_construct, stddll_destruct, stddll_size, stddll_empty, stddll_push_front, stddll_pop_front, stddll_push_back, stddll_pop_back, stddll_multi_push_front, stddll_multi_pop_front, stddll_multi_push_back, stddll_multi_pop_back, stddll_insert, stddll_erase, stddll_repeat_insert, stddll_multi_insert, stddll_multi_erase, stddll_resize, stddll_clear, stddll_begin, stddll_end, stddll_last, stddll_get, stddll_max_size, stddll_val_size - operations on a stddll, a list data structure
+<P>
+<H2>SYNOPSIS</H2>
+
+<P>
+<B>#include <stdutil/stddll.h></B>
+
+<P>
+<B>int stddll_construct(stddll *</B><I>dll</I><B>, size_t </B><I>sizeof_val</I><B>);</B>
+
+<P>
+<B>int stddll_copy_construct(stddll *</B><I>dst</I><B>, const stddll *</B><I>src</I><B>);</B>
+
+<P>
+<B>void stddll_destruct(stddll *</B><I>dll</I><B>);</B>
+
+<P>
+<B>size_t stddll_size(const stddll *</B><I>dll</I><B>);</B>
+
+<P>
+<B>stdbool stddll_empty(const stddll *</B><I>dll</I><B>);</B>
+
+<P>
+<B>int stddll_push_front(stddll *</B><I>dll</I><B>, const void *</B><I>val</I><B>);</B>
+
+<P>
+<B>int stddll_pop_front(stddll *</B><I>dll</I><B>);</B>
+
+<P>
+<B>int stddll_push_back(stddll *</B><I>dll</I><B>, const void *</B><I>val</I><B>);</B>
+
+<P>
+<B>int stddll_pop_back(stddll *</B><I>dll</I><B>);</B>
+
+<P>
+<B>int stddll_multi_push_front(stddll *</B><I>dll</I><B>, const void *</B><I>vals</I><B>, size_t </B><I>num_push</I><B>);</B>
+
+<P>
+<B>int stddll_multi_pop_front(stddll *</B><I>dll</I><B>, size_t </B><I>num_pop</I><B>);</B>
+
+<P>
+<B>int stddll_multi_push_back(stddll *</B><I>dll</I><B>, const void *</B><I>vals</I><B>, size_t </B><I>num_push</I><B>);</B>
+
+<P>
+<B>int stddll_multi_pop_back(stddll *</B><I>dll</I><B>, size_t </B><I>num_pop</I><B>);</B>
+
+<P>
+<B>stddll_it *stddll_insert(stddll_it *</B><I>it</I><B>, const void *</B><I>val</I><B>);</B>
+
+<P>
+<B>stddll_it *stddll_erase(stddll_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stddll_it *stddll_repeat_insert(stddll_it *</B><I>it</I><B>, const void *</B><I>val</I><B>, size_t </B><I>num_times</I><B>);</B>
+
+<P>
+<B>stddll_it *stddll_multi_insert(stddll_it *</B><I>it</I><B>, const void *</B><I>vals</I><B>, size_t </B><I>num_insert</I><B>);</B>
+
+<P>
+<B>stddll_it *stddll_multi_erase(stddll_it *</B><I>it</I><B>, size_t </B><I>num_erase</I><B>);</B>
+
+<P>
+<B>int stddll_resize(stddll *</B><I>dll</I><B>, size_t </B><I>num_elems</I><B>);</B>
+
+<P>
+<B>int stddll_clear(stddll *</B><I>dll</I><B>);</B>
+
+<P>
+<B>stddll_it *stddll_begin(const stddll *</B><I>dll</I><B>, stddll_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stddll_it *stddll_end(const stddll *</B><I>dll</I><B>, stddll_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stddll_it *stddll_last(const stddll *</B><I>dll</I><B>, stddll_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stddll_it *stddll_get(const stddll *</B><I>dll</I><B>, stddll_it *</B><I>it</I><B>, size_t </B><I>elem_num</I><B>);</B>
+
+<P>
+<B>size_t stddll_max_size(const stddll *</B><I>dll</I><B>);</B>
+
+<P>
+<B>size_t stddll_val_size(const stddll *</B><I>dll</I><B>);</B>
+
+<P>
+<H2>DESCRIPTION</H2>
+
+<P>
+stddll is a generic data structure that contains, by value, a user
+defined sequence of same sized values. The values can be referenced in
+worst case linear O(n) time by their 0-based index in the sequence,
+where n is the number of values in the list. This data structure is
+the equivalent of a doubly linked list in other languages. This
+structure is well suited to applications where insertions at arbitrary
+points in a user defined sequence often occur. Some obvious uses of a
+stddll are as an efficient stack or as a FIFO queue.
+<P>
+Before a stddll can legally be used it must be successfully
+initialized.
+<B>stddll_construct</B>
+
+dynamically initializes the stddll object pointed to by
+<I>dll</I>
+
+to contain values of size
+<I>sizeof_val</I>
+
+bytes. A list initialized using this method initially contains no
+values.
+<B>stddll_copy_construct</B>
+
+makes
+<I>dst</I>
+
+contain a clone (copy by value) of the sequence of values that the
+successfully initialized
+<I>src</I>
+
+list contains. The clone list has the same operational parameters
+(i.e. - sizeof_val) as the source list. It is illegal to call a
+constructor on an already successfully constructed stddll -- doing so
+will cause memory leaks at best. When a list is no longer in use its
+memory should be released by calling
+<B>stddll_destruct</B>
+
+on it. Once a stddll has been destructed it must be successfully
+initialized again before being legally used.
+<P>
+<B>stddll_size</B>
+
+indicates the current number of values contained in the list.
+<B>stddll_empty</B>
+
+indicates whether or not the list contains no values.
+<P>
+stddll stores its values as a doubly linked (forwards and backwards)
+node list, where each node is allocated independently and contains a
+value. Due to this scheme stddll supports fast stack operations
+(push and pop) onto both the beginning and the end of the sequence.
+Push and pop operations run in linear O(m) time, where m is the number
+of values being pushed or popped.
+<B>stddll_push_front </B>
+
+pushes the referenced value onto the beginning of the list.
+<B>stddll_pop_front</B>
+
+pops the first element off of the front of the list.
+<B>stddll_push_back</B>
+
+pushes the referenced value onto the end of the list.
+<B>stddll_pop_back</B>
+
+pops the last value off of the end of the list.
+<B>stddll_multi_push_front</B>
+
+prepends an array of
+<I>num_push</I>
+
+values onto the beginning of the list.
+<B>stddll_multi_pop_front</B>
+
+pops the first
+<I>num_pop</I>
+
+values off of the beginning of the list.
+<B>stddll_multi_push_back </B>
+
+appends an array of
+<I>num_push</I>
+
+values onto the end of the list.
+<B>stddll_multi_pop_back</B>
+
+pops the last
+<I>num_erase</I>
+
+values off of the end of the list.
+<P>
+Because stddll stores its values in a linked node list, it supports
+fast list operations (insert and erase) on the sequence in linear O(m)
+time, where m is the number of values being inserted or erased.
+<B>stddll_insert</B>
+
+inserts the referenced value into the sequence immediately before the
+value that the iterator
+<I>it</I>
+
+references. The passed iterator is set to point at the inserted
+value. All of the old values after the insertion point have their
+index in the sequence incremented by one.
+<B>stddll_multi_insert</B>
+
+inserts an array of
+<I>num_insert </I>
+
+values into the list immediately before the value that the iterator
+<I>it </I>
+
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their index in the sequence incremented by
+<I>num_insert</I>.
+
+<B>stddll_repeat_insert</B>
+
+inserts the referenced value into the sequence
+<I>num_times</I>
+
+times immediately before the value that
+<I>it</I>
+
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their index in the sequence incremented by
+<I>num_times</I>.
+
+<P>
+<B>stddll_erase</B>
+
+erases the value that
+<I>it</I>
+
+references. All of the remaining values after the erased value have
+their index in the sequence decremented by one. The passed iterator is
+set to point at the value that shifted into the erased position, or
+end if none.
+<B>stddll_multi_erase</B>
+
+erases the contiguous increasing subsequence of
+<I>num_erase</I>
+
+values starting at and including the index/value that
+<I>it</I>
+
+references. All of the remaining values after the erased subsequence
+have their index in the sequence decremented by
+<I>num_erase</I>.
+
+The passed iterator is set to point at the value that shifted into the
+beginning position of the erased subsequence, or end if none. All of
+the list operations return a pointer to the passed iterator to allow
+for function composition.
+<P>
+<B>stddll_resize</B>
+
+resizes the list to contain
+<I>num_elems</I>
+
+values. If
+<I>num_elems</I>
+
+is smaller than the current size of the list, then this will truncate
+the sequence to only contain the first
+<I>num_elems</I>
+
+values in the list. If
+<I>num_elems</I>
+
+is larger than the current size of the list, then additional
+uninitialized values will be added to the end of the sequence of
+values.
+<B>stddll_clear</B>
+
+deletes all of the values contained in the sequence.
+<P>
+stddll, like the other stdutil data structures, has several methods
+for getting iterators that reference particular values in its
+sequence. stddll provides bi-directional iterators (see std_it).
+<B>stddll_begin</B>
+
+sets the iterator
+<I>it</I>
+
+to reference the first or 0th value of the list, or, if the list is
+empty to reference the end of the list.
+<B>stddll_end</B>
+
+sets the iterator to reference the end of the list. The end of the
+list is one past the last value contained in the list and has an index
+of n.
+<B>stddll_last</B>
+
+sets the iterator to reference the nth value in the sequence (index of
+n-1). It is illegal to call stddll_last on an empty list. The above
+three iterator functions operate in constant O(1) time.
+<B>stddll_get</B>
+
+sets the iterator to reference the value with index
+<I>elem_num</I>
+
+or end if
+<I>elem_num</I>
+
+is n.
+<I>elem_num</I>
+
+must be less than or equal to n. This operation runs in worst case
+O(n) time and is provided only as a convenience. If the application
+often references arbitrary positions in the sequence, then another
+structure (such as stdarr or stdcarr) should probably be
+considered. All of these functions return pointers to the passed
+iterator to allow function composition.
+<P>
+<B>stddll_max_size</B>
+
+returns the absolute maximum number of values a list can hold and is
+invariant across different lists.
+<P>
+<B>stddll_val_size</B>
+
+returns the size, in bytes, of the value type this list is currently
+containing.
+<P>
+<H2>RETURN VALUES</H2>
+
+<P>
+Most of the functions' return values are described in the SYNOPSIS and
+cannot fail. However, the constructors and functions that potentially
+affect the size of the list can fail. If such a function returns an
+int, then it returns zero on success and non-zero on failure. If such
+a function returns a stddll_it *, then it returns non-zero on success
+and null(0) on failure. Whenever any stddll function fails it has no
+side effects.
+<P>
+<H2>ERRORS</H2>
+
+<P>
+The constructor functions can return the following error codes:
+<DL COMPACT><DT><DD>
+<DL COMPACT>
+<DT><B>STD_ILLEGAL_PARAM </B>
+
+<DD>
+the sizeof the value type was zero.
+<P>
+<DT><B>STD_MEM_FAILURE</B>
+
+<DD>
+a memory allocation failure occurred.
+</DL></DL>
+
+<P>
+Functions that potentially affect the size of the list and return an
+int, return the following error codes on error:
+<DL COMPACT><DT><DD>
+<DL COMPACT>
+<DT><B>STD_MEM_FAILURE</B>
+
+<DD>
+a memory allocation failure occurred.
+</DL></DL>
+
+<P>
+<H2>NOTES</H2>
+
+<P>
+For performance reasons, by default the stdutil library does no usage
+checking. It assumes the programmer knows what s/he is doing and
+doesn't want additional overhead incurred from sanity checks.
+<P>
+However, the library can be built will several types of checks,
+including bounds and initialization checks that can catch many common
+programming mistakes. See the README file included with the stdutil
+library distribution to see how to create such a "checked" or debug
+library.
+<P>
+<H2>AUTHOR</H2>
+
+<P>
+John Schultz <<A HREF="mailto:[email protected]">[email protected]</A>>
+<P>
+<H2>SEE ALSO</H2>
+
+<P>
+std_it, stdarr, stdcarr
+
+<!--#include virtual="/includes/footer" -->
+
+</BODY>
+</HTML>
Added: vendor/stdutil/current/docs/html/stdhash.html
===================================================================
--- vendor/stdutil/current/docs/html/stdhash.html 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/html/stdhash.html 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,497 @@
+<HTML><HEAD><TITLE>Manpage of FL_version</TITLE>
+</HEAD>
+
+<body bgcolor="#FFFFFF">
+
+<!--#include virtual="/includes/header-a" -->
+
+<a href="http://www.cnds.jhu.edu/software/stdutil">
+<img src="stdutil_title.gif" alt="Stdutil Library" border=0>
+</a>
+
+<!--#include virtual="/includes/header-b" -->
+
+<H1>STDHASH</H1>
+Section: User Manuals (3)<BR>Updated: NOV 2000<BR>
+<HR>
+
+<P>
+<H2>NAME</H2>
+
+<P>
+stdhash, stdhash_construct, stdhash_construct2, stdhash_copy_construct, stdhash_destruct, stdhash_size, stdhash_empty, stdhash_find, stdhash_insert, stdhash_erase, stdhash_erase_key, stdhash_clear, stdhash_reserve, stdhash_rehash, stdhash_begin, stdhash_end, stdhash_last, stdhash_get, stdhash_max_size, stdhash_key_size, stdhash_val_size, stdhash_key_val_size, stdhash_it_key, stdhash_it_val, stdhash_it_kvp, stdhash_it_keyed_next - operations on a stdhash, a dictionary data structure
+<P>
+<H2>SYNOPSIS</H2>
+
+<P>
+<B>#include <stdutil/stdhash.h></B>
+
+<P>
+<B>stdhash </B><I>h</I><B> = STDHASH_STATIC_CONSTRUCT(</B><I>sizeof_key</I><B>, </B><I>sizeof_val</I><B>, </B><I>kequals</I><B>, </B><I>khcode</I><B>);</B>
+
+<P>
+<B>stdhash </B><I>h</I><B> = STDHASH_STATIC_CONSTRUCT2(</B><I>sizeof_key</I><B>, </B><I>sizeof_val</I><B>, </B><I>kequals</I><B>, </B><I>khcode</I><B>, </B><I>dseed</I><B>);</B>
+
+<P>
+<B>int stdhash_construct(stdhash *</B><I>h</I><B>, size_t </B><I>sizeof_key</I><B>, size_t </B><I>sizeof_val</I><B>, stdequals_fcn </B><I>kequals</I><B>, stdhcode_fcn </B><I>khcode</I><B>);</B>
+
+<P>
+<B>int stdhash_construct2(stdhash *</B><I>h</I><B>, size_t </B><I>sizeof_key</I><B>, size_t </B><I>sizeof_val</I><B>, stdequals_fcn </B><I>kequals</I><B>, stdhcode_fcn </B><I>khcode</I><B>, size_t </B><I>dseed</I><B>);</B>
+
+<P>
+<B>int stdhash_copy_construct(stdhash *</B><I>dst</I><B>, const stdhash *</B><I>src</I><B>);</B>
+
+<P>
+<B>void stdhash_destruct(stdhash *</B><I>h</I><B>);</B>
+
+<P>
+<B>size_t stdhash_size(const stdhash *</B><I>h</I><B>);</B>
+
+<P>
+<B>stdbool stdhash_empty(const stdhash *</B><I>h</I><B>);</B>
+
+<P>
+<B>stdhash_it *stdhash_find(const stdhash *</B><I>h</I><B>, stdhash_it *</B><I>it</I><B>, const void *</B><I>key</I><B>);</B>
+
+<P>
+<B>stdhash_it *stdhash_insert(stdhash *</B><I>h</I><B>, stdhash_it *</B><I>it</I><B>, const void *</B><I>key</I><B>, const void *</B><I>val</I><B>);</B>
+
+<P>
+<B>stdhash_it *stdhash_erase(stdhash_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>int stdhash_erase_key(stdhash *</B><I>h</I><B>, const void *</B><I>key</I><B>);</B>
+
+<P>
+<B>int stdhash_clear(stdhash *</B><I>h</I><B>);</B>
+
+<P>
+<B>int stdhash_reserve(stdhash *</B><I>h</I><B>, size_t </B><I>num_elems</I><B>);</B>
+
+<P>
+<B>int stdhash_rehash(stdhash *</B><I>h</I><B>);</B>
+
+<P>
+<B>stdhash_it *stdhash_begin(const stdhash *</B><I>h</I><B>, stdhash_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdhash_it *stdhash_end(const stdhash *</B><I>h</I><B>, stdhash_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdhash_it *stdhash_last(const stdhash *</B><I>h</I><B>, stdhash_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdhash_it *stdhash_get(const stdhash *</B><I>h</I><B>, stdhash_it *</B><I>it</I><B>, size_t </B><I>elem_num</I><B>);</B>
+
+<P>
+<B>void *stdhash_it_key(const stdhash_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>void *stdhash_it_val(const stdhash_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdkvp *stdhash_it_kvp(const stdhash_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>stdhash_it *stdhash_it_keyed_next(stdhash_it *</B><I>it</I><B>);</B>
+
+<P>
+<B>size_t stdhash_max_size(const stdhash *</B><I>h</I><B>);</B>
+
+<P>
+<B>size_t stdhash_key_size(const stdhash *</B><I>h</I><B>);</B>
+
+<P>
+<B>size_t stdhash_val_size(const stdhash *</B><I>h</I><B>);</B>
+
+<P>
+<B>size_t stdhash_key_val_size(const stdhash *</B><I>h</I><B>);</B>
+
+<P>
+<H2>DESCRIPTION</H2>
+
+<P>
+stdhash is a generic data structure that contains, by value, a
+collection of same-sized key-val pairs, where the keys remain constant
+while in the stdhash. These pairs can be referenced in expected
+constant O(1) time, worst case linear O(n) time (where n is the number
+of pairs in the hash), by their non-unique keys. This data structure
+is the equivalent of a dynamic, non-unique key dictionary or multihash
+in other languages. One can construct a stdhash to only contain key
+types. In that case, the stdhash acts as a collection of non-unique
+keys. This can be useful to test for key existence (e.g. - does the
+hash contain 5?). This structure is well suited to applications where
+quick look-ups based on a key often occur and long structural updates
+can be occasionaly tolerated.
+<P>
+Before a stdhash can legally be used it must be successfully
+initialized. The user must specify the size of the key and value types
+to be stored. Values can be zero bytes in size. In addition, the user
+can specify two functions that will be used to compare keys. The first
+function is an equality tester for keys: it invariantly returns
+stdtrue (1) if the keys are equal and stdfalse (0) if the keys are not
+equal -- it should be a reflexive, symmetric and transitive relation
+on keys. The second function is a hashcode function that takes a
+pointer to a key and invariantly returns a size_t that represents the
+key as a size_t. This hashcode fcn must be consistent with the
+equality function, meaning that if two keys are equal then they must
+have the same hashcode. It is legal for two unequal keys to return the
+same hashcode, however, such hashcode collisions should occur with a
+probability of approximately 1 / (2^(sizeof(size_t) * 8)) for optimal
+performance.
+<P>
+If the key type being stored is appropriate, the user can specify
+null (0) for either, or both, of the key comparison functions. In this
+case, a bitwise memory comparison is done for key equality and the
+hashcodes are computed as a function of the bits of the constant key.
+<P>
+In addition, upon initialization a stdhash is given a seed number that
+it uses to generate random numbers. Two stdhashs that start with the
+same seeds and are modified in the exact same manner will be
+synchronized in terms of the key-val pairs and the sequence of those
+pairs that they contain.
+<P>
+<B>STDHASH_STATIC_CONSTRUCT</B>
+
+is a macro that initializes the assigned stdhash at definition to
+contain key-val pairs with keys of size
+<I>sizeof_key</I>
+
+bytes and values of
+<I>sizeof_val</I>
+
+bytes. The keys will be compared for equality using the function
+<I>kequals</I>
+
+and key hashcodes will be computed using the function
+<I>khcode</I>.
+
+stdhashs constructed this way will be initialized with the same
+constant seed.
+<B>STDHASH_STATIC_CONSTRUCT2</B>
+
+is the same as
+<B>STDHASH_STATIC_CONSTRUCT</B>
+
+except that the caller may specify a different seed with which to
+initialize the stdhash instead of the default seed.
+<B>stdhash_construct</B>
+
+dynamically initializes the stdhash object pointed to by
+<I>h</I>
+
+to contain key-val pairs with keys of size
+<I>sizeof_key</I>
+
+bytes and values of
+<I>sizeof_val</I>
+
+bytes. The keys will be compared for equality using the function
+<I>kequals</I>
+
+and key hashcodes will be computed using the function
+<I>khcode</I>.
+
+stdhashs constructed this way will be initialized with a seed that is
+based on the current time on the system.
+<B>stdhash_construct2</B>
+
+works the same way as
+<B>stdhash_construct</B>
+
+except that the seed,
+is explicitly given by the caller as
+<I>dseed</I>.
+
+stdhashs initialized using any of these methods initially contain no
+key-val pairs.
+<B>stdhash_copy_construct</B>
+
+makes
+<I>dst</I>
+
+contain a clone (copy by value) of the sequence of key-val pairs that
+the successfully initialized
+<I>src</I>
+
+stdhash contains. The cloned stdhash has the same operational parameters
+(i.e. - sizeof_key, sizeof_val, key_equals, key_hcode, rand_seed) as
+the source stdhash. It is illegal to call a constructor on an already
+successfully constructed stdhash -- doing so will cause memory leaks
+at best. When a stdhash is no longer in use its memory should be
+released by calling
+<B>stdhash_destruct</B>
+
+on it. Once a stdhash has been destructed it must be initialized again
+before being legally reused.
+<P>
+<B>stdhash_size</B>
+
+indicates the current number of key-vals contained in the stdhash.
+<B>stdhash_empty</B>
+
+indicates whether or not the stdhash contains no key-vals.
+<P>
+stdhash stores its values in a contiguous slab of memory. Due to
+this scheme, stdhash supports expected O(1) find, insert and erase
+operations of key-vals. However, insert and erase operations that
+require reallocation of the table will run in O(n) time and,
+technically, with vanishingly small probability, find operations can
+run in O(n) time.
+<B>stdhash_find</B>
+
+finds the first instance of the key
+<I>key</I>
+
+in the table and points the iterator
+<I>it</I>
+
+at that key-val pair.
+<B>stdhash_insert</B>
+
+inserts the key-val pair (
+<I>key</I>,
+
+<I>value</I>)
+
+into the table and points
+<I>it</I>
+
+at the newly inserted pair. Note, that this insertion
+<B>DOES NOT </B>
+
+overwrite any other pairs with an equal key. In addtion, the caller
+can pass a null (0) pointer for
+<I>it</I>.
+
+However, if the caller does this, there will be no way to detect
+if the insertion fails, so this is not recommended.
+<B>stdhash_erase</B>
+
+erases the key-val pair at which
+<I>it</I>
+
+is pointing. After the erasure
+<I>it</I>
+
+is pointed at the beginning of the stdhash.
+<B>stdhash_erase_key</B>
+
+erases all key-val pairs that have a key equal to
+<I>key</I>.
+
+It returns the number of key-val pairs that were erased.
+<P>
+<B>stdhash_clear</B>
+
+erases all of the key-val pairs contained in the stdhash.
+<B>stdhash_reserve</B>
+
+reserves enough memory to contain
+<I>num_elems</I>
+
+key-val pairs without requiring a reallocation.
+<B>stdhash_rehash</B>
+
+can be called to reallocate the table to its most appropriate size and
+to potentially increase the performance of the table.
+<P>
+stdhash is mainly used as a lookup table. However, it also contains
+a sequence of values. At any particular point between structural
+operations, each of the key-val pairs can be assigned a rank [0, n)
+just like the sequence stdutil data structures. However, unlike the
+sequence data structures this sequence appears random in nature and
+can change in a drastic and apparently random fashion upon structural
+changes. Like the other stdutil data structures, stdhash has several
+methods for getting iterators that reference particular values in its
+sequence. stdhash provides bi-directional iterators (see std_it).
+<B>stdhash_begin</B>
+
+sets the iterator
+<I>it</I>
+
+to reference the first, or 0th, value of the stdhash, or, if the
+stdhash is empty to reference the end of the stdhash. The end of the
+stdhash is one past the last value it contains.
+<B>stdhash_end</B>
+
+sets the iterator to reference the end of the stdhash.
+<B>stdhash_last</B>
+
+sets the iterator to reference the last value in the sequence. It is
+illegal to call stdhash_last on an empty stdhash. The above three
+iterator functions operate in constant O(1) time.
+<B>stdhash_get</B>
+
+sets the iterator to reference the value with index
+<I>elem_num</I>
+
+or end if
+<I>elem_num</I>
+
+is n.
+<I>elem_num</I>
+
+must be less than or equal to n. This operation runs in O(n) time and
+is provided only as a convenience. If the application often references
+arbitrary positions in the sequence, then another structure (such as
+stdarr or stdcarr) should probably be considered. All of these
+functions return pointers to the passed iterator to allow function
+composition.
+<P>
+stdhash iterators provide functionality that is slightly different
+and beyond the ``normal'' iterator functions (see std_it).
+<B>stdhash_it_key</B>
+
+returns a pointer to the key of the key-val pair to which
+<I>it</I>
+
+is referencing.
+<B>stdhash_it_val</B>
+
+returns a pointer to the value of the key-val pair to which
+<I>it</I>
+
+is referencing. Note, that it
+<B>DOES NOT</B>
+
+provide a pointer to the whole key-val pair as you might expect.
+<B>stdhash_it_kvp</B>
+
+returns a pointer to the struct stdkvp (see stdutil/stdkvp.h) that
+contains the entire key-val pair to which
+<I>it</I>
+
+is referencing.
+<B>stdhash_it_keyed_next</B>
+
+moves the iterator to reference the next key-val pair that has a key
+equal to the key to which
+<I>it</I>
+
+is currently referencing. If no such key-val pair exists then
+<I>it</I>
+
+will reference the end of the stdhash. This function allows you, for a
+given key, to iterate through all the duplicate keys in the
+stdhash. For example, let's say you had a stdhash that used ints as
+its key type and C strings as its values. Let's say you then inserted
+the key-val pairs: (5, "Hello") (5, "World"), (5, "!"). Then if you
+did a
+<B>stdhash_find</B>
+
+for 5, it would return an iterator to whichever of the 3 key-val pairs
+was ``first'', as defined by the stdhash (this is invariant between
+structural changes) and the key. Then if you did
+<B>stdhash_it_keyed_next</B>
+
+on that iterator it would move the iterator to reference the
+``second'' of those pairs as defined by the stdhash and the key
+(invariant between structural changes). If you did it one more time,
+then
+<B>stdhash_it_keyed_next</B>
+
+would move the iterator to reference the ``last'' of those pairs as
+defined by the stdhash and the key. If you called it one more time it
+would advance the iterator to point at the end of the stdhash. Also,
+if you got an iterator to the ``last'' key-val pair through some other
+method (e.g. -
+<B>stdhash_get</B>)
+
+and then called
+<B>stdhash_it_keyed_next</B>
+
+it would move the iterator to reference the end of the
+stdhash. Duplicate keys define a sort of mini-sequence of themselves
+within the stdhash. This sequence currently can only be iterated
+through
+<B>stdhash_it_keyed_next</B>.
+
+<P>
+<B>stdhash_max_size</B>
+
+returns the absolute maximum number of key-val pairs stdhash can hold
+and is invariant across different stdhashs.
+<B>stdhash_key_size</B>
+
+returns the size, in bytes, of the key type this stdhash is currently
+containing.
+<B>stdhash_val_size</B>
+
+returns the size, in bytes, of the value type this stdhash is
+currently containing.
+<B>stdhash_key_val_size</B>
+
+returns the size, in bytes, of the key-value type struct stdkvp (see
+stdkvp.h) that contains the key-val pair.
+<P>
+<H2>RETURN VALUES</H2>
+
+<P>
+Most of the functions' return values are described in the SYNOPSIS and
+cannot fail. However, the constructors and functions that potentially
+affect the size of the stdhash can fail. If such a function returns an
+int, then it returns zero on success and non-zero on failure (except
+for
+<B>stdhash_erase_key</B>).
+
+If such a function returns a stdhash_it *, then it returns non-zero
+on success and null(0) on failure. Whenever any stdhash function fails
+it has no side effects.
+<P>
+<H2>ERRORS</H2>
+
+<P>
+The constructor functions can return the following error codes:
+<DL COMPACT><DT><DD>
+<DL COMPACT>
+<DT><B>STD_ILLEGAL_PARAM </B>
+
+<DD>
+the sizeof the key type was zero.
+<P>
+<DT><B>STD_MEM_FAILURE</B>
+
+<DD>
+a memory allocation failure occurred.
+</DL></DL>
+
+<P>
+Functions that potentially affect the size of the stdhash and return
+an int, return the following error codes on error:
+<DL COMPACT><DT><DD>
+<DL COMPACT>
+<DT><B>STD_MEM_FAILURE</B>
+
+<DD>
+a memory allocation failure occurred.
+</DL></DL>
+
+<P>
+<H2>NOTES</H2>
+
+<P>
+For performance reasons, by default the stdutil library does no usage
+checking. It assumes the programmer knows what s/he is doing and
+doesn't want additional overhead incurred from sanity checks.
+<P>
+However, the library can be built will several types of checks,
+including bounds and initialization checks that can catch many common
+programming mistakes. See the README file included with the stdutil
+library distribution to see how to create such a "checked" or debug
+library.
+<P>
+<H2>AUTHOR</H2>
+
+<P>
+John Schultz <<A HREF="mailto:[email protected]">[email protected]</A>>
+<P>
+<H2>SEE ALSO</H2>
+
+<P>
+std_it
+
+<!--#include virtual="/includes/footer" -->
+
+</BODY>
+</HTML>
Added: vendor/stdutil/current/docs/html/stdutil_title.gif
===================================================================
(Binary files differ)
Property changes on: vendor/stdutil/current/docs/html/stdutil_title.gif
___________________________________________________________________
Name: svn:executable
+
Name: svn:mime-type
+ application/octet-stream
Added: vendor/stdutil/current/docs/index.html
===================================================================
--- vendor/stdutil/current/docs/index.html 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/index.html 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,48 @@
+<!--#include virtual="/includes/header" -->
+
+<title>Software: The Stdutil Library</title>
+
+
+</head>
+
+<body bgcolor="#FFFFFF">
+
+<!--#include virtual="/includes/header-a" -->
+
+<img src="docs/stdutil_title.gif" alt="Stdutil Library">
+
+<!--#include virtual="/includes/header-b" -->
+
+<font size=-1>
+<DD><A href="http://www.cnds.jhu.edu/~jschultz">John Schultz</A>
+</font>
+<HR>
+
+<p>
+The stdutil library is a C library that provides many tools for basic C development. The
+core of the stdutil library is a set of high-performance data structures.
+</p>
+
+<font size=+2><b>Stdutil Resources:</b></font>
+
+<UL>
+<li>Read the Stdutil's <a href="README">README</a> file.
+
+<li>Read the Stdutil's <a href="STDUTIL_LICENSE">license</a>.
+
+<li>Read the Stdutil's <a href="docs/index.html">documentation</a>.<br>
+
+<li><a href="http://www.cnds.jhu.edu/download/stdutil.tar.gz">Download</a> Stdutil now!<br>
+</UL>
+
+E-mail <a href="mailto:[email protected]"><i>[email protected]</i></a>
+for more information.</p>
+
+<br>
+<br>
+<br>
+<br>
+
+<!--#include virtual="/includes/footer" -->
+
+</body></html>
Added: vendor/stdutil/current/docs/man/std_it.3thr
===================================================================
--- vendor/stdutil/current/docs/man/std_it.3thr 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/man/std_it.3thr 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,199 @@
+.TH STD_IT 3 "NOV 2000" "Stdutil Library"
+
+.SH "NAME"
+
+std_it, std_it_val, std_it_equals, std_it_is_begin, std_it_is_end, std_it_seek_begin, std_it_seek_end, std_it_next, std_it_advance, std_it_prev, std_it_retreat, std_it_offset, std_it_compare \- basic operations provided by stdutil iterators.
+
+.SH "SYNOPSIS"
+
+.BI "void *std_it_val(const std_it *" it ");"
+
+.BI "stdbool std_it_equals(const std_it *" it1 ", const std_it *" it2 ");"
+
+.BI "stdbool std_it_is_begin(const std_it *" it ");"
+
+.BI "stdbool std_it_is_end(const std_it *" it ");"
+
+.BI "std_it *std_it_seek_begin(std_it *" it ");"
+
+.BI "std_it *std_it_seek_end(std_it *" it ");"
+
+.BI "std_it *std_it_next(std_it *" it ");"
+
+.BI "std_it *std_it_advance(std_it *" it ", size_t " num_advance ");"
+
+.BI "std_it *std_it_prev(std_it *" it ");"
+
+.BI "std_it *std_it_retreat(std_it *" it ", size_t " num_retreat ");"
+
+.BI "std_it *std_it_offset(std_it *" it ", stdssize_t " offset ");"
+
+.BI "stdssize_t std_it_compare(const std_it *" it1 ", const std_it *" it2 ");"
+
+.SH "DESCRIPTION"
+
+A std_it is an abstract type that describes several iterator types
+defined by the stdutil library (e.g. - stdarr_it, stdcarr_it,
+stddll_it and stdhash_it). An iterator is a common design pattern used
+to represent a sequence of values contained in a data structure. The
+main purpose of an iterator is to allow for unique iteration through
+all of the values contained within a data structure. However,
+iterators can also be used in many other operations as well.
+
+Any data structure that supports unique iteration through all of its
+values defines a sequence on those values at the time of iteration. If
+the structure S contains n values, then each contained value in S can
+be uniquely associated with an integer rank in the range [0, n), which
+is equal to the number of values in S that precede it in the
+sequence.
+
+For the stdutil library, multiple iterations on the same data
+structure instance that occur without intervening structural
+operations on that instance see the same rank sequence of values.
+Furthermore, many stdutil data structures define precise semantics on
+how iterators and the rank sequence of the structure are affected by
+structural changes (see each structure's documentation).
+
+The stdutil is modeled loosely after C++'s STL library, which uses
+iterators extensively. In both the stdutil and STL libraries there are
+three types of iterators: forward, bi-directional and random-access
+iterators. See each stdutil data structure's documentation for what
+type of iterator it provides.
+
+A forward iterator allows some basic operations and tests, but in
+general only allows the iterator to move forward (increasing rank) in
+the data structure's sequence. A simple singly linked list should only
+provide a forward iterator, for example. A bi-directional iterator is
+a forward iterator, but also allows the iterator to move backwards
+(decreasing rank) in the structure's sequence. A simple doubly-linked
+list should provide a bi-directional iterator, for example. A
+random-access iterator is a bi-directional iterator that allows for
+arbitrary offset and comparison of sequence ranks. A tightly packed
+array of values should provide a random-access iterator, for example.
+
+A data structure's iterator implementation should attempt to support
+the broadest class it can, while maintaing expected O(1) space and
+time overhead for each of its basic operations (next, previous and
+offset, respectively).
+
+In the stdutil library, an iterator must be correctly initialized by a
+data structure instance before it can legally be used. All operations
+on that iterator are then done in the context of the initializing
+instance. The results of using an iterator initialized by one instance
+with another instance are undefined. Likewise, the results of calling
+iterator functions (such as
+.BR "std_it_compare" )
+on iterators initialized by different structure instances are
+undefined.
+
+.SH "FORWARD ITERATORS"
+
+A forward iterator is the most restricted class of iterator and
+supports the following operations in expected O(1) space and time.
+
+.B "std_it_val"
+returns a pointer to the value to which this iterator is currently
+referencing.
+
+.B "std_it_equals"
+returns stdtrue if the two iterators are referencing the same value.
+
+.B "std_it_is_begin"
+returns stdtrue if the iterator is referencing the beginning of the
+sequence. The beginning of a sequence is defined as the first value in
+the sequence or the end of the sequence if it is empty.
+
+.B "std_it_is_end"
+returns stdtrue if the iterator is referencing the end of the
+sequence. The end of a sequence is defined as one position past the
+last value contained in the sequence (rank n). It is illegal to call
+.B "std_it_val"
+on the end of sequence.
+
+.B "std_it_seek_begin"
+sets the iterator to reference the beginning of the sequence.
+
+.B "std_it_seek_end"
+sets the iterator to reference the end of the sequence.
+
+.B "std_it_next"
+advances the iterator forward one position in the sequence.
+
+.B "std_it_advance"
+advances the iterator forward
+.I "num_advance"
+positions in the sequence. This operation should execute in O(1) space
+and
+.RI "O(" "num_advance" ")"
+time.
+
+.SH "BI-DIRECTIONAL ITERATORS"
+
+A bi-directional iterator is a forward iterator that also supports the
+following operations in expected O(1) space and time.
+
+.B "std_it_prev"
+retreats the iterator back one position in the sequence.
+
+.B "std_it_retreat"
+retreats the iterator back
+.I "num_retreat"
+positions in the sequence. This operation should execute in O(1) space
+and
+.RI "O(" "num_retreat" ")"
+time.
+
+.SH "RANDOM-ACCESS ITERATORS"
+
+A random-access iterator is a bi-directional iterator that supports
+the following operations in expected O(1) space and time.
+
+.B "std_it_offset"
+offsets the iterator
+.I "offset"
+positions forward in the sequence. If
+.I "offset"
+is negative, then it retreats the iterator that many positions.
+
+.B "std_it_compare"
+compares two iterators and returns the offset in sequence rank needed
+to move from
+.I "it2"
+to
+.IR "it1" .
+For example, say
+.I "it1"
+is referencing the value with rank 2 and
+.I "it2"
+is referencing the value with rank 5, then
+.B std_it_compare
+.RI "(" "it1" ", " "it2" ")"
+would return -3.
+
+.SH "RETURN VALUES"
+
+When called legally, none of the above functions can fail. Most of the
+functions' return values are described in the SYNOPSIS. The functions
+that return std_it *'s return the
+.I "it"
+passed to them to allow for function composition.
+
+.SH "NOTES"
+
+For performance reasons, by default the stdutil library does no usage
+checking. It assumes the programmer knows what s/he is doing and
+doesn't want additional overhead incurred from sanity checks.
+
+However, the library can be built will several types of checks,
+including bounds and initialization checks that can catch many common
+programming mistakes. See the README file included with the stdutil
+library distribution to see how to create such a "checked" or debug
+library.
+
+.SH "AUTHOR"
+
+John Schultz <[email protected]>
+
+.SH "SEE ALSO"
+
+stdarr, stdcarr, stddll, stdhash
Added: vendor/stdutil/current/docs/man/stdarr.3thr
===================================================================
--- vendor/stdutil/current/docs/man/stdarr.3thr 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/man/stdarr.3thr 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,352 @@
+.TH STDARR 3 "NOV 2000" "Stdutil Library"
+
+.SH "NAME"
+
+stdarr, stdarr_construct, stdarr_copy_construct, stdarr_destruct, stdarr_size, stdarr_empty, stdarr_high_capacity, stdarr_low_capacity, stdarr_get_auto_alloc, stdarr_set_auto_alloc, stdarr_push_back, stdarr_pop_back, stdarr_multi_push_back, stdarr_multi_pop_back, stdarr_insert, stdarr_erase, stdarr_repeat_insert, stdarr_multi_insert, stdarr_multi_erase, stdarr_resize, stdarr_clear, stdarr_set_capacity, stdarr_reserve, stdarr_shrink_fit, stdarr_begin, stdarr_end, stdarr_last, stdarr_get, stdarr_max_size, stdarr_val_size \- operations on a stdarr, a resizable array data structure
+
+.SH "SYNOPSIS"
+
+.B "#include <stdutil/stdarr.h>"
+
+.BI "stdarr " array " = STDARR_STATIC_CONSTRUCT(sizeof_val);"
+
+.BI "int stdarr_construct(stdarr *" arr ", size_t " sizeof_val ");"
+
+.BI "int stdarr_copy_construct(stdarr *" dst ", const stdarr *" src ");"
+
+.BI "void stdarr_destruct(stdarr *" arr ");"
+
+.BI "size_t stdarr_size(const stdarr *" arr ");"
+
+.BI "stdbool stdarr_empty(const stdarr *" arr ");"
+
+.BI "size_t stdarr_high_capacity(const stdarr *" arr ");"
+
+.BI "size_t stdarr_low_capacity(const stdarr *" arr ");"
+
+.BI "stdbool stdarr_get_auto_alloc(const stdarr *" arr ");"
+
+.BI "void stdarr_set_auto_alloc(stdarr *" arr ", stdbool " use_auto_alloc ");"
+
+.BI "int stdarr_push_back(stdarr *" arr ", const void *" val ");"
+
+.BI "int stdarr_pop_back(stdarr *" arr ");"
+
+.BI "int stdarr_multi_push_back(stdarr *" arr ", const void *" vals ", size_t " num_push ");"
+
+.BI "int stdarr_multi_pop_back(stdarr *" arr ", size_t " num_pop ");"
+
+.BI "stdarr_it *stdarr_insert(stdarr_it *" it ", const void *" val ");"
+
+.BI "stdarr_it *stdarr_erase(stdarr_it *" it ");"
+
+.BI "stdarr_it *stdarr_repeat_insert(stdarr_it *" it ", const void *" val ", size_t " num_times ");"
+
+.BI "stdarr_it *stdarr_multi_insert(stdarr_it *" it ", const void *" vals ", size_t " num_insert ");"
+
+.BI "stdarr_it *stdarr_multi_erase(stdarr_it *" it ", size_t " num_erase ");"
+
+.BI "int stdarr_resize(stdarr *" arr ", size_t " num_elems ");"
+
+.BI "int stdarr_clear(stdarr *" arr ");"
+
+.BI "int stdarr_set_capacity(stdarr *" arr " , size_t " num_elems ");"
+
+.BI "int stdarr_reserve(stdarr *" arr ", size_t " num_elems ");"
+
+.BI "int stdarr_shrink_fit(stdarr *" arr ");"
+
+.BI "stdarr_it *stdarr_begin(const stdarr *" arr ", stdarr_it *" it ");"
+
+.BI "stdarr_it *stdarr_end(const stdarr *" arr ", stdarr_it *" it ");"
+
+.BI "stdarr_it *stdarr_last(const stdarr *" arr ", stdarr_it *" it ");"
+
+.BI "stdarr_it *stdarr_get(const stdarr *" arr ", stdarr_it *" it ", size_t " elem_num ");"
+
+.BI "size_t stdarr_max_size(const stdarr *" arr ");"
+
+.BI "size_t stdarr_val_size(const stdarr *" arr ");"
+
+.SH "DESCRIPTION"
+
+stdarr is a generic data structure that contains, by value, a user
+defined sequence of same sized values. The values can be referenced in
+constant O(1) time by their 0-based rank in the sequence. This data
+structure is the equivalent of a resizable array or vector in other
+languages. This structure is well suited to applications where
+references to arbitrary points in a user defined sequence often occur.
+
+Before a stdarr can legally be used it must be successfully
+initialized.
+.BI "STDARR_STATIC_CONSTRUCT(" sizeof_val ")"
+is a macro that initializes the assigned stdarr at definition to
+contain values of size
+.I "sizeof_val"
+bytes.
+.B "stdarr_construct"
+dynamically initializes the stdarr object pointed to by
+.I "arr"
+to contain values of size
+.I "sizeof_val"
+bytes. Arrays initialized using either of these methods initially
+contain no values.
+.B "stdarr_copy_construct"
+makes
+.I "dst"
+contain a clone (copy by value) of the sequence of values that the
+successfully initialized
+.I "src"
+array contains. The cloned array has the same operational parameters
+(i.e. - sizeof_val, auto_alloc) as the source array. It is illegal to
+call a constructor on an already successfully constructed stdarr --
+doing so will cause memory leaks at best. When an array is no longer
+in use its memory should be released by calling
+.BR "stdarr_destruct"
+on it. Once a stdarr has been destructed it must be initialized again
+before being legally used.
+
+.B "stdarr_size"
+indicates the current number of values contained in the array.
+.B "stdarr_empty"
+indicates whether or not the array contains no values.
+
+In order to support constant time access to any value, stdarr
+allocates a contiguous block of memory in which it stores its sequence
+of values. When a rank is referenced (see stdarr_get), an offset
+from the base address of the allocated memory is calculated, which
+gives the address of the value. Because of this block memory scheme,
+when too many values are inserted to fit into the allocated memory,
+the stdarr must allocate a new block of memory to contain the sequence
+and move its sequence there.
+
+Reallocating and copying a sequence of values is an expensive linear
+O(n) time operation, where n is the number of values in the array. In
+order to minimize the frequency of these operations, stdarr defaults
+to using an auto-allocation mechanism that handles memory
+allocation. When this mechanism is active, it allocates more memory
+than the array currently needs so that every insertion and deletion
+does not result in a reallocation. If the mechanism is active, then
+.B "stdarr_high_capacity"
+indicates the maximum number of values the array can contain before
+being reallocated and
+.B "stdarr_low_capacity"
+indicates the minimum number of values the array can contain before
+.B "possibly"
+being reallocated. If the size of the array always remains between
+these two numbers, then the array will never be reallocated by the
+auto-allocation mechanism.
+
+Oftentimes the programmer will want to control the allocation of the
+array's memory manually. For this reason, the programmer can activate
+or deactivate the auto-allocation mechanism by passing, respectively,
+.I "stdtrue"
+or
+.I "stdfalse"
+to
+.BR "stdarr_set_auto_alloc" .
+The programmer can query if the auto-allocation mechanism is currently
+active by calling
+.BR "stdarr_get_auto_alloc" .
+While the auto-allocation mechanism is disabled, the current memory
+allocation of the array is fixed and no size affecting operations
+(insert, pop, resize, etc.) will result in reallocations. In this
+case, it is the user's responsibility to ensure that there is enough
+memory to contain the values stored in the array.
+.B "stdarr_high_capacity"
+indicates the maximum number of values an array can legally contain in
+its current allocation.
+
+Because stdarr stores its values in contiguous memory it provides
+fast stack operations (push and pop) onto the end of the
+sequence. Push operations run in linear O(m) time, where m is the
+number of elements being pushed. Pop operations run in constant O(1)
+time. If a stack operation causes an auto-reallocation then it runs in
+linear O(n) time.
+.B "stdarr_push_back"
+pushes the referenced value onto the end of the array.
+.B "stdarr_pop_back"
+pops the last value off of the end of the array.
+.B "stdarr_multi_push_back"
+appends an array of
+.I "num_push"
+values onto the end of the stdarr.
+.B "stdarr_multi_pop_back"
+pops the last
+.I "num_pop"
+values off of the end of the array.
+
+Because stdarr stores its values in contiguous memory it provides
+slow list operations (insert and erase) on the sequence in worst case
+linear O(n) time. These functions are very expensive and are only
+provided as a convenience. If the user performs list operations often,
+then another data structure (such as stddll) should probably be
+considered.
+.B "stdarr_insert"
+inserts the referenced value into the sequence immediately before the
+value that the iterator
+.I "it"
+references. The passed iterator is set to point at the inserted
+value. All of the old values after the insertion point have their
+rank in the sequence incremented by one.
+.B "stdarr_multi_insert"
+inserts an array of
+.I "num_insert"
+values into the array immediately before the value that the iterator
+.I "it"
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their rank in the sequence incremented by
+.IR "num_insert" .
+.B "stdarr_repeat_insert"
+inserts the referenced value into the sequence
+.I "num_times"
+times immediately before the value that
+.I "it"
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their rank in the sequence incremented by
+.IR "num_times" .
+
+.B "stdarr_erase"
+erases the value that
+.I "it"
+references. All of the remaining values after the erased value have
+their rank in the sequence decremented by one. The passed iterator is
+set to point at the value that shifted into the erased position, or
+end if none.
+.B "stdarr_multi_erase"
+erases the contiguous increasing subsequence of
+.I "num_erase"
+values starting at and including the rank/value that
+.I "it"
+references. All of the remaining values after the erased subsequence
+have their rank in the sequence decremented by
+.IR "num_erase" .
+The passed iterator is set to point at the value that shifted into the
+beginning position of the erased subsequence, or end if none. All of
+the list operations return a pointer to the passed iterator to allow
+for function composition.
+
+Stdarr also has several resizing and capacity (allocation) features.
+.B "stdarr_resize"
+resizes the array to contain
+.I "num_elems"
+values. If
+.I "num_elems"
+is smaller than the current size of the array, then this will truncate
+the sequence to only contain the first
+.I "num_elems"
+values in the array. If
+.I "num_elems"
+is larger than the current size of the array, then additional
+uninitialized values will be added to the end of the sequence of
+values.
+.B "stdarr_clear"
+deletes all of the values contained in the sequence.
+.B "stdarr_set_capacity"
+sets the high capacity of the array to be
+.IR "num_elems" ,
+which will usually require a re-allocation. This function is often
+used when the user has turned off the auto-allocation mechanism and
+wants to set the size of memory allocated to the array manually.
+.B "stdarr_reserve"
+reserves enough memory space to contain
+.I "num_elems"
+values; if the auto-allocation mechanism is disabled this function
+has the same effect as
+.BR "stdarr_set_capacity" .
+.B "stdarr_shrink_fit"
+makes the capacity of the array the same as the size of the array so
+that there is no unused allocated memory. This operation will usually
+require a re-allocation.
+
+stdarr, like the other stdutil data structures, has several methods
+for getting iterators that reference particular values in its
+sequence. stdarr provides random-access iterators (see std_it).
+.B "stdarr_begin"
+sets the iterator
+.I "it"
+to reference the first or 0th value of the array, or, if the array is
+empty to reference the end of the array.
+.B "stdarr_end"
+sets the iterator to reference the end of the array. The end of the
+array is one past the last value contained in the array and has a
+sequence rank of n.
+.B "stdarr_last"
+sets the iterator to reference the nth value in the sequence (rank of
+n-1). It is illegal to call stdarr_last on an empty array.
+.B "stdarr_get"
+sets the iterator to reference the value with rank
+.I "elem_num"
+or end if
+.I "elem_num"
+is n.
+.I "elem_num"
+must be less than or equal to n. All of these functions return
+pointers to the passed iterator to allow function composition. All of
+these functions work in constant O(1) time.
+
+.B "stdarr_max_size"
+returns the absolute maximum number of values of a particular size an
+array can hold. As an array's size approaches this number (within a
+small multiplicative factor) the auto-allocation mechanism may begin
+to fail because it tries to allocate too much memory. If an array
+needs to be able to hold somewhere around this many values, then the
+user should disable the auto-allocation mechanism and manually control
+the capacity of the array.
+
+.B "stdarr_val_size"
+returns the size, in bytes, of the value type this array is currently
+containing.
+
+.SH "RETURN VALUES"
+
+Most of the functions' return values are described in the SYNOPSIS and
+cannot fail. However, the constructors and functions that potentially
+affect the capacity of the array can fail. If such a function returns
+an int, then it returns zero on success and non-zero on failure. If
+such a function returns a stdarr_it *, then it returns non-zero on
+success and null(0) on failure. Whenever any stdarr function fails it
+has no side effects.
+
+.SH "ERRORS"
+
+The constructor functions can return the following error codes:
+.RS
+.TP
+.B "STD_ILLEGAL_PARAM"
+the sizeof the value type was zero.
+
+.TP
+.B "STD_MEM_FAILURE"
+a memory allocation failure occurred.
+.RE
+
+Functions that potentially affect the capacity of the array and return
+an int, return the following error codes on error:
+.RS
+.TP
+.B "STD_MEM_FAILURE"
+a memory allocation failure occurred.
+.RE
+
+.SH "NOTES"
+
+For performance reasons, by default the stdutil library does no usage
+checking. It assumes the programmer knows what s/he is doing and
+doesn't want additional overhead incurred from sanity checks.
+
+However, the library can be built will several types of checks,
+including bounds and initialization checks that can catch many common
+programming mistakes. See the README file included with the stdutil
+library distribution to see how to create such a "checked" or debug
+library.
+
+.SH "AUTHOR"
+
+John Schultz <[email protected]>
+
+.SH "SEE ALSO"
+
+std_it, stdcarr, stddll
Added: vendor/stdutil/current/docs/man/stdcarr.3thr
===================================================================
--- vendor/stdutil/current/docs/man/stdcarr.3thr 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/man/stdcarr.3thr 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,384 @@
+.TH STDCARR 3 "NOV 2000" "Stdutil Library"
+
+.SH "NAME"
+
+stdcarr, stdcarr_construct, stdcarr_copy_construct, stdcarr_destruct, stdcarr_size, stdcarr_empty, stdcarr_high_capacity, stdcarr_low_capacity, stdcarr_get_auto_alloc, stdcarr_set_auto_alloc, stdcarr_push_front, stdcarr_pop_front, stdcarr_push_back, stdcarr_pop_back, stdcarr_multi_push_front, stdcarr_multi_pop_front, stdcarr_multi_push_back, stdcarr_multi_pop_back, stdcarr_insert, stdcarr_erase, stdcarr_repeat_insert, stdcarr_multi_insert, stdcarr_multi_erase, stdcarr_resize, stdcarr_clear, stdcarr_set_capacity, stdcarr_reserve, stdcarr_shrink_fit, stdcarr_begin, stdcarr_end, stdcarr_last, stdcarr_get, stdcarr_max_size, stdcarr_val_size \- operations on a stdcarr, a resizable circular array data structure
+
+.SH "SYNOPSIS"
+
+.B "#include <stdutil/stdcarr.h>"
+
+.BI "stdcarr " carray " = STDCARR_STATIC_CONSTRUCT(sizeof_val);"
+
+.BI "int stdcarr_construct(stdcarr *" carr ", size_t " sizeof_val ");"
+
+.BI "int stdcarr_copy_construct(stdcarr *" dst ", const stdcarr *" src ");"
+
+.BI "void stdcarr_destruct(stdcarr *" carr ");"
+
+.BI "size_t stdcarr_size(const stdcarr *" carr ");"
+
+.BI "stdbool stdcarr_empty(const stdcarr *" carr ");"
+
+.BI "size_t stdcarr_high_capacity(const stdcarr *" carr ");"
+
+.BI "size_t stdcarr_low_capacity(const stdcarr *" carr ");"
+
+.BI "stdbool stdcarr_get_auto_alloc(const stdcarr *" carr ");"
+
+.BI "void stdcarr_set_auto_alloc(stdcarr *" carr ", stdbool " use_auto_alloc ");"
+
+.BI "int stdcarr_push_front(stdcarr *" carr ", const void *" val ");"
+
+.BI "int stdcarr_pop_front(stdcarr *" carr ");"
+
+.BI "int stdcarr_push_back(stdcarr *" carr ", const void *" val ");"
+
+.BI "int stdcarr_pop_back(stdcarr *" carr ");"
+
+.BI "int stdcarr_multi_push_front(stdcarr *" carr ", const void *" vals ", size_t " num_push ");"
+
+.BI "int stdcarr_multi_pop_front(stdcarr *" carr ", size_t " num_pop ");"
+
+.BI "int stdcarr_multi_push_back(stdcarr *" carr ", const void *" vals ", size_t " num_push ");"
+
+.BI "int stdcarr_multi_pop_back(stdcarr *" carr ", size_t " num_pop ");"
+
+.BI "stdcarr_it *stdcarr_insert(stdcarr_it *" it ", const void *" val ");"
+
+.BI "stdcarr_it *stdcarr_erase(stdcarr_it *" it ");"
+
+.BI "stdcarr_it *stdcarr_repeat_insert(stdcarr_it *" it ", const void *" val ", size_t " num_times ");"
+
+.BI "stdcarr_it *stdcarr_multi_insert(stdcarr_it *" it ", const void *" vals ", size_t " num_insert ");"
+
+.BI "stdcarr_it *stdcarr_multi_erase(stdcarr_it *" it ", size_t " num_erase ");"
+
+.BI "int stdcarr_resize(stdcarr *" carr ", size_t " num_elems ");"
+
+.BI "int stdcarr_clear(stdcarr *" carr ");"
+
+.BI "int stdcarr_set_capacity(stdcarr *" carr " , size_t " num_elems ");"
+
+.BI "int stdcarr_reserve(stdcarr *" carr ", size_t " num_elems ");"
+
+.BI "int stdcarr_shrink_fit(stdcarr *" carr ");"
+
+.BI "stdcarr_it *stdcarr_begin(const stdcarr *" carr ", stdcarr_it *" it ");"
+
+.BI "stdcarr_it *stdcarr_end(const stdcarr *" carr ", stdcarr_it *" it ");"
+
+.BI "stdcarr_it *stdcarr_last(const stdcarr *" carr ", stdcarr_it *" it ");"
+
+.BI "stdcarr_it *stdcarr_get(const stdcarr *" carr ", stdcarr_it *" it ", size_t " elem_num ");"
+
+.BI "size_t stdcarr_max_size(const stdcarr *" carr ");"
+
+.BI "size_t stdcarr_val_size(const stdcarr *" carr ");"
+
+.SH "DESCRIPTION"
+
+stdcarr is a generic data structure that contains, by value, a user
+defined sequence of same sized values. The values can be referenced in
+constant O(1) time by their 0-based rank in the sequence. This data
+structure is the equivalent of a resizable circular array or circular
+vector in other languages. This structure is well suited to
+applications where references to arbitrary points in a user defined
+sequence often occur.
+
+This data structure is closely related to the stdarr. The main
+differences between these structures are: (1) most operations should
+work slightly faster on a stdarr, and (2) stdcarr provides
+expected constant O(1) time push and pop operations on both ends of
+the array, while a stdarr only provides those operations on the end
+of the array. Obviously stdcarr supports any type of queuing
+application
+.B much
+better than stdarr.
+
+Before a stdcarr can legally be used it must be successfully
+initialized.
+.BI "STDCARR_STATIC_CONSTRUCT(" sizeof_val ")"
+is a macro that initializes the assigned stdcarr at definition to
+contain values of size
+.I "sizeof_val"
+bytes.
+.B "stdcarr_construct"
+dynamically initializes the stdcarr object pointed to by
+.I "carr"
+to contain values of size
+.I "sizeof_val"
+bytes. Arrays initialized using either of these methods initially
+contain no values.
+.B "stdcarr_copy_construct"
+makes
+.I "dst"
+contain a clone (copy by value) of the sequence of values that the
+successfully initialized
+.I "src"
+array contains. The cloned array has the same operational parameters
+(i.e. - sizeof_val, auto_alloc) as the source array. It is illegal to
+call a constructor on an already successfully constructed stdcarr --
+doing so will cause memory leaks at best. When an array is no longer
+in use its memory should be released by calling
+.BR "stdcarr_destruct"
+on it. Once a stdcarr has been destructed it must be successfully
+initialized again before being legally used.
+
+.B "stdcarr_size"
+indicates the current number of values contained in the array.
+.B "stdcarr_empty"
+indicates whether or not the array contains no values.
+
+In order to support constant time access to any value, stdcarr
+allocates a contiguous block of memory in which it stores its sequence
+of values. When a rank is referenced (see stdcarr_get), an offset from
+the arbitrary beginning address of the stored values is calculated
+modulo the size of the allocated memory, which gives the address of
+the value. Because of this block memory scheme, when too many values
+are inserted to fit into the allocated memory, the stdcarr must
+allocate a new block of memory to contain the sequence and move its
+sequence there.
+
+Reallocating and copying a sequence of values is an expensive linear
+O(n) time operation, where n is the number of values contained. In
+order to minimize the frequency of these operations, stdcarr defaults
+to using an auto-allocation mechanism that handles memory
+allocation. When this mechanism is active, it allocates more memory
+than the array currently needs so that every insertion and deletion
+does not result in a reallocation. If the mechanism is active, then
+.B "stdcarr_high_capacity"
+indicates the maximum number of values the array can contain before
+being reallocated and
+.B "stdcarr_low_capacity"
+indicates the minimum number of values the array can contain before
+.B "possibly"
+being reallocated. If the size of the array always remains between
+these two numbers, then the array will never be reallocated by the
+auto-allocation mechanism.
+
+Oftentimes the programmer will want to control the allocation of the
+array's memory manually. For this reason, the programmer can activate
+or deactivate the auto-allocation mechanism by passing, respectively,
+.I "stdtrue"
+or
+.I "stdfalse"
+to
+.BR "stdcarr_set_auto_alloc" .
+The programmer can query if the auto-allocation mechanism is currently
+active by calling
+.BR "stdcarr_get_auto_alloc" .
+While the auto-allocation mechanism is disabled, the current memory
+allocation of the array is fixed and no size affecting operations
+(insert, pop, resize, etc.) will result in reallocations. In this
+case, it is the user's responsibility to ensure that there is enough
+memory to contain the values stored in the array.
+.B "stdcarr_high_capacity"
+indicates the maximum number of values an array can legally contain in
+its current allocation.
+
+Because stdcarr stores its values in contiguous memory it provides
+fast stack operations (push and pop) onto both the beginning and the
+end of the sequence. Push operations run in O(m) time, where m is the
+number of elements being pushed. Pop operations run in constant O(1)
+time. If a stack operation causes an auto-reallocation it runs in
+linear O(n) time.
+.B "stdcarr_push_front"
+pushes the referenced value onto the beginning of the array.
+.B "stdcarr_pop_front"
+pops the first element off of the front of the array.
+.B "stdcarr_push_back"
+pushes the referenced value onto the end of the array.
+.B "stdcarr_pop_back"
+pops the last value off of the end of the array.
+.B "stdcarr_multi_push_front"
+prepends an array of
+.I "num_push"
+values onto the beginning of the stdcarr.
+.B "stdcarr_multi_pop_front"
+pops the first
+.I "num_pop"
+values off of the beginning of the array.
+.B "stdcarr_multi_push_back"
+appends an array of
+.I "num_push"
+values onto the end of the stdcarr.
+.B "stdcarr_multi_pop_back"
+pops the last
+.I "num_erase"
+values off of the end of the array.
+
+Because stdcarr stores its values in contiguous memory it provides
+slow list operations (insert and erase) on the sequence in worst
+case linear O(n) time. These functions are very expensive and are only
+provided as a convenience. If the user needs to do list operations
+often, then another data structure (such as stddll) should probably be
+considered.
+.B "stdcarr_insert"
+inserts the referenced value into the sequence immediately before the
+value that the iterator
+.I "it"
+references. The passed iterator is set to point at the inserted
+value. All of the old values after the insertion point have their
+rank in the sequence incremented by one.
+.B "stdcarr_multi_insert"
+inserts an array of
+.I "num_insert"
+values into the array immediately before the value that the iterator
+.I "it"
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their rank in the sequence incremented by
+.IR "num_insert" .
+.B "stdcarr_repeat_insert"
+inserts the referenced value into the sequence
+.I "num_times"
+times immediately before the value that
+.I "it"
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their rank in the sequence incremented by
+.IR "num_times" .
+
+.B "stdcarr_erase"
+erases the value that
+.I "it"
+references. All of the remaining values after the erased value have
+their rank in the sequence decremented by one. The passed iterator is
+set to point at the value that shifted into the erased position, or
+end if none.
+.B "stdcarr_multi_erase"
+erases the contiguous increasing subsequence of
+.I "num_erase"
+values starting at and including the rank/value that
+.I "it"
+references. All of the remaining values after the erased subsequence
+have their rank in the sequence decremented by
+.IR "num_erase" .
+The passed iterator is set to point at the value that shifted into the
+beginning position of the erased subsequence, or end if none. All of
+the list operations return a pointer to the passed iterator to allow
+for function composition.
+
+Stdcarr also has several resizing and capacity (allocation) features.
+.B "stdcarr_resize"
+resizes the array to contain
+.I "num_elems"
+values. If
+.I "num_elems"
+is smaller than the current size of the array, then this will truncate
+the sequence to only contain the first
+.I "num_elems"
+values in the array. If
+.I "num_elems"
+is larger than the current size of the array, then additional
+uninitialized values will be added to the end of the sequence of
+values.
+.B "stdcarr_clear"
+deletes all of the values contained in the sequence.
+.B "stdcarr_set_capacity"
+sets the high capacity of the array to be
+.IR "num_elems" ,
+which will usually require a reallocation. This function is often
+used when the user has turned off the auto-allocation mechanism and
+wants to set the size of memory allocated to the array manually.
+.B "stdcarr_reserve"
+reserves enough memory space to contain
+.I "num_elems"
+values; if the auto-allocation mechanism is disabled this function
+has the same effect as
+.BR "stdcarr_set_capacity" .
+.B "stdcarr_shrink_fit"
+makes the capacity of the array the same as the size of the array so
+that there is no unused allocated memory. This operation will usually
+require a re-allocation.
+
+stdcarr, like the other stdutil data structures, has several methods
+for getting iterators that reference particular values in its
+sequence. stdcarr provides random-access iterators (see std_it).
+.B "stdcarr_begin"
+sets the iterator
+.I "it"
+to reference the first or 0th value of the array, or, if the array is
+empty to reference the end of the array.
+.B "stdcarr_end"
+sets the iterator to reference the end of the array. The end of the
+array is one past the last value contained in the array and has an
+rank of n.
+.B "stdcarr_last"
+sets the iterator to reference the nth value in the sequence (rank of
+n-1). It is illegal to call stdcarr_last on an empty array.
+.B "stdcarr_get"
+sets the iterator to reference the value with rank
+.I "elem_num"
+or end if
+.I "elem_num"
+is n.
+.I "elem_num"
+must be less than or equal to n. All of these functions return
+pointers to the passed iterator to allow function composition. All of
+these functions work in constant O(1) time.
+
+.B "stdcarr_max_size"
+returns the absolute maximum number of values of a particular size an
+array can hold. As an array's size approaches this number (within a
+small multiplicative factor) the auto-allocation mechanism may begin
+to fail because it tries to allocate too much memory. If an array
+needs to be able to hold somewhere around this many values, then the
+user should disable the auto-allocation mechanism and manually control
+the capacity of the array.
+
+.B "stdcarr_val_size"
+returns the size, in bytes, of the value type this array is currently
+containing.
+
+.SH "RETURN VALUES"
+
+Most of the functions' return values are described in the SYNOPSIS and
+cannot fail. However, the constructors and functions that potentially
+affect the capacity of the array can fail. If such a function returns
+an int, then it returns zero on success and non-zero on failure. If
+such a function returns a stdcarr_it *, then it returns non-zero on
+success and null(0) on failure. Whenever any stdcarr function fails it
+has no side effects.
+
+.SH "ERRORS"
+
+The constructor functions can return the following error codes:
+.RS
+.TP
+.B "STD_ILLEGAL_PARAM"
+the sizeof the value type was zero.
+
+.TP
+.B "STD_MEM_FAILURE"
+a memory allocation failure occurred.
+.RE
+
+Functions that potentially affect the capacity of the array and return
+an int, return the following error codes on error:
+.RS
+.TP
+.B "STD_MEM_FAILURE"
+a memory allocation failure occurred.
+.RE
+
+.SH "NOTES"
+
+For performance reasons, by default the stdutil library does no usage
+checking. It assumes the programmer knows what s/he is doing and
+doesn't want additional overhead incurred from sanity checks.
+
+However, the library can be built will several types of checks,
+including bounds and initialization checks that can catch many common
+programming mistakes. See the README file included with the stdutil
+library distribution to see how to create such a "checked" or debug
+library.
+
+.SH "AUTHOR"
+
+John Schultz <[email protected]>
+
+.SH "SEE ALSO"
+
+std_it, stdarr, stddll
Added: vendor/stdutil/current/docs/man/stddll.3thr
===================================================================
--- vendor/stdutil/current/docs/man/stddll.3thr 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/man/stddll.3thr 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,286 @@
+.TH STDDLL 3 "NOV 2000" "Stdutil Library"
+
+.SH "NAME"
+
+stddll, stddll_construct, stddll_copy_construct, stddll_destruct, stddll_size, stddll_empty, stddll_push_front, stddll_pop_front, stddll_push_back, stddll_pop_back, stddll_multi_push_front, stddll_multi_pop_front, stddll_multi_push_back, stddll_multi_pop_back, stddll_insert, stddll_erase, stddll_repeat_insert, stddll_multi_insert, stddll_multi_erase, stddll_resize, stddll_clear, stddll_begin, stddll_end, stddll_last, stddll_get, stddll_max_size, stddll_val_size \- operations on a stddll, a list data structure
+
+.SH "SYNOPSIS"
+
+.B "#include <stdutil/stddll.h>"
+
+.BI "int stddll_construct(stddll *" dll ", size_t " sizeof_val ");"
+
+.BI "int stddll_copy_construct(stddll *" dst ", const stddll *" src ");"
+
+.BI "void stddll_destruct(stddll *" dll ");"
+
+.BI "size_t stddll_size(const stddll *" dll ");"
+
+.BI "stdbool stddll_empty(const stddll *" dll ");"
+
+.BI "int stddll_push_front(stddll *" dll ", const void *" val ");"
+
+.BI "int stddll_pop_front(stddll *" dll ");"
+
+.BI "int stddll_push_back(stddll *" dll ", const void *" val ");"
+
+.BI "int stddll_pop_back(stddll *" dll ");"
+
+.BI "int stddll_multi_push_front(stddll *" dll ", const void *" vals ", size_t " num_push ");"
+
+.BI "int stddll_multi_pop_front(stddll *" dll ", size_t " num_pop ");"
+
+.BI "int stddll_multi_push_back(stddll *" dll ", const void *" vals ", size_t " num_push ");"
+
+.BI "int stddll_multi_pop_back(stddll *" dll ", size_t " num_pop ");"
+
+.BI "stddll_it *stddll_insert(stddll_it *" it ", const void *" val ");"
+
+.BI "stddll_it *stddll_erase(stddll_it *" it ");"
+
+.BI "stddll_it *stddll_repeat_insert(stddll_it *" it ", const void *" val ", size_t " num_times ");"
+
+.BI "stddll_it *stddll_multi_insert(stddll_it *" it ", const void *" vals ", size_t " num_insert ");"
+
+.BI "stddll_it *stddll_multi_erase(stddll_it *" it ", size_t " num_erase ");"
+
+.BI "int stddll_resize(stddll *" dll ", size_t " num_elems ");"
+
+.BI "int stddll_clear(stddll *" dll ");"
+
+.BI "stddll_it *stddll_begin(const stddll *" dll ", stddll_it *" it ");"
+
+.BI "stddll_it *stddll_end(const stddll *" dll ", stddll_it *" it ");"
+
+.BI "stddll_it *stddll_last(const stddll *" dll ", stddll_it *" it ");"
+
+.BI "stddll_it *stddll_get(const stddll *" dll ", stddll_it *" it ", size_t " elem_num ");"
+
+.BI "size_t stddll_max_size(const stddll *" dll ");"
+
+.BI "size_t stddll_val_size(const stddll *" dll ");"
+
+.SH "DESCRIPTION"
+
+stddll is a generic data structure that contains, by value, a user
+defined sequence of same sized values. The values can be referenced in
+worst case linear O(n) time by their 0-based index in the sequence,
+where n is the number of values in the list. This data structure is
+the equivalent of a doubly linked list in other languages. This
+structure is well suited to applications where insertions at arbitrary
+points in a user defined sequence often occur. Some obvious uses of a
+stddll are as an efficient stack or as a FIFO queue.
+
+Before a stddll can legally be used it must be successfully
+initialized.
+.B "stddll_construct"
+dynamically initializes the stddll object pointed to by
+.I "dll"
+to contain values of size
+.I "sizeof_val"
+bytes. A list initialized using this method initially contains no
+values.
+.B "stddll_copy_construct"
+makes
+.I "dst"
+contain a clone (copy by value) of the sequence of values that the
+successfully initialized
+.I "src"
+list contains. The clone list has the same operational parameters
+(i.e. - sizeof_val) as the source list. It is illegal to call a
+constructor on an already successfully constructed stddll -- doing so
+will cause memory leaks at best. When a list is no longer in use its
+memory should be released by calling
+.BR "stddll_destruct"
+on it. Once a stddll has been destructed it must be successfully
+initialized again before being legally used.
+
+.B "stddll_size"
+indicates the current number of values contained in the list.
+.B "stddll_empty"
+indicates whether or not the list contains no values.
+
+stddll stores its values as a doubly linked (forwards and backwards)
+node list, where each node is allocated independently and contains a
+value. Due to this scheme stddll supports fast stack operations
+(push and pop) onto both the beginning and the end of the sequence.
+Push and pop operations run in linear O(m) time, where m is the number
+of values being pushed or popped.
+.B "stddll_push_front"
+pushes the referenced value onto the beginning of the list.
+.B "stddll_pop_front"
+pops the first element off of the front of the list.
+.B "stddll_push_back"
+pushes the referenced value onto the end of the list.
+.B "stddll_pop_back"
+pops the last value off of the end of the list.
+.B "stddll_multi_push_front"
+prepends an array of
+.I "num_push"
+values onto the beginning of the list.
+.B "stddll_multi_pop_front"
+pops the first
+.I "num_pop"
+values off of the beginning of the list.
+.B "stddll_multi_push_back"
+appends an array of
+.I "num_push"
+values onto the end of the list.
+.B "stddll_multi_pop_back"
+pops the last
+.I "num_erase"
+values off of the end of the list.
+
+Because stddll stores its values in a linked node list, it supports
+fast list operations (insert and erase) on the sequence in linear O(m)
+time, where m is the number of values being inserted or erased.
+.B "stddll_insert"
+inserts the referenced value into the sequence immediately before the
+value that the iterator
+.I "it"
+references. The passed iterator is set to point at the inserted
+value. All of the old values after the insertion point have their
+index in the sequence incremented by one.
+.B "stddll_multi_insert"
+inserts an array of
+.I "num_insert"
+values into the list immediately before the value that the iterator
+.I "it"
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their index in the sequence incremented by
+.IR "num_insert" .
+.B "stddll_repeat_insert"
+inserts the referenced value into the sequence
+.I "num_times"
+times immediately before the value that
+.I "it"
+references. The passed iterator is set to point at the first value of
+the inserted values. All of the old values after the insertion point
+have their index in the sequence incremented by
+.IR "num_times" .
+
+.B "stddll_erase"
+erases the value that
+.I "it"
+references. All of the remaining values after the erased value have
+their index in the sequence decremented by one. The passed iterator is
+set to point at the value that shifted into the erased position, or
+end if none.
+.B "stddll_multi_erase"
+erases the contiguous increasing subsequence of
+.I "num_erase"
+values starting at and including the index/value that
+.I "it"
+references. All of the remaining values after the erased subsequence
+have their index in the sequence decremented by
+.IR "num_erase" .
+The passed iterator is set to point at the value that shifted into the
+beginning position of the erased subsequence, or end if none. All of
+the list operations return a pointer to the passed iterator to allow
+for function composition.
+
+.B "stddll_resize"
+resizes the list to contain
+.I "num_elems"
+values. If
+.I "num_elems"
+is smaller than the current size of the list, then this will truncate
+the sequence to only contain the first
+.I "num_elems"
+values in the list. If
+.I "num_elems"
+is larger than the current size of the list, then additional
+uninitialized values will be added to the end of the sequence of
+values.
+.B "stddll_clear"
+deletes all of the values contained in the sequence.
+
+stddll, like the other stdutil data structures, has several methods
+for getting iterators that reference particular values in its
+sequence. stddll provides bi-directional iterators (see std_it).
+.B "stddll_begin"
+sets the iterator
+.I "it"
+to reference the first or 0th value of the list, or, if the list is
+empty to reference the end of the list.
+.B "stddll_end"
+sets the iterator to reference the end of the list. The end of the
+list is one past the last value contained in the list and has an index
+of n.
+.B "stddll_last"
+sets the iterator to reference the nth value in the sequence (index of
+n-1). It is illegal to call stddll_last on an empty list. The above
+three iterator functions operate in constant O(1) time.
+.B "stddll_get"
+sets the iterator to reference the value with index
+.I "elem_num"
+or end if
+.I "elem_num"
+is n.
+.I "elem_num"
+must be less than or equal to n. This operation runs in worst case
+O(n) time and is provided only as a convenience. If the application
+often references arbitrary positions in the sequence, then another
+structure (such as stdarr or stdcarr) should probably be
+considered. All of these functions return pointers to the passed
+iterator to allow function composition.
+
+.B "stddll_max_size"
+returns the absolute maximum number of values a list can hold and is
+invariant across different lists.
+
+.B "stddll_val_size"
+returns the size, in bytes, of the value type this list is currently
+containing.
+
+.SH "RETURN VALUES"
+
+Most of the functions' return values are described in the SYNOPSIS and
+cannot fail. However, the constructors and functions that potentially
+affect the size of the list can fail. If such a function returns an
+int, then it returns zero on success and non-zero on failure. If such
+a function returns a stddll_it *, then it returns non-zero on success
+and null(0) on failure. Whenever any stddll function fails it has no
+side effects.
+
+.SH "ERRORS"
+
+The constructor functions can return the following error codes:
+.RS
+.TP
+.B "STD_ILLEGAL_PARAM"
+the sizeof the value type was zero.
+
+.TP
+.B "STD_MEM_FAILURE"
+a memory allocation failure occurred.
+.RE
+
+Functions that potentially affect the size of the list and return an
+int, return the following error codes on error:
+.RS
+.TP
+.B "STD_MEM_FAILURE"
+a memory allocation failure occurred.
+.RE
+
+.SH "NOTES"
+
+For performance reasons, by default the stdutil library does no usage
+checking. It assumes the programmer knows what s/he is doing and
+doesn't want additional overhead incurred from sanity checks.
+
+However, the library can be built will several types of checks,
+including bounds and initialization checks that can catch many common
+programming mistakes. See the README file included with the stdutil
+library distribution to see how to create such a "checked" or debug
+library.
+
+.SH "AUTHOR"
+
+John Schultz <[email protected]>
+
+.SH "SEE ALSO"
+
+std_it, stdarr, stdcarr
Added: vendor/stdutil/current/docs/man/stdhash.3thr
===================================================================
--- vendor/stdutil/current/docs/man/stdhash.3thr 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/docs/man/stdhash.3thr 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,364 @@
+.TH STDHASH 3 "NOV 2000" "Stdutil Library"
+
+.SH "NAME"
+
+stdhash, stdhash_construct, stdhash_construct2, stdhash_copy_construct, stdhash_destruct, stdhash_size, stdhash_empty, stdhash_find, stdhash_insert, stdhash_erase, stdhash_erase_key, stdhash_clear, stdhash_reserve, stdhash_rehash, stdhash_begin, stdhash_end, stdhash_last, stdhash_get, stdhash_max_size, stdhash_key_size, stdhash_val_size, stdhash_key_val_size, stdhash_it_key, stdhash_it_val, stdhash_it_kvp, stdhash_it_keyed_next \- operations on a stdhash, a dictionary data structure
+
+.SH "SYNOPSIS"
+
+.B "#include <stdutil/stdhash.h>"
+
+.BI "stdhash " h " = STDHASH_STATIC_CONSTRUCT(" sizeof_key ", " sizeof_val ", " kequals ", " khcode ");"
+
+.BI "stdhash " h " = STDHASH_STATIC_CONSTRUCT2(" sizeof_key ", " sizeof_val ", " kequals ", " khcode ", " dseed ");"
+
+.BI "int stdhash_construct(stdhash *" h ", size_t " sizeof_key ", size_t " sizeof_val ", stdequals_fcn " kequals ", stdhcode_fcn " khcode ");"
+
+.BI "int stdhash_construct2(stdhash *" h ", size_t " sizeof_key ", size_t " sizeof_val ", stdequals_fcn " kequals ", stdhcode_fcn " khcode ", size_t " dseed ");"
+
+.BI "int stdhash_copy_construct(stdhash *" dst ", const stdhash *" src ");"
+
+.BI "void stdhash_destruct(stdhash *" h ");"
+
+.BI "size_t stdhash_size(const stdhash *" h ");"
+
+.BI "stdbool stdhash_empty(const stdhash *" h ");"
+
+.BI "stdhash_it *stdhash_find(const stdhash *" h ", stdhash_it *" it ", const void *" key ");"
+
+.BI "stdhash_it *stdhash_insert(stdhash *" h ", stdhash_it *" it ", const void *" key ", const void *" val ");"
+
+.BI "stdhash_it *stdhash_erase(stdhash_it *" it ");"
+
+.BI "int stdhash_erase_key(stdhash *" h ", const void *" key ");"
+
+.BI "int stdhash_clear(stdhash *" h ");"
+
+.BI "int stdhash_reserve(stdhash *" h ", size_t " num_elems ");"
+
+.BI "int stdhash_rehash(stdhash *" h ");"
+
+.BI "stdhash_it *stdhash_begin(const stdhash *" h ", stdhash_it *" it ");"
+
+.BI "stdhash_it *stdhash_end(const stdhash *" h ", stdhash_it *" it ");"
+
+.BI "stdhash_it *stdhash_last(const stdhash *" h ", stdhash_it *" it ");"
+
+.BI "stdhash_it *stdhash_get(const stdhash *" h ", stdhash_it *" it ", size_t " elem_num ");"
+
+.BI "void *stdhash_it_key(const stdhash_it *" it ");"
+
+.BI "void *stdhash_it_val(const stdhash_it *" it ");"
+
+.BI "stdkvp *stdhash_it_kvp(const stdhash_it *" it ");"
+
+.BI "stdhash_it *stdhash_it_keyed_next(stdhash_it *" it ");"
+
+.BI "size_t stdhash_max_size(const stdhash *" h ");"
+
+.BI "size_t stdhash_key_size(const stdhash *" h ");"
+
+.BI "size_t stdhash_val_size(const stdhash *" h ");"
+
+.BI "size_t stdhash_key_val_size(const stdhash *" h ");"
+
+.SH "DESCRIPTION"
+
+stdhash is a generic data structure that contains, by value, a
+collection of same-sized key-val pairs, where the keys remain constant
+while in the stdhash. These pairs can be referenced in expected
+constant O(1) time, worst case linear O(n) time (where n is the number
+of pairs in the hash), by their non-unique keys. This data structure
+is the equivalent of a dynamic, non-unique key dictionary or multihash
+in other languages. One can construct a stdhash to only contain key
+types. In that case, the stdhash acts as a collection of non-unique
+keys. This can be useful to test for key existence (e.g. - does the
+hash contain 5?). This structure is well suited to applications where
+quick look-ups based on a key often occur and long structural updates
+can be occasionaly tolerated.
+
+Before a stdhash can legally be used it must be successfully
+initialized. The user must specify the size of the key and value types
+to be stored. Values can be zero bytes in size. In addition, the user
+can specify two functions that will be used to compare keys. The first
+function is an equality tester for keys: it invariantly returns
+stdtrue (1) if the keys are equal and stdfalse (0) if the keys are not
+equal -- it should be a reflexive, symmetric and transitive relation
+on keys. The second function is a hashcode function that takes a
+pointer to a key and invariantly returns a size_t that represents the
+key as a size_t. This hashcode fcn must be consistent with the
+equality function, meaning that if two keys are equal then they must
+have the same hashcode. It is legal for two unequal keys to return the
+same hashcode, however, such hashcode collisions should occur with a
+probability of approximately 1 / (2^(sizeof(size_t) * 8)) for optimal
+performance.
+
+If the key type being stored is appropriate, the user can specify
+null (0) for either, or both, of the key comparison functions. In this
+case, a bitwise memory comparison is done for key equality and the
+hashcodes are computed as a function of the bits of the constant key.
+
+In addition, upon initialization a stdhash is given a seed number that
+it uses to generate random numbers. Two stdhashs that start with the
+same seeds and are modified in the exact same manner will be
+synchronized in terms of the key-val pairs and the sequence of those
+pairs that they contain.
+
+.BI "STDHASH_STATIC_CONSTRUCT"
+is a macro that initializes the assigned stdhash at definition to
+contain key-val pairs with keys of size
+.I "sizeof_key"
+bytes and values of
+.I "sizeof_val"
+bytes. The keys will be compared for equality using the function
+.I "kequals"
+and key hashcodes will be computed using the function
+.IR "khcode" .
+stdhashs constructed this way will be initialized with the same
+constant seed.
+.BI "STDHASH_STATIC_CONSTRUCT2"
+is the same as
+.B "STDHASH_STATIC_CONSTRUCT"
+except that the caller may specify a different seed with which to
+initialize the stdhash instead of the default seed.
+.B "stdhash_construct"
+dynamically initializes the stdhash object pointed to by
+.I "h"
+to contain key-val pairs with keys of size
+.I "sizeof_key"
+bytes and values of
+.I "sizeof_val"
+bytes. The keys will be compared for equality using the function
+.I "kequals"
+and key hashcodes will be computed using the function
+.IR "khcode" .
+stdhashs constructed this way will be initialized with a seed that is
+based on the current time on the system.
+.B "stdhash_construct2"
+works the same way as
+.B "stdhash_construct"
+except that the seed,
+is explicitly given by the caller as
+.IR "dseed" .
+stdhashs initialized using any of these methods initially contain no
+key-val pairs.
+.B "stdhash_copy_construct"
+makes
+.I "dst"
+contain a clone (copy by value) of the sequence of key-val pairs that
+the successfully initialized
+.I "src"
+stdhash contains. The cloned stdhash has the same operational parameters
+(i.e. - sizeof_key, sizeof_val, key_equals, key_hcode, rand_seed) as
+the source stdhash. It is illegal to call a constructor on an already
+successfully constructed stdhash -- doing so will cause memory leaks
+at best. When a stdhash is no longer in use its memory should be
+released by calling
+.B "stdhash_destruct"
+on it. Once a stdhash has been destructed it must be initialized again
+before being legally reused.
+
+.B "stdhash_size"
+indicates the current number of key-vals contained in the stdhash.
+.B "stdhash_empty"
+indicates whether or not the stdhash contains no key-vals.
+
+stdhash stores its values in a contiguous slab of memory. Due to
+this scheme, stdhash supports expected O(1) find, insert and erase
+operations of key-vals. However, insert and erase operations that
+require reallocation of the table will run in O(n) time and,
+technically, with vanishingly small probability, find operations can
+run in O(n) time.
+.B "stdhash_find"
+finds the first instance of the key
+.I "key"
+in the table and points the iterator
+.I "it"
+at that key-val pair.
+.B "stdhash_insert"
+inserts the key-val pair (
+.IR "key" ,
+.IR "value" )
+into the table and points
+.I "it"
+at the newly inserted pair. Note, that this insertion
+.B "DOES NOT"
+overwrite any other pairs with an equal key. In addtion, the caller
+can pass a null (0) pointer for
+.IR "it" .
+However, if the caller does this, there will be no way to detect
+if the insertion fails, so this is not recommended.
+.B "stdhash_erase"
+erases the key-val pair at which
+.I "it"
+is pointing. After the erasure
+.I "it"
+is pointed at the beginning of the stdhash.
+.B "stdhash_erase_key"
+erases all key-val pairs that have a key equal to
+.IR "key" .
+It returns the number of key-val pairs that were erased.
+
+.B "stdhash_clear"
+erases all of the key-val pairs contained in the stdhash.
+.B "stdhash_reserve"
+reserves enough memory to contain
+.I "num_elems"
+key-val pairs without requiring a reallocation.
+.B "stdhash_rehash"
+can be called to reallocate the table to its most appropriate size and
+to potentially increase the performance of the table.
+
+stdhash is mainly used as a lookup table. However, it also contains
+a sequence of values. At any particular point between structural
+operations, each of the key-val pairs can be assigned a rank [0, n)
+just like the sequence stdutil data structures. However, unlike the
+sequence data structures this sequence appears random in nature and
+can change in a drastic and apparently random fashion upon structural
+changes. Like the other stdutil data structures, stdhash has several
+methods for getting iterators that reference particular values in its
+sequence. stdhash provides bi-directional iterators (see std_it).
+.B "stdhash_begin"
+sets the iterator
+.I "it"
+to reference the first, or 0th, value of the stdhash, or, if the
+stdhash is empty to reference the end of the stdhash. The end of the
+stdhash is one past the last value it contains.
+.B "stdhash_end"
+sets the iterator to reference the end of the stdhash.
+.B "stdhash_last"
+sets the iterator to reference the last value in the sequence. It is
+illegal to call stdhash_last on an empty stdhash. The above three
+iterator functions operate in constant O(1) time.
+.B "stdhash_get"
+sets the iterator to reference the value with index
+.I "elem_num"
+or end if
+.I "elem_num"
+is n.
+.I "elem_num"
+must be less than or equal to n. This operation runs in O(n) time and
+is provided only as a convenience. If the application often references
+arbitrary positions in the sequence, then another structure (such as
+stdarr or stdcarr) should probably be considered. All of these
+functions return pointers to the passed iterator to allow function
+composition.
+
+stdhash iterators provide functionality that is slightly different
+and beyond the ``normal'' iterator functions (see std_it).
+.B "stdhash_it_key"
+returns a pointer to the key of the key-val pair to which
+.I "it"
+is referencing.
+.B "stdhash_it_val"
+returns a pointer to the value of the key-val pair to which
+.I "it"
+is referencing. Note, that it
+.B "DOES NOT"
+provide a pointer to the whole key-val pair as you might expect.
+.B "stdhash_it_kvp"
+returns a pointer to the struct stdkvp (see stdutil/stdkvp.h) that
+contains the entire key-val pair to which
+.I "it"
+is referencing.
+.B "stdhash_it_keyed_next"
+moves the iterator to reference the next key-val pair that has a key
+equal to the key to which
+.I "it"
+is currently referencing. If no such key-val pair exists then
+.I "it"
+will reference the end of the stdhash. This function allows you, for a
+given key, to iterate through all the duplicate keys in the
+stdhash. For example, let's say you had a stdhash that used ints as
+its key type and C strings as its values. Let's say you then inserted
+the key-val pairs: (5, "Hello") (5, "World"), (5, "!"). Then if you
+did a
+.B "stdhash_find"
+for 5, it would return an iterator to whichever of the 3 key-val pairs
+was ``first'', as defined by the stdhash (this is invariant between
+structural changes) and the key. Then if you did
+.B "stdhash_it_keyed_next"
+on that iterator it would move the iterator to reference the
+``second'' of those pairs as defined by the stdhash and the key
+(invariant between structural changes). If you did it one more time,
+then
+.B "stdhash_it_keyed_next"
+would move the iterator to reference the ``last'' of those pairs as
+defined by the stdhash and the key. If you called it one more time it
+would advance the iterator to point at the end of the stdhash. Also,
+if you got an iterator to the ``last'' key-val pair through some other
+method (e.g. -
+.BR "stdhash_get" )
+and then called
+.B "stdhash_it_keyed_next"
+it would move the iterator to reference the end of the
+stdhash. Duplicate keys define a sort of mini-sequence of themselves
+within the stdhash. This sequence currently can only be iterated
+through
+.BR "stdhash_it_keyed_next" .
+
+.B "stdhash_max_size"
+returns the absolute maximum number of key-val pairs stdhash can hold
+and is invariant across different stdhashs.
+.B "stdhash_key_size"
+returns the size, in bytes, of the key type this stdhash is currently
+containing.
+.B "stdhash_val_size"
+returns the size, in bytes, of the value type this stdhash is
+currently containing.
+.B "stdhash_key_val_size"
+returns the size, in bytes, of the key-value type struct stdkvp (see
+stdkvp.h) that contains the key-val pair.
+
+.SH "RETURN VALUES"
+
+Most of the functions' return values are described in the SYNOPSIS and
+cannot fail. However, the constructors and functions that potentially
+affect the size of the stdhash can fail. If such a function returns an
+int, then it returns zero on success and non-zero on failure (except
+for
+.BR "stdhash_erase_key" ).
+If such a function returns a stdhash_it *, then it returns non-zero
+on success and null(0) on failure. Whenever any stdhash function fails
+it has no side effects.
+
+.SH "ERRORS"
+
+The constructor functions can return the following error codes:
+.RS
+.TP
+.B "STD_ILLEGAL_PARAM"
+the sizeof the key type was zero.
+
+.TP
+.B "STD_MEM_FAILURE"
+a memory allocation failure occurred.
+.RE
+
+Functions that potentially affect the size of the stdhash and return
+an int, return the following error codes on error:
+.RS
+.TP
+.B "STD_MEM_FAILURE"
+a memory allocation failure occurred.
+.RE
+
+.SH "NOTES"
+
+For performance reasons, by default the stdutil library does no usage
+checking. It assumes the programmer knows what s/he is doing and
+doesn't want additional overhead incurred from sanity checks.
+
+However, the library can be built will several types of checks,
+including bounds and initialization checks that can catch many common
+programming mistakes. See the README file included with the stdutil
+library distribution to see how to create such a "checked" or debug
+library.
+
+.SH "AUTHOR"
+
+John Schultz <[email protected]>
+
+.SH "SEE ALSO"
+
+std_it
Added: vendor/stdutil/current/src/Makefile.in
===================================================================
--- vendor/stdutil/current/src/Makefile.in 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/Makefile.in 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,57 @@
+CC=@CC@
+AR=@AR@
+
+# where to put libraries and test/example programs
+TARGET_DIR = ../lib
+APP_DIR = ../bin
+
+# build thread safe library and enable std locking mechanisms (stdthreads.h)
+CFLAGS += -D_REENTRANT
+
+# SAFETY_CHECKS - check and be sure some condition that should be true is true (sanity checks)
+CFLAGS += -DSTDSAFETY_CHECKS
+
+# BOUNDS_CHECKS - try to check that the user is using the DS's properly (doesn't check all uses)
+CFLAGS += -DSTDBOUNDS_CHECKS
+
+# other flags
+CFLAGS += -fPIC -Wall -O2 -I ./
+
+# add pthreads library if necessary
+LIBS = @LIBS@
+
+# stdutil library object files
+OBJS = stdutil.o stderror.o stdthread.o stdtime.o stdfd.o stdit.o stdarr.o stdcarr.o stddll.o stdhash.o stdskl.o
+
+# targets
+LIBSTDUTIL = $(TARGET_DIR)/libstdutil.a
+TESTS = $(APP_DIR)/stdarch_test $(APP_DIR)/stddll_test $(APP_DIR)/stdarr_test $(APP_DIR)/stdcarr_test $(APP_DIR)/stdhash_test
+TARGETS = $(LIBSTDUTIL) $(TESTS)
+
+$(LIBSTDUTIL): $(OBJS)
+ $(AR) -rs $(LIBSTDUTIL) $(OBJS)
+
+tests: $(TESTS)
+ $(APP_DIR)/stdarch_test
+ $(APP_DIR)/stddll_test
+ $(APP_DIR)/stdarr_test
+ $(APP_DIR)/stdcarr_test
+ $(APP_DIR)/stdhash_test
+
+$(APP_DIR)/stddll_test: $(LIBSTDUTIL) stdtest/stddll_test.c
+ $(CC) $(CFLAGS) -o $(APP_DIR)/stddll_test stdtest/stddll_test.c $(LIBSTDUTIL) $(LIBS)
+
+$(APP_DIR)/stdarr_test: $(APP_DIR)/stddll_test stdtest/stdarr_test.c
+ $(CC) $(CFLAGS) -o $(APP_DIR)/stdarr_test stdtest/stdarr_test.c $(LIBSTDUTIL) $(LIBS)
+
+$(APP_DIR)/stdcarr_test: $(APP_DIR)/stddll_test stdtest/stdcarr_test.c
+ $(CC) $(CFLAGS) -o $(APP_DIR)/stdcarr_test stdtest/stdcarr_test.c $(LIBSTDUTIL) $(LIBS)
+
+$(APP_DIR)/stdhash_test: $(LIBSTDUTIL) stdtest/stdhash_test.c
+ $(CC) $(CFLAGS) -o $(APP_DIR)/stdhash_test stdtest/stdhash_test.c $(LIBSTDUTIL) $(LIBS)
+
+clean:
+ rm -f *.o core* *~ stdutil/*~ stdutil/private/*~ stdtest/*~ $(TARGETS)
+
+distclean: clean
+ rm -f config.* Makefile
Added: vendor/stdutil/current/src/configure
===================================================================
--- vendor/stdutil/current/src/configure 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/configure 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,7855 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.59.
+#
+# Copyright (C) 2003 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete. It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+
+ac_unique_file="stdutil/stddefines.h"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+# include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT AR CPP EGREP LIBOBJS LTLIBOBJS'
+ac_subst_files=''
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+ac_prev=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_option in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ eval "enable_$ac_feature=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_$ac_feature='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_$ac_package='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package | sed 's/-/_/g'`
+ eval "with_$ac_package=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+ eval "$ac_envvar='$ac_optarg'"
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+ localstatedir libdir includedir oldincludedir infodir mandir
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$0" : 'X\(//\)[^/]' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+ { (exit 1); exit 1; }; }
+ else
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+ fi
+fi
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+ { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+ { (exit 1); exit 1; }; }
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+_ACEOF
+
+ cat <<_ACEOF
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --infodir=DIR info documentation [PREFIX/info]
+ --mandir=DIR man documentation [PREFIX/man]
+_ACEOF
+
+ cat <<\_ACEOF
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+
+ cat <<\_ACEOF
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
+ headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+_ACEOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ ac_popdir=`pwd`
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d $ac_dir || continue
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+ cd $ac_dir
+ # Check for guested configure; otherwise get Cygnus style configure.
+ if test -f $ac_srcdir/configure.gnu; then
+ echo
+ $SHELL $ac_srcdir/configure.gnu --help=recursive
+ elif test -f $ac_srcdir/configure; then
+ echo
+ $SHELL $ac_srcdir/configure --help=recursive
+ elif test -f $ac_srcdir/configure.ac ||
+ test -f $ac_srcdir/configure.in; then
+ echo
+ $ac_configure --help
+ else
+ echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi
+ cd $ac_popdir
+ done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+ cat <<\_ACEOF
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit 0
+fi
+exec 5>config.log
+cat >&5 <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ echo "PATH: $as_dir"
+done
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_sep=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+ # Get rid of the leading space.
+ ac_sep=" "
+ ;;
+ esac
+ done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+{
+ (set) 2>&1 |
+ case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ sed -n \
+ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+ ;;
+ *)
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+}
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ sed "/^$/d" confdefs.h | sort
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ echo "$as_me: caught signal $ac_signal"
+ echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core &&
+ rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+ ' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special
+ # files actually), so we avoid doing that.
+ if test -f "$cache_file"; then
+ { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . $cache_file;;
+ *) . ./$cache_file;;
+ esac
+ fi
+else
+ { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+ sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+ eval ac_new_val="\$ac_env_${ac_var}_value"
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+echo "$as_me: former value: $ac_old_val" >&2;}
+ { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
+echo "$as_me: current value: $ac_new_val" >&2;}
+ ac_cache_corrupted=:
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ac_config_headers="$ac_config_headers stdutil/private/stdarch.h"
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ac_ct_CC" && break
+done
+
+ CC=$ac_ct_CC
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+ "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+ (eval $ac_compiler --version </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+ (eval $ac_compiler -v </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+ (eval $ac_compiler -V </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
+ (eval $ac_link_default) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Find the output, starting from the most likely. This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+ ;;
+ conftest.$ac_ext )
+ # This is the source file.
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ # FIXME: I believe we export ac_cv_exeext for Libtool,
+ # but it would be cool to find out if it's true. Does anybody
+ # maintain Libtool? --akim.
+ export ac_cv_exeext
+ break;;
+ * )
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+ if { ac_try='./$ac_file'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ fi
+fi
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ export ac_cv_exeext
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_compiler_gnu=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std1 is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std1. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX -qlanglvl=ansi
+# Ultrix and OSF/1 -std1
+# HP-UX 10.20 and later -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+ x|xno)
+ echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+ *)
+ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+ CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+# Some people use a C++ compiler to compile C. Since we use `exit',
+# in C++ we need to declare it. In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+ choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ for ac_declaration in \
+ '' \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);'
+do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+#include <stdlib.h>
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+ echo '#ifdef __cplusplus' >>confdefs.h
+ echo $ac_declaration >>confdefs.h
+ echo '#endif' >>confdefs.h
+fi
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+for ac_prog in ar
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_AR+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AR="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+ echo "$as_me:$LINENO: result: $AR" >&5
+echo "${ECHO_T}$AR" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$AR" && break
+done
+
+
+
+echo "$as_me:$LINENO: checking for pthread_mutex_init in -lpthread" >&5
+echo $ECHO_N "checking for pthread_mutex_init in -lpthread... $ECHO_C" >&6
+if test "${ac_cv_lib_pthread_pthread_mutex_init+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char pthread_mutex_init ();
+int
+main ()
+{
+pthread_mutex_init ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_pthread_pthread_mutex_init=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_pthread_pthread_mutex_init=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_mutex_init" >&5
+echo "${ECHO_T}$ac_cv_lib_pthread_pthread_mutex_init" >&6
+if test $ac_cv_lib_pthread_pthread_mutex_init = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBPTHREAD 1
+_ACEOF
+
+ LIBS="-lpthread $LIBS"
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+ then ac_cv_prog_egrep='grep -E'
+ else ac_cv_prog_egrep='egrep'
+ fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_stdc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+ exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+echo "$as_me:$LINENO: checking for char" >&5
+echo $ECHO_N "checking for char... $ECHO_C" >&6
+if test "${ac_cv_type_char+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((char *) 0)
+ return 0;
+if (sizeof (char))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_char=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_char=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_char" >&5
+echo "${ECHO_T}$ac_cv_type_char" >&6
+
+echo "$as_me:$LINENO: checking size of char" >&5
+echo $ECHO_N "checking size of char... $ECHO_C" >&6
+if test "${ac_cv_sizeof_char+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$ac_cv_type_char" = yes; then
+ # The cast to unsigned long works around a bug in the HP C Compiler
+ # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+ # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+ # This bug is HP SR number 8606223364.
+ if test "$cross_compiling" = yes; then
+ # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (char))) >= 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (char))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (char))) < 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (char))) >= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (char))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_char=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (char), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (char), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; } ;;
+esac
+else
+ if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+long longval () { return (long) (sizeof (char)); }
+unsigned long ulongval () { return (long) (sizeof (char)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ exit (1);
+ if (((long) (sizeof (char))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (char))))
+ exit (1);
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (char))))
+ exit (1);
+ fprintf (f, "%lu\n", i);
+ }
+ exit (ferror (f) || fclose (f) != 0);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_sizeof_char=`cat conftest.val`
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (char), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (char), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+ ac_cv_sizeof_char=0
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_char" >&5
+echo "${ECHO_T}$ac_cv_sizeof_char" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_CHAR $ac_cv_sizeof_char
+_ACEOF
+
+
+echo "$as_me:$LINENO: checking for short" >&5
+echo $ECHO_N "checking for short... $ECHO_C" >&6
+if test "${ac_cv_type_short+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((short *) 0)
+ return 0;
+if (sizeof (short))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_short=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_short=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_short" >&5
+echo "${ECHO_T}$ac_cv_type_short" >&6
+
+echo "$as_me:$LINENO: checking size of short" >&5
+echo $ECHO_N "checking size of short... $ECHO_C" >&6
+if test "${ac_cv_sizeof_short+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$ac_cv_type_short" = yes; then
+ # The cast to unsigned long works around a bug in the HP C Compiler
+ # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+ # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+ # This bug is HP SR number 8606223364.
+ if test "$cross_compiling" = yes; then
+ # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (short))) >= 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (short))) < 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (short))) >= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_short=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (short), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; } ;;
+esac
+else
+ if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+long longval () { return (long) (sizeof (short)); }
+unsigned long ulongval () { return (long) (sizeof (short)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ exit (1);
+ if (((long) (sizeof (short))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (short))))
+ exit (1);
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (short))))
+ exit (1);
+ fprintf (f, "%lu\n", i);
+ }
+ exit (ferror (f) || fclose (f) != 0);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_sizeof_short=`cat conftest.val`
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (short), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+ ac_cv_sizeof_short=0
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5
+echo "${ECHO_T}$ac_cv_sizeof_short" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+_ACEOF
+
+
+echo "$as_me:$LINENO: checking for int" >&5
+echo $ECHO_N "checking for int... $ECHO_C" >&6
+if test "${ac_cv_type_int+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((int *) 0)
+ return 0;
+if (sizeof (int))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_int=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_int=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5
+echo "${ECHO_T}$ac_cv_type_int" >&6
+
+echo "$as_me:$LINENO: checking size of int" >&5
+echo $ECHO_N "checking size of int... $ECHO_C" >&6
+if test "${ac_cv_sizeof_int+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$ac_cv_type_int" = yes; then
+ # The cast to unsigned long works around a bug in the HP C Compiler
+ # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+ # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+ # This bug is HP SR number 8606223364.
+ if test "$cross_compiling" = yes; then
+ # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_int=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; } ;;
+esac
+else
+ if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+long longval () { return (long) (sizeof (int)); }
+unsigned long ulongval () { return (long) (sizeof (int)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ exit (1);
+ if (((long) (sizeof (int))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (int))))
+ exit (1);
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (int))))
+ exit (1);
+ fprintf (f, "%lu\n", i);
+ }
+ exit (ferror (f) || fclose (f) != 0);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_sizeof_int=`cat conftest.val`
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+ ac_cv_sizeof_int=0
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5
+echo "${ECHO_T}$ac_cv_sizeof_int" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+_ACEOF
+
+
+echo "$as_me:$LINENO: checking for long" >&5
+echo $ECHO_N "checking for long... $ECHO_C" >&6
+if test "${ac_cv_type_long+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((long *) 0)
+ return 0;
+if (sizeof (long))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_long=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_long=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5
+echo "${ECHO_T}$ac_cv_type_long" >&6
+
+echo "$as_me:$LINENO: checking size of long" >&5
+echo $ECHO_N "checking size of long... $ECHO_C" >&6
+if test "${ac_cv_sizeof_long+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$ac_cv_type_long" = yes; then
+ # The cast to unsigned long works around a bug in the HP C Compiler
+ # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+ # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+ # This bug is HP SR number 8606223364.
+ if test "$cross_compiling" = yes; then
+ # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_long=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; } ;;
+esac
+else
+ if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+long longval () { return (long) (sizeof (long)); }
+unsigned long ulongval () { return (long) (sizeof (long)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ exit (1);
+ if (((long) (sizeof (long))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (long))))
+ exit (1);
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (long))))
+ exit (1);
+ fprintf (f, "%lu\n", i);
+ }
+ exit (ferror (f) || fclose (f) != 0);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_sizeof_long=`cat conftest.val`
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+ ac_cv_sizeof_long=0
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5
+echo "${ECHO_T}$ac_cv_sizeof_long" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+_ACEOF
+
+
+echo "$as_me:$LINENO: checking for long long" >&5
+echo $ECHO_N "checking for long long... $ECHO_C" >&6
+if test "${ac_cv_type_long_long+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((long long *) 0)
+ return 0;
+if (sizeof (long long))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_long_long=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_long_long=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5
+echo "${ECHO_T}$ac_cv_type_long_long" >&6
+
+echo "$as_me:$LINENO: checking size of long long" >&5
+echo $ECHO_N "checking size of long long... $ECHO_C" >&6
+if test "${ac_cv_sizeof_long_long+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$ac_cv_type_long_long" = yes; then
+ # The cast to unsigned long works around a bug in the HP C Compiler
+ # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+ # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+ # This bug is HP SR number 8606223364.
+ if test "$cross_compiling" = yes; then
+ # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long long))) < 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_long_long=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long long), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; } ;;
+esac
+else
+ if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+long longval () { return (long) (sizeof (long long)); }
+unsigned long ulongval () { return (long) (sizeof (long long)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ exit (1);
+ if (((long) (sizeof (long long))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (long long))))
+ exit (1);
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (long long))))
+ exit (1);
+ fprintf (f, "%lu\n", i);
+ }
+ exit (ferror (f) || fclose (f) != 0);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_sizeof_long_long=`cat conftest.val`
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long long), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+ ac_cv_sizeof_long_long=0
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5
+echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
+_ACEOF
+
+
+echo "$as_me:$LINENO: checking for size_t" >&5
+echo $ECHO_N "checking for size_t... $ECHO_C" >&6
+if test "${ac_cv_type_size_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((size_t *) 0)
+ return 0;
+if (sizeof (size_t))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_size_t=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_size_t=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
+echo "${ECHO_T}$ac_cv_type_size_t" >&6
+
+echo "$as_me:$LINENO: checking size of size_t" >&5
+echo $ECHO_N "checking size of size_t... $ECHO_C" >&6
+if test "${ac_cv_sizeof_size_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$ac_cv_type_size_t" = yes; then
+ # The cast to unsigned long works around a bug in the HP C Compiler
+ # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+ # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+ # This bug is HP SR number 8606223364.
+ if test "$cross_compiling" = yes; then
+ # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (size_t))) >= 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (size_t))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (size_t))) < 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (size_t))) >= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (size_t))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_size_t=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (size_t), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; } ;;
+esac
+else
+ if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+long longval () { return (long) (sizeof (size_t)); }
+unsigned long ulongval () { return (long) (sizeof (size_t)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ exit (1);
+ if (((long) (sizeof (size_t))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (size_t))))
+ exit (1);
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (size_t))))
+ exit (1);
+ fprintf (f, "%lu\n", i);
+ }
+ exit (ferror (f) || fclose (f) != 0);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_sizeof_size_t=`cat conftest.val`
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (size_t), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+ ac_cv_sizeof_size_t=0
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_size_t" >&5
+echo "${ECHO_T}$ac_cv_sizeof_size_t" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t
+_ACEOF
+
+
+echo "$as_me:$LINENO: checking for void *" >&5
+echo $ECHO_N "checking for void *... $ECHO_C" >&6
+if test "${ac_cv_type_void_p+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((void * *) 0)
+ return 0;
+if (sizeof (void *))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_void_p=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_void_p=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_void_p" >&5
+echo "${ECHO_T}$ac_cv_type_void_p" >&6
+
+echo "$as_me:$LINENO: checking size of void *" >&5
+echo $ECHO_N "checking size of void *... $ECHO_C" >&6
+if test "${ac_cv_sizeof_void_p+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$ac_cv_type_void_p" = yes; then
+ # The cast to unsigned long works around a bug in the HP C Compiler
+ # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+ # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+ # This bug is HP SR number 8606223364.
+ if test "$cross_compiling" = yes; then
+ # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (void *))) >= 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (void *))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (void *))) < 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (void *))) >= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_lo=$ac_mid; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (void *))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_hi=$ac_mid
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_void_p=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (void *), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (void *), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; } ;;
+esac
+else
+ if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+long longval () { return (long) (sizeof (void *)); }
+unsigned long ulongval () { return (long) (sizeof (void *)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ exit (1);
+ if (((long) (sizeof (void *))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (void *))))
+ exit (1);
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (void *))))
+ exit (1);
+ fprintf (f, "%lu\n", i);
+ }
+ exit (ferror (f) || fclose (f) != 0);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_sizeof_void_p=`cat conftest.val`
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (void *), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (void *), 77
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+ ac_cv_sizeof_void_p=0
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_void_p" >&5
+echo "${ECHO_T}$ac_cv_sizeof_void_p" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_VOID_P $ac_cv_sizeof_void_p
+_ACEOF
+
+
+
+echo "$as_me:$LINENO: checking checking all necessary integer types are defined" >&5
+echo $ECHO_N "checking checking all necessary integer types are defined... $ECHO_C" >&6
+
+if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#if (SIZEOF_CHAR != 1)
+# error No 1 byte integer type found!
+#endif
+
+#if (SIZEOF_SHORT != 2)
+# error No 2 byte integer type found!
+#endif
+
+#if (SIZEOF_INT != 4 && SIZEOF_LONG != 4)
+# error No 4 byte integer type found!
+#endif
+
+#if (!defined(_WIN32) && SIZEOF_LONG != 8 && SIZEOF_LONG_LONG != 8)
+# error No 8 byte integeral type found!
+#endif
+
+#if (SIZEOF_SIZE_T != 2 && SIZEOF_SIZE_T != 4 && SIZEOF_SIZE_T != 8)
+# error No integral type of same size as size_t!
+#endif
+
+int main() { return 0; }
+
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: one or more required integer sizes not found or of really unexpected size please fix stdutil/private/stdarch.h.in!" >&5
+echo "$as_me: error: one or more required integer sizes not found or of really unexpected size please fix stdutil/private/stdarch.h.in!" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+echo "$as_me:$LINENO: checking endianness of architecture" >&5
+echo $ECHO_N "checking endianness of architecture... $ECHO_C" >&6
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<\_ACEOF
+#define STDENDIAN16_SWAP 1
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+ short x = 0x1;
+ char * xptr = (char*) &x;
+
+ exit(xptr[0] == 1); /* return 1 if bytes are opposite of network order, else 0 */
+ return xptr[0] == 1;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<\_ACEOF
+#define STDENDIAN16_SWAP 0
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+cat >>confdefs.h <<\_ACEOF
+#define STDENDIAN16_SWAP 1
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET0_FROM_HOST 3
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST3_FROM_NET 0
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if (SIZEOF_INT == 4)
+ int x = 0x1;
+#elif (SIZEOF_LONG == 4)
+ long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 24;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET0_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST0_FROM_NET 0
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET0_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST${temp}_FROM_NET 0
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET1_FROM_HOST 2
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST2_FROM_NET 1
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if (SIZEOF_INT == 4)
+ int x = 0x1;
+#elif (SIZEOF_LONG == 4)
+ long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 16;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET1_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST0_FROM_NET 1
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET1_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST${temp}_FROM_NET 1
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET2_FROM_HOST 1
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST1_FROM_NET 2
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if (SIZEOF_INT == 4)
+ int x = 0x1;
+#elif (SIZEOF_LONG == 4)
+ long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 8;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET2_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST0_FROM_NET 2
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET2_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST${temp}_FROM_NET 2
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET3_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST0_FROM_NET 3
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if (SIZEOF_INT == 4)
+ int x = 0x1;
+#elif (SIZEOF_LONG == 4)
+ long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 0;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET3_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST0_FROM_NET 3
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET3_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST${temp}_FROM_NET 3
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET0_FROM_HOST 7
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST7_FROM_NET 0
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 56;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET0_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST0_FROM_NET 0
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET0_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${temp}_FROM_NET 0
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET1_FROM_HOST 6
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST6_FROM_NET 1
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 48;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET1_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST0_FROM_NET 1
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET1_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${temp}_FROM_NET 1
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET2_FROM_HOST 5
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST5_FROM_NET 2
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 40;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET2_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST0_FROM_NET 2
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET2_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${temp}_FROM_NET 2
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET3_FROM_HOST 4
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST4_FROM_NET 3
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 32;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET3_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST0_FROM_NET 3
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET3_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${temp}_FROM_NET 3
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET4_FROM_HOST 3
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST3_FROM_NET 4
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 24;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET4_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST0_FROM_NET 4
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET4_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${temp}_FROM_NET 4
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET5_FROM_HOST 2
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST2_FROM_NET 5
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 16;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET5_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST0_FROM_NET 5
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET5_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${temp}_FROM_NET 5
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET6_FROM_HOST 1
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST1_FROM_NET 6
+_ACEOF
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 8;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET6_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST0_FROM_NET 6
+_ACEOF
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET6_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${temp}_FROM_NET 6
+_ACEOF
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$cross_compiling" = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET7_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST0_FROM_NET 7
+_ACEOF
+ { echo "$as_me:$LINENO: WARNING: Unable to check due to cross compiling! ASSUMING LITTLE ENDIAN ARCHITECTURE! To change this please see stdutil.c!" >&5
+echo "$as_me: WARNING: Unable to check due to cross compiling! ASSUMING LITTLE ENDIAN ARCHITECTURE! To change this please see stdutil.c!" >&2;}
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 0;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET7_FROM_HOST 0
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST0_FROM_NET 7
+_ACEOF
+ echo "$as_me:$LINENO: result: done" >&5
+echo "${ECHO_T}done" >&6
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+temp=$?;
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET7_FROM_HOST $temp
+_ACEOF
+ cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${temp}_FROM_NET 7
+_ACEOF
+ echo "$as_me:$LINENO: result: done" >&5
+echo "${ECHO_T}done" >&6
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+ ac_config_files="$ac_config_files Makefile"
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+{
+ (set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+} |
+ sed '
+ t clear
+ : clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ : end' >>confcache
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
+ if test -w $cache_file; then
+ test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+ cat confcache >$cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[ ]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[ ]*$//;
+}'
+fi
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_i=`echo "$ac_i" |
+ sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+ # 2. Add them.
+ ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+exec 6>&1
+
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling. Logging --version etc. is OK.
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+ echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+ echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+ echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+ echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to <[email protected]>."
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.59,
+ with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value. By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "x$1" : 'x\([^=]*\)='`
+ ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ -*)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ *) # This is not an option, so the user has probably given explicit
+ # arguments.
+ ac_option=$1
+ ac_need_defaults=false;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --vers* | -V )
+ echo "$ac_cs_version"; exit 0 ;;
+ --he | --h)
+ # Conflict between --help and --header
+ { { echo "$as_me:$LINENO: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
+ echo "$ac_cs_usage"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+ ac_need_defaults=false;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1" ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+ echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+ exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+
+
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_config_target in $ac_config_targets
+do
+ case "$ac_config_target" in
+ # Handling of arguments.
+ "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "stdutil/private/stdarch.h" ) CONFIG_HEADERS="$CONFIG_HEADERS stdutil/private/stdarch.h" ;;
+ *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=./confstat$$-$RANDOM
+ (umask 077 && mkdir $tmp)
+} ||
+{
+ echo "$me: cannot create a temporary directory in ." >&2
+ { (exit 1); exit 1; }
+}
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+ # Protect against being on the right side of a sed subst in config.status.
+ sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+ s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s,@SHELL@,$SHELL,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@exec_prefix@,$exec_prefix,;t t
+s,@prefix@,$prefix,;t t
+s,@program_transform_name@,$program_transform_name,;t t
+s,@bindir@,$bindir,;t t
+s,@sbindir@,$sbindir,;t t
+s,@libexecdir@,$libexecdir,;t t
+s,@datadir@,$datadir,;t t
+s,@sysconfdir@,$sysconfdir,;t t
+s,@sharedstatedir@,$sharedstatedir,;t t
+s,@localstatedir@,$localstatedir,;t t
+s,@libdir@,$libdir,;t t
+s,@includedir@,$includedir,;t t
+s,@oldincludedir@,$oldincludedir,;t t
+s,@infodir@,$infodir,;t t
+s,@mandir@,$mandir,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@DEFS@,$DEFS,;t t
+s,@ECHO_C@,$ECHO_C,;t t
+s,@ECHO_N@,$ECHO_N,;t t
+s,@ECHO_T@,$ECHO_T,;t t
+s,@LIBS@,$LIBS,;t t
+s,@CC@,$CC,;t t
+s,@CFLAGS@,$CFLAGS,;t t
+s,@LDFLAGS@,$LDFLAGS,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
+s,@ac_ct_CC@,$ac_ct_CC,;t t
+s,@EXEEXT@,$EXEEXT,;t t
+s,@OBJEXT@,$OBJEXT,;t t
+s,@AR@,$AR,;t t
+s,@CPP@,$CPP,;t t
+s,@EGREP@,$EGREP,;t t
+s,@LIBOBJS@,$LIBOBJS,;t t
+s,@LTLIBOBJS@,$LTLIBOBJS,;t t
+CEOF
+
+_ACEOF
+
+ cat >>$CONFIG_STATUS <<\_ACEOF
+ # Split the substitutions into bite-sized pieces for seds with
+ # small command number limits, like on Digital OSF/1 and HP-UX.
+ ac_max_sed_lines=48
+ ac_sed_frag=1 # Number of current file.
+ ac_beg=1 # First line for current file.
+ ac_end=$ac_max_sed_lines # Line after last line for current file.
+ ac_more_lines=:
+ ac_sed_cmds=
+ while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ else
+ sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ fi
+ if test ! -s $tmp/subs.frag; then
+ ac_more_lines=false
+ else
+ # The purpose of the label and of the branching condition is to
+ # speed up the sed processing (if there are no `@' at all, there
+ # is no need to browse any of the substitutions).
+ # These are the two extra sed commands mentioned above.
+ (echo ':t
+ /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+ fi
+ ac_sed_frag=`expr $ac_sed_frag + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_lines`
+ fi
+ done
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+ fi
+fi # test -n "$CONFIG_FILES"
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+
+
+ if test x"$ac_file" != x-; then
+ { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+ rm -f "$ac_file"
+ fi
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ configure_input=
+ else
+ configure_input="$ac_file. "
+ fi
+ configure_input=$configure_input"Generated from `echo $ac_file_in |
+ sed 's,.*/,,'` by configure."
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ echo "$f";;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo "$f"
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo "$srcdir/$f"
+ else
+ # /dev/null tree
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@configure_input@,$configure_input,;t t
+s,@srcdir@,$ac_srcdir,;t t
+s,@abs_srcdir@,$ac_abs_srcdir,;t t
+s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
+s,@builddir@,$ac_builddir,;t t
+s,@abs_builddir@,$ac_abs_builddir,;t t
+s,@top_builddir@,$ac_top_builddir,;t t
+s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+ rm -f $tmp/stdin
+ if test x"$ac_file" != x-; then
+ mv $tmp/out $ac_file
+ else
+ cat $tmp/out
+ rm -f $tmp/out
+ fi
+
+done
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+#
+# CONFIG_HEADER section.
+#
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='[ ].*$,\1#\2'
+ac_dC=' '
+ac_dD=',;t'
+# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='$,\1#\2define\3'
+ac_uC=' '
+ac_uD=',;t'
+
+for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ # Do quote $f, to prevent DOS paths from being IFS'd.
+ echo "$f";;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo "$f"
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo "$srcdir/$f"
+ else
+ # /dev/null tree
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+ # Remove the trailing spaces.
+ sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
+
+_ACEOF
+
+# Transform confdefs.h into two sed scripts, `conftest.defines' and
+# `conftest.undefs', that substitutes the proper values into
+# config.h.in to produce config.h. The first handles `#define'
+# templates, and the second `#undef' templates.
+# And first: Protect against being on the right side of a sed subst in
+# config.status. Protect against being in an unquoted here document
+# in config.status.
+rm -f conftest.defines conftest.undefs
+# Using a here document instead of a string reduces the quoting nightmare.
+# Putting comments in sed scripts is not portable.
+#
+# `end' is used to avoid that the second main sed command (meant for
+# 0-ary CPP macros) applies to n-ary macro definitions.
+# See the Autoconf documentation for `clear'.
+cat >confdef2sed.sed <<\_ACEOF
+s/[\\&,]/\\&/g
+s,[\\$`],\\&,g
+t clear
+: clear
+s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
+t end
+s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
+: end
+_ACEOF
+# If some macros were called several times there might be several times
+# the same #defines, which is useless. Nevertheless, we may not want to
+# sort them, since we want the *last* AC-DEFINE to be honored.
+uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
+sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
+rm -f confdef2sed.sed
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >>conftest.undefs <<\_ACEOF
+s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
+_ACEOF
+
+# Break up conftest.defines because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
+echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
+echo ' :' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.defines >/dev/null
+do
+ # Write a limited-size here document to $tmp/defines.sed.
+ echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
+ # Speed up: don't consider the non `#define' lines.
+ echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
+ # Work around the forget-to-reset-the-flag bug.
+ echo 't clr' >>$CONFIG_STATUS
+ echo ': clr' >>$CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+ echo 'CEOF
+ sed -f $tmp/defines.sed $tmp/in >$tmp/out
+ rm -f $tmp/in
+ mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
+ rm -f conftest.defines
+ mv conftest.tail conftest.defines
+done
+rm -f conftest.defines
+echo ' fi # grep' >>$CONFIG_STATUS
+echo >>$CONFIG_STATUS
+
+# Break up conftest.undefs because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.undefs >/dev/null
+do
+ # Write a limited-size here document to $tmp/undefs.sed.
+ echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
+ # Speed up: don't consider the non `#undef'
+ echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
+ # Work around the forget-to-reset-the-flag bug.
+ echo 't clr' >>$CONFIG_STATUS
+ echo ': clr' >>$CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
+ echo 'CEOF
+ sed -f $tmp/undefs.sed $tmp/in >$tmp/out
+ rm -f $tmp/in
+ mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
+ rm -f conftest.undefs
+ mv conftest.tail conftest.undefs
+done
+rm -f conftest.undefs
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ echo "/* Generated by configure. */" >$tmp/config.h
+ else
+ echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
+ fi
+ cat $tmp/in >>$tmp/config.h
+ rm -f $tmp/in
+ if test x"$ac_file" != x-; then
+ if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
+ { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ rm -f $ac_file
+ mv $tmp/config.h $ac_file
+ fi
+ else
+ cat $tmp/config.h
+ rm -f $tmp/config.h
+ fi
+done
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || { (exit 1); exit 1; }
+fi
+
Property changes on: vendor/stdutil/current/src/configure
___________________________________________________________________
Name: svn:executable
+
Added: vendor/stdutil/current/src/configure.in
===================================================================
--- vendor/stdutil/current/src/configure.in 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/configure.in 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,362 @@
+AC_INIT(stdutil/stddefines.h)
+AC_CONFIG_HEADER(stdutil/private/stdarch.h)
+AC_PROG_CC
+AC_CHECK_PROGS(AR, ar)
+AC_CHECK_LIB(pthread, pthread_mutex_init)
+AC_LANG_C
+
+AC_CHECK_SIZEOF(char, 1)
+AC_CHECK_SIZEOF(short, 2)
+AC_CHECK_SIZEOF(int, 4)
+AC_CHECK_SIZEOF(long, 4)
+AC_CHECK_SIZEOF(long long, 8)
+AC_CHECK_SIZEOF(size_t, 4)
+AC_CHECK_SIZEOF(void *, 4)
+
+AC_MSG_CHECKING(checking all necessary integer types are defined)
+
+AC_TRY_RUN([
+#if (SIZEOF_CHAR != 1)
+# error No 1 byte integer type found!
+#endif
+
+#if (SIZEOF_SHORT != 2)
+# error No 2 byte integer type found!
+#endif
+
+#if (SIZEOF_INT != 4 && SIZEOF_LONG != 4)
+# error No 4 byte integer type found!
+#endif
+
+#if (!defined(_WIN32) && SIZEOF_LONG != 8 && SIZEOF_LONG_LONG != 8)
+# error No 8 byte integeral type found!
+#endif
+
+#if (SIZEOF_SIZE_T != 2 && SIZEOF_SIZE_T != 4 && SIZEOF_SIZE_T != 8)
+# error No integral type of same size as size_t!
+#endif
+
+int main() { return 0; }
+
+], AC_MSG_RESULT(yes), AC_MSG_ERROR(one or more required integer sizes not found or of really unexpected size please fix stdutil/private/stdarch.h.in!))
+
+AC_MSG_CHECKING(endianness of architecture)
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+ short x = 0x1;
+ char * xptr = (char*) &x;
+
+ exit(xptr[0] == 1); /* return 1 if bytes are opposite of network order, else 0 */
+ return xptr[0] == 1;
+}
+], AC_DEFINE(STDENDIAN16_SWAP, 0), AC_DEFINE(STDENDIAN16_SWAP, 1), AC_DEFINE(STDENDIAN16_SWAP, 1))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if (SIZEOF_INT == 4)
+ int x = 0x1;
+#elif (SIZEOF_LONG == 4)
+ long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 24;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN32_NET0_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST0_FROM_NET, 0), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN32_NET0_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${temp}_FROM_NET, 0),
+ AC_DEFINE_UNQUOTED(STDENDIAN32_NET0_FROM_HOST, 3) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST3_FROM_NET, 0))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if (SIZEOF_INT == 4)
+ int x = 0x1;
+#elif (SIZEOF_LONG == 4)
+ long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 16;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN32_NET1_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST0_FROM_NET, 1), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN32_NET1_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${temp}_FROM_NET, 1),
+ AC_DEFINE_UNQUOTED(STDENDIAN32_NET1_FROM_HOST, 2) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST2_FROM_NET, 1))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if (SIZEOF_INT == 4)
+ int x = 0x1;
+#elif (SIZEOF_LONG == 4)
+ long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 8;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN32_NET2_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST0_FROM_NET, 2), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN32_NET2_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${temp}_FROM_NET, 2),
+ AC_DEFINE_UNQUOTED(STDENDIAN32_NET2_FROM_HOST, 1) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST1_FROM_NET, 2))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if (SIZEOF_INT == 4)
+ int x = 0x1;
+#elif (SIZEOF_LONG == 4)
+ long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 0;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN32_NET3_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST0_FROM_NET, 3), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN32_NET3_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${temp}_FROM_NET, 3),
+ AC_DEFINE_UNQUOTED(STDENDIAN32_NET3_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST0_FROM_NET, 3))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 56;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN64_NET0_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 0), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET0_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 0),
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET0_FROM_HOST, 7) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST7_FROM_NET, 0))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 48;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN64_NET1_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 1), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET1_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 1),
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET1_FROM_HOST, 6) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST6_FROM_NET, 1))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 40;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN64_NET2_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 2), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET2_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 2),
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET2_FROM_HOST, 5) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST5_FROM_NET, 2))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 32;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN64_NET3_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 3), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET3_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 3),
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET3_FROM_HOST, 4) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST4_FROM_NET, 3))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 24;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN64_NET4_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 4), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET4_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 4),
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET4_FROM_HOST, 3) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST3_FROM_NET, 4))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 16;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN64_NET5_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 5), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET5_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 5),
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET5_FROM_HOST, 2) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST2_FROM_NET, 5))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 8;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN64_NET6_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 6), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET6_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 6),
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET6_FROM_HOST, 1) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST1_FROM_NET, 6))
+
+AC_TRY_RUN([
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_WIN32)
+ __int64 x = 0x1;
+#elif (SIZEOF_LONG == 8)
+ long x = 0x1;
+#elif (SIZEOF_LONG_LONG == 8)
+ long long x = 0x1;
+#endif
+ char * xptr = (char*) &x;
+ int i;
+
+ x <<= 0;
+
+ for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
+
+ exit(i);
+ return i;
+}
+], AC_DEFINE_UNQUOTED(STDENDIAN64_NET7_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 7) AC_MSG_RESULT(done), temp=$?;
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET7_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 7) AC_MSG_RESULT(done),
+ AC_DEFINE_UNQUOTED(STDENDIAN64_NET7_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 7) AC_MSG_WARN(Unable to check due to cross compiling! ASSUMING LITTLE ENDIAN ARCHITECTURE! To change this please see stdutil.c!))
+
+AC_OUTPUT(Makefile)
Added: vendor/stdutil/current/src/stdarr.c
===================================================================
--- vendor/stdutil/current/src/stdarr.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdarr.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,880 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <stdutil/stderror.h>
+#include <stdutil/stdarr.h>
+
+#define STDARR_IS_LEGAL(arr) ((arr)->begin <= (arr)->end && \
+ (arr)->begin + (arr)->size * (arr)->vsize == (arr)->end && \
+ ( ((arr)->cap != 0 && (arr)->begin != NULL) || ((arr)->cap == 0 && (arr)->begin == NULL) ) && \
+ (arr)->size <= (arr)->cap && \
+ (arr)->vsize != 0 && \
+ ((arr)->opts & ~(STDARR_OPTS_NO_AUTO_GROW | STDARR_OPTS_NO_AUTO_SHRINK)) == 0)
+
+#define STDARR_IT_IS_LEGAL(arr, it) ((it)->val >= (arr)->begin && (it)->val <= (arr)->end && (it)->vsize == (arr)->vsize)
+#define STDARR_IT_IS_LEGAL2(it) ((it)->vsize != 0)
+#define STDIT_ARR_IS_LEGAL(it) ((it)->type_id == STDARR_IT_ID && STDARR_IT_IS_LEGAL2(&(it)->impl.arr))
+
+/************************************************************************************************
+ * stdarr_low_insert_space: This fcn efficiently inserts 'num_insert'
+ * element positions before the position pointed at by 'impl.' The fcn
+ * updates and possibly grows the array.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdarr_low_insert_space(stdarr *arr, stdarr_it *it, stdsize num_insert)
+{
+ stdcode ret = STDESUCCESS;
+ stdsize nsize = arr->size + num_insert;
+ stdsize delta = num_insert * arr->vsize;
+ stdsize after = (stdsize) (arr->end - it->val);
+
+ if (nsize > arr->cap) { /* nsize > arr->cap -> nsize > 0 */
+ stdsize ncap = (nsize << 1); /* nsize > 0 -> ncap > 0 */
+ stdsize prior = (stdsize) (it->val - arr->begin);
+ stdsize asize;
+ char * mem;
+
+ if ((arr->opts & STDARR_OPTS_NO_AUTO_GROW) != 0) { /* growth explicitly disallowed */
+ ret = STDEACCES;
+ goto stdarr_low_insert_space_end;
+ }
+
+ ncap = STDMAX(ncap, STDARR_MIN_AUTO_ALLOC); /* ensure minimum allocation */
+ asize = ncap * arr->vsize; /* calc. alloc size in bytes */
+
+ if ((mem = (char*) realloc(arr->begin, asize)) == NULL) {
+ ret = STDENOMEM;
+ goto stdarr_low_insert_space_end;
+ }
+
+ arr->begin = mem; /* fill in new values for 'arr' */
+ arr->end = mem + prior + after;
+ arr->cap = ncap;
+
+ it->val = mem + prior; /* relocate 'it' to insertion point */
+ }
+
+ memmove(it->val + delta, it->val, after); /* shift mem */
+
+ arr->end += delta;
+ arr->size = nsize;
+
+ stdarr_low_insert_space_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdarr_low_remove_space: This fcn efficiently removes 'num_remove'
+ * element positions starting at the position pointed at by 'it.' The
+ * fcn updates and possibly shrinks the array.
+ ***********************************************************************************************/
+
+STDINLINE static void stdarr_low_remove_space(stdarr *arr, stdarr_it *it, stdsize num_remove)
+{
+ stdsize nsize = arr->size - num_remove;
+ stdsize delta = num_remove * arr->vsize;
+ char * it_end = it->val + delta;
+ stdsize after = (stdsize) (arr->end - it_end);
+
+ memmove(it->val, it_end, after); /* shift mem */
+
+ arr->end -= delta;
+ arr->size = nsize;
+
+ if ((arr->opts & STDARR_OPTS_NO_AUTO_SHRINK) == 0 && /* shrinking wanted */
+ nsize <= stdarr_low_capacity(arr) && /* shrinking necessary */
+ arr->cap != STDARR_MIN_AUTO_ALLOC) { /* cap not at min alloc */
+
+ stdsize ncap = (nsize << 1);
+ stdsize prior = (stdsize) (it->val - arr->begin);
+
+ ncap = STDMAX(ncap, STDARR_MIN_AUTO_ALLOC); /* ensure minimum allocation */
+
+ if (ncap != 0) { /* nsize/ncap can be zero here */
+ stdsize asize = ncap * arr->vsize;
+ char * mem;
+
+ if ((mem = (char*) realloc(arr->begin, asize)) == NULL) {
+ return; /* couldn't realloc -> that's OK */
+ }
+
+ arr->begin = mem; /* fill in new values for 'arr' */
+ arr->end = mem + prior + after;
+ arr->size = nsize;
+ arr->cap = ncap;
+
+ } else { /* ncap == 0 -> go to zero */
+
+ if (arr->begin != NULL) {
+ free(arr->begin);
+ }
+
+ arr->begin = NULL;
+ arr->end = NULL;
+ arr->size = 0; /* implicitly already 0 */
+ arr->cap = 0;
+ }
+
+ it->val = arr->begin + prior; /* relocate 'it' to new position */
+ }
+}
+
+/************************************************************************************************
+ * stdarr_construct: Construct an initially empty array that will
+ * contain elements 'sizeof_val' bytes long.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_construct(stdarr *arr, stdsize vsize, stduint8 opts)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (vsize == 0 || (opts & ~(STDARR_OPTS_NO_AUTO_GROW | STDARR_OPTS_NO_AUTO_SHRINK)) != 0) {
+ ret = STDEINVAL;
+ goto stdarr_construct_fail;
+ }
+
+ arr->begin = NULL;
+ arr->end = NULL;
+ arr->cap = 0;
+ arr->size = 0;
+ arr->vsize = vsize;
+ arr->opts = opts;
+
+ goto stdarr_construct_end;
+
+ /* error handling and return */
+
+ stdarr_construct_fail:
+ arr->vsize = 0; /* make STDARR_IS_LEGAL(arr) false */
+
+ stdarr_construct_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdarr_copy_construct: Construct a copy of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_copy_construct(stdarr *dst, const stdarr *src)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(src));
+
+ *dst = *src;
+
+ if (src->begin != NULL) {
+ stdsize esize = src->vsize * src->size;
+ stdsize asize = src->vsize * src->cap;
+
+ if ((dst->begin = (char*) malloc(asize)) == NULL) {
+ ret = STDENOMEM;
+ goto stdarr_copy_construct_fail;
+ }
+
+ dst->end = dst->begin + esize;
+ memcpy(dst->begin, src->begin, esize);
+ }
+
+ goto stdarr_copy_construct_end;
+
+ /* error handling and return */
+
+ stdarr_copy_construct_fail:
+ dst->vsize = 0; /* make STDARR_IS_LEGAL(dst) false */
+
+ stdarr_copy_construct_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdarr_destruct: Reclaim an array's resources and invalidate impl.
+ ***********************************************************************************************/
+
+STDINLINE void stdarr_destruct(stdarr *arr)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ if (arr->begin != NULL) {
+ free(arr->begin);
+ arr->begin = NULL;
+ }
+
+ arr->vsize = 0; /* make STDARR_IS_LEGAL(arr) false */
+}
+
+/************************************************************************************************
+ * stdarr_set_eq: Set 'dst' to have the same contents as 'src.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_set_eq(stdarr *dst, const stdarr *src)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(dst) && STDARR_IS_LEGAL(src) && dst->vsize == src->vsize);
+
+ if (dst == src) {
+ goto stdarr_set_eq_end;
+ }
+
+ if ((ret = stdarr_resize(dst, src->size)) != STDESUCCESS) {
+ goto stdarr_set_eq_end;
+ }
+
+ memcpy(dst->begin, src->begin, src->vsize * src->size);
+
+ stdarr_set_eq_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdarr_swap: Make arr1 reference arr2's sequence and vice versa.
+ ***********************************************************************************************/
+
+STDINLINE void stdarr_swap(stdarr *arr1, stdarr *arr2)
+{
+ stdarr cpy;
+
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr1) && STDARR_IS_LEGAL(arr2) && arr1->vsize == arr2->vsize);
+
+ STDSWAP(*arr1, *arr2, cpy);
+}
+
+/************************************************************************************************
+ * stdarr_begin: Get an iterator to the beginning of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdarr_begin(const stdarr *arr, stdit *it)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ it->impl.arr.val = (char*) arr->begin;
+ it->impl.arr.vsize = arr->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdarr_last: Get an iterator the last entry of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdarr_last(const stdarr *arr, stdit *it)
+{
+ STDBOUNDS_CHECK(arr->size != 0);
+
+ return stdarr_it_prev(stdarr_end(arr, it));
+}
+
+/************************************************************************************************
+ * stdarr_end: Get an iterator to the sentinel end entry of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdarr_end(const stdarr *arr, stdit *it)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ it->impl.arr.val = (char*) arr->end;
+ it->impl.arr.vsize = arr->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdarr_get: Get an iterator the 'elem_num'th (0 based) entry of an
+ * array. Can request/return sentinel end position (i.e. get(size(arr))).
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdarr_get(const stdarr *arr, stdit *it, stdsize elem_num)
+{
+ STDBOUNDS_CHECK(elem_num <= arr->size);
+
+ return stdarr_it_advance(stdarr_begin(arr, it), elem_num);
+}
+
+/************************************************************************************************
+ * stdarr_is_begin: Returns whether or not an iterator refers to the beginning of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdarr_is_begin(const stdarr *arr, const stdit *it)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr) && STDIT_ARR_IS_LEGAL(it) && STDARR_IT_IS_LEGAL(arr, &it->impl.arr));
+
+ return it->impl.arr.val == arr->begin;
+}
+
+/************************************************************************************************
+ * stdarr_is_end: Returns whether or not an iterator refers to the end of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdarr_is_end(const stdarr *arr, const stdit *it)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr) && STDIT_ARR_IS_LEGAL(it) && STDARR_IT_IS_LEGAL(arr, &it->impl.arr));
+
+ return it->impl.arr.val == arr->end;
+}
+
+/************************************************************************************************
+ * stdarr_rank: Returns the 0-based rank of an iterator.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdarr_rank(const stdarr *arr, const stdit *it)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr) && STDIT_ARR_IS_LEGAL(it) && STDARR_IT_IS_LEGAL(arr, &it->impl.arr));
+
+ return (stdsize) (it->impl.arr.val - arr->begin) / arr->vsize;
+}
+
+/************************************************************************************************
+ * stdarr_size: Return the number of entries contained in 'arr.'
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdarr_size(const stdarr *arr)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ return arr->size;
+}
+
+/************************************************************************************************
+ * stdarr_empty: Return whether or not 'arr' is empty.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdarr_empty(const stdarr *arr)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ return arr->size == 0;
+}
+
+/************************************************************************************************
+ * stdarr_high_capacity: Return the maximum size 'arr' can be without
+ * needing to be grown (re-allocated).
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdarr_high_capacity(const stdarr *arr)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ return arr->cap;
+}
+
+/************************************************************************************************
+ * stdarr_low_capacity: Return the size at which 'arr' would be
+ * automatically shrunk (re-allocated).
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdarr_low_capacity(const stdarr *arr)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ return (arr->cap >> 2);
+}
+
+/************************************************************************************************
+ * stdarr_max_size: Return the theoretical maximum number of elements
+ * 'arr' could possibly hold.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdarr_max_size(const stdarr *arr)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ return STDSIZE_MAX / arr->vsize;
+}
+
+/************************************************************************************************
+ * stdarr_val_size: Return the size in bytes of the type of elements
+ * 'arr' holds.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdarr_val_size(const stdarr *arr)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ return arr->vsize;
+}
+
+/************************************************************************************************
+ * stdarr_resize: Resize an array to contain 'num_elems' elements.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_resize(stdarr *arr, stdsize num_elems)
+{
+ stdcode ret = STDESUCCESS;
+ stdit it;
+
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ if (num_elems > arr->size) {
+ ret = stdarr_low_insert_space(arr, &stdarr_end(arr, &it)->impl.arr, num_elems - arr->size);
+
+ } else if (num_elems < arr->size) {
+ stdarr_low_remove_space(arr, &stdarr_get(arr, &it, num_elems)->impl.arr, arr->size - num_elems);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdarr_clear: Remove all elements from an array (i.e. - make
+ * stdarr_size() 0).
+ ***********************************************************************************************/
+
+STDINLINE void stdarr_clear(stdarr *arr)
+{
+ stdarr_resize(arr, 0);
+}
+
+/************************************************************************************************
+ * stdarr_set_capacity: Set the capacity of an array. Ignores all auto
+ * allocation considerations.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_set_capacity(stdarr *arr, stdsize num_elems)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ if (num_elems != arr->cap) {
+
+ if (num_elems != 0) {
+ char * mem;
+
+ if ((mem = (char*) realloc(arr->begin, num_elems * arr->vsize)) == NULL) {
+ ret = STDENOMEM;
+ goto stdarr_set_capacity_end;
+ }
+
+ arr->cap = num_elems;
+ arr->size = STDMIN(arr->size, num_elems);
+
+ arr->begin = mem;
+ arr->end = mem + arr->size * num_elems;
+
+ } else {
+
+ if (arr->begin != NULL) {
+ free(arr->begin);
+ }
+
+ arr->begin = NULL;
+ arr->end = NULL;
+ arr->size = 0;
+ arr->cap = 0;
+ }
+ }
+
+ stdarr_set_capacity_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdarr_reserve: Ensures 'arr' can contain 'num_elems' elements
+ * without any additional reallocations. Ignores all auto allocation
+ * considerations.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_reserve(stdarr *arr, stdsize num_elems)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ if (num_elems > arr->cap) {
+ ret = stdarr_set_capacity(arr, num_elems);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdarr_shrink_fit: Sets 'arr's capacity to 'arr's size. Ignores
+ * all auto allocation considerations.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_shrink_fit(stdarr *arr)
+{
+ return stdarr_set_capacity(arr, arr->size);
+}
+
+/************************************************************************************************
+ * stdarr_push_back: Push an element onto the end of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_push_back(stdarr *arr, const void *val)
+{
+ stdit it;
+
+ return stdarr_insert(arr, stdarr_end(arr, &it), val);
+}
+
+/************************************************************************************************
+ * stdarr_push_back_n: Push a C array of elements onto the end of an
+ * array.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_push_back_n(stdarr *arr, const void *vals, stdsize num_push)
+{
+ stdit it;
+
+ return stdarr_insert_n(arr, stdarr_end(arr, &it), vals, num_push);
+}
+
+/************************************************************************************************
+ * stdarr_push_back_seq: Push a sequence of elements on the end of an
+ * array.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_push_back_seq(stdarr *arr, const stdit *b, const stdit *e)
+{
+ stdit it;
+
+ return stdarr_insert_seq(arr, stdarr_end(arr, &it), b, e);
+}
+
+/************************************************************************************************
+ * stdarr_push_back_seq_n: Push a sequence of elements on the end of an
+ * array.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_push_back_seq_n(stdarr *arr, const stdit *b, stdsize num_push)
+{
+ stdit it;
+
+ return stdarr_insert_seq_n(arr, stdarr_end(arr, &it), b, num_push);
+}
+
+/************************************************************************************************
+ * stdarr_push_back_rep: Push a C array of elements onto the end of an
+ * array.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_push_back_rep(stdarr *arr, const void *val, stdsize num_times)
+{
+ stdit it;
+
+ return stdarr_insert_rep(arr, stdarr_end(arr, &it), val, num_times);
+}
+
+/************************************************************************************************
+ * stdarr_pop_back: Pop an element off of the end of an array.
+ ***********************************************************************************************/
+
+STDINLINE void stdarr_pop_back(stdarr *arr)
+{
+ stdarr_pop_back_n(arr, 1);
+}
+
+/************************************************************************************************
+ * stdarr_pop_back_n: Pop multiple elements off of the end of an array.
+ ***********************************************************************************************/
+
+STDINLINE void stdarr_pop_back_n(stdarr *arr, stdsize num_pop)
+{
+ STDBOUNDS_CHECK(num_pop <= arr->size);
+
+ stdarr_resize(arr, arr->size - num_pop);
+}
+
+/************************************************************************************************
+ * stdarr_insert: Insert an element into an array at a point.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_insert(stdarr *arr, stdit *it, const void *val)
+{
+ return stdarr_insert_n(arr, it, val, 1);
+}
+
+/************************************************************************************************
+ * stdarr_insert_n: Insert multiple elements into an array at a point.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_insert_n(stdarr *arr, stdit *it, const void *vals, stdsize num_insert)
+{
+ stdcode ret;
+
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr) && STDIT_ARR_IS_LEGAL(it) && STDARR_IT_IS_LEGAL(arr, &it->impl.arr));
+
+ if ((ret = stdarr_low_insert_space(arr, &it->impl.arr, num_insert)) != STDESUCCESS) {
+ goto stdarr_insert_n_end;
+ }
+
+ memcpy(it->impl.arr.val, vals, num_insert * arr->vsize);
+
+ stdarr_insert_n_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdarr_insert_seq: Insert a sequence of elements into an array at a
+ * point.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_insert_seq(stdarr *arr, stdit *it, const stdit *b, const stdit *e)
+{
+ stdcode ret;
+ stdssize num_insert;
+
+ if ((num_insert = stdit_distance(b, e)) < 0) { /* calc how many elements in [b, e) */
+ ret = STDEINVAL;
+ goto stdarr_insert_seq_end;
+ }
+
+ ret = stdarr_insert_seq_n(arr, it, b, num_insert);
+
+ stdarr_insert_seq_end:
+ return ret;
+}
+
+
+/************************************************************************************************
+ * stdarr_insert_seq_n: Insert a sequence of elements into an array at
+ * a point.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_insert_seq_n(stdarr *arr, stdit *it, const stdit *b, stdsize num_insert)
+{
+ stdcode ret;
+ char * dst_it;
+ stdit src_it;
+
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr) && STDIT_ARR_IS_LEGAL(it) && STDARR_IT_IS_LEGAL(arr, &it->impl.arr));
+
+ if ((ret = stdarr_low_insert_space(arr, &it->impl.arr, num_insert)) != STDESUCCESS) {
+ goto stdarr_insert_seq_n_end;
+ }
+
+ dst_it = it->impl.arr.val;
+ src_it = *b;
+
+ for (; num_insert-- != 0; dst_it += arr->vsize, stdit_next(&src_it)) {
+ memcpy(dst_it, stdit_val(&src_it), arr->vsize);
+ }
+
+ stdarr_insert_seq_n_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdarr_insert_rep: Insert the same element into an array at a point
+ * multiple times.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_insert_rep(stdarr *arr, stdit *it, const void *val, stdsize num_times)
+{
+ stdcode ret;
+ char * dst_it;
+
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr) && STDIT_ARR_IS_LEGAL(it) && STDARR_IT_IS_LEGAL(arr, &it->impl.arr));
+
+ if ((ret = stdarr_low_insert_space(arr, &it->impl.arr, num_times)) != STDESUCCESS) {
+ goto stdarr_insert_rep_end;
+ }
+
+ dst_it = it->impl.arr.val;
+
+ for (; num_times-- != 0; dst_it += arr->vsize) {
+ memcpy(dst_it, val, arr->vsize);
+ }
+
+ stdarr_insert_rep_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdarr_erase: Erase an element from an array.
+ ***********************************************************************************************/
+
+STDINLINE void stdarr_erase(stdarr *arr, stdit *it)
+{
+ stdarr_erase_n(arr, it, 1);
+}
+
+/************************************************************************************************
+ * stdarr_erase_n: Erase multiple elements from an array.
+ ***********************************************************************************************/
+
+STDINLINE void stdarr_erase_n(stdarr *arr, stdit *it, stdsize num_erase)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr) && STDIT_ARR_IS_LEGAL(it) && STDARR_IT_IS_LEGAL(arr, &it->impl.arr));
+
+ stdarr_low_remove_space(arr, &it->impl.arr, num_erase);
+}
+
+/************************************************************************************************
+ * stdarr_erase_seq: Erase a sequence of elements from an array.
+ ***********************************************************************************************/
+
+STDINLINE void stdarr_erase_seq(stdarr *arr, stdit *b, stdit *e)
+{
+ stdssize diff = stdarr_it_cmp(e, b);
+
+ STDSAFETY_CHECK(diff >= 0);
+
+ stdarr_erase_n(arr, b, diff);
+ *e = *b;
+}
+
+/************************************************************************************************
+ * stdarr_get_opts: Get the options of an array.
+ ***********************************************************************************************/
+
+STDINLINE stduint8 stdarr_get_opts(const stdarr *arr)
+{
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ return arr->opts;
+}
+
+/************************************************************************************************
+ * stdarr_set_opts: Set the options of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdarr_set_opts(stdarr *arr, stduint8 opts)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(STDARR_IS_LEGAL(arr));
+
+ if ((opts & ~(STDARR_OPTS_NO_AUTO_GROW | STDARR_OPTS_NO_AUTO_SHRINK)) != 0) {
+ ret = STDEINVAL;
+ goto stdarr_set_opts_end;
+ }
+
+ arr->opts = opts;
+
+ stdarr_set_opts_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdarr_it_val: Get a pointer to the element that 'it' references.
+ ***********************************************************************************************/
+
+STDINLINE void *stdarr_it_val(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_ARR_IS_LEGAL(it));
+
+ return it->impl.arr.val;
+}
+
+/************************************************************************************************
+ * stdarr_it_val_size: Returns the size of the element in bytes that 'it' references.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdarr_it_val_size(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_ARR_IS_LEGAL(it));
+
+ return it->impl.arr.vsize;
+}
+
+/************************************************************************************************
+ * stdarr_it_eq: Compare two iterators for equality (refer to same element).
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdarr_it_eq(const stdit *it1, const stdit *it2)
+{
+ STDSAFETY_CHECK(STDIT_ARR_IS_LEGAL(it1) && STDIT_ARR_IS_LEGAL(it2) && it1->impl.arr.vsize == it2->impl.arr.vsize);
+
+ return it1->impl.arr.val == it2->impl.arr.val;
+}
+
+/************************************************************************************************
+ * stdarr_it_cmp: Compare two iterators for rank difference.
+ ***********************************************************************************************/
+
+STDINLINE stdssize stdarr_it_cmp(const stdit *it1, const stdit *it2)
+{
+ STDSAFETY_CHECK(STDIT_ARR_IS_LEGAL(it1) && STDIT_ARR_IS_LEGAL(it2) && it1->impl.arr.vsize == it2->impl.arr.vsize);
+
+ return (stdssize) (it1->impl.arr.val - it2->impl.arr.val) / (stdssize) it1->impl.arr.vsize;
+}
+
+/************************************************************************************************
+ * stdarr_it_next: Advance 'it' by one position.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdarr_it_next(stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_ARR_IS_LEGAL(it));
+
+ it->impl.arr.val += it->impl.arr.vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdarr_it_advance: Advance 'it' by 'num_advance' positions.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdarr_it_advance(stdit *it, stdsize num_advance)
+{
+ STDSAFETY_CHECK(STDIT_ARR_IS_LEGAL(it));
+
+ it->impl.arr.val += num_advance * it->impl.arr.vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdarr_it_prev: Retreat 'it' by one position.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdarr_it_prev(stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_ARR_IS_LEGAL(it));
+
+ it->impl.arr.val -= it->impl.arr.vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdarr_it_retreat: Retreat 'it' by 'num_retreat' positions.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdarr_it_retreat(stdit *it, stdsize num_retreat)
+{
+ STDSAFETY_CHECK(STDIT_ARR_IS_LEGAL(it));
+
+ it->impl.arr.val -= num_retreat * it->impl.arr.vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdarr_it_offset: Offset 'it' by 'offset' positions.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdarr_it_offset(stdit *it, stdssize offset)
+{
+ STDSAFETY_CHECK(STDIT_ARR_IS_LEGAL(it));
+
+ it->impl.arr.val += offset * it->impl.arr.vsize;
+
+ return it;
+}
Added: vendor/stdutil/current/src/stdcarr.c
===================================================================
--- vendor/stdutil/current/src/stdcarr.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdcarr.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,1447 @@
+/* Copyright (c) 2000, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <stdutil/stderror.h>
+#include <stdutil/stdcarr.h>
+
+#define STDCARR_IS_LEGAL(carr) (( ((carr)->cap != 0 && (carr)->base != NULL) || ((carr)->cap == 0 && (carr)->base == NULL) ) && \
+ (stdsize) ((carr)->endbase - (carr)->base) == (carr)->cap * (carr)->vsize && \
+ (carr)->begin >= (carr)->base && (carr)->begin <= (carr)->endbase && \
+ (carr)->end >= (carr)->base && (carr)->end <= (carr)->endbase && \
+ (stdsize) ((carr)->begin > (carr)->end ? \
+ ((carr)->endbase - (carr)->begin) + ((carr)->end - (carr)->base) : \
+ (carr)->end - (carr)->begin) == (carr)->size * (carr)->vsize && \
+ ((carr)->endbase == NULL || ((carr)->begin != (carr)->endbase && (carr)->end != (carr)->endbase)) && \
+ ( ((carr)->size < (carr)->cap) || ((carr)->size == 0 && (carr)->cap == 0) ) && \
+ (carr)->vsize != 0 && \
+ ((carr)->opts & ~(STDCARR_OPTS_NO_AUTO_GROW | STDCARR_OPTS_NO_AUTO_SHRINK)) == 0)
+
+#define STDCARR_IT_IS_LEGAL(carr, it) ((it)->base == (carr)->base && (it)->endbase == (carr)->endbase && \
+ (it)->begin == (carr)->begin && (it)->end == (carr)->end && (it)->vsize == (carr)->vsize)
+
+#define STDCARR_IT_IS_LEGAL2(it) ((it)->base <= (it)->endbase && \
+ (it)->begin >= (it)->base && (it)->begin <= (it)->endbase && \
+ (it)->end >= (it)->base && (it)->end <= (it)->endbase && \
+ ((it)->begin <= (it)->end ? \
+ ((it)->val >= (it)->begin && (it)->val <= (it)->end) : \
+ (((it)->val >= (it)->begin && (it)->val < (it)->endbase) || \
+ ((it)->val >= (it)->base && (it)->val <= (it)->end))) && \
+ ((it)->endbase == NULL || ((it)->begin != (it)->endbase && (it)->end != (it)->endbase && (it)->val != (it)->endbase)) && \
+ (it)->vsize != 0)
+
+#define STDIT_CARR_IS_LEGAL(it) ((it)->type_id == STDCARR_IT_ID && STDCARR_IT_IS_LEGAL2(&(it)->impl.carr))
+
+#define STDCARR_INS_SHIFT_RIGHT(carr, ptr) \
+((ptr) >= (carr)->begin ? (stdsize) ((ptr) - (carr)->begin) > ((carr)->size >> 1) * (carr)->vsize \
+ : (stdsize) ((carr)->end - (ptr)) <= ((carr)->size >> 1) * (carr)->vsize)
+
+/* NOTE: the '+' sign in '(carr)->size + (n)' is correct don't change it -- work it out on paper */
+
+#define STDCARR_ERS_SHIFT_RIGHT(carr, ptr, n) \
+((ptr) >= (carr)->begin ? (stdsize) ((ptr) - (carr)->begin) < (((carr)->size - (n)) >> 1) * (carr)->vsize \
+ : (stdsize) ((carr)->end - (ptr)) >= (((carr)->size + (n)) >> 1) * (carr)->vsize)
+
+/************************************************************************************************
+ * stdcarr_low_copy_to_buf: Copy a portion of a circular array to a
+ * buffer. Returns ptr to right after copied data in dst. 'c_begin'
+ * and 'c_end' point at positions inside of carr.
+ ***********************************************************************************************/
+
+STDINLINE static char *stdcarr_low_copy_to_buf(char *dst, const stdcarr *carr, const char *c_begin, const char *c_end)
+{
+ stdsize diff;
+
+ STDSAFETY_CHECK(c_begin >= carr->base && c_begin <= carr->endbase &&
+ c_end >= carr->base && c_end <= carr->endbase &&
+ (carr->endbase == NULL || (c_begin != carr->endbase && c_end != carr->endbase)));
+
+ if (c_begin <= c_end) {
+ diff = (stdsize) (c_end - c_begin);
+
+ memcpy(dst, c_begin, diff);
+ dst += diff;
+
+ } else {
+ diff = (stdsize) (carr->endbase - c_begin);
+
+ memcpy(dst, c_begin, diff);
+ dst += diff;
+
+ diff = (stdsize) (c_end - carr->base);
+
+ memcpy(dst, carr->base, diff);
+ dst += diff;
+ }
+
+ return dst;
+}
+
+/************************************************************************************************
+ * stdcarr_low_forward: Return 'p' advanced by 'n' bytes forward, with wrapping.
+ ***********************************************************************************************/
+
+STDINLINE static char *stdcarr_low_forward(char *p, stdsize n, const char *base, const char *endbase)
+{
+ STDSAFETY_CHECK(p >= base && p <= endbase && (endbase == NULL || p != endbase));
+
+ return ((p += n) < endbase ? p : (char*) base + (p - (char*) endbase));
+}
+
+/************************************************************************************************
+ * stdcarr_low_backward: Return 'p' advanced by 'n' bytes backward, with wrapping.
+ ***********************************************************************************************/
+
+STDINLINE static char *stdcarr_low_backward(char *p, stdsize n, const char *base, const char *endbase)
+{
+ STDSAFETY_CHECK(p >= base && p <= endbase && (endbase == NULL || p != endbase));
+
+ return ((p -= n) >= base ? p : (char*) endbase - ((char*) base - p));
+}
+
+/************************************************************************************************
+ * stdcarr_low_insert_shift_right: This function shifts all the values
+ * from 'it' and on, to the right by delta bytes. It also updates end
+ * and size.
+ ***********************************************************************************************/
+
+STDINLINE static void stdcarr_low_insert_shift_right(stdcarr *carr, char *it, stdsize delta, stdsize new_size)
+{
+ stdssize diff;
+ stdssize diff2;
+
+ if (carr->begin <= carr->end) {
+
+ if ((diff = carr->end + delta - carr->endbase) <= 0) { /* no data wraps around */
+ memmove(it + delta, it, (stdsize) (carr->end - it));
+
+ } else {
+
+ if ((diff2 = carr->end - it) <= diff) { /* data to shift can fit between base and new end */
+ memcpy(carr->base + diff - diff2, it, (stdsize) diff2);
+
+ } else { /* partial fit */
+ memcpy(carr->base, carr->end - diff, (stdsize) diff);
+ memmove(it + delta, it, (stdsize) (diff2 - diff));
+ }
+ }
+
+ } else { /* space exists between end and begin for insertion */
+
+ if ((diff = carr->end - it) >= 0) { /* it is below end */
+ memmove(it + delta, it, (stdsize) diff);
+
+ } else {
+ memmove(carr->base + delta, carr->base, (stdsize) (carr->end - carr->base)); /* shift lower data */
+
+ if ((stdsize) (diff = carr->endbase - it) <= delta) { /* higher data fits into newly opened area */
+ memcpy(carr->base + delta - diff, it, (stdsize) diff);
+
+ } else { /* partial fit */
+ memcpy(carr->base, carr->endbase - delta, delta);
+ memmove(it + delta, it, (stdsize) (diff - delta));
+ }
+ }
+ }
+
+ carr->size = new_size;
+ carr->end = stdcarr_low_forward(carr->end, delta, carr->base, carr->endbase);
+}
+
+/************************************************************************************************
+ * stdcarr_low_insert_shift_left: This function shifts all values
+ * before 'it' to the left by delta bytes. It also updates begin and
+ * size.
+ ***********************************************************************************************/
+
+STDINLINE static void stdcarr_low_insert_shift_left(stdcarr *carr, char *it, stdsize delta, stdsize new_size)
+{
+ stdssize diff;
+ stdssize diff2;
+
+ if (carr->begin <= carr->end) {
+
+ if ((diff = carr->base - (carr->begin - delta)) <= 0) { /* new begin doesn't wrap around */
+ memmove(carr->begin - delta, carr->begin, (stdsize) (it - carr->begin));
+
+ } else {
+
+ if ((diff2 = it - carr->begin) <= diff) { /* data to shift fits between new begin and endbase */
+ memcpy(carr->endbase - diff, carr->begin, (stdsize) diff2);
+
+ } else { /* partial fit */
+ memcpy(carr->endbase - diff, carr->begin, (stdsize) diff);
+ memmove(carr->base, carr->begin + diff, (stdsize) (diff2 - diff));
+ }
+ }
+
+ } else { /* space exists between end and begin for insertion */
+
+ if (it >= carr->begin) { /* it is above begin */
+ memmove(carr->begin - delta, carr->begin, (stdsize) (it - carr->begin));
+
+ } else {
+ memmove(carr->begin - delta, carr->begin, (stdsize) (carr->endbase - carr->begin));
+
+ if ((stdsize) (diff = it - carr->base) <= delta) { /* fits into newly opened area */
+ memcpy(carr->endbase - delta, carr->base, (stdsize) diff);
+
+ } else {
+ memcpy(carr->endbase - delta, carr->base, delta);
+ memmove(carr->base, carr->base + delta, (stdsize) (diff - delta));
+ }
+ }
+ }
+
+ carr->size = new_size;
+ carr->begin = stdcarr_low_backward(carr->begin, delta, carr->base, carr->endbase);
+}
+
+/************************************************************************************************
+ * stdcarr_low_erase_shift_left: This function shifts values from the
+ * right to the left into erased values. erase_end points to one past
+ * the last value to be erased. (e.g. - delta == 4 * carr->vsize)
+ *
+ * erase_shift_left(__****----1***___) => __****1***_______
+ *
+ * Legend: _ = empty slot, * = occupied slot, 1 = erase_end, - = to be
+ * deleted.
+ ***********************************************************************************************/
+
+STDINLINE static void stdcarr_low_erase_shift_left(stdcarr *carr, char *erase_end, stdsize delta, stdsize new_size)
+{
+ char * erase_begin = erase_end - delta; /* may point outside alloc'ed mem */
+ stdssize diff;
+ stdssize diff2;
+
+ if ((diff = carr->end - erase_end) >= 0) { /* end is at or above erase_end */
+
+ if ((diff2 = carr->base - erase_begin) <= 0) { /* erase region doesn't wrap around */
+ memmove(erase_begin, erase_end, (stdsize) diff);
+
+ } else {
+ /* diff2: how many bytes to erase off of high portion of array */
+
+ erase_begin = carr->endbase - diff2; /* implicitly valid */
+
+ if (diff <= diff2) { /* data to shift fits between erase_begin and endbase */
+ memcpy(erase_begin, erase_end, (stdsize) diff);
+
+ } else { /* only a partial fit */
+ memcpy(erase_begin, erase_end, (stdsize) diff2);
+ memmove(carr->base, erase_end + diff2, (stdsize) (diff - diff2));
+ }
+ }
+
+ } else { /* carr->end is wrapped around */
+ diff = carr->endbase - erase_end;
+ memmove(erase_begin, erase_end, (stdsize) diff); /* shift higher data first */
+ erase_begin += diff; /* move erase_begin forward diff bytes */
+
+ if ((stdsize) (diff = carr->end - carr->base) <= delta) { /* lower data fits in opened area */
+ memcpy(erase_begin, carr->base, (stdsize) diff); /* copy lower data to higher */
+
+ } else { /* partial fit */
+ memcpy(erase_begin, carr->base, delta); /* copy delta bytes higher */
+ memmove(carr->base, carr->base + delta, (stdsize) (diff - delta)); /* shift rest lower */
+ }
+ }
+
+ carr->size = new_size;
+ carr->end = stdcarr_low_backward(carr->end, delta, carr->base, carr->endbase);
+}
+
+/************************************************************************************************
+ * stdcarr_low_erase_shift_right: This function shifts values from the
+ * left to the right into erased values. erase_begin points to the
+ * first value to be erased. (e.g. - delta == 4 * carr->vsize).
+ *
+ * erase_shift_right(__**1---*****___) => ______*******___
+ *
+ * Legend: _ = empty slot, * = occupied slot, 1 = it, - = to be
+ * deleted.
+ ***********************************************************************************************/
+
+STDINLINE static void stdcarr_low_erase_shift_right(stdcarr *carr, char *erase_begin, stdsize delta, stdsize new_size)
+{
+ char * erase_end = erase_begin + delta; /* may point outside valid range */
+ stdssize diff;
+ stdssize diff2;
+ stdssize diff3;
+
+ if ((diff = erase_begin - carr->begin) >= 0) { /* erase_begin is at or above begin */
+
+ if ((diff2 = erase_end - carr->endbase) <= 0) { /* erase region doesn't wrap around */
+ memmove(carr->begin + delta, carr->begin, (stdsize) diff);
+
+ } else {
+ /* diff2: how many bytes to erase off of low portion of array */
+
+ if ((diff3 = diff2 - diff) >= 0) { /* data to shift fits between base and erase_end */
+ memcpy(carr->base + diff3, carr->begin, (stdsize) diff);
+
+ } else { /* only a partial fit */
+ memcpy(carr->base, erase_begin - diff2, (stdsize) diff2);
+ memmove(carr->begin + delta, carr->begin, (stdsize) -diff3);
+ }
+ }
+
+ } else {
+ diff = erase_begin - carr->base;
+ erase_end -= diff; /* move erase_end back diff bytes */
+ memmove(erase_end, carr->base, (stdsize) diff); /* shift lower data first */
+
+ if ((stdsize) (diff = carr->endbase - carr->begin) <= delta) { /* fits into newly opened area */
+ memcpy(erase_end - diff, carr->begin, (stdsize) diff);
+
+ } else { /* partial fit */
+ memcpy(carr->base, carr->endbase - delta, delta); /* copy delta bytes lower */
+ memmove(carr->begin + delta, carr->begin, (stdsize) (diff - delta)); /* shift rest higher */
+ }
+ }
+
+ carr->size = new_size;
+ carr->begin = stdcarr_low_forward(carr->begin, delta, carr->base, carr->endbase);
+}
+
+/************************************************************************************************
+ * stdcarr_low_insert_shift: This function first determines if an
+ * insertion will require a reallocation. If reallocation isn't
+ * needed, it calls the specified array shift function. If
+ * reallocation is called for, it does it and copies the values from
+ * carr to the new array while creating the open space requested. This
+ * function returns a pointer to the beginning of the insertion region
+ * through itp on success.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdcarr_low_insert_shift(stdcarr *carr, char **itp, stdsize delta,
+ stdsize new_size, stdbool shift_right)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (delta == 0) { /* no-op */
+ goto stdcarr_low_insert_shift_end;
+ }
+
+ /* delta != 0 -> new_size >= 1 */
+
+ if (new_size <= stdcarr_high_capacity(carr)) { /* current table is big enough */
+
+ if (shift_right) {
+ stdcarr_low_insert_shift_right(carr, *itp, delta, new_size);
+
+ } else {
+ stdcarr_low_insert_shift_left(carr, *itp, delta, new_size);
+ *itp = stdcarr_low_backward(*itp, delta, carr->base, carr->endbase);
+ }
+
+ } else if ((carr->opts & STDCARR_OPTS_NO_AUTO_GROW) == 0) { /* auto-growth allowed */
+ stdsize new_cap = (new_size << 1); /* new_cap > 0 */
+ stdsize asize;
+ char * mem;
+ char * tmp;
+
+ new_cap = STDMAX(new_cap, STDCARR_MIN_AUTO_ALLOC);
+ asize = new_cap * carr->vsize;
+
+ if ((mem = (char*) malloc(asize)) == NULL) {
+ ret = STDENOMEM;
+ goto stdcarr_low_insert_shift_end;
+ }
+
+ if (carr->base != NULL) {
+ tmp = *itp;
+ *itp = stdcarr_low_copy_to_buf(mem, carr, carr->begin, tmp); /* copy [begin, it) */
+ stdcarr_low_copy_to_buf(*itp + delta, carr, tmp, carr->end); /* insert space and copy [it, end) */
+ free(carr->base); /* free old array */
+
+ } else {
+ *itp = mem;
+ }
+
+ carr->base = mem;
+ carr->endbase = mem + asize;
+ carr->begin = mem;
+ carr->end = mem + new_size * carr->vsize;
+ carr->cap = new_cap;
+ carr->size = new_size;
+
+ } else { /* auto-growth disallowed */
+ ret = STDEACCES;
+ goto stdcarr_low_insert_shift_end;
+ }
+
+ stdcarr_low_insert_shift_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_low_erase_shift: This function determines if an erasure
+ * will require a reallocation or not. If reallocation isn't needed,
+ * it calls the specified array shift function. If reallocation is
+ * called for, it does it and copies the values to the new carray
+ * while deleting the proper elements. The boolean parameter
+ * shift_right indicates whether 'itp' points to the beginning of the
+ * erase sequence or to one past the end of the erase sequence. This
+ * parameter also determines whether we erase_shift_right or
+ * erase_shift_left.
+ ***********************************************************************************************/
+
+STDINLINE static void stdcarr_low_erase_shift(stdcarr *carr, char **itp, stdsize delta,
+ stdsize new_size, stdbool shift_right)
+{
+ if (delta == 0) { /* no-op */
+ return;
+ }
+
+ /* delta != 0 -> carr->size >= 1 && carr->cap > carr->size */
+
+ if ((carr->opts & STDCARR_OPTS_NO_AUTO_SHRINK) != 0 || /* no shrinking wanted */
+ new_size > stdcarr_low_capacity(carr) || /* no shrinking necessary */
+ carr->cap == STDCARR_MIN_AUTO_ALLOC) { /* already at min alloc size */
+
+ /* label used for alloc failures from below */
+ stdcarr_low_erase_shift_fail:
+
+ if (shift_right) {
+ stdcarr_low_erase_shift_right(carr, *itp, delta, new_size);
+ *itp = stdcarr_low_forward(*itp, delta, carr->base, carr->endbase);
+
+ } else {
+ stdcarr_low_erase_shift_left(carr, *itp, delta, new_size);
+ }
+
+ } else { /* need+allowed to shrink */
+ stdsize new_cap = (new_size << 1);
+ stdsize asize;
+ char * mem;
+ char * tmp;
+ char * tmp2;
+
+ new_cap = STDMAX(new_cap, STDCARR_MIN_AUTO_ALLOC);
+ asize = new_cap * carr->vsize;
+
+ if (asize != 0) {
+
+ if ((mem = (char*) malloc(asize)) == NULL) {
+ goto stdcarr_low_erase_shift_fail; /* fallback to no realloc pathway */
+ }
+
+ if (shift_right) {
+ tmp = stdcarr_low_forward(*itp, delta, carr->base, carr->endbase);
+ *itp = stdcarr_low_copy_to_buf(mem, carr, carr->begin, *itp); /* copy [begin, it) */
+ stdcarr_low_copy_to_buf(*itp, carr, tmp, carr->end); /* copy [it + delta, end) */
+
+ } else {
+ tmp = *itp;
+ tmp2 = stdcarr_low_backward(*itp, delta, carr->base, carr->endbase);
+ *itp = stdcarr_low_copy_to_buf(mem, carr, carr->begin, tmp2); /* copy [begin, it - delta) */
+ stdcarr_low_copy_to_buf(*itp, carr, tmp, carr->end); /* copy [it, end) */
+ }
+
+ } else {
+ mem = NULL;
+ *itp = NULL;
+ }
+
+ if (carr->base != NULL) {
+ free(carr->base);
+ }
+
+ carr->base = mem;
+ carr->endbase = mem + asize;
+ carr->begin = mem;
+ carr->end = mem + new_size * carr->vsize;
+ carr->cap = new_cap;
+ carr->size = new_size;
+ }
+}
+
+/************************************************************************************************
+ * stdcarr_construct: Construct an initially empty circular array.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_construct(stdcarr *carr, stdsize vsize, stduint8 opts)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (vsize == 0 || (opts & ~(STDCARR_OPTS_NO_AUTO_GROW | STDCARR_OPTS_NO_AUTO_SHRINK)) != 0) {
+ ret = STDEINVAL;
+ goto stdcarr_construct_fail;
+ }
+
+ carr->base = NULL;
+ carr->endbase = NULL;
+ carr->begin = NULL;
+ carr->end = NULL;
+ carr->cap = 0;
+ carr->size = 0;
+ carr->vsize = vsize;
+ carr->opts = opts;
+
+ goto stdcarr_construct_end;
+
+ /* error handling and return */
+
+ stdcarr_construct_fail:
+ carr->vsize = 0; /* make STDCARR_IS_LEGAL(carr) false */
+
+ stdcarr_construct_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_copy_construct: Construct a copy of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_copy_construct(stdcarr *dst, const stdcarr *src)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(src));
+
+ *dst = *src;
+
+ if (src->base != NULL) {
+ stdsize asize = src->vsize * src->cap;
+
+ if ((dst->base = (char*) malloc(asize)) == NULL) {
+ ret = STDENOMEM;
+ goto stdcarr_copy_construct_fail;
+ }
+
+ dst->endbase = dst->base + asize;
+ dst->begin = dst->base;
+ dst->end = stdcarr_low_copy_to_buf(dst->base, src, src->begin, src->end);
+ }
+
+ goto stdcarr_copy_construct_end;
+
+ /* error handling and return */
+
+ stdcarr_copy_construct_fail:
+ dst->vsize = 0; /* make STDCARR_IS_LEGAL(dst) false */
+
+ stdcarr_copy_construct_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_destruct: Reclaim a circular array's resources and invalidate it.
+ ***********************************************************************************************/
+
+STDINLINE void stdcarr_destruct(stdcarr *carr)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ if (carr->base != NULL) {
+ free(carr->base);
+ carr->base = NULL;
+ }
+
+ carr->vsize = 0; /* make STDCARR_IS_LEGAL(carr) false */
+}
+
+/************************************************************************************************
+ * stdcarr_set_eq: Set 'dst' to have the same contents as 'src.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_set_eq(stdcarr *dst, stdcarr *src)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(dst) && STDCARR_IS_LEGAL(src) && dst->vsize == src->vsize);
+
+ if (dst == src) {
+ goto stdcarr_set_eq_end;
+ }
+
+ if ((ret = stdcarr_resize(dst, src->size)) != STDESUCCESS) {
+ goto stdcarr_set_eq_end;
+ }
+
+ dst->begin = dst->base;
+ dst->end = stdcarr_low_copy_to_buf(dst->begin, src, src->begin, src->end);
+
+ stdcarr_set_eq_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_swap: Make 'carr1' reference 'carr2's sequence and vice versa.
+ ***********************************************************************************************/
+
+STDINLINE void stdcarr_swap(stdcarr *carr1, stdcarr *carr2)
+{
+ stdcarr cpy;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr1) && STDCARR_IS_LEGAL(carr2));
+
+ STDSWAP(*carr1, *carr2, cpy);
+}
+
+/************************************************************************************************
+ * stdcarr_begin: Get an iterator to the beginning of a circular array.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdcarr_begin(const stdcarr *carr, stdit *it)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ it->impl.carr.val = (char*) carr->begin;
+ it->impl.carr.base = (char*) carr->base;
+ it->impl.carr.endbase = (char*) carr->endbase;
+ it->impl.carr.begin = (char*) carr->begin;
+ it->impl.carr.end = (char*) carr->end;
+ it->impl.carr.vsize = carr->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdcarr_last: Get an iterator to the last entry of a circular array.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdcarr_last(const stdcarr *carr, stdit *it)
+{
+ STDBOUNDS_CHECK(carr->size != 0);
+
+ return stdcarr_it_prev(stdcarr_end(carr, it));
+}
+
+/************************************************************************************************
+ * stdcarr_end: Get an iterator to the sentinel end entry of a circular array.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdcarr_end(const stdcarr *carr, stdit *it)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ it->impl.carr.val = (char*) carr->end;
+ it->impl.carr.base = (char*) carr->base;
+ it->impl.carr.endbase = (char*) carr->endbase;
+ it->impl.carr.begin = (char*) carr->begin;
+ it->impl.carr.end = (char*) carr->end;
+ it->impl.carr.vsize = carr->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdcarr_get: Get an iterator to the 'elem_num'th entry in a circular array.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdcarr_get(const stdcarr *carr, stdit *it, stdsize elem_num)
+{
+ STDBOUNDS_CHECK(elem_num <= carr->size);
+
+ return stdcarr_it_advance(stdcarr_begin(carr, it), elem_num);
+}
+
+/************************************************************************************************
+ * stdcarr_is_begin: Return whether or not an iterator references the begin of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdcarr_is_begin(const stdcarr *carr, const stdit *it)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr) && STDIT_CARR_IS_LEGAL(it) && STDCARR_IT_IS_LEGAL(carr, &it->impl.carr));
+
+ return it->impl.carr.val == carr->begin;
+}
+
+/************************************************************************************************
+ * stdcarr_is_end: Return whether or not an iterator references the end of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdcarr_is_end(const stdcarr *carr, const stdit *it)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr) && STDIT_CARR_IS_LEGAL(it) && STDCARR_IT_IS_LEGAL(carr, &it->impl.carr));
+
+ return it->impl.carr.val == carr->end;
+}
+
+/************************************************************************************************
+ * stdcarr_rank: Returns the 0-based rank of an iterator.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdcarr_rank(const stdcarr *carr, const stdit *it)
+{
+ stdsize rank;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr) && STDIT_CARR_IS_LEGAL(it) && STDCARR_IT_IS_LEGAL(carr, &it->impl.carr));
+
+ if (it->impl.carr.val >= carr->begin) {
+ rank = (stdsize) (it->impl.carr.val - carr->begin) / carr->vsize;
+
+ } else {
+ rank = (stdsize) ((carr->endbase - carr->begin) + (it->impl.carr.val - carr->base)) / carr->vsize;
+ }
+
+ return rank;
+}
+
+/************************************************************************************************
+ * stdcarr_size: Return the number of elements in an array.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdcarr_size(const stdcarr *carr)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ return carr->size;
+}
+
+/************************************************************************************************
+ * stdcarr_empty: Return whether or not an array's size is zero.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdcarr_empty(const stdcarr *carr)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ return carr->size == 0;
+}
+
+/************************************************************************************************
+ * stdcarr_high_capacity: Return the size beyond which 'carr' will
+ * (try to) grow.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdcarr_high_capacity(const stdcarr *carr)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ return (carr->cap != 0 ? carr->cap - 1 : 0); /* -1 for unusable sentinel position */
+}
+
+/************************************************************************************************
+ * stdcarr_low_capacity: Return the size at (or below) which 'carr'
+ * will (try to) shrink.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdcarr_low_capacity(const stdcarr *carr)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ return (carr->cap >> 2);
+}
+
+/************************************************************************************************
+ * stdcarr_max_size: Return the theoretical maximum number of elements 'carr' could hold.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdcarr_max_size(const stdcarr *carr)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ return STDSIZE_MAX / carr->vsize;
+}
+
+/************************************************************************************************
+ * stdcarr_val_size: Return the size in bytes of the values 'carr' contains.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdcarr_val_size(const stdcarr *carr)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ return carr->vsize;
+}
+
+/************************************************************************************************
+ * stdcarr_resize: Resize an array to contain 'num_elems' elements.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_resize(stdcarr *carr, stdsize num_elems)
+{
+ stdcode ret = STDESUCCESS;
+ char * ptr = carr->end;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ if (num_elems > carr->size) {
+ ret = stdcarr_low_insert_shift(carr, &ptr, (num_elems - carr->size) * carr->vsize, num_elems, STDTRUE);
+
+ } else if (num_elems < carr->size) {
+ stdcarr_low_erase_shift(carr, &ptr, (carr->size - num_elems) * carr->vsize, num_elems, STDFALSE);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_clear: Set the size of 'carr' to zero.
+ ***********************************************************************************************/
+
+STDINLINE void stdcarr_clear(stdcarr *carr)
+{
+ stdcarr_resize(carr, 0);
+}
+
+/************************************************************************************************
+ * stdcarr_set_capacity: Set the capacity of 'carr' to num_elems.
+ * Ignores all auto-allocation considerations.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_set_capacity(stdcarr *carr, stdsize num_elems)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (num_elems != stdcarr_high_capacity(carr)) {
+
+ if (num_elems != 0) {
+ stdsize new_cap = num_elems + 1; /* +1 for sentinel end position */
+ stdsize asize = new_cap * carr->vsize;
+ char * mem;
+
+ /* alloc table */
+
+ if ((mem = (char*) malloc(asize)) == NULL) {
+ ret = STDENOMEM;
+ goto stdcarr_set_capacity_end;
+ }
+
+ /* truncate if requested capacity is smaller than size */
+
+ if (num_elems < carr->size) {
+ carr->end = stdcarr_low_forward(carr->begin, num_elems * carr->vsize, carr->base, carr->endbase);
+ carr->size = num_elems;
+ }
+
+ /* copy to new table */
+
+ stdcarr_low_copy_to_buf(mem, carr, carr->begin, carr->end);
+
+ /* free old table */
+
+ if (carr->base != NULL) {
+ free(carr->base);
+ }
+
+ carr->base = mem;
+ carr->endbase = mem + asize;
+ carr->begin = mem;
+ carr->end = mem + carr->size * carr->vsize;
+ carr->cap = new_cap;
+
+ } else {
+
+ if (carr->base != NULL) {
+ free(carr->base);
+ }
+
+ carr->base = NULL;
+ carr->endbase = NULL;
+ carr->begin = NULL;
+ carr->end = NULL;
+ carr->cap = 0;
+ carr->size = 0;
+ }
+ }
+
+ stdcarr_set_capacity_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_reserve: Ensures 'carr' can contain 'num_elems' elements
+ * without any additional reallocations. Ignores all auto allocation
+ * considerations.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_reserve(stdcarr *carr, stdsize num_elems)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (num_elems > stdcarr_high_capacity(carr)) {
+ ret = stdcarr_set_capacity(carr, num_elems);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_shrink_fit: Sets 'carr's capacity to 'carr's size. Ignores
+ * all auto allocation considerations.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_shrink_fit(stdcarr *carr)
+{
+ return stdcarr_set_capacity(carr, carr->size);
+}
+
+/************************************************************************************************
+ * stdcarr_push_front: Push a copy of 'val' onto the beginning of
+ * 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_push_front(stdcarr *carr, const void *val)
+{
+ stdit it;
+
+ return stdcarr_insert(carr, stdcarr_begin(carr, &it), val);
+}
+
+/************************************************************************************************
+ * stdcarr_push_front_n: Push copies of the 'num_push' values in
+ * 'vals' onto the beginning of 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_push_front_n(stdcarr *carr, const void *vals, stdsize num_push)
+{
+ stdit it;
+
+ return stdcarr_insert_n(carr, stdcarr_begin(carr, &it), vals, num_push);
+}
+
+/************************************************************************************************
+ * stdcarr_push_front_seq: Push a sequence of elements onto the
+ * beginning of 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_push_front_seq(stdcarr *carr, const stdit *b, const stdit *e)
+{
+ stdit it;
+
+ return stdcarr_insert_seq(carr, stdcarr_begin(carr, &it), b, e);
+}
+
+/************************************************************************************************
+ * stdcarr_push_front_seq_n: Push a sequence of elements onto the
+ * beginning of 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_push_front_seq_n(stdcarr *carr, const stdit *b, stdsize num_push)
+{
+ stdit it;
+
+ return stdcarr_insert_seq_n(carr, stdcarr_begin(carr, &it), b, num_push);
+}
+
+/************************************************************************************************
+ * stdcarr_push_front_rep: Push 'num_push' copies of 'val' onto
+ * the beginning of 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_push_front_rep(stdcarr *carr, const void *val, stdsize num_times)
+{
+ stdit it;
+
+ return stdcarr_insert_rep(carr, stdcarr_begin(carr, &it), val, num_times);
+}
+
+/************************************************************************************************
+ * stdcarr_pop_front: Pop an element off of the beginning of an array.
+ ***********************************************************************************************/
+
+STDINLINE void stdcarr_pop_front(stdcarr *carr)
+{
+ stdcarr_pop_front_n(carr, 1);
+}
+
+/************************************************************************************************
+ * stdcarr_pop_front_n: Pop multiple elements off of the beginning of
+ * an array.
+ ***********************************************************************************************/
+
+STDINLINE void stdcarr_pop_front_n(stdcarr *carr, stdsize num_pop)
+{
+ char * begin_ptr = carr->begin;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+ STDBOUNDS_CHECK(num_pop <= carr->size);
+
+ stdcarr_low_erase_shift(carr, &begin_ptr, num_pop * carr->vsize, carr->size - num_pop, STDTRUE);
+}
+
+/************************************************************************************************
+ * stdcarr_push_back: Push a copy of 'val' onto the end of 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_push_back(stdcarr *carr, const void *val)
+{
+ stdit it;
+
+ return stdcarr_insert(carr, stdcarr_end(carr, &it), val);
+}
+
+/************************************************************************************************
+ * stdcarr_push_back_n: Push copies of the 'num_push' values in 'vals'
+ * onto the end of 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_push_back_n(stdcarr *carr, const void *vals, stdsize num_push)
+{
+ stdit it;
+
+ return stdcarr_insert_n(carr, stdcarr_end(carr, &it), vals, num_push);
+}
+
+/************************************************************************************************
+ * stdcarr_push_back_seq: Push a sequence of elements onto the
+ * beginning of 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_push_back_seq(stdcarr *carr, const stdit *b, const stdit *e)
+{
+ stdit it;
+
+ return stdcarr_insert_seq(carr, stdcarr_end(carr, &it), b, e);
+}
+
+/************************************************************************************************
+ * stdcarr_push_back_seq_n: Push a sequence of elements onto the
+ * beginning of 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_push_back_seq_n(stdcarr *carr, const stdit *b, stdsize num_push)
+{
+ stdit it;
+
+ return stdcarr_insert_seq_n(carr, stdcarr_end(carr, &it), b, num_push);
+}
+
+/************************************************************************************************
+ * stdcarr_push_back_rep: Push 'num_push' copies of 'val' onto the end
+ * of 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_push_back_rep(stdcarr *carr, const void *val, stdsize num_times)
+{
+ stdit it;
+
+ return stdcarr_insert_rep(carr, stdcarr_end(carr, &it), val, num_times);
+}
+
+/************************************************************************************************
+ * stdcarr_pop_back: Pop an element off of the end of an array.
+ ***********************************************************************************************/
+
+STDINLINE void stdcarr_pop_back(stdcarr *carr)
+{
+ stdcarr_pop_back_n(carr, 1);
+}
+
+/************************************************************************************************
+ * stdcarr_pop_back_n: Pop multiple elements off of the end of an
+ * array.
+ ***********************************************************************************************/
+
+STDINLINE void stdcarr_pop_back_n(stdcarr *carr, stdsize num_pop)
+{
+ char * end_ptr = carr->end;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+ STDBOUNDS_CHECK(num_pop <= carr->size);
+
+ stdcarr_low_erase_shift(carr, &end_ptr, num_pop * carr->vsize, carr->size - num_pop, STDFALSE);
+}
+
+/************************************************************************************************
+ * stdcarr_insert: Insert a copy of 'val' into 'carr' before 'it.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_insert(stdcarr *carr, stdit *it, const void *val)
+{
+ return stdcarr_insert_n(carr, it, val, 1);
+}
+
+/************************************************************************************************
+ * stdcarr_insert_n: Insert copies of the 'num_insert' elements in
+ * 'vals' into 'carr' before 'it.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_insert_n(stdcarr *carr, stdit *it, const void *vals, stdsize num_insert)
+{
+ stdcode ret;
+ stdsize diff;
+ stdsize delta;
+ stdbool shift_right;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr) && STDIT_CARR_IS_LEGAL(it) && STDCARR_IT_IS_LEGAL(carr, &it->impl.carr));
+
+ delta = num_insert * carr->vsize;
+
+ /* compute whether it is roughly cheaper to shift right or left if we don't realloc */
+
+ shift_right = STDCARR_INS_SHIFT_RIGHT(carr, it->impl.carr.val);
+
+ /* make room for the insertion */
+
+ if ((ret = stdcarr_low_insert_shift(carr, &it->impl.carr.val, delta,
+ carr->size + num_insert, shift_right)) != STDESUCCESS) {
+ goto stdcarr_insert_n_end;
+ }
+
+ /* copy the elements */
+
+ diff = (stdsize) (carr->endbase - it->impl.carr.val); /* open space b4 wrap around */
+
+ if (diff >= delta) { /* vals fits in open space b4 wrap around */
+ memcpy(it->impl.carr.val, vals, delta);
+
+ } else { /* wrap data around */
+ memcpy(it->impl.carr.val, vals, diff);
+ memcpy(carr->base, (char*) vals + diff, (stdsize) (delta - diff));
+ }
+
+ stdcarr_insert_n_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_insert_seq: Insert a sequence of elements into 'carr' before
+ * 'it.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_insert_seq(stdcarr *carr, stdit *it, const stdit *b, const stdit *e)
+{
+ stdcode ret;
+ stdssize num_insert;
+
+ if ((num_insert = stdit_distance(b, e)) < 0) { /* calc how many elements in [b, e) */
+ ret = STDEINVAL;
+ goto stdcarr_insert_seq_end;
+ }
+
+ ret = stdcarr_insert_seq_n(carr, it, b, num_insert);
+
+ stdcarr_insert_seq_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_insert_seq_n: Insert a sequence of elements into 'carr' before
+ * 'it.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_insert_seq_n(stdcarr *carr, stdit *it, const stdit *b, stdsize num_insert)
+{
+ stdcode ret;
+ stdsize delta;
+ stdbool shift_right;
+ char * dst_it;
+ stdit src_it;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr) && STDIT_CARR_IS_LEGAL(it) && STDCARR_IT_IS_LEGAL(carr, &it->impl.carr));
+
+ delta = num_insert * carr->vsize;
+
+ /* compute whether it is roughly cheaper to shift right or left if we don't realloc */
+
+ shift_right = STDCARR_INS_SHIFT_RIGHT(carr, it->impl.carr.val);
+
+ /* make room for the insertion */
+
+ if ((ret = stdcarr_low_insert_shift(carr, &it->impl.carr.val, delta,
+ carr->size + num_insert, shift_right)) != STDESUCCESS) {
+ goto stdcarr_insert_seq_n_end;
+ }
+
+ /* copy the elements */
+
+ dst_it = it->impl.carr.val;
+ src_it = *b;
+
+ while (num_insert-- != 0) {
+ memcpy(dst_it, stdit_val(&src_it), carr->vsize);
+
+ dst_it = stdcarr_low_forward(dst_it, carr->vsize, carr->base, carr->endbase);
+ stdit_next(&src_it);
+ }
+
+ stdcarr_insert_seq_n_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_insert_rep: Insert 'num_times' copies of 'val' into 'carr' before 'it.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_insert_rep(stdcarr *carr, stdit *it, const void *val, stdsize num_times)
+{
+ stdcode ret;
+ stdsize delta;
+ stdbool shift_right;
+ char * dst_it;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr) && STDIT_CARR_IS_LEGAL(it) && STDCARR_IT_IS_LEGAL(carr, &it->impl.carr));
+
+ delta = num_times * carr->vsize;
+
+ /* compute whether it is roughly cheaper to shift right or left if we don't realloc */
+
+ shift_right = STDCARR_INS_SHIFT_RIGHT(carr, it->impl.carr.val);
+
+ /* make room for the insertion */
+
+ if ((ret = stdcarr_low_insert_shift(carr, &it->impl.carr.val, delta,
+ carr->size + num_times, shift_right)) != STDESUCCESS) {
+ goto stdcarr_insert_rep_end;
+ }
+
+ /* copy the elements */
+
+ dst_it = it->impl.carr.val;
+
+ while (num_times-- != 0) {
+ memcpy(dst_it, val, carr->vsize);
+
+ dst_it = stdcarr_low_forward(dst_it, carr->vsize, carr->base, carr->endbase);
+ }
+
+ stdcarr_insert_rep_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_erase: Erase the element pointed at by 'it' from 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE void stdcarr_erase(stdcarr *carr, stdit *it)
+{
+ stdcarr_erase_n(carr, it, 1);
+}
+
+/************************************************************************************************
+ * stdcarr_erase_n: Erase 'num_erase' elements from 'carr' starting at
+ * 'it.'
+ ***********************************************************************************************/
+
+STDINLINE void stdcarr_erase_n(stdcarr *carr, stdit *it, stdsize num_erase)
+{
+ stdsize delta;
+ stdbool shift_right;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr) && STDIT_CARR_IS_LEGAL(it) && STDCARR_IT_IS_LEGAL(carr, &it->impl.carr));
+
+#ifdef STDBOUNDS_CHECKS
+ {
+ stdit c_end;
+
+ stdcarr_end(carr, &c_end);
+ STDBOUNDS_CHECK((stdsize) stdcarr_it_cmp(&c_end, it) >= num_erase);
+ }
+#endif
+
+ delta = num_erase * carr->vsize;
+
+ /* determine whether it is roughly cheaper to shift right or left if we don't realloc */
+
+ shift_right = STDCARR_ERS_SHIFT_RIGHT(carr, it->impl.carr.val, num_erase);
+
+ /* if we are shifting left, advance 'it' to point to end of erasure */
+
+ if (!shift_right) {
+ it->impl.carr.val = stdcarr_low_forward(it->impl.carr.val, delta, carr->base, carr->endbase);
+ }
+
+ stdcarr_low_erase_shift(carr, &it->impl.carr.val, delta, carr->size - num_erase, shift_right);
+}
+
+/************************************************************************************************
+ * stdcarr_erase_seq: Erase a sequence of elements from 'carr.'
+ ***********************************************************************************************/
+
+STDINLINE void stdcarr_erase_seq(stdcarr *carr, stdit *b, stdit *e)
+{
+ stdssize diff = stdcarr_it_cmp(e, b);
+
+ STDSAFETY_CHECK(diff >= 0);
+
+ stdcarr_erase_n(carr, b, diff);
+ *e = *b;
+}
+
+/************************************************************************************************
+ * stdcarr_get_opts: Get the options of an array.
+ ***********************************************************************************************/
+
+STDINLINE stduint8 stdcarr_get_opts(const stdcarr *carr)
+{
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ return carr->opts;
+}
+
+/************************************************************************************************
+ * stdcarr_set_opts: Set the options of an array.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcarr_set_opts(stdcarr *carr, stduint8 opts)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(STDCARR_IS_LEGAL(carr));
+
+ if ((opts & ~(STDCARR_OPTS_NO_AUTO_GROW | STDCARR_OPTS_NO_AUTO_SHRINK)) != 0) {
+ ret = STDEINVAL;
+ goto stdcarr_set_opts_end;
+ }
+
+ carr->opts = opts;
+
+ stdcarr_set_opts_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcarr_it_val: Get a pointer to the element to which 'it' refers.
+ ***********************************************************************************************/
+
+STDINLINE void *stdcarr_it_val(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_CARR_IS_LEGAL(it));
+
+ return it->impl.carr.val;
+}
+
+/************************************************************************************************
+ * stdcarr_it_val_size: Return the size in bytes of the value type
+ * 'it' references.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdcarr_it_val_size(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_CARR_IS_LEGAL(it));
+
+ return it->impl.carr.vsize;
+}
+
+/************************************************************************************************
+ * stdcarr_it_eq: Compare two iterators for equality (refer to same element).
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdcarr_it_eq(const stdit *it1, const stdit *it2)
+{
+ STDSAFETY_CHECK(STDIT_CARR_IS_LEGAL(it1) && STDIT_CARR_IS_LEGAL(it2) &&
+ it1->impl.carr.base == it2->impl.carr.base &&
+ it1->impl.carr.endbase == it2->impl.carr.endbase &&
+ it1->impl.carr.begin == it2->impl.carr.begin &&
+ it1->impl.carr.end == it2->impl.carr.end &&
+ it1->impl.carr.vsize == it2->impl.carr.vsize);
+
+ return it1->impl.carr.val == it2->impl.carr.val;
+}
+
+/************************************************************************************************
+ * stdcarr_it_cmp: Compare two iterators for rank difference.
+ ***********************************************************************************************/
+
+STDINLINE stdssize stdcarr_it_cmp(const stdit *it_gen1, const stdit *it_gen2)
+{
+ stdssize ret;
+ const stdcarr_it * it1 = &it_gen1->impl.carr;
+ const stdcarr_it * it2 = &it_gen2->impl.carr;
+
+ STDSAFETY_CHECK(STDIT_CARR_IS_LEGAL(it_gen1) && STDIT_CARR_IS_LEGAL(it_gen2) &&
+ it1->base == it2->base &&
+ it1->endbase == it2->endbase &&
+ it1->begin == it2->begin &&
+ it1->end == it2->end &&
+ it1->vsize == it2->vsize);
+
+ if (it1->val >= it1->begin) {
+ ret = (it2->val >= it1->begin ? it1->val - it2->val : (it1->val - it1->endbase) + (it1->base - it2->val));
+
+ } else {
+ ret = (it2->val < it1->begin ? it1->val - it2->val : (it1->endbase - it2->val) + (it1->val - it1->base));
+ }
+
+ return ret / it1->vsize;
+}
+
+/************************************************************************************************
+ * stdcarr_it_next: Advance 'it' by one position towards end.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdcarr_it_next(stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_CARR_IS_LEGAL(it));
+ STDBOUNDS_CHECK(it->impl.carr.val != it->impl.carr.end);
+
+ it->impl.carr.val = stdcarr_low_forward(it->impl.carr.val, it->impl.carr.vsize,
+ it->impl.carr.base, it->impl.carr.endbase);
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdcarr_it_advance: Advance 'it' by 'num_advance' positions towards end.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdcarr_it_advance(stdit *it, stdsize num_advance)
+{
+ STDSAFETY_CHECK(STDIT_CARR_IS_LEGAL(it));
+ STDBOUNDS_CHECK(it->impl.carr.val <= it->impl.carr.end ?
+ (stdsize) (it->impl.carr.end - it->impl.carr.val) <= num_advance * it->impl.carr.vsize :
+ (stdsize) (it->impl.carr.endbase - it->impl.carr.val) + (it->impl.carr.end - it->impl.carr.base) <= num_advance * it->impl.carr.vsize);
+
+ it->impl.carr.val = stdcarr_low_forward(it->impl.carr.val, it->impl.carr.vsize * num_advance,
+ it->impl.carr.base, it->impl.carr.endbase);
+
+ return it;
+}
+
+
+/************************************************************************************************
+ * stdcarr_it_prev: Advance 'it' by one position towards begin.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdcarr_it_prev(stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_CARR_IS_LEGAL(it));
+ STDBOUNDS_CHECK(it->impl.carr.val != it->impl.carr.begin);
+
+ it->impl.carr.val = stdcarr_low_backward(it->impl.carr.val, it->impl.carr.vsize,
+ it->impl.carr.base, it->impl.carr.endbase);
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdcarr_it_retreat: Advance 'it' by 'num_retreat' positions towards begin.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdcarr_it_retreat(stdit *it, stdsize num_retreat)
+{
+ STDSAFETY_CHECK(STDIT_CARR_IS_LEGAL(it));
+ STDBOUNDS_CHECK(it->impl.carr.val >= it->impl.carr.begin ?
+ (stdsize) (it->impl.carr.val - it->impl.carr.begin) <= num_retreat * it->impl.carr.vsize :
+ (stdsize) (it->impl.carr.val - it->impl.carr.base) + (it->impl.carr.endbase - it->impl.carr.begin) <= num_retreat * it->impl.carr.vsize);
+
+ it->impl.carr.val = stdcarr_low_backward(it->impl.carr.val, it->impl.carr.vsize * num_retreat,
+ it->impl.carr.base, it->impl.carr.endbase);
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdcarr_it_offset: Advance 'it' by 'offset' positions towards end.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdcarr_it_offset(stdit *it, stdssize offset)
+{
+ return (offset >= 0 ? stdcarr_it_advance(it, (stdsize) offset) : stdcarr_it_retreat(it, (stdsize) -offset));
+}
Added: vendor/stdutil/current/src/stddll.c
===================================================================
--- vendor/stdutil/current/src/stddll.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stddll.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,850 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <stdutil/stderror.h>
+#include <stdutil/stddll.h>
+
+#define STDDLL_IS_LEGAL(l) ((l)->end_node != NULL && (l)->vsize != 0)
+#define STDDLL_IT_IS_LEGAL(l, it) ((it)->end_node == (l)->end_node && (it)->vsize == (l)->vsize)
+#define STDDLL_IT_IS_LEGAL2(it) ((it)->node != NULL && (it)->end_node != NULL && (it)->vsize != 0)
+#define STDIT_DLL_IS_LEGAL(it) ((it)->type_id == STDDLL_IT_ID && STDDLL_IT_IS_LEGAL2(&(it)->impl.dll))
+
+#define STDDLL_NODE_SIZE(vsize) (STDARCH_PADDED_SIZE(sizeof(stddll_node)) + (vsize))
+#define STDDLL_NVAL(node_ptr) ((char*) (node_ptr) + STDARCH_PADDED_SIZE(sizeof(stddll_node)))
+
+#define STDDLL_LBEGIN(list_ptr) ((list_ptr)->end_node->next)
+#define STDDLL_LEND(list_ptr) ((list_ptr)->end_node)
+
+/************************************************************************************************
+ * stddll_low_alloc_chain: This fcn allocates a non-zero length
+ * sequence of (optionally initialized) linked nodes. It returns
+ * pointers to the first and last nodes. The sequence is null
+ * terminated on both ends. If (init) the sequence will be
+ * initialized by the sequence starting at 'b.' If (!advnc) then the
+ * initializing sequnce will not be advanced (i.e. - repeat insert).
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stddll_low_alloc_chain(stdsize num_ins, stdsize vsize, stdbool init, const stdit *b, stdbool advnc,
+ stddll_node **first, stddll_node **last)
+{
+ stdcode ret = STDESUCCESS;
+ stdit src_it = *b;
+ const void * val = NULL;
+ stddll_node * prev = NULL;
+ stddll_node * curr;
+
+ if ((curr = (stddll_node*) malloc(STDDLL_NODE_SIZE(vsize))) == NULL) { /* append values on to end of node in memory */
+ ret = STDENOMEM;
+ goto stddll_low_alloc_chain_end;
+ }
+
+ if (init) {
+ val = stdit_val(&src_it);
+ memcpy(STDDLL_NVAL(curr), val, vsize);
+ }
+
+ *first = curr;
+ curr->prev = NULL;
+
+ while (--num_ins != 0) {
+ prev = curr;
+
+ if ((curr = (stddll_node*) malloc(STDDLL_NODE_SIZE(vsize))) == NULL) {
+ ret = STDENOMEM;
+ goto stddll_low_alloc_chain_fail;
+ }
+
+ if (init) {
+
+ if (advnc) {
+ stdit_next(&src_it);
+ val = stdit_val(&src_it);
+ }
+
+ memcpy(STDDLL_NVAL(curr), val, vsize);
+ }
+
+ prev->next = curr;
+ curr->prev = prev;
+ }
+
+ curr->next = NULL;
+ *last = curr;
+
+ goto stddll_low_alloc_chain_end;
+
+ /* error handling and return */
+
+ stddll_low_alloc_chain_fail:
+ while (prev != NULL) {
+ curr = prev->prev;
+ free(prev);
+ prev = curr;
+ }
+
+ *first = NULL;
+ *last = NULL;
+
+ stddll_low_alloc_chain_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stddll_low_insert: This fcn allocates and inserts a sequence of
+ * initialized nodes into a list before next.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stddll_low_insert(stddll *l, stdsize num_ins, stdbool init, const stdit *b, stdbool advnc,
+ stddll_node *next, stddll_node **first_ptr)
+{
+ stdcode ret = STDESUCCESS;
+ stddll_node * first = NULL;
+ stddll_node * last;
+ stddll_node * prev;
+
+ if (num_ins == 0 ||
+ (ret = stddll_low_alloc_chain(l->vsize, num_ins, init, b, advnc, &first, &last)) != STDESUCCESS) {
+ goto stddll_low_insert_end;
+ }
+
+ prev = next->prev;
+ prev->next = first;
+ first->prev = prev;
+ last->next = next;
+ next->prev = last;
+
+ l->size += num_ins;
+
+ if (first_ptr != NULL) {
+ *first_ptr = first;
+ }
+
+ stddll_low_insert_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stddll_low_erase: Erase a subsequence of the list starting at
+ * erase_begin of length num_erase. It returns a pointer to the node
+ * that is shifted into the position of erase_begin after the removal.
+ ***********************************************************************************************/
+
+STDINLINE static stddll_node *stddll_low_erase(stddll *l, stddll_node *erase_begin, stdsize num_erase)
+{
+ stddll_node * curr = erase_begin;
+ stddll_node * prev;
+
+ erase_begin = erase_begin->prev; /* get last node before erase region */
+
+ while (num_erase-- != 0) {
+ STDBOUNDS_CHECK(curr != STDDLL_LEND(l)); /* check for an illegal erasure */
+ prev = curr;
+ curr = curr->next;
+ free(prev);
+ }
+
+ erase_begin->next = curr;
+ curr->prev = erase_begin;
+
+ l->size -= num_erase;
+
+ return curr;
+}
+
+/************************************************************************************************
+ * stddll_low_erase_seq: Erase a subsequence of the list starting at
+ * erase_begin and going to erase_end. It returns a pointer to the
+ * node that is shifted into the position of erase_begin after the
+ * removal.
+ ***********************************************************************************************/
+
+STDINLINE static stddll_node *stddll_low_erase_seq(stddll *l, stddll_node *erase_begin, stddll_node *erase_end)
+{
+ stddll_node * curr = erase_begin;
+ stddll_node * prev;
+ stdsize num_erase;
+
+ erase_begin = erase_begin->prev; /* get last node before erase region */
+
+ for (num_erase = 0; curr != erase_end; ++num_erase) {
+ STDBOUNDS_CHECK(curr != STDDLL_LEND(l)); /* check for an illegal erasure */
+ prev = curr;
+ curr = curr->next;
+ free(prev);
+ }
+
+ erase_begin->next = curr;
+ curr->prev = erase_begin;
+
+ l->size -= num_erase;
+
+ return curr;
+}
+
+/************************************************************************************************
+ * stddll_low_rerase: Same as stddll_low_erase, except the erase
+ * region ends with erase_end and is of length num_erase.
+ ***********************************************************************************************/
+
+STDINLINE static stddll_node *stddll_low_rerase(stddll *l, stddll_node *erase_end, stdsize num_erase)
+{
+ stddll_node * curr = erase_end->prev;
+ stddll_node * prev;
+
+ while (num_erase-- != 0) {
+ STDBOUNDS_CHECK(curr != STDDLL_LEND(l)); /* check for an illegal erasure */
+ prev = curr;
+ curr = curr->prev;
+ free(prev);
+ }
+
+ curr->next = erase_end;
+ erase_end->prev = curr;
+
+ l->size -= num_erase;
+
+ return erase_end;
+}
+
+/************************************************************************************************
+ * stddll_construct: Construct an initially empty list that will
+ * contain elements sizeof_val bytes long.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_construct(stddll *l, stdsize vsize)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (vsize == 0) {
+ ret = STDEINVAL;
+ goto stddll_construct_fail;
+ }
+
+ if ((l->end_node = (stddll_node*) malloc(STDDLL_NODE_SIZE(vsize))) == NULL) {
+ ret = STDENOMEM;
+ goto stddll_construct_fail;
+ }
+
+ l->end_node->prev = l->end_node;
+ l->end_node->next = l->end_node;
+
+ l->size = 0;
+ l->vsize = vsize;
+
+ goto stddll_construct_end;
+
+ /* error handling and return */
+
+ stddll_construct_fail:
+ l->vsize = 0; /* make STDDLL_IS_LEGAL(l) false */
+
+ stddll_construct_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stddll_copy_construct: Construct a copy of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_copy_construct(stddll *dst, const stddll *src)
+{
+ stdcode ret;
+
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(src));
+
+ if ((ret = stddll_construct(dst, src->vsize)) != STDESUCCESS) {
+ goto stddll_copy_construct_end;
+ }
+
+ if ((ret = stddll_set_eq(dst, src)) != STDESUCCESS) {
+ goto stddll_copy_construct_fail;
+ }
+
+ goto stddll_copy_construct_end;
+
+ /* error handling and return */
+
+ stddll_copy_construct_fail:
+ stddll_destruct(dst);
+
+ stddll_copy_construct_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stddll_destruct: Reclaim a list's resources and invalidate it.
+ ***********************************************************************************************/
+
+STDINLINE void stddll_destruct(stddll *l)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l));
+
+ stddll_clear(l);
+ free(l->end_node);
+
+ l->end_node = NULL;
+ l->vsize = 0; /* make STDDLL_IS_LEGAL(l) false */
+}
+
+/************************************************************************************************
+ * stddll_set_eq: Set 'dst' to have the same contents as 'src.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_set_eq(stddll *dst, const stddll *src)
+{
+ stdcode ret = STDESUCCESS;
+ stddll_node * dst_node;
+ stddll_node * src_node;
+
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(dst) && STDDLL_IS_LEGAL(src) && dst->vsize == src->vsize);
+
+ if (dst == src) {
+ goto stddll_set_eq_end;
+ }
+
+ if ((ret = stddll_resize(dst, src->size)) != STDESUCCESS) {
+ goto stddll_set_eq_end;
+ }
+
+ dst_node = STDDLL_LBEGIN(dst);
+ src_node = STDDLL_LBEGIN(src);
+
+ while (dst_node != STDDLL_LEND(dst)) {
+ memcpy(STDDLL_NVAL(dst_node), STDDLL_NVAL(src_node), dst->vsize);
+ dst_node = dst_node->next;
+ src_node = src_node->next;
+ }
+
+ stddll_set_eq_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stddll_swap: Make l1 reference l2's sequence and vice versa.
+ ***********************************************************************************************/
+
+STDINLINE void stddll_swap(stddll *l1, stddll *l2)
+{
+ stddll cpy;
+
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l1) && STDDLL_IS_LEGAL(l2) && l1->vsize == l2->vsize);
+
+ STDSWAP(*l1, *l2, cpy);
+}
+
+/************************************************************************************************
+ * stddll_begin: Get an iterator the beginning of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stddll_begin(const stddll *l, stdit *it)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l));
+
+ it->impl.dll.node = (stddll_node*) STDDLL_LBEGIN(l);
+ it->impl.dll.end_node = (stddll_node*) STDDLL_LEND(l);
+ it->impl.dll.vsize = l->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stddll_last: Get an iterator the last element of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stddll_last(const stddll *l, stdit *it)
+{
+ STDBOUNDS_CHECK(l->size != 0);
+
+ return stdit_prev(stddll_end(l, it));
+}
+
+/************************************************************************************************
+ * stddll_end: Get an iterator to the sentinel 'end' entry of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stddll_end(const stddll *l, stdit *it)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l));
+
+ it->impl.dll.node = (stddll_node*) STDDLL_LEND(l);
+ it->impl.dll.end_node = (stddll_node*) STDDLL_LEND(l);
+ it->impl.dll.vsize = l->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stddll_get: Get an iterator to the 'elem_num'th (0 based) entry of
+ * a list. Can request/return sentinel end position.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stddll_get(const stddll *l, stdit *it, stdsize elem_num)
+{
+ STDBOUNDS_CHECK(elem_num <= l->size);
+
+ if (elem_num < (l->size >> 1)) {
+ stddll_it_advance(stddll_begin(l, it), elem_num);
+
+ } else {
+ stddll_it_retreat(stddll_end(l, it), l->size - elem_num);
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stddll_is_begin: Returns whether or not an iterator refers to the beginning of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stddll_is_begin(const stddll *l, const stdit *it)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l) && STDIT_DLL_IS_LEGAL(it) && STDDLL_IT_IS_LEGAL(l, &it->impl.dll));
+
+ return it->impl.dll.node == STDDLL_LBEGIN(l);
+}
+
+/************************************************************************************************
+ * stddll_is_end: Returns whether or not an iterator refers to the end of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stddll_is_end(const stddll *l, const stdit *it)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l) && STDIT_DLL_IS_LEGAL(it) && STDDLL_IT_IS_LEGAL(l, &it->impl.dll));
+
+ return it->impl.dll.node == STDDLL_LEND(l);
+}
+
+/************************************************************************************************
+ * stddll_size: Return the number of elements in 'l.'
+ ***********************************************************************************************/
+
+STDINLINE stdsize stddll_size(const stddll *l)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l));
+
+ return l->size;
+}
+
+/************************************************************************************************
+ * stddll_empty: Return whether or not 'l' is empty.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stddll_empty(const stddll *l)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l));
+
+ return l->size == 0;
+}
+
+/************************************************************************************************
+ * stddll_max_size: Return the theoretical maximum number of elements
+ * 'l' could possibly hold.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stddll_max_size(const stddll *l)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l));
+
+ return STDSIZE_MAX;
+}
+
+/************************************************************************************************
+ * stddll_val_size: Return the size in bytes of the type of elements
+ * 'l' holds.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stddll_val_size(const stddll *l)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l));
+
+ return l->vsize;
+}
+
+/************************************************************************************************
+ * stddll_resize: Resize a list to contain 'num_elems' elements.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_resize(stddll *l, stdsize num_elems)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l));
+
+ if (num_elems > l->size) {
+
+ if ((ret = stddll_low_insert(l, num_elems - l->size, STDFALSE, NULL, STDFALSE, STDDLL_LEND(l), NULL)) != STDESUCCESS) {
+ goto stddll_resize_end;
+ }
+
+ } else if (num_elems < l->size) {
+ stddll_low_rerase(l, STDDLL_LEND(l), l->size - num_elems);
+ }
+
+ stddll_resize_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stddll_clear: Set a list's size to zero.
+ ***********************************************************************************************/
+
+STDINLINE void stddll_clear(stddll *l)
+{
+ stddll_resize(l, 0);
+}
+
+/************************************************************************************************
+ * stddll_push_front: Push an element onto the beginning of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_push_front(stddll *l, const void *val)
+{
+ return stddll_push_front_n(l, val, 1);
+}
+
+/************************************************************************************************
+ * stddll_push_front_n: Push multiple elements onto the beginning of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_push_front_n(stddll *l, const void *vals, stdsize num_push)
+{
+ stdit it;
+
+ return stddll_insert_n(l, stddll_begin(l, &it), vals, num_push);
+}
+
+/************************************************************************************************
+ * stddll_push_front_seq: Push a sequence of elements onto the beginning of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_push_front_seq(stddll *l, const stdit *b, const stdit *e)
+{
+ stdit it;
+
+ return stddll_insert_seq(l, stddll_begin(l, &it), b, e);
+}
+
+/************************************************************************************************
+ * stddll_push_front_seq_n: Push multiple elements onto the beginning of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_push_front_seq_n(stddll *l, const stdit *b, stdsize num_push)
+{
+ stdit it;
+
+ return stddll_insert_seq_n(l, stddll_begin(l, &it), b, num_push);
+}
+
+/************************************************************************************************
+ * stddll_push_front_rep: Push multiple elements onto the beginning of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_push_front_rep(stddll *l, const void *val, stdsize num_times)
+{
+ stdit it;
+
+ return stddll_insert_rep(l, stddll_begin(l, &it), val, num_times);
+}
+
+/************************************************************************************************
+ * stddll_pop_front: Pop an element off of the beginning of a list.
+ ***********************************************************************************************/
+
+STDINLINE void stddll_pop_front(stddll *l)
+{
+ stddll_pop_front_n(l, 1);
+}
+
+/************************************************************************************************
+ * stddll_pop_front: Pop multiple elements off of the front of a list.
+ ***********************************************************************************************/
+
+STDINLINE void stddll_pop_front_n(stddll *l, stdsize num_pop)
+{
+ stdit it;
+
+ stddll_erase_n(l, stddll_begin(l, &it), num_pop);
+}
+
+/************************************************************************************************
+ * stddll_push_back: Push an element onto the end of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_push_back(stddll *l, const void *val)
+{
+ return stddll_push_back_n(l, val, 1);
+}
+
+/************************************************************************************************
+ * stddll_push_back_n: Push multiple elements onto the end of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_push_back_n(stddll *l, const void *vals, stdsize num_push)
+{
+ stdit it;
+
+ return stddll_insert_n(l, stddll_end(l, &it), vals, num_push);
+}
+
+/************************************************************************************************
+ * stddll_push_back_seq: Push multiple elements onto the end of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_push_back_seq(stddll *l, const stdit *b, const stdit *e)
+{
+ stdit it;
+
+ return stddll_insert_seq(l, stddll_end(l, &it), b, e);
+}
+
+/************************************************************************************************
+ * stddll_push_back_seq_n: Push multiple elements onto the end of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_push_back_seq_n(stddll *l, const stdit *b, stdsize num_push)
+{
+ stdit it;
+
+ return stddll_insert_seq_n(l, stddll_end(l, &it), b, num_push);
+}
+
+/************************************************************************************************
+ * stddll_push_back_rep: Push multiple elements onto the end of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_push_back_rep(stddll *l, const void *val, stdsize num_times)
+{
+ stdit it;
+
+ return stddll_insert_rep(l, stddll_end(l, &it), val, num_times);
+}
+
+/************************************************************************************************
+ * stddll_pop_back: Pop an element off of the end of a list.
+ ***********************************************************************************************/
+
+STDINLINE void stddll_pop_back(stddll *l)
+{
+ stddll_pop_back_n(l, 1);
+}
+
+/************************************************************************************************
+ * stddll_pop_back_n: Pop multiple elements off of the back of a list.
+ ***********************************************************************************************/
+
+STDINLINE void stddll_pop_back_n(stddll *l, stdsize num_pop)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l));
+ STDBOUNDS_CHECK(num_pop <= stddll_size(l));
+
+ stddll_low_rerase(l, STDDLL_LEND(l), num_pop);
+}
+
+/************************************************************************************************
+ * stddll_insert: Insert an element into a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_insert(stddll *l, stdit *it, const void *val)
+{
+ return stddll_insert_n(l, it, val, 1);
+}
+
+/************************************************************************************************
+ * stddll_insert_n: Insert multiple elements into a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_insert_n(stddll *l, stdit *it, const void *vals, stdsize num_insert)
+{
+ stdit vals_it;
+
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l) && STDIT_DLL_IS_LEGAL(it) && STDDLL_IT_IS_LEGAL(l, &it->impl.dll));
+
+ return stddll_low_insert(l, num_insert, STDTRUE, stdit_ptr(&vals_it, vals, l->vsize),
+ STDTRUE, it->impl.dll.node, &it->impl.dll.node);
+}
+
+/************************************************************************************************
+ * stddll_insert_seq: Insert multiple elements into a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_insert_seq(stddll *l, stdit *it, const stdit *b, const stdit *e)
+{
+ stdcode ret;
+ stdssize num_ins = stdit_distance(b, e);
+
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l) && STDIT_DLL_IS_LEGAL(it) && STDDLL_IT_IS_LEGAL(l, &it->impl.dll));
+
+ if (num_ins < 0) {
+ ret = STDEINVAL;
+ goto stddll_insert_seq_end;
+ }
+
+ ret = stddll_low_insert(l, num_ins, STDTRUE, b, STDTRUE, it->impl.dll.node, &it->impl.dll.node);
+
+ stddll_insert_seq_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stddll_insert_seq_n: Insert multiple elements into a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_insert_seq_n(stddll *l, stdit *it, const stdit *b, stdsize num_insert)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l) && STDIT_DLL_IS_LEGAL(it) && STDDLL_IT_IS_LEGAL(l, &it->impl.dll));
+
+ return stddll_low_insert(l, num_insert, STDTRUE, b, STDTRUE, it->impl.dll.node, &it->impl.dll.node);
+}
+
+/************************************************************************************************
+ * stddll_insert_rep: Insert an item into a list repeatedly.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stddll_insert_rep(stddll *l, stdit *it, const void *val, stdsize num_times)
+{
+ stdit val_it;
+
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l) && STDIT_DLL_IS_LEGAL(it) && STDDLL_IT_IS_LEGAL(l, &it->impl.dll));
+
+ return stddll_low_insert(l, num_times, STDTRUE, stdit_ptr(&val_it, val, l->vsize),
+ STDFALSE, it->impl.dll.node, &it->impl.dll.node);
+}
+
+/************************************************************************************************
+ * stddll_erase: Erase a particular element from a list.
+ ***********************************************************************************************/
+
+STDINLINE void stddll_erase(stddll *l, stdit *it)
+{
+ stddll_erase_n(l, it, 1);
+}
+
+/************************************************************************************************
+ * stddll_erase_n: Erase multiple elements from a list.
+ ***********************************************************************************************/
+
+STDINLINE void stddll_erase_n(stddll *l, stdit *it, stdsize num_erase)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l) && STDIT_DLL_IS_LEGAL(it) && STDDLL_IT_IS_LEGAL(l, &it->impl.dll));
+
+ it->impl.dll.node = stddll_low_erase(l, it->impl.dll.node, num_erase);
+}
+
+/************************************************************************************************
+ * stddll_erase_seq: Erase multiple elements from a list.
+ ***********************************************************************************************/
+
+STDINLINE void stddll_erase_seq(stddll *l, stdit *b, stdit *e)
+{
+ STDSAFETY_CHECK(STDDLL_IS_LEGAL(l) && STDIT_DLL_IS_LEGAL(b) && STDIT_DLL_IS_LEGAL(e) &&
+ STDDLL_IT_IS_LEGAL(l, &b->impl.dll) && STDDLL_IT_IS_LEGAL(l, &e->impl.dll));
+
+ b->impl.dll.node = stddll_low_erase_seq(l, b->impl.dll.node, e->impl.dll.node);
+ *e = *b;
+}
+
+/************************************************************************************************
+ * stdit_val: Return a pointer to an element from an iterator.
+ ***********************************************************************************************/
+
+STDINLINE void *stdit_val(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it));
+
+ return (void*) STDDLL_NVAL(it->impl.dll.node);
+}
+
+/************************************************************************************************
+ * stdit_eq: Compare to iterators for equality (refer to the same element).
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdit_eq(const stdit *it1, const stdit *it2)
+{
+ STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it1) && STDIT_DLL_IS_LEGAL(it2) &&
+ it1->impl.dll.end_node == it2->impl.dll.end_node &&
+ it1->impl.dll.vsize == it2->impl.dll.vsize);
+
+ return it1->impl.dll.node == it2->impl.dll.node;
+}
+
+/************************************************************************************************
+ * stdit_next: Advance an iterator one position towards the end.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_next(stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it));
+ STDBOUNDS_CHECK(it->impl.dll.node != it->impl.dll.end_node);
+
+ it->impl.dll.node = it->impl.dll.node->next;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_advance: Advance an iterator 'num_advance' positions towards the end.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_advance(stdit *it, stdsize num_advance)
+{
+ STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it));
+
+ while (num_advance-- != 0) {
+ STDBOUNDS_CHECK(it->impl.dll.node != it->impl.dll.end_node);
+ it->impl.dll.node = it->impl.dll.node->next;
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_prev: Advance an iterator one postion towards the beginning.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_prev(stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it));
+ STDBOUNDS_CHECK(it->impl.dll.node->prev != it->impl.dll.end_node);
+
+ it->impl.dll.node = it->impl.dll.node->prev;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_retreat: Advance an iterator 'num_retreat' positions towards the beginning.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_retreat(stdit *it, stdsize num_retreat)
+{
+ STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it));
+
+ while (num_retreat-- != 0) {
+ STDBOUNDS_CHECK(it->impl.dll.node->prev != it->impl.dll.end_node);
+ it->impl.dll.node = it->impl.dll.node->prev;
+ }
+
+ return it;
+}
Added: vendor/stdutil/current/src/stderror.c
===================================================================
--- vendor/stdutil/current/src/stderror.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stderror.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,202 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include <stdutil/stddefines.h>
+#include <stdutil/stderror.h>
+
+/************************************************************************************************
+ * stderr_doit: Print a message to stderr and flush it. If errnoflag
+ * is non-zero, also print error msg from errno. Return # of
+ * characters written.
+ *
+ * NOTE: I'd prefer to use snprintf and vsnprintf but they aren't part of C89.
+ ***********************************************************************************************/
+
+STDINLINE static int stderr_doit(int errno_copy, const char *fmt, va_list ap)
+{
+ char buf[STDERR_MAX_ERR_MSG_LEN + 1];
+ int ret1;
+ int ret2 = 0;
+
+ ret1 = vsprintf(buf, fmt, ap); /* write the msg */
+ ret1 = STDMAX(ret1, 0); /* zero out any error */
+ buf[ret1] = 0; /* ensure termination */
+
+ if (errno_copy != 0) {
+ ret2 = vsprintf(buf + ret1, ": %s", strerror(errno_copy)); /* write errno msg */
+ ret2 = STDMAX(ret2, 0); /* zero out any error */
+ buf[ret1 + ret2] = 0; /* ensure termination */
+ }
+
+ fprintf(stderr, "%s\r\n", buf);
+ fflush(stderr);
+
+ return ret1 + ret2;
+}
+
+/************************************************************************************************
+ * stderr_msg: Nonfatal error unrelated to a system call. Print a
+ * message and return.
+ ***********************************************************************************************/
+
+int stderr_msg(const char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+ va_start(ap, fmt);
+ ret = stderr_doit(0, fmt, ap);
+ va_end(ap);
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stderr_ret: Nonfatal error related to a system call. Print a
+ * message and return.
+ ***********************************************************************************************/
+
+int stderr_ret(const char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+ va_start(ap, fmt);
+ ret = stderr_doit(errno, fmt, ap);
+ va_end(ap);
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stderr_quit: Fatal error unrelated to a system call. Print a
+ * message and terminate.
+ ***********************************************************************************************/
+
+void stderr_quit(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ stderr_doit(0, fmt, ap);
+ va_end(ap);
+ exit(-1);
+}
+
+/************************************************************************************************
+ * stderr_abort: Fatal error unrelated to a system call. Print a
+ * message and abort.
+ ***********************************************************************************************/
+
+void stderr_abort(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ stderr_doit(0, fmt, ap);
+ va_end(ap);
+ abort();
+}
+
+/************************************************************************************************
+ * stderr_sys: Fatal error related to a system call. Print a message
+ * and terminate.
+ ***********************************************************************************************/
+
+void stderr_sys(const char *fmt, ...)
+{
+ int errno_cpy = errno;
+ va_list ap;
+
+ va_start(ap, fmt);
+ stderr_doit(errno_cpy, fmt, ap);
+ va_end(ap);
+ exit(errno_cpy != 0 ? errno_cpy : -1);
+}
+
+/************************************************************************************************
+ * stderr_dump: Fatal error related to a system call. Print a message
+ * and abort.
+ ***********************************************************************************************/
+
+void stderr_dump(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ stderr_doit(errno, fmt, ap);
+ va_end(ap);
+ abort();
+}
+
+/************************************************************************************************
+ * stderr_strerr: Returns a constant string in response to a StdUtil
+ * error code. Some StdUtil fcns can return system specific codes.
+ * In that case this fcn will return a "Unknown Error" string and you
+ * should consult your system specific error lookup service.
+ ***********************************************************************************************/
+
+STDINLINE const char *stderr_strerr(stdcode code)
+{
+ const char * ret;
+
+ switch (code) {
+ case STDEUNKNOWN:
+ ret = "Unknown Error";
+ break;
+
+ case STDEINVAL:
+ ret = "Invalid Argument";
+ break;
+
+ case STDENOMEM:
+ ret = "Memory Allocation Failed";
+ break;
+
+ case STDEACCES:
+ ret = "Permission Denied";
+ break;
+
+ case STDEBUSY:
+ ret = "Resource Busy";
+ break;
+
+ case STDEPERM:
+ ret = "Operation Not Permitted";
+ break;
+
+ case STDENOSYS:
+ ret = "Functionality Not Implemented";
+ break;
+
+ default:
+ ret = "Unknown Error Code (system error code)";
+ break;
+ }
+
+ return ret;
+}
Added: vendor/stdutil/current/src/stdfd.c
===================================================================
--- vendor/stdutil/current/src/stdfd.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdfd.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,277 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <stdutil/stderror.h>
+#include <stdutil/stdfd.h>
+
+#if defined(_WIN32)
+# include <io.h>
+# include <sys/locking.h>
+# define STDFILENO(s) _fileno(s)
+# define STDFSYNC(fd) _commit(fd)
+#else
+# include <unistd.h>
+# define STDFILENO(s) fileno(s)
+# define STDFSYNC(fd) fsync(fd)
+#endif
+
+/************************************************************************************************
+ * stdfd_open: Open a file descriptor.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_open(stdfd *fd, const char *path, const char *mode)
+{
+ stdcode ret = STDESUCCESS;
+
+ if ((fd->stream = fopen(path, mode)) != NULL) {
+ fd->fd = STDFILENO(fd->stream);
+
+ } else {
+ ret = errno;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_close: Close a file descriptor.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_close(stdfd *fd)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(fd->stream != NULL);
+
+ if ((ret = fclose(fd->stream)) != 0) {
+ ret = errno;
+ }
+
+ fd->stream = NULL;
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_read: Read 'nmemb' entries of 'nsize' bytes each from a file
+ * descriptor into 'ptr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_read(stdfd *fd, void *ptr, stdsize nsize, stdsize nmemb, stdsize *num)
+{
+ stdcode ret;
+
+ if ((*num = fread(ptr, nsize, nmemb, fd->stream)) == nmemb) {
+ ret = STDESUCCESS;
+
+ } else if (feof(fd->stream)) {
+ ret = STDEOF;
+
+ } else if (ferror(fd->stream)) {
+ ret = errno;
+
+ } else {
+ ret = STDESUCCESS;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_write: Write 'nmemb' entries of 'nsize' bytes each from 'ptr'
+ * to a file descriptor.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_write(stdfd *fd, const void *ptr, stdsize nsize, stdsize nmemb, stdsize *num)
+{
+ stdcode ret;
+
+ if ((*num = fwrite(ptr, nsize, nmemb, fd->stream)) == nmemb) {
+ ret = STDESUCCESS;
+
+ } else if (feof(fd->stream)) {
+ ret = STDEOF;
+
+ } else if (ferror(fd->stream)) {
+ ret = errno;
+
+ } else {
+ ret = STDESUCCESS;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_flush: Flush any user space data on a file descriptor to the OS.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_flush(stdfd *fd)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (fflush(fd->stream) != 0) {
+ ret = errno;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_sync: Flush user space data to the OS and force the OS to
+ * flush all data to disk.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_sync(stdfd * fd)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (stdfd_flush(fd) != 0 || STDFSYNC(fd->fd) != 0) {
+ ret = errno;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_seek: Move the read/write head position of a file descriptor.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_seek(stdfd *fd, stdfd_pos offset, stdfd_whence whence)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (fseek(fd->stream, offset, whence) != 0) {
+ ret = errno;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_get_pos: Get the read/write head position of a file descriptor.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_get_pos(stdfd *fd, stdfd_pos *pos)
+{
+ stdcode ret = STDESUCCESS;
+
+ if ((*pos = ftell(fd->stream)) == -1) {
+ ret = errno;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_eof: Return whether or not the EOF indicator on a file descriptor is set.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdfd_eof(stdfd * fd)
+{
+ return (feof(fd->stream) != 0);
+}
+
+/************************************************************************************************
+ * stdfd_err: Return whether or not an error indicator on a file descriptor is set.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdfd_err(stdfd * fd)
+{
+ return (ferror(fd->stream) != 0);
+}
+
+/************************************************************************************************
+ * stdfd_clr_err: Clear any error indicator on a file descriptor.
+ ***********************************************************************************************/
+
+STDINLINE void stdfd_clr_err(stdfd * fd)
+{
+ clearerr(fd->stream);
+}
+
+/************************************************************************************************
+ * stdfd_trylock: Try to acquire an advisory lock on a file
+ * descriptor's underlying file.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_trylock(stdfd * fd)
+{
+ stdcode ret = STDESUCCESS;
+
+#if defined(_WIN32)
+ if (_locking(fd->fd, _LK_NBLCK, 1) != 0) {
+#else
+ struct flock lock = { 0 };
+
+ lock.l_type = F_WRLCK;
+
+ if (fcntl(fd->fd, F_SETLK, &lock) != 0) {
+#endif
+ ret = errno;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_unlock: Release an advisory lock on a file descriptor's
+ * underlying file.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_unlock(stdfd * fd)
+{
+ stdcode ret = STDESUCCESS;
+
+#if defined(_WIN32)
+ if (_locking(fd->fd, _LK_UNLCK, 1) != 0) {
+#else
+ struct flock lock = { 0 };
+
+ lock.l_type = F_UNLCK;
+
+ if (fcntl(fd->fd, F_SETLK, &lock) != 0) {
+#endif
+ ret = errno;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfile_unlink: Erase a file.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfile_unlink(const char *path)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (remove(path) != 0) {
+ ret = errno;
+ }
+
+ return ret;
+}
Added: vendor/stdutil/current/src/stdhash.c
===================================================================
--- vendor/stdutil/current/src/stdhash.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdhash.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,1338 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <stdutil/stdutil.h>
+#include <stdutil/stderror.h>
+#include <stdutil/stdhash.h>
+
+/* stdhash is a table based implementation of a dictionary data
+ structure. In particular, it is an open-address, double hashing
+ hashtable (ref: Sedgewick: Algorithms in C, 3rd Ed.) that maps
+ non-unique keys to values. Values can be zero length which allows
+ this dictionary to function as a hashset of keys.
+
+ stdhash uses a key comparison function to test for key equality and
+ a key hashcode function to map keys to integers. The key
+ comparison function need only return zero when two keys are equal
+ and non-zero when they are unequal.
+
+ The default cmp and hcode fcns, used when, respectively, one or
+ both of the fcns is NULL, operate directly on all the bytes of the
+ key type. The default cmp fcn is a memcmp of the two keys' bytes,
+ while the hcode fcn uses stdhcode_sfh (see stdutil.h), which
+ computes a 32 bit hash code based on all the bytes of the key. If
+ these defaults are inappropriate for your key type (e.g. - your key
+ type is just a pointer to the data that should be compared, like a
+ C string, or a structure that contains padding (most do) that you
+ don't always zero out, or only part of the "key" should be used for
+ comparison), then you must specify appropriate fcns when you create
+ the stdhash.
+
+ ** The user must be very careful when crafting such a pair of fcns!
+
+ (1) (cmp(k1, k2) == 0) MUST be reflexive, symmetric, and transitive
+ (2) hcode(k) MUST be invariant (always the same for a particular key)
+ (3) if (cmp(k1, k2) == 0) then hcode(k1) == hhcode(k2) MUST hold
+
+ Also the user should consider the following:
+
+ (4) The hcodes generated by hcode should not have significant
+ underlying mathematical structure to them (e.g. - all even,
+ etc.). The construction of good hash fcns is a large topic.
+ We recommend you either use the defaults or use the stdhcode_*
+ fcns (see stdutil.h) in constructing your own hcode fcns.
+
+ (5) if (cmp(k1, k2) != 0) then the probability that hashcode(k1) ==
+ hashcode(k2) should not be significantly more than 1 /
+ 2^sizeof(stdhcode) for best performance.
+
+ (6) stdhash will consider any hcode of zero as an hcode of 1. This
+ will skew the collision probabilities for keys that map to
+ the hcodes 0 and 1.
+
+ At the core of this hashtable implementation are two internal hash
+ fcns:
+
+ The first hash fcn maps a key's hashcode to the range [0, n) (where
+ n is the capacity of the hashtable). This mapping is used to find
+ where in the table a search for that key should begin.
+
+ The second hash fcn returns an offset (based on the hashcode) for
+ the key that is non-zero, less than and relatively prime to n.
+ This offset is used to offset through the hashtable when searching
+ for a particular key.
+
+ Example: searching for a key in the table ... First, the hashcode
+ is computed for the key. Based on that, the first hash fcn returns
+ an index in the table, ind, at which to begin searching for the
+ key. If ind contains no key-val pair then the key does not exist in
+ the table and our search is done. If ind contains a pair and it's
+ key matches the search key then our search is done. If ind contains
+ a pair but it's key doesn't match the search key (i.e. either its
+ hashcode or cmp return a non-match) then I examine index (ind +=
+ offset) (mod n). I continue this process until I find a key match
+ or I find an empty index. Because offset is relatively prime to n,
+ I can check every index in the table in this manner in n iterations
+ (the sequence of indexes generated by this process for a particular
+ key is called a probe sequence). However, by keeping the table
+ sparsely populated the search will always terminate, and in
+ practice the search will on average terminate after a constant
+ number of steps.
+
+ The first hash fcn is the hcode fcn which is then modulo'ed the
+ size of the table. We keep the size of the table a power of 2, so
+ this is implemented with a fast bitwise AND operation. Therefore,
+ the first hash fcn is the lowest lg n bits of the hcode of the key.
+
+ The second hash fcn is the highest lg(n) - 1 bits of the hcode of
+ the key and the least signficant bit set to 1. Because the lowest
+ bit is set, the second hash value is odd and therefore relatively
+ prime to the power of 2 table size, so it can be used to offset
+ through the table.
+
+ Because stdhash uses an open-addressing scheme, key removals are
+ more complex than in other schemes. Instead of actually deleting
+ the node and saying it is empty, I leave the node in its space but
+ I set the cached, hashcode to an "impossible" value (0) to indicate
+ that it was removed, but searchs should not terminate here. This is
+ because some insert probe sequence might have depended on the
+ removed node when it was inserted and so I can't simply delete the
+ node. But, if a user tries to insert into the table and such an
+ "inactive" node is found it can be used by the new pair being
+ inserted. Leaving these nodes in the table causes still another
+ problem. If the nodes still exist in the table, then the load
+ factor thresholds must be modified to take this into account when
+ deciding whether or not to grow, shrink, or rehash the table. If
+ they didn't, the table could be filled with "inactive" nodes and
+ searches might never terminate. In this implementation I track the
+ number of nodes in the table by the num_nodes variable. I make
+ decisions on whether to resize or rehash the table based on: size,
+ num_nodes and cap_min1.
+
+ Some more points: I cache hashcodes for keys in stdhash_nodes.
+ Obviously a key should be constant, meaning that it shouldn't
+ change once it is inserted in to an associative data structure. I
+ depend on that fact and property 3 (above) strongly when I am
+ searching for keys.
+
+ When rehashing occurs I don't free and reallocate active nodes. I
+ allocate a new table and free those inactive nodes (hcode == 0)
+ that are acting only as place holders (see prior paragraph). Then,
+ all of the active nodes are inserted into the new table.
+*/
+
+#define STDHASH_IS_LEGAL(h) ((h)->table <= (h)->begin && (h)->begin <= (h)->table_end && \
+ (h)->table + (h)->cap_min1 + 1 == (h)->table_end && \
+ (((h)->table != NULL && (h)->cap_min1 + 1 != 0) || ((h)->table == NULL && (h)->cap_min1 + 1 == 0)) && \
+ (h)->size <= (h)->num_nodes && \
+ (h)->num_nodes <= (h)->cap_min1 + 1 && \
+ (h)->ksize != 0 && \
+ ((h)->opts & ~(STDHASH_OPTS_NO_AUTO_GROW | STDHASH_OPTS_NO_AUTO_SHRINK)) == 0)
+
+#define STDHASH_IT_IS_LEGAL(h, it) ((it)->table == (h)->table && (it)->table_end == (h)->table_end && \
+ (it)->ksize == (h)->ksize && (it)->vsize == (h)->vsize && \
+ (it)->node_pos >= (h)->begin)
+
+#define STDHASH_IT_IS_LEGAL2(it) ((it)->table <= (it)->table_end && \
+ (it)->node_pos >= (it)->table && (it)->node_pos <= (it)->table_end && \
+ ((it)->node_pos == (it)->table_end || (!STDHASH_POS_EMPTY((it)->node_pos) && !STDHASH_POS_INACTIVE((it)->node_pos))) && \
+ (it)->ksize != 0)
+
+#define STDIT_HASH_IS_LEGAL(it) (((it)->type_id == STDHASH_IT_ID || (it)->type_id == STDHASH_IT_KEY_ID) && STDHASH_IT_IS_LEGAL2(&(it)->impl.hash))
+
+/* macros for table positions (stdhash_node**s) */
+
+#define STDHASH_POS_EMPTY(node_pos) (*(node_pos) == NULL)
+#define STDHASH_POS_INACTIVE(node_pos) ((*(node_pos))->hcode == 0)
+
+/* macros for table nodes (stdhash_node*s) (keys and values are appended onto the end of stdhash_nodes) */
+
+#define STDHASH_NODE_SIZE(ksize, vsize) (STDARCH_PADDED_SIZE(sizeof(stdhash_node)) + STDARCH_PADDED_SIZE(ksize) + (vsize))
+#define STDHASH_NKEY(node) ((char*) (node) + STDARCH_PADDED_SIZE(sizeof(stdhash_node)))
+#define STDHASH_NVAL(node, ksize) ((char*) (node) + STDARCH_PADDED_SIZE(sizeof(stdhash_node)) + STDARCH_PADDED_SIZE(ksize))
+
+/************************************************************************************************
+ * stdhash_low_cmp: Compares two keys for equality.
+ ***********************************************************************************************/
+
+STDINLINE static int stdhash_low_cmp(const stdhash *h, const void *k1, const void *k2)
+{
+ int ret;
+
+ if (h->cmp_fcn == NULL) {
+ ret = memcmp(k1, k2, h->ksize);
+
+ } else {
+ ret = h->cmp_fcn(k1, k2);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdhash_low_hcode: Computes the hcode for a key.
+ ***********************************************************************************************/
+
+STDINLINE static stdhcode stdhash_low_hcode(const stdhash *h, const void *key)
+{
+ stdhcode ret;
+
+ if (h->hcode_fcn == NULL) {
+ ret = (stdhcode) stdhcode_sfh(key, h->ksize);
+
+ } else {
+ ret = h->hcode_fcn(key);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdhash_low_hash: Computes initial search position and offset for a hcode.
+ ***********************************************************************************************/
+
+STDINLINE static void stdhash_low_hash(stdhcode hcode, stdsize cap_min1, stdsize cap_lg,
+ stdsize *h1, stdsize *h2)
+{
+ /* h1 - is the lowest lg(cap) bits of hcode
+ h2 - is the highest lg(cap) bits of hcode, but the least significant bit is set to 1
+ */
+
+ *h1 = (stdsize) (hcode & cap_min1); /* [0, cap) */
+ *h2 = (stdsize) ((hcode >> (sizeof(stdhcode) * 8 - cap_lg)) | 0x1); /* (0, cap) and odd */
+}
+
+/************************************************************************************************
+ * stdhash_low_next: Get the next entry.
+ ***********************************************************************************************/
+
+STDINLINE static stdhash_node **stdhash_low_next(stdhash_node ** curr_pos, stdhash_node ** end_pos)
+{
+ ++curr_pos;
+
+ for (; curr_pos != end_pos && (STDHASH_POS_EMPTY(curr_pos) || STDHASH_POS_INACTIVE(curr_pos)); ++curr_pos);
+
+ return curr_pos;
+}
+
+/************************************************************************************************
+ * stdhash_low_prev: Get the previous entry.
+ ***********************************************************************************************/
+
+STDINLINE static stdhash_node **stdhash_low_prev(stdhash_node ** curr_pos)
+{
+ --curr_pos;
+
+ for (; STDHASH_POS_EMPTY(curr_pos) || STDHASH_POS_INACTIVE(curr_pos); --curr_pos);
+
+ return curr_pos;
+}
+
+/************************************************************************************************
+ * stdhash_low_clear: Make a hashtable contain zero elements.
+ ***********************************************************************************************/
+
+STDINLINE static void stdhash_low_clear(stdhash *h)
+{
+ stdhash_node ** curr_pos;
+ stdhash_node ** end_pos;
+
+ /* loop over entire table deleteing all allocated nodes (i.e. - h->num_nodes) */
+
+ curr_pos = h->table;
+ end_pos = h->table_end;
+
+ for (; curr_pos != end_pos && h->num_nodes != 0; ++curr_pos) {
+
+ if (!STDHASH_POS_EMPTY(curr_pos)) {
+ free(*curr_pos);
+ *curr_pos = NULL;
+ --h->num_nodes;
+ }
+ }
+
+ STDSAFETY_CHECK(h->num_nodes == 0);
+
+ h->begin = h->table_end;
+ h->size = 0;
+}
+
+/************************************************************************************************
+ * stdhash_low_find: Return a key lookup and its hcode. If
+ * (find_match) return only upon finding the first match or realizing
+ * the key isn't in the table. If (!find_match) return upon finding
+ * the first empty position or inactive node in key's probe sequence.
+ ***********************************************************************************************/
+
+STDINLINE static stdhash_node ** stdhash_low_find(const stdhash *h, stdbool find_match,
+ const void *key, stdhcode * hcode_ptr)
+{
+ stdhash_node ** curr_pos;
+ stdhash_node ** end_pos;
+ stdhcode hcode;
+ stdsize h1;
+ stdsize h2;
+
+ STDSAFETY_CHECK(h->table != NULL); /* no table -> no searches */
+
+ hcode = stdhash_low_hcode(h, key); /* compute hcode of key */
+ *hcode_ptr = hcode;
+
+ stdhash_low_hash(hcode, h->cap_min1, h->cap_lg, &h1, &h2); /* compute hashes of hcode */
+
+ curr_pos = h->table + h1; /* initial probe position */
+ end_pos = h->table_end;
+
+ while (1) { /* search probe sequence */
+
+ if (STDHASH_POS_EMPTY(curr_pos)) { /* empty -> key is not in table */
+ break;
+ }
+
+ if (find_match) { /* looking for a match */
+
+ if ((*curr_pos)->hcode == hcode && /* hcodes match (inactives can't) */
+ stdhash_low_cmp(h, key, STDHASH_NKEY(*curr_pos)) == 0) { /* keys match */
+ break;
+ }
+
+ } else if (STDHASH_POS_INACTIVE(curr_pos)) { /* else looking for a hole */
+ break; /* found one */
+ }
+
+ curr_pos += h2; /* offset to next probe position */
+
+ if (curr_pos >= end_pos) { /* wrap around */
+ curr_pos = h->table + (curr_pos - end_pos);
+ }
+ }
+
+ return curr_pos;
+}
+
+/************************************************************************************************
+ * stdhash_low_reshash: This function is called when it has been
+ * determined that the active pairs in h need to be put into a
+ * different table. It allocates an appropriately sized table, moves
+ * active nodes there and frees inactive nodes from the table.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdhash_low_rehash(stdhash *h, stdsize request_size)
+{
+ stdcode ret = STDESUCCESS;
+
+ stdhash_node ** table;
+ stdhash_node ** table_end;
+ stdhash_node ** curr_pos;
+ stdhash_node ** end_pos;
+ stdhash_node ** search_pos;
+
+ stdsize new_cap;
+ stdsize new_cap_min1;
+ stdsize new_cap_lg;
+ stdsize h1;
+ stdsize h2;
+
+ stduint64 good_cap;
+
+ STDSAFETY_CHECK(request_size >= h->size);
+
+ /* compute a good table size based on request_size */
+
+ good_cap = (stdpow2_cap(request_size) << 1); /* (>= 3, < 6) * request_size */
+
+ if (good_cap < request_size || good_cap > STDSIZE_MAX) { /* overflow check */
+ ret = STDENOMEM;
+ goto stdhash_low_rehash_end;
+ }
+
+ /* good_cap will make load factor w/ request_size nodes in range (1/6, 1/3] */
+
+ new_cap = (stdsize) good_cap;
+ new_cap = STDMAX(new_cap, STDHASH_MIN_AUTO_ALLOC); /* ensure min allocation */
+ new_cap_lg = (stdsize) stdlg_up(new_cap); /* compute lg base 2 */
+ new_cap_min1 = new_cap - 1;
+
+ /* allocate a new table */
+
+ if (new_cap != 0) {
+
+ /* table needs to be initially full of NULL pointers */
+
+#if (STDARCH_NULL_IS_ZERO == 1)
+ if ((table = (stdhash_node**) calloc(new_cap, sizeof(stdhash_node*))) == NULL) {
+ ret = STDENOMEM;
+ goto stdhash_low_rehash_end;
+ }
+
+ table_end = table + new_cap;
+
+#else
+ if ((table = (stdhash_node**) malloc(new_cap * sizeof(stdhash_node*))) == NULL) {
+ ret = STDENOMEM;
+ goto stdhash_low_rehash_end;
+ }
+
+ table_end = table + new_cap;
+
+ for (curr_pos = table; curr_pos != table_end; ++curr_pos) {
+ *curr_pos = NULL;
+ }
+
+#endif
+ } else {
+ table = NULL;
+ table_end = NULL;
+ }
+
+ /* loop over 'h' free'ing inactive nodes and inserting active nodes into new table */
+
+ for (curr_pos = h->table, end_pos = h->table_end; curr_pos != end_pos; ++curr_pos) {
+
+ if (STDHASH_POS_EMPTY(curr_pos)) { /* skip empty positions */
+ continue;
+ }
+
+ if (STDHASH_POS_INACTIVE(curr_pos)) { /* free inactive nodes */
+ free(*curr_pos);
+
+ } else {
+ /* compute hash values for entry in new table, then insert in first empty position */
+
+ stdhash_low_hash((*curr_pos)->hcode, new_cap_min1, new_cap_lg, &h1, &h2);
+
+ for (search_pos = table + h1; !STDHASH_POS_EMPTY(search_pos); ) {
+ search_pos += h2; /* offset */
+
+ if (search_pos >= table_end) { /* wrap around */
+ search_pos = table + (search_pos - table_end);
+ }
+ }
+
+ *search_pos = *curr_pos; /* insert into new table */
+ }
+ }
+
+ if (h->table != NULL) { /* free old table */
+ free(h->table);
+ }
+
+ h->table = table;
+ h->table_end = table_end;
+ h->cap_min1 = new_cap_min1;
+ h->cap_lg = new_cap_lg;
+ h->num_nodes = h->size; /* zero inactive nodes now */
+
+ /* search for begin */
+
+ h->begin = (h->size != 0 ? stdhash_low_next(h->table - 1, h->table_end) : h->table_end);
+
+ stdhash_low_rehash_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdhash_low_insert:
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdhash_low_insert(stdhash *h, stdit *it, const stdit *b, const stdit *e,
+ stdsize num_ins, stdbool overwrite, stdbool advance)
+{
+ stdcode ret = STDESUCCESS;
+ stdsize hthresh = stdhash_high_thresh(h);
+ stdhash_node ** search = NULL;
+ stdhash_node ** first_ins = NULL;
+ stdit src_it = *b;
+ stdbool keyed = (stdit_key_size(b) != 0);
+ stdhcode hcode;
+ const void * key;
+ const void * val;
+
+ while (num_ins-- != 0 && (e == NULL || !stdit_eq(&src_it, e))) {
+
+ /* check the loading factor on the table: grow/rehash if necessary */
+
+ if (h->num_nodes > hthresh) { /* load factor too high */
+
+ if ((h->opts & STDHASH_OPTS_NO_AUTO_GROW) != 0) { /* growth disallowed */
+ ret = STDEACCES;
+ goto stdhash_low_insert_end;
+ }
+
+ if ((ret = stdhash_low_rehash(h, h->size + 1)) != STDESUCCESS) { /* rehash/growth failed */
+ goto stdhash_low_insert_end;
+ }
+
+ hthresh = stdhash_high_thresh(h);
+ }
+
+ /* get pointers to the key and value we are about to insert */
+
+ val = stdit_val(&src_it);
+ key = (keyed ? stdit_key(&src_it) : val);
+
+ /* look for the next insertion point */
+
+ search = stdhash_low_find(h, overwrite, key, &hcode);
+
+ if (STDHASH_POS_EMPTY(search)) { /* found a truly empty hole: create+insert a new node */
+
+ if ((*search = (stdhash_node*) malloc(STDHASH_NODE_SIZE(h->ksize, h->vsize))) == NULL) {
+ ret = STDENOMEM;
+ goto stdhash_low_insert_end;
+ }
+
+ ++h->num_nodes; /* increased # of nodes in table */
+ } /* else found a useable node */
+
+ /* update the table's meta information */
+
+ ++h->size;
+
+ if (search < h->begin) { /* insert was before begin */
+ h->begin = search;
+ }
+
+ /* set the node with the new key-value pair */
+
+ (*search)->hcode = hcode;
+ memcpy(STDHASH_NKEY(*search), key, h->ksize);
+ memcpy(STDHASH_NVAL(*search, h->ksize), val, h->vsize);
+
+ /* remember first insertion */
+
+ if (first_ins == NULL) {
+ first_ins = search;
+ }
+
+ /* advance iterator if so requested */
+
+ if (advance) {
+ stdit_next(&src_it);
+ }
+ }
+
+ if (first_ins == NULL) { /* empty input sequence, set 'it' to end */
+ first_ins = h->table_end;
+ }
+
+ stdhash_low_insert_end:
+ if (first_ins != NULL && it != NULL) { /* at least one insertion succeeded/empty input sequence */
+ it->type_id = STDHASH_IT_ID;
+ it->impl.hash.node_pos = first_ins;
+ it->impl.hash.table = h->table;
+ it->impl.hash.table_end = h->table_end;
+ it->impl.hash.ksize = h->ksize;
+ it->impl.hash.vsize = h->vsize;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdhash_construct: Construct an initially empty hashtable.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_construct(stdhash *h, stdsize ksize, stdsize vsize,
+ stdcmp_fcn kcmp, stdhcode_fcn khcode, stduint8 opts)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (ksize == 0 || (opts & ~(STDHASH_OPTS_NO_AUTO_GROW | STDHASH_OPTS_NO_AUTO_SHRINK)) != 0) {
+ ret = STDEINVAL;
+ goto stdhash_construct_fail;
+ }
+
+ h->table = NULL;
+ h->table_end = NULL;
+ h->begin = NULL;
+
+ h->cap_min1 = (stdsize) -1;
+ h->cap_lg = (stdsize) -1;
+ h->num_nodes = 0;
+ h->size = 0;
+
+ h->ksize = ksize;
+ h->vsize = vsize;
+
+ h->cmp_fcn = kcmp;
+ h->hcode_fcn = khcode;
+
+ h->opts = opts;
+
+ goto stdhash_construct_end;
+
+ /* error handling and return */
+
+ stdhash_construct_fail:
+ h->ksize = 0; /* make STDHASH_IS_LEGAL(h) false */
+
+ stdhash_construct_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdhash_copy_construct: Construct a copy of a hashtable.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_copy_construct(stdhash *dst, const stdhash *src)
+{
+ stdcode ret = STDESUCCESS;
+ stdhash_node ** dst_pos = NULL;
+
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(src));
+
+ *dst = *src;
+
+ if (src->table != NULL) {
+ stdhash_node ** src_pos;
+ stdhash_node ** src_end;
+
+ /* allocate a table */
+
+ if ((dst->table = (stdhash_node**) malloc(sizeof(stdhash_node*) * (dst->cap_min1 + 1))) == NULL) {
+ ret = STDENOMEM;
+ goto stdhash_copy_construct_fail;
+ }
+
+ dst->table_end = dst->table + dst->cap_min1 + 1;
+ dst->begin = dst->table + (src->begin - src->table);
+
+ dst_pos = dst->table;
+ src_pos = src->table;
+ src_end = src->table_end;
+
+ /* loop over src cloning its nodes in dst */
+
+ for (; src_pos != src_end; ++src_pos, ++dst_pos) {
+
+ if (STDHASH_POS_EMPTY(src_pos)) {
+ *dst_pos = NULL;
+
+ } else {
+
+ /* alloc, init and insert a new node */
+
+ if ((*dst_pos = (stdhash_node*) malloc(STDHASH_NODE_SIZE(dst->ksize, dst->vsize))) == NULL) {
+ ret = STDENOMEM;
+ goto stdhash_copy_construct_clean;
+ }
+
+ (*dst_pos)->hcode = (*src_pos)->hcode;
+ memcpy(STDHASH_NKEY(*dst_pos), STDHASH_NKEY(*src_pos), src->ksize);
+ memcpy(STDHASH_NVAL(*dst_pos, src->ksize), STDHASH_NVAL(*src_pos, src->ksize), src->vsize);
+ }
+ }
+ }
+
+ goto stdhash_copy_construct_end;
+
+ /* error handling and return */
+
+ stdhash_copy_construct_clean:
+
+ while (--dst_pos >= dst->table) {
+ if (!STDHASH_POS_EMPTY(dst_pos)) {
+ free(*dst_pos);
+ }
+ }
+
+ free(dst->table);
+ dst->table = NULL;
+
+ stdhash_copy_construct_fail:
+ dst->ksize = 0; /* make STDHASH_IS_LEGAL(dst) false */
+
+ stdhash_copy_construct_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdhash_destruct: Reclaim a hash's resources and invalidate it.
+ ***********************************************************************************************/
+
+STDINLINE void stdhash_destruct(stdhash *h)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ stdhash_low_clear(h);
+
+ if (h->table != NULL) {
+ free(h->table);
+ h->table = NULL;
+ }
+
+ h->ksize = 0; /* make STDHASH_IS_LEGAL(h) false */
+}
+
+/************************************************************************************************
+ * stdhash_set_eq: Set 'dst' to have the same contents as 'src.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_set_eq(stdhash *dst, const stdhash *src)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(dst) && STDHASH_IS_LEGAL(src) &&
+ dst->ksize == src->ksize && dst->vsize == src->vsize &&
+ dst->cmp_fcn == src->cmp_fcn && dst->hcode_fcn == src->hcode_fcn);
+
+ if (src->size != 0) {
+ stdhash cpy;
+
+ if ((ret = stdhash_copy_construct(&cpy, src)) != STDESUCCESS) { /* make a copy */
+ goto stdhash_set_eq_end;
+ }
+
+ stdhash_swap(dst, &cpy); /* swap the hashes */
+ stdhash_destruct(&cpy); /* destroy the old hash */
+
+ } else {
+ stdhash_clear(dst);
+ }
+
+ stdhash_set_eq_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdhash_swap: Make h1 reference h2's contents and vice versa.
+ ***********************************************************************************************/
+
+STDINLINE void stdhash_swap(stdhash *h1, stdhash *h2)
+{
+ stdhash cpy;
+
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h1) && STDHASH_IS_LEGAL(h2) &&
+ h1->ksize == h2->ksize && h1->vsize == h2->vsize &&
+ h1->cmp_fcn == h2->cmp_fcn && h1->hcode_fcn == h2->hcode_fcn);
+
+ STDSWAP(*h1, *h2, cpy);
+}
+
+/************************************************************************************************
+ * stdhash_begin: Get an iterator to the beginning of a hash.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdhash_begin(const stdhash *h, stdit *it)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ it->impl.hash.node_pos = (stdhash_node**) h->begin;
+ it->impl.hash.table = (stdhash_node**) h->table;
+ it->impl.hash.table_end = (stdhash_node**) h->table_end;
+ it->impl.hash.ksize = h->ksize;
+ it->impl.hash.vsize = h->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdhash_last: Get an iterator to the last entry of a hash.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdhash_last(const stdhash *h, stdit *it)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+ STDBOUNDS_CHECK(h->size != 0);
+
+ return stdit_prev(stdhash_end(h, it));
+}
+
+/************************************************************************************************
+ * stdhash_end: Get an iterator to the end of a hash.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdhash_end(const stdhash *h, stdit *it)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ it->impl.hash.node_pos = (stdhash_node**) h->table_end;
+ it->impl.hash.table = (stdhash_node**) h->table;
+ it->impl.hash.table_end = (stdhash_node**) h->table_end;
+ it->impl.hash.ksize = h->ksize;
+ it->impl.hash.vsize = h->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdhash_get: Get an iterator to the 'elem_num'th element of a hash.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdhash_get(const stdhash *h, stdit *it, stdsize elem_num)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+ STDBOUNDS_CHECK(elem_num <= h->size);
+
+ if (elem_num <= (h->size >> 1)) {
+ stdit_advance(stdhash_begin(h, it), elem_num);
+
+ } else {
+ stdit_retreat(stdhash_end(h, it), h->size - elem_num);
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdhash_is_begin: Return whether or not an iterator refers to the beginning of a hash.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdhash_is_begin(const stdhash *h, const stdit *it)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h) && STDIT_HASH_IS_LEGAL(it) && STDHASH_IT_IS_LEGAL(h, &it->impl.hash));
+
+ return it->impl.hash.node_pos == h->begin;
+}
+
+/************************************************************************************************
+ * stdhash_is_end: Return whether or not an iterator refers to the end of a hash.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdhash_is_end(const stdhash *h, const stdit *it)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h) && STDIT_HASH_IS_LEGAL(it) && STDHASH_IT_IS_LEGAL(h, &it->impl.hash));
+
+ return it->impl.hash.node_pos == h->table_end;
+}
+
+/************************************************************************************************
+ * stdhash_keyed_next: Get the next entry with the same key as 'it.'
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdhash_keyed_next(const stdhash *h, stdit *it)
+{
+ stdhash_node ** curr_pos = it->impl.hash.node_pos;
+ stdsize h1;
+ stdsize h2;
+
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h) && STDIT_HASH_IS_LEGAL(it) &&
+ STDHASH_IT_IS_LEGAL(h, &it->impl.hash) && it->impl.hash.node_pos != h->table_end);
+
+ /* compute hash values of 'it's key */
+
+ stdhash_low_hash((*it->impl.hash.node_pos)->hcode, h->cap_min1, h->cap_lg, &h1, &h2);
+
+ while (1) {
+ curr_pos += h2; /* offset in table */
+
+ if (curr_pos >= h->table_end) { /* wrap around */
+ curr_pos = h->table + (curr_pos - h->table_end);
+ }
+
+ if (STDHASH_POS_EMPTY(curr_pos)) { /* empty position -> no more matches */
+ it->impl.hash.node_pos = h->table_end; /* set to end */
+ break;
+ }
+
+ if ((*curr_pos)->hcode == (*it->impl.hash.node_pos)->hcode &&
+ stdhash_low_cmp(h, STDHASH_NKEY(*curr_pos), STDHASH_NKEY(*it->impl.hash.node_pos)) == 0) {
+ it->impl.hash.node_pos = curr_pos; /* match */
+ break;
+ }
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdhash_keyed_prev: Get the previous entry with the same key as 'it.'
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdhash_keyed_prev(const stdhash *h, stdit *it)
+{
+ stdhash_node ** curr_pos = it->impl.hash.node_pos;
+ stdsize h1;
+ stdsize h2;
+
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h) && STDIT_HASH_IS_LEGAL(it) &&
+ STDHASH_IT_IS_LEGAL(h, &it->impl.hash) && it->impl.hash.node_pos != h->table_end);
+
+ /* compute hash values of 'it's key */
+
+ stdhash_low_hash((*it->impl.hash.node_pos)->hcode, h->cap_min1, h->cap_lg, &h1, &h2);
+
+ while (1) {
+ if (curr_pos == h->table + h1) { /* on first probe sequence spot */
+ it->impl.hash.node_pos = h->table_end; /* no more matches */
+ break;
+ }
+
+ curr_pos -= h2; /* offset in table */
+
+ if (curr_pos < h->table) { /* wrap around */
+ curr_pos = h->table_end - (h->table - curr_pos);
+ }
+
+ if ((*curr_pos)->hcode == (*it->impl.hash.node_pos)->hcode &&
+ stdhash_low_cmp(h, STDHASH_NKEY(*curr_pos), STDHASH_NKEY(*it->impl.hash.node_pos)) == 0) {
+ it->impl.hash.node_pos = curr_pos; /* match */
+ break;
+ }
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdhash_size: Return the number of key-value pair elements in a hash.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdhash_size(const stdhash *h)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ return h->size;
+}
+
+/************************************************************************************************
+ * stdhash_empty: Return whether or not an array contains zero elements.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdhash_empty(const stdhash *h)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ return h->size == 0;
+}
+
+/************************************************************************************************
+ * stdhash_curr_load: The number of nodes currently in the table.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdhash_curr_load(const stdhash *h)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ return h->num_nodes;
+}
+
+/************************************************************************************************
+ * stdhash_high_thresh: The load beyond which the table will (try to) grow.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdhash_high_thresh(const stdhash *h)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ return ((h->cap_min1 + 1) >> 1); /* keep load factor < 50% */
+}
+
+/************************************************************************************************
+ * stdhash_low_thresh: The size at (or below) which the table will (try to) shrink.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdhash_low_thresh(const stdhash *h)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ return ((h->cap_min1 + 1) >> 3); /* keep load factor > 12.5% */
+}
+
+/************************************************************************************************
+ * stdhash_max_size: Return the theoretical max number of elements a hash can contain.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdhash_max_size(const stdhash *h)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ return (STDSIZE_MAX >> 2);
+}
+
+/************************************************************************************************
+ * stdhash_key_size: Return the size in bytes of the keys a hash contains.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdhash_key_size(const stdhash *h)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ return h->ksize;
+}
+
+/************************************************************************************************
+ * stdhash_val_size: Return the size in bytes of the values a hash contains.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdhash_val_size(const stdhash *h)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ return h->vsize;
+}
+
+/************************************************************************************************
+ * stdhash_clear: Make a hashtable contain zero elements.
+ ***********************************************************************************************/
+
+STDINLINE void stdhash_clear(stdhash *h)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ stdhash_low_clear(h); /* free all nodes */
+
+ if ((h->opts & STDHASH_OPTS_NO_AUTO_SHRINK) == 0 && /* if shrinking allowed */
+ h->cap_min1 + 1 != STDHASH_MIN_AUTO_ALLOC && /* not at min alloc already */
+ h->size <= stdhash_low_thresh(h)) { /* fallen to low cap */
+
+ stdhash_low_rehash(h, h->size); /* realloc */
+ }
+}
+
+/************************************************************************************************
+ * stdhash_reserve: Adjusts hash to be able to accomadate num_pairs
+ * elements wo/ realloc. Ignores all auto allocation considerations.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_reserve(stdhash *h, stdsize num_pairs)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (num_pairs > stdhash_high_thresh(h)) { /* request wouldn't fit in current table */
+ ret = stdhash_low_rehash(h, num_pairs);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdhash_rehash: Reallocates table to optimum size and removes all
+ * inactive nodes. Ignores all auto allocation considerations.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_rehash(stdhash *h)
+{
+ return stdhash_low_rehash(h, h->size);
+}
+
+/************************************************************************************************
+ * stdhash_find: Lookup a key. Return an iterator to the first
+ * key-value pair that matches, end if none.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdhash_find(const stdhash *h, stdit *it, const void *key)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ if (h->size != 0) { /* size == 0 -> give end immediately; avoid special case of no table */
+ stdhcode hcode;
+ stdhash_node ** search = stdhash_low_find(h, STDTRUE, key, &hcode);
+
+ it->impl.hash.node_pos = (!STDHASH_POS_EMPTY(search) ? search : h->table_end); /* not found */
+
+ } else {
+ it->impl.hash.node_pos = h->table_end;
+ }
+
+ it->type_id = STDHASH_IT_ID;
+ it->impl.hash.table = h->table;
+ it->impl.hash.table_end = h->table_end;
+ it->impl.hash.ksize = h->ksize;
+ it->impl.hash.vsize = h->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdhash_contains: Return whether or not a stdhash contains a key.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdhash_contains(const stdhash *h, const void *key)
+{
+ stdit it;
+
+ return !stdhash_is_end(h, stdhash_find(h, &it, key));
+}
+
+/************************************************************************************************
+ * stdhash_put:
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_put(stdhash *h, stdit *it, const void *key, const void *val)
+{
+ return stdhash_put_n(h, it, key, val, 1);
+}
+
+/************************************************************************************************
+ * stdhash_put_n:
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_put_n(stdhash *h, stdit *it, const void *keys, const void *vals, stdsize num_put)
+{
+ stdit b;
+
+ return stdhash_put_seq_n(h, it, stdit_pptr(&b, keys, vals, h->ksize, h->vsize), num_put);
+}
+
+/************************************************************************************************
+ * stdhash_put_seq:
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_put_seq(stdhash *h, stdit *it, const stdit *b, const stdit *e)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h) && (stdit_eq(b, e) || STDTRUE) &&
+ (stdit_key_size(b) == h->ksize || (stdit_key_size(b) == 0 && stdit_val_size(b) == h->ksize)) &&
+ (stdit_val_size(b) == h->vsize || h->vsize == 0));
+
+ return stdhash_low_insert(h, it, b, e, (stdsize) -1, STDTRUE, STDTRUE);
+}
+
+/************************************************************************************************
+ * stdhash_put_seq_n:
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_put_seq_n(stdhash *h, stdit *it, const stdit *b, stdsize num_put)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h) &&
+ (stdit_key_size(b) == h->ksize || (stdit_key_size(b) == 0 && stdit_val_size(b) == h->ksize)) &&
+ (stdit_val_size(b) == h->vsize || h->vsize == 0));
+
+ return stdhash_low_insert(h, it, b, NULL, num_put, STDTRUE, STDTRUE);
+}
+
+/************************************************************************************************
+ * stdhash_insert:
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_insert(stdhash *h, stdit *it, const void *key, const void *val)
+{
+ return stdhash_insert_n(h, it, key, val, 1);
+}
+
+/************************************************************************************************
+ * stdhash_insert_n:
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_insert_n(stdhash *h, stdit *it, const void *keys, const void *vals, stdsize num_insert)
+{
+ stdit b;
+
+ return stdhash_insert_seq_n(h, it, stdit_pptr(&b, keys, vals, h->ksize, h->vsize), num_insert);
+}
+
+/************************************************************************************************
+ * stdhash_insert_seq:
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_insert_seq(stdhash *h, stdit *it, const stdit *b, const stdit *e)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h) && (stdit_eq(b, e) || STDTRUE) &&
+ (stdit_key_size(b) == h->ksize || (stdit_key_size(b) == 0 && stdit_val_size(b) == h->ksize)) &&
+ (stdit_val_size(b) == h->vsize || h->vsize == 0));
+
+ return stdhash_low_insert(h, it, b, e, (stdsize) -1, STDFALSE, STDTRUE);
+}
+
+/************************************************************************************************
+ * stdhash_insert_seq_n:
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_insert_seq_n(stdhash *h, stdit *it, const stdit *b, stdsize num_insert)
+{
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h) &&
+ (stdit_key_size(b) == h->ksize || (stdit_key_size(b) == 0 && stdit_val_size(b) == h->ksize)) &&
+ (stdit_val_size(b) == h->vsize || h->vsize == 0));
+
+ return stdhash_low_insert(h, it, b, NULL, num_insert, STDFALSE, STDTRUE);
+}
+
+/************************************************************************************************
+ * stdhash_insert_rep:
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhash_insert_rep(stdhash *h, stdit *it, const void *key, const void *val, stdsize num_times)
+{
+ stdit b;
+
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h));
+
+ return stdhash_low_insert(h, it, stdit_pptr(&b, key, val, h->ksize, h->vsize), NULL, num_times, STDFALSE, STDFALSE);
+}
+
+/************************************************************************************************
+ * stdhash_erase: Erase a key-value pair from a hash.
+ ***********************************************************************************************/
+
+STDINLINE void stdhash_erase(stdhash *h, stdit *it)
+{
+ stdhash_node ** orig_pos;
+
+ STDSAFETY_CHECK(STDHASH_IS_LEGAL(h) && STDIT_HASH_IS_LEGAL(it) && STDHASH_IT_IS_LEGAL(h, &it->impl.hash));
+ STDBOUNDS_CHECK(it->impl.hash.node_pos != h->table_end);
+
+ orig_pos = it->impl.hash.node_pos; /* remember initial position */
+
+ (*it->impl.hash.node_pos)->hcode = 0; /* mark node as inactive */
+ it->impl.hash.node_pos = stdhash_low_next(it->impl.hash.node_pos, it->impl.hash.table_end);
+
+ if (orig_pos == h->begin) { /* update begin if necessary */
+ h->begin = it->impl.hash.node_pos;
+ }
+
+ --h->size; /* update size */
+
+ if ((h->opts & STDHASH_OPTS_NO_AUTO_SHRINK) == 0 && /* if shrinking allowed */
+ h->cap_min1 + 1 != STDHASH_MIN_AUTO_ALLOC && /* not at min alloc already */
+ h->size <= stdhash_low_thresh(h)) { /* fallen to low cap */
+
+ if (stdhash_low_rehash(h, h->size) == STDESUCCESS) { /* rehash successful */
+ it->impl.hash.node_pos = h->begin; /* set iterator to begin */
+ }
+ }
+}
+
+/************************************************************************************************
+ * stdhash_erase_key: Removes all key-values pairs that match key. (KISS)
+ ***********************************************************************************************/
+
+STDINLINE void stdhash_erase_key(stdhash *h, const void *key)
+{
+ stdit search;
+
+ while (!stdhash_is_end(h, stdhash_find(h, &search, key))) {
+ stdhash_erase(h, &search);
+ }
+}
+
+/************************************************************************************************
+ * stdit_key: Return a pointer to the key of the key-value pair 'it' references.
+ ***********************************************************************************************/
+
+STDINLINE const void *stdit_key(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
+
+ return STDHASH_NKEY(*it->impl.hash.node_pos);
+}
+
+/************************************************************************************************
+ * stdit_key_size: Return the size in bytes of keys 'it' references.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdit_key_size(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
+
+ return it->impl.hash.ksize;
+}
+
+/************************************************************************************************
+ * stdit_val: Return a pointer to the key of the key-value pair 'it' references.
+ ***********************************************************************************************/
+
+STDINLINE void *stdit_val(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
+
+ return STDHASH_NVAL(*it->impl.hash.node_pos, it->impl.hash.ksize);
+}
+
+/************************************************************************************************
+ * stdit_val_size: Return the size in bytes of the values 'it' references.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdit_val_size(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
+
+ return it->impl.hash.vsize;
+}
+
+/************************************************************************************************
+ * stdit_eq: Compare two iterators for equality (same pair).
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdit_eq(const stdit *it1, const stdit *it2)
+{
+ STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it1) && STDIT_HASH_IS_LEGAL(it2) &&
+ it1->impl.hash.table == it2->impl.hash.table &&
+ it1->impl.hash.table_end == it2->impl.hash.table_end &&
+ it1->impl.hash.ksize == it2->impl.hash.ksize &&
+ it1->impl.hash.vsize == it2->impl.hash.vsize);
+
+ return it1->impl.hash.node_pos == it2->impl.hash.node_pos;
+}
+
+/************************************************************************************************
+ * stdit_next: Advance an iterator towards end by 1 position.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_next(stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
+ STDBOUNDS_CHECK(it->impl.hash.node_pos != it->impl.hash.table_end);
+
+ it->impl.hash.node_pos = stdhash_low_next(it->impl.hash.node_pos, it->impl.hash.table_end);
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_advance: Advance an iterator towards end by 'num_advance' positions.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_advance(stdit *it, stdsize num_advance)
+{
+ STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
+
+ while (num_advance-- != 0) {
+ STDBOUNDS_CHECK(it->impl.hash.node_pos != it->impl.hash.table_end);
+ it->impl.hash.node_pos = stdhash_low_next(it->impl.hash.node_pos, it->impl.hash.table_end);
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_prev: Advance an iterator towards begin by 1 position.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_prev(stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
+ STDBOUNDS_CHECK(it->impl.hash.node_pos != it->impl.hash.table); /* should be begin, but we don't track that */
+
+ it->impl.hash.node_pos = stdhash_low_prev(it->impl.hash.node_pos);
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_retreat: Advance an iterator towards begin by 'num_retreat' positions.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_retreat(stdit *it, stdsize num_retreat)
+{
+ STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
+
+ while (num_retreat-- != 0) {
+ STDBOUNDS_CHECK(it->impl.hash.node_pos != it->impl.hash.table); /* should be begin, but we don't track that */
+ it->impl.hash.node_pos = stdhash_low_prev(it->impl.hash.node_pos);
+ }
+
+ return it;
+}
Added: vendor/stdutil/current/src/stdit.c
===================================================================
--- vendor/stdutil/current/src/stdit.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdit.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,642 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdutil/stderror.h>
+#include <stdutil/stdit.h>
+#include <stdutil/stdarr.h>
+#include <stdutil/stdcarr.h>
+#include <stdutil/stddll.h>
+#include <stdutil/stdhash.h>
+#include <stdutil/stdskl.h>
+
+/************************************************************************************************
+ * stdit_get_type: Get the functional type of an iterator.
+ ***********************************************************************************************/
+
+STDINLINE stdit_type stdit_get_type(const stdit *it)
+{
+ stdit_type ret;
+
+ switch (it->type_id) {
+ case STDPTR_IT_ID:
+ case STDPPTR_IT_ID:
+ case STDARR_IT_ID:
+ case STDCARR_IT_ID:
+ ret = STDIT_RANDOM_ACCESS;
+ break;
+
+ case STDDLL_IT_ID:
+ case STDHASH_IT_ID:
+ case STDHASH_IT_KEY_ID:
+ case STDSKL_IT_ID:
+ case STDSKL_IT_KEY_ID:
+ ret = STDIT_BIDIRECTIONAL;
+ break;
+
+ default:
+ ret = STDIT_FORWARD;
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdit_key: Get the key of a key-value pair from an iterator.
+ ***********************************************************************************************/
+
+STDINLINE const void *stdit_key(const stdit *it)
+{
+ const void * ret;
+
+ switch (it->type_id) {
+ case STDPTR_IT_ID:
+ case STDARR_IT_ID:
+ case STDCARR_IT_ID:
+ case STDDLL_IT_ID:
+ ret = NULL;
+ break;
+
+ case STDPPTR_IT_ID:
+ ret = it->impl.pptr.key;
+ break;
+
+ case STDHASH_IT_ID:
+ case STDHASH_IT_KEY_ID:
+ ret = stdhash_it_key(it);
+ break;
+
+ case STDSKL_IT_ID:
+ case STDSKL_IT_KEY_ID:
+ ret = stdskl_it_key(it);
+ break;
+
+ default:
+ ret = NULL;
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdit_key_size: Get the size in bytes of the key type 'it' references.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdit_key_size(const stdit *it)
+{
+ stdsize ret;
+
+ switch (it->type_id) {
+ case STDPTR_IT_ID:
+ case STDARR_IT_ID:
+ case STDCARR_IT_ID:
+ case STDDLL_IT_ID:
+ ret = 0;
+ break;
+
+ case STDPPTR_IT_ID:
+ ret = it->impl.pptr.ksize;
+ break;
+
+ case STDHASH_IT_ID:
+ case STDHASH_IT_KEY_ID:
+ ret = stdhash_it_key_size(it);
+ break;
+
+ case STDSKL_IT_ID:
+ case STDSKL_IT_KEY_ID:
+ ret = stdskl_it_key_size(it);
+ break;
+
+ default:
+ ret = 0;
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdit_val: Get the value that 'it' references.
+ ***********************************************************************************************/
+
+STDINLINE void *stdit_val(const stdit *it)
+{
+ void * ret;
+
+ switch (it->type_id) {
+ case STDPTR_IT_ID:
+ ret = it->impl.ptr.val;
+ break;
+
+ case STDPPTR_IT_ID:
+ ret = it->impl.pptr.val;
+ break;
+
+ case STDARR_IT_ID:
+ ret = stdarr_it_val(it);
+ break;
+
+ case STDCARR_IT_ID:
+ ret = stdcarr_it_val(it);
+ break;
+
+ case STDDLL_IT_ID:
+ ret = stddll_it_val(it);
+ break;
+
+ case STDHASH_IT_ID:
+ ret = stdhash_it_val(it);
+ break;
+
+ case STDHASH_IT_KEY_ID:
+ ret = (void*) stdhash_it_key(it);
+ break;
+
+ case STDSKL_IT_ID:
+ ret = stdskl_it_val(it);
+ break;
+
+ case STDSKL_IT_KEY_ID:
+ ret = (void*) stdskl_it_key(it);
+ break;
+
+ default:
+ ret = NULL;
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdit_val_size: Get the size in bytes of the value 'it' references.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdit_val_size(const stdit *it)
+{
+ stdsize ret;
+
+ switch (it->type_id) {
+ case STDPTR_IT_ID:
+ ret = it->impl.ptr.vsize;
+ break;
+
+ case STDPPTR_IT_ID:
+ ret = it->impl.pptr.vsize;
+ break;
+
+ case STDARR_IT_ID:
+ ret = stdarr_it_val_size(it);
+ break;
+
+ case STDCARR_IT_ID:
+ ret = stdcarr_it_val_size(it);
+ break;
+
+ case STDDLL_IT_ID:
+ ret = stddll_it_val_size(it);
+ break;
+
+ case STDHASH_IT_ID:
+ ret = stdhash_it_val_size(it);
+ break;
+
+ case STDHASH_IT_KEY_ID:
+ ret = stdhash_it_key_size(it);
+ break;
+
+ case STDSKL_IT_ID:
+ ret = stdskl_it_val_size(it);
+ break;
+
+ case STDSKL_IT_KEY_ID:
+ ret = stdskl_it_key_size(it);
+ break;
+
+ default:
+ ret = 0;
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdit_eq: Compare two iterators for equality (reference same element).
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdit_eq(const stdit *it1, const stdit *it2)
+{
+ stdbool ret;
+
+ STDSAFETY_CHECK(it1->type_id == it2->type_id);
+
+ switch (it1->type_id) {
+ case STDPTR_IT_ID:
+ STDSAFETY_CHECK(it1->impl.ptr.vsize == it2->impl.ptr.vsize);
+ ret = (it1->impl.ptr.val == it2->impl.ptr.val);
+ break;
+
+ case STDPPTR_IT_ID:
+ STDSAFETY_CHECK(it1->impl.pptr.ksize == it2->impl.pptr.ksize && it1->impl.pptr.vsize == it2->impl.pptr.vsize);
+ ret = (it1->impl.pptr.key == it2->impl.pptr.key && it1->impl.pptr.val == it2->impl.pptr.val);
+ break;
+
+ case STDARR_IT_ID:
+ ret = stdarr_it_eq(it1, it2);
+ break;
+
+ case STDCARR_IT_ID:
+ ret = stdcarr_it_eq(it1, it2);
+ break;
+
+ case STDDLL_IT_ID:
+ ret = stddll_it_eq(it1, it2);
+ break;
+
+ case STDHASH_IT_ID:
+ case STDHASH_IT_KEY_ID:
+ ret = stdhash_it_eq(it1, it2);
+ break;
+
+ case STDSKL_IT_ID:
+ case STDSKL_IT_KEY_ID:
+ ret = stdskl_it_eq(it1, it2);
+ break;
+
+ default:
+ ret = STDFALSE;
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdit_next: Advance an iterator towards "end" by one position.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_next(stdit *it)
+{
+ switch (it->type_id) {
+ case STDPTR_IT_ID:
+ it->impl.ptr.val += it->impl.ptr.vsize;
+ break;
+
+ case STDPPTR_IT_ID:
+ it->impl.pptr.key += it->impl.pptr.ksize;
+ it->impl.pptr.val += it->impl.pptr.vsize;
+ break;
+
+ case STDARR_IT_ID:
+ stdarr_it_next(it);
+ break;
+
+ case STDCARR_IT_ID:
+ stdcarr_it_next(it);
+ break;
+
+ case STDDLL_IT_ID:
+ stddll_it_next(it);
+ break;
+
+ case STDHASH_IT_ID:
+ case STDHASH_IT_KEY_ID:
+ stdhash_it_next(it);
+ break;
+
+ case STDSKL_IT_ID:
+ case STDSKL_IT_KEY_ID:
+ stdskl_it_next(it);
+ break;
+
+ default:
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_advance: Advance an iterator towards "end" by num_advance positions.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_advance(stdit *it, stdsize num_advance)
+{
+ switch (it->type_id) {
+ case STDPTR_IT_ID:
+ it->impl.ptr.val += it->impl.ptr.vsize * num_advance;
+ break;
+
+ case STDPPTR_IT_ID:
+ it->impl.pptr.key += it->impl.pptr.ksize * num_advance;
+ it->impl.pptr.val += it->impl.pptr.vsize * num_advance;
+ break;
+
+ case STDARR_IT_ID:
+ stdarr_it_advance(it, num_advance);
+ break;
+
+ case STDCARR_IT_ID:
+ stdcarr_it_advance(it, num_advance);
+ break;
+
+ case STDDLL_IT_ID:
+ stddll_it_advance(it, num_advance);
+ break;
+
+ case STDHASH_IT_ID:
+ case STDHASH_IT_KEY_ID:
+ stdhash_it_advance(it, num_advance);
+ break;
+
+ case STDSKL_IT_ID:
+ case STDSKL_IT_KEY_ID:
+ stdskl_it_advance(it, num_advance);
+ break;
+
+ default:
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_distance: Calculate the distance from b to e.
+ ***********************************************************************************************/
+
+STDINLINE stdssize stdit_distance(const stdit *b, const stdit *e)
+{
+ stdsize ret = 0;
+ stdit curr = *b;
+
+ switch (b->type_id) {
+ case STDPTR_IT_ID:
+ case STDPPTR_IT_ID:
+ case STDARR_IT_ID:
+ case STDCARR_IT_ID:
+ ret = stdit_cmp(e, b);
+ break;
+
+ case STDDLL_IT_ID:
+ for (; !stddll_it_eq(&curr, e); stddll_it_next(&curr), ++ret);
+ break;
+
+ case STDHASH_IT_ID:
+ case STDHASH_IT_KEY_ID:
+ for (; !stdhash_it_eq(&curr, e); stdhash_it_next(&curr), ++ret);
+ break;
+
+ case STDSKL_IT_ID:
+ case STDSKL_IT_KEY_ID:
+ for (; !stdskl_it_eq(&curr, e); stdskl_it_next(&curr), ++ret);
+ break;
+
+ default:
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdit_prev: Advance an iterator towards "begin" by one position.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_prev(stdit *it)
+{
+ switch (it->type_id) {
+ case STDPTR_IT_ID:
+ it->impl.ptr.val -= it->impl.ptr.vsize;
+ break;
+
+ case STDPPTR_IT_ID:
+ it->impl.pptr.key -= it->impl.pptr.ksize;
+ it->impl.pptr.val -= it->impl.pptr.vsize;
+ break;
+
+ case STDARR_IT_ID:
+ stdarr_it_prev(it);
+ break;
+
+ case STDCARR_IT_ID:
+ stdcarr_it_prev(it);
+ break;
+
+ case STDDLL_IT_ID:
+ stddll_it_prev(it);
+ break;
+
+ case STDHASH_IT_ID:
+ case STDHASH_IT_KEY_ID:
+ stdhash_it_prev(it);
+ break;
+
+ case STDSKL_IT_ID:
+ case STDSKL_IT_KEY_ID:
+ stdskl_it_prev(it);
+ break;
+
+ default:
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_retreat: Advance an iterator towards "begin" by num_retreat positions.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_retreat(stdit *it, stdsize num_retreat)
+{
+ switch (it->type_id) {
+ case STDPTR_IT_ID:
+ it->impl.ptr.val -= it->impl.ptr.vsize * num_retreat;
+ break;
+
+ case STDPPTR_IT_ID:
+ it->impl.pptr.key -= it->impl.pptr.ksize * num_retreat;
+ it->impl.pptr.val -= it->impl.pptr.vsize * num_retreat;
+ break;
+
+ case STDARR_IT_ID:
+ stdarr_it_retreat(it, num_retreat);
+ break;
+
+ case STDCARR_IT_ID:
+ stdcarr_it_retreat(it, num_retreat);
+ break;
+
+ case STDDLL_IT_ID:
+ stddll_it_retreat(it, num_retreat);
+ break;
+
+ case STDHASH_IT_ID:
+ case STDHASH_IT_KEY_ID:
+ stdhash_it_retreat(it, num_retreat);
+ break;
+
+ case STDSKL_IT_ID:
+ case STDSKL_IT_KEY_ID:
+ stdskl_it_retreat(it, num_retreat);
+ break;
+
+ default:
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_cmp: Compare two iterators for rank difference.
+ ***********************************************************************************************/
+
+STDINLINE stdssize stdit_cmp(const stdit *it1, const stdit *it2)
+{
+ stdssize ret;
+
+ STDSAFETY_CHECK(it1->type_id == it2->type_id);
+
+ switch (it1->type_id) {
+ case STDPTR_IT_ID:
+ STDSAFETY_CHECK(it1->impl.ptr.vsize == it2->impl.ptr.vsize);
+ ret = (it1->impl.ptr.val - it2->impl.ptr.val) / it1->impl.ptr.vsize;
+ break;
+
+ case STDPPTR_IT_ID:
+ STDSAFETY_CHECK(it1->impl.pptr.ksize == it2->impl.pptr.ksize && it1->impl.pptr.vsize == it2->impl.pptr.vsize);
+ ret = (it1->impl.pptr.key - it2->impl.pptr.key) / it1->impl.pptr.ksize;
+ STDSAFETY_CHECK(ret == (it1->impl.pptr.val - it2->impl.pptr.val) / it1->impl.pptr.vsize);
+ break;
+
+ case STDARR_IT_ID:
+ ret = stdarr_it_cmp(it1, it2);
+ break;
+
+ case STDCARR_IT_ID:
+ ret = stdcarr_it_cmp(it1, it2);
+ break;
+
+ case STDDLL_IT_ID:
+ case STDHASH_IT_ID:
+ case STDHASH_IT_KEY_ID:
+ case STDSKL_IT_ID:
+ case STDSKL_IT_KEY_ID:
+ ret = 0;
+ STDEXCEPTION(iterator type does not support stdit_cmp);
+ break;
+
+ default:
+ ret = 0;
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdit_offset: Advance an iterator towards "end" by 'offset' positions.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_offset(stdit *it, stdssize offset)
+{
+ switch (it->type_id) {
+ case STDPTR_IT_ID:
+ it->impl.ptr.val += it->impl.ptr.vsize * offset;
+ break;
+
+ case STDPPTR_IT_ID:
+ it->impl.pptr.key += it->impl.pptr.ksize * offset;
+ it->impl.pptr.val += it->impl.pptr.vsize * offset;
+ break;
+
+ case STDARR_IT_ID:
+ stdarr_it_offset(it, offset);
+ break;
+
+ case STDCARR_IT_ID:
+ stdcarr_it_offset(it, offset);
+ break;
+
+ case STDDLL_IT_ID:
+ case STDHASH_IT_ID:
+ case STDHASH_IT_KEY_ID:
+ case STDSKL_IT_ID:
+ case STDSKL_IT_KEY_ID:
+ STDEXCEPTION(iterator type does not support stdit_offset);
+ break;
+
+ default:
+ STDEXCEPTION(uninitialized or corrupted iterator);
+ break;
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_ptr: Initialize a stdit from a pointer.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_ptr(stdit *it, const void * val, stdsize vsize)
+{
+ it->impl.ptr.val = (char*) val;
+ it->impl.ptr.vsize = vsize;
+
+ it->type_id = STDPTR_IT_ID;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_pptr: Initialize a stdit from two parallel pointers.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_pptr(stdit *it, const void *key, const void * val, stdsize ksize, stdsize vsize)
+{
+ it->impl.pptr.key = (char*) key;
+ it->impl.pptr.ksize = ksize;
+
+ it->impl.pptr.val = (char*) val;
+ it->impl.pptr.vsize = vsize;
+
+ it->type_id = STDPPTR_IT_ID;
+
+ return it;
+}
Added: vendor/stdutil/current/src/stdskl.c
===================================================================
--- vendor/stdutil/current/src/stdskl.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdskl.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,1150 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <stdutil/stdutil.h>
+#include <stdutil/stderror.h>
+#include <stdutil/stdtime.h>
+#include <stdutil/stdskl.h>
+
+#define STDSKL_MAX_HEIGHT 31
+
+#define STDSKL_IS_LEGAL(l) ((l)->end_node != NULL && (l)->ksize != 0 && (l)->bits_left < 32)
+#define STDSKL_IT_IS_LEGAL(l, i) ((i)->ksize == (l)->ksize && (i)->vsize == (l)->vsize)
+#define STDIT_SKL_IS_LEGAL(i) (((i)->type_id == STDSKL_IT_ID || (i)->type_id == STDSKL_IT_KEY_ID) && \
+ (i)->impl.skl.node != NULL && (i)->impl.skl.ksize != 0)
+
+#define STDSKL_NKEY(node) ((node)->key)
+#define STDSKL_NVAL(node) ((node)->val)
+
+/************************************************************************************************
+ * stdskl_low_key_cmp: Compares 2 keys, uses memcmp if no comparison fcn defined.
+ ***********************************************************************************************/
+
+STDINLINE static int stdskl_low_key_cmp(const stdskl *l, const void *k1, const void *k2)
+{
+ return (l->cmp_fcn == NULL ? memcmp(k1, k2, l->ksize) : l->cmp_fcn(k1, k2));
+}
+
+/************************************************************************************************
+ * stdskl_low_create_node: Create a node to be inserted into 'l.'
+ ***********************************************************************************************/
+
+STDINLINE static stdskl_node *stdskl_low_create_node(stdskl *l, stdint8 height, const void *key, const void *val)
+{
+ stdskl_node * node;
+ stdsize mem_tot;
+ stdsize prevs_off;
+ stdsize nexts_off;
+ stdsize key_off;
+ stdsize val_off;
+
+ if (height == -1) { /* height generation requested */
+ stdbool keep_going = STDTRUE;
+
+ for (; keep_going && height < STDSKL_MAX_HEIGHT; ++height) { /* count how many random "on" bits we get in a row */
+
+ if (l->bits_left == 0) { /* out of random bits */
+ l->rand_bits = stdrand32(l->seed); /* generate 32 new ones */
+ l->bits_left = 32;
+ }
+
+ keep_going = ((l->rand_bits & 0x1) == 0x1); /* break loop on a "off" bit */
+
+ --l->bits_left; /* consume a bit */
+ l->rand_bits >>= 1;
+ }
+ }
+
+ /* calculate memory needed for node and pointer arrays and the offsets for the pointers in the node */
+
+ mem_tot = sizeof(stdskl_node); /* memory for node structure */
+ prevs_off = mem_tot;
+
+ mem_tot += (height + 1) * sizeof(stdskl_node*); /* memory for prevs array */
+ nexts_off = mem_tot;
+
+ mem_tot += (height + 1) * sizeof(stdskl_node*); /* memory for nexts array */
+ mem_tot = STDARCH_PADDED_SIZE(mem_tot); /* pad memory for key */
+ key_off = mem_tot;
+
+ mem_tot += STDARCH_PADDED_SIZE(l->ksize); /* memory for key and padding for value */
+ val_off = mem_tot;
+
+ mem_tot += l->vsize; /* memory for value */
+
+ /* allocate the node and extra memory */
+
+ if ((node = (stdskl_node*) malloc(mem_tot)) == NULL) {
+ goto stdskl_low_create_node_end;
+ }
+
+ /* init node: set height, point pointers to appropriate offsets in allocated memory block */
+
+ node->height = height;
+ node->prevs = (stdskl_node**) ((char*) node + prevs_off);
+ node->nexts = (stdskl_node**) ((char*) node + nexts_off);
+ node->key = (char*) node + key_off;
+ node->val = (char*) node + val_off;
+
+ /* copy key + value if given */
+
+ if (key != NULL) {
+ memcpy((void*) STDSKL_NKEY(node), key, l->ksize);
+ memcpy(STDSKL_NVAL(node), val, l->vsize);
+ }
+
+ stdskl_low_create_node_end:
+ return node;
+}
+
+/************************************************************************************************
+ * stdskl_low_find_right: Search 'l' for 'key' from left to right.
+ *
+ * If (find_any) immediately return on any match. Otherwise if 'key'
+ * exists in 'l' return the "leftmost" (least) match if multiple
+ * matches exist. On no match, returns the "leftmost" (least) entry
+ * in 'l' with a greater key, or end if no such entry.
+ ***********************************************************************************************/
+
+STDINLINE static stdbool stdskl_low_find_right(const stdskl *l, const void *key,
+ stdbool find_any, stdskl_node **pos)
+{
+ const stdskl_node * next = NULL;
+ const stdskl_node * curr = l->end_node;
+ stdint8 lvl = l->end_node->height;
+ int cmp = -1; /* get rid of compiler warning */
+
+ /* run down to bottom level */
+
+ while (lvl > 0) {
+ next = curr->nexts[lvl];
+
+ /* run right at this level while key is greater than next's key */
+
+ while (next != l->end_node &&
+ (cmp = stdskl_low_key_cmp(l, key, STDSKL_NKEY(next))) > 0) {
+ curr = next;
+ next = next->nexts[lvl];
+ }
+
+ /* if we found a match and any match will do */
+
+ if (find_any && next != l->end_node && cmp == 0) {
+ *pos = (stdskl_node*) next;
+ return STDTRUE;
+ }
+
+ /* run down curr's nexts levels while they equal next */
+
+ for (--lvl; lvl > 0 && curr->nexts[lvl] == next; --lvl);
+ }
+
+ /* lvl is zero: run right on bottom level trying to match key */
+
+ curr = curr->nexts[0];
+
+ if (curr != next) {
+
+ while (curr != l->end_node &&
+ (cmp = stdskl_low_key_cmp(l, key, STDSKL_NKEY(curr))) > 0) {
+ curr = curr->nexts[0];
+ }
+ } /* else we already compared key to curr above */
+
+ *pos = (stdskl_node*) curr;
+
+ return (curr != l->end_node && cmp == 0);
+}
+
+/************************************************************************************************
+ * stdskl_low_find_left: Search 'l' for 'key' from right to left.
+ *
+ * If (find_any) immediately return on any match. Otherwise if 'key'
+ * exists in 'l' return the "rightmost" (greatest) match if multiple
+ * matches exist. On no match, returns the "rightmost" (greatest)
+ * entry in 'l' with a lesser key, or end if no such entry.
+ ***********************************************************************************************/
+
+STDINLINE static stdbool stdskl_low_find_left(const stdskl *l, const void *key,
+ stdbool find_any, stdskl_node **pos)
+{
+ const stdskl_node * prev = NULL;
+ const stdskl_node * curr = l->end_node;
+ stdint8 lvl = l->end_node->height;
+ int cmp = -1; /* get rid of compiler warning */
+
+ /* run down to bottom level */
+
+ while (lvl > 0) {
+ prev = curr->prevs[lvl];
+
+ /* run left at this level while key is less than prev's key */
+
+ while (prev != l->end_node &&
+ (cmp = stdskl_low_key_cmp(l, key, STDSKL_NKEY(prev))) < 0) {
+ curr = prev;
+ prev = prev->prevs[lvl];
+ }
+
+ /* if we found a match and any match will do */
+
+ if (find_any && prev != l->end_node && cmp == 0) {
+ *pos = (stdskl_node*) prev;
+ return STDTRUE;
+ }
+
+ /* run down curr's prevs levels while they equal prev */
+
+ for (--lvl; lvl > 0 && curr->prevs[lvl] == prev; --lvl);
+ }
+
+ /* run left on bottom level trying to match key */
+
+ curr = curr->prevs[0];
+
+ if (curr != prev) {
+
+ while (curr != l->end_node &&
+ (cmp = stdskl_low_key_cmp(l, key, STDSKL_NKEY(curr))) < 0) {
+ curr = curr->prevs[0];
+ }
+ } /* else we already compared key to curr above */
+
+ *pos = (stdskl_node*) curr;
+
+ return (curr != l->end_node && cmp == 0);
+}
+
+/************************************************************************************************
+ * stdskl_low_link_right: Link 'node' into entries greater than or
+ * equal to 'ins_pos' in 'l.'
+ ***********************************************************************************************/
+
+STDINLINE static void stdskl_low_link_right(const stdskl *l, stdskl_node *ins_pos, stdskl_node *node)
+{
+ stdskl_node * next = ins_pos;
+ stdint8 height = node->height;
+ stdint8 lvl = 0;
+
+ node->nexts[0] = next;
+ next->prevs[0] = node;
+
+ while (lvl != height) {
+
+ /* if we've maxed out next's height, then find a later, taller node on this lvl */
+
+ while (lvl == next->height) { /* NOTE: node->height <= end_node->height -> lvl < end_node->height here */
+ next = next->nexts[lvl]; /* so we can't erroneously wrap around past sentinel end node here */
+ }
+
+ ++lvl;
+ node->nexts[lvl] = next;
+ next->prevs[lvl] = node;
+ }
+}
+
+/************************************************************************************************
+ * stdskl_low_link_left: Link in 'node' to entries less than 'ins_pos'
+ * in 'l.'
+ ***********************************************************************************************/
+
+STDINLINE static void stdskl_low_link_left(const stdskl *l, stdskl_node *ins_pos, stdskl_node *node)
+{
+ stdskl_node * prev = ins_pos->prevs[0]; /* NOTE: this is why we must link_left b4 link_right */
+ stdint8 height = node->height;
+ stdint8 lvl = 0;
+
+ node->prevs[0] = prev;
+ prev->nexts[0] = node;
+
+ while (lvl != height) {
+
+ /* if we've maxed out prev's height, then find an earlier, taller node on this lvl */
+
+ while (lvl == prev->height) { /* NOTE: node->height <= end_node->height -> lvl < end_node->height here */
+ prev = prev->prevs[lvl]; /* so we can't erroneously wrap around past sentinel end node here */
+ }
+
+ ++lvl;
+ node->prevs[lvl] = prev;
+ prev->nexts[lvl] = node;
+ }
+}
+
+/************************************************************************************************
+ * stdskl_low_insert: Insert multiple keys and values into a list
+ * using an iterator sequence with various options.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdskl_low_insert(stdskl *l, stdit *it, const stdit *b, const stdit *e, stdsize num_ins,
+ stdbool hint, stdbool overwrite, stdbool advance)
+{
+ stdcode ret = STDESUCCESS;
+ stdskl_node * node;
+ stdskl_node * prev;
+ stdskl_node * next = (it != NULL ? it->impl.skl.node : l->end_node);
+ stdskl_node * first_ins = NULL;
+ stdit src_it = *b;
+ stdbool keyed = (stdit_key_size(b) != 0);
+ stdint8 lvl;
+ const void * key;
+ const void * val;
+ int cmp;
+
+ /* loop over input sequence defined either by [b, b+num_ins) or [b, e) */
+
+ while (num_ins-- != 0 && (e == NULL || !stdit_eq(&src_it, e))) {
+
+ /* get pointers to the key and value we are about to insert */
+
+ val = stdit_val(&src_it);
+ key = (keyed ? stdit_key(&src_it) : val);
+ cmp = -1;
+
+ /* get insertion position for this key */
+
+ if (hint) { /* 'next' is a potential insertion point -> verify! */
+ prev = next->prevs[0];
+
+ if ((next != l->end_node && (cmp = stdskl_low_key_cmp(l, key, STDSKL_NKEY(next))) > 0) ||
+ (prev != l->end_node && stdskl_low_key_cmp(l, key, STDSKL_NKEY(prev)) < 0)) {
+
+ prev = next;
+ next = next->nexts[0]; /* next was inappropriate; try ++next */
+ cmp = -1;
+
+ if ((next != l->end_node && (cmp = stdskl_low_key_cmp(l, key, STDSKL_NKEY(next))) > 0) ||
+ (prev != l->end_node && stdskl_low_key_cmp(l, key, STDSKL_NKEY(prev)) < 0)) {
+ hint = STDFALSE; /* both next and ++next were inappropriate: do a full search */
+ }
+ }
+ }
+
+ if (!hint) {
+ cmp = !stdskl_low_find_right(l, key, STDTRUE, &next);
+ }
+
+ hint = STDTRUE; /* use next as a hint for following iteration (optimize for nearly contiguous, sorted inserts) */
+
+ if (!overwrite || next == l->end_node || cmp != 0) { /* create new node to insert */
+
+ if ((node = stdskl_low_create_node(l, -1, key, val)) == NULL) { /* create a node with a random height */
+ ret = STDENOMEM;
+ goto stdskl_low_insert_end;
+ }
+
+ /* ensure that l->end_node is at least as tall as the new node */
+
+ if (node->height > l->end_node->height) {
+ stdskl_node * new_end;
+
+ /* ratchet up new end_node's height to be at least 2 levels higher than before if not already at max height */
+
+ lvl = node->height;
+
+ if (lvl < STDSKL_MAX_HEIGHT) {
+ ++lvl;
+ }
+
+ if ((new_end = stdskl_low_create_node(l, lvl, NULL, NULL)) == NULL) {
+ ret = STDENOMEM;
+ goto stdskl_low_insert_fail;
+ }
+
+ /* set new_end's nexts and prevs and correct nodes ref'ing end to new_end */
+
+ lvl = 0;
+ do {
+ new_end->prevs[lvl] = l->end_node->prevs[lvl];
+ new_end->prevs[lvl]->nexts[lvl] = new_end;
+
+ new_end->nexts[lvl] = l->end_node->nexts[lvl];
+ new_end->nexts[lvl]->prevs[lvl] = new_end;
+
+ } while (lvl++ != l->end_node->height);
+
+ /* set additional lvls in new_end to be self-referencing */
+
+ do {
+ new_end->prevs[lvl] = new_end;
+ new_end->nexts[lvl] = new_end;
+
+ } while (lvl++ != new_end->height);
+
+ /* correct next if it referenced the old end */
+
+ if (next == l->end_node) {
+ next = new_end;
+ }
+
+ free(l->end_node);
+ l->end_node = new_end;
+ }
+
+ /* link 'node' into list before next */
+
+ stdskl_low_link_left(l, next, node); /* NOTE: we must link_left before we link_right due to loss of information */
+ stdskl_low_link_right(l, next, node);
+
+ ++l->size;
+
+ } else { /* overwrite existing match */
+ node = next;
+ memcpy((void*) STDSKL_NKEY(node), key, l->ksize); /* overwrite */
+ memcpy(STDSKL_NVAL(node), val, l->vsize);
+ }
+
+ /* remember first insertion */
+
+ if (first_ins == NULL) {
+ first_ins = node;
+ }
+
+ /* advance 'src_it' if so instructed */
+
+ if (advance) {
+ stdit_next(&src_it);
+ }
+ }
+
+ if (first_ins == NULL) { /* empty input sequence, set 'it' to end */
+ first_ins = l->end_node;
+ }
+
+ goto stdskl_low_insert_end;
+
+ /* error handling and return */
+
+ stdskl_low_insert_fail:
+ free(node);
+
+ stdskl_low_insert_end:
+ if (first_ins != NULL && it != NULL) { /* at least one insertion succeeded or empty input sequence */
+ it->type_id = STDSKL_IT_ID;
+ it->impl.skl.node = first_ins;
+ it->impl.skl.ksize = l->ksize;
+ it->impl.skl.vsize = l->vsize;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdskl_low_erase: Erase multiple key-value pairs from a list using
+ * either an iterator sequence to delete or a number of elements to
+ * erase.
+ ***********************************************************************************************/
+
+STDINLINE static void stdskl_low_erase(stdskl *l, stdit *b, stdit *e, stdsize num_erase)
+{
+ stdskl_node * ers;
+ stdskl_node * prev = b->impl.skl.node->prevs[0];
+ stdskl_node * next = b->impl.skl.node;
+ stdskl_node * end_node = (e != NULL ? e->impl.skl.node : NULL);
+ stdint8 max_lvl = 0;
+ stdsize erased;
+ stdint8 lvl;
+
+ /* go through [b, b+num_erase) or [b, e) free'ing nodes -- record
+ max height of free'd nodes and how many nodes we erased
+ */
+
+ for (erased = 0; erased != num_erase && next != end_node; ++erased) {
+ STDBOUNDS_CHECK(next != l->end_node);
+
+ if (next->height > max_lvl) {
+ max_lvl = next->height;
+ }
+
+ ers = next;
+ next = next->nexts[0];
+ free(ers);
+ }
+
+ /* update list size */
+
+ l->size -= num_erase;
+
+ /* stitch together the left and right portions of the list */
+
+ ers = next; /* remember where erasure stopped */
+ prev->nexts[0] = next; /* perform base re-linkage */
+ next->prevs[0] = prev;
+
+ for (lvl = 0; lvl != max_lvl; ) { /* run left and run right up to max_lvl height nodes re-linking */
+
+ while (lvl == prev->height) {
+ prev = prev->prevs[lvl];
+ }
+
+ while (lvl == next->height) {
+ next = next->nexts[lvl];
+ }
+
+ ++lvl;
+ prev->nexts[lvl] = next;
+ next->prevs[lvl] = prev;
+ }
+
+ /* advance 'b' and 'e' */
+
+ b->impl.skl.node = ers;
+
+ if (e != NULL) {
+ e->impl.skl.node = ers;
+ }
+}
+
+/************************************************************************************************
+ * stdskl_construct: Construct an initially empty list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_construct(stdskl *l, stdsize ksize, stdsize vsize, stdcmp_fcn kcmp)
+{
+ stdcode ret = STDESUCCESS;
+ stdint8 lvl;
+ stdtime t;
+
+ if (ksize != 0) {
+ ret = STDEINVAL;
+ goto stdskl_construct_fail;
+ }
+
+ /* allocate and init end_node */
+
+ if ((l->end_node = stdskl_low_create_node(l, 4, NULL, NULL)) == NULL) {
+ ret = STDENOMEM;
+ goto stdskl_construct_fail;
+ }
+
+ /* make end_node reference itself */
+
+ lvl = l->end_node->height;
+
+ do {
+ l->end_node->nexts[lvl] = l->end_node;
+ l->end_node->prevs[lvl] = l->end_node;
+
+ } while (lvl-- != 0);
+
+ l->size = 0;
+ l->ksize = ksize;
+ l->vsize = vsize;
+ l->cmp_fcn = kcmp;
+
+ /* initialize randomization using current system time w/ subsecond precision */
+
+ stdtime_now(&t);
+ stdskl_dseed(l, &t, sizeof(t));
+
+ goto stdskl_construct_end;
+
+ /* error handling and return */
+
+ stdskl_construct_fail:
+ l->end_node = NULL;
+ l->ksize = 0; /* make STDSKL_IS_LEGAL(l) false */
+
+ stdskl_construct_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdskl_copy_construct: Construct a copy of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_copy_construct(stdskl *dst, const stdskl *src)
+{
+ stdcode ret;
+ stdit it;
+ stdit dend;
+
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(src));
+
+ if ((ret = stdskl_construct(dst, src->ksize, src->vsize, src->cmp_fcn)) != STDESUCCESS) {
+ goto stdskl_copy_construct_fail;
+ }
+
+ if ((ret = stdskl_insert_seq_n(dst, stdskl_end(dst, &dend), stdskl_begin(src, &it), src->size, STDTRUE)) != STDESUCCESS) {
+ goto stdskl_copy_construct_fail2;
+ }
+
+ goto stdskl_copy_construct_end;
+
+ /* error handling and return */
+
+ stdskl_copy_construct_fail2:
+ stdskl_destruct(dst);
+
+ stdskl_copy_construct_fail:
+ dst->end_node = NULL;
+ dst->ksize = 0; /* make STDSKL_IS_LEGAL(dst) false */
+
+ stdskl_copy_construct_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdskl_destruct: Reclaim a list's resources and invalidate it.
+ ***********************************************************************************************/
+
+STDINLINE void stdskl_destruct(stdskl *l)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ stdskl_clear(l);
+ free(l->end_node);
+
+ l->end_node = NULL;
+ l->ksize = 0; /* make STDSKL_IS_LEGAL(l) false */
+}
+
+/************************************************************************************************
+ * stdskl_set_eq: Set a list to contain the same contents as another.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_set_eq(stdskl *dst, const stdskl *src)
+{
+ stdcode ret;
+ stdskl cpy;
+
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(dst) && STDSKL_IS_LEGAL(src));
+
+ if ((ret = stdskl_copy_construct(&cpy, src)) != STDESUCCESS) {
+ goto stdskl_set_eq_end;
+ }
+
+ stdskl_swap(dst, &cpy);
+ stdskl_destruct(&cpy);
+
+ stdskl_set_eq_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdskl_swap: Set a l1 to reference l2's sequence and vice versa.
+ ***********************************************************************************************/
+
+STDINLINE void stdskl_swap(stdskl *l1, stdskl *l2)
+{
+ stdskl cpy;
+
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l1) && STDSKL_IS_LEGAL(l2));
+
+ STDSWAP(*l1, *l2, cpy);
+}
+
+/************************************************************************************************
+ * stdskl_begin: Get an iterator to the beginning of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdskl_begin(const stdskl *l, stdit *it)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ it->type_id = STDSKL_IT_ID;
+ it->impl.skl.node = l->end_node->nexts[0];
+ it->impl.skl.ksize = l->ksize;
+ it->impl.skl.vsize = l->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdskl_last: Get an iterator to the last element of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdskl_last(const stdskl *l, stdit *it)
+{
+ STDBOUNDS_CHECK(l->size != 0);
+
+ return stdit_prev(stdskl_end(l, it));
+}
+
+/************************************************************************************************
+ * stdskl_end: Get an iterator to the sentinel end of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdskl_end(const stdskl *l, stdit *it)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ it->type_id = STDSKL_IT_ID;
+ it->impl.skl.node = l->end_node;
+ it->impl.skl.ksize = l->ksize;
+ it->impl.skl.vsize = l->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdskl_get: Get an iterator to an element of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdskl_get(const stdskl *l, stdit *it, stdsize elem_num)
+{
+ STDBOUNDS_CHECK(elem_num <= l->size);
+
+ if (elem_num < (l->size >> 1)) {
+ stdskl_it_advance(stdskl_begin(l, it), elem_num);
+
+ } else {
+ stdskl_it_retreat(stdskl_end(l, it), l->size - elem_num);
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdskl_is_begin: Return whether or not an iterator refers to the beginning of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdskl_is_begin(const stdskl *l, const stdit *it)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) && STDIT_SKL_IS_LEGAL(it) && STDSKL_IT_IS_LEGAL(l, &it->impl.skl));
+
+ return it->impl.skl.node == l->end_node->nexts[0];
+}
+
+/************************************************************************************************
+ * stdskl_is_end: Return whether or not an iterator refers to the end of a list.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdskl_is_end(const stdskl *l, const stdit *it)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) && STDIT_SKL_IS_LEGAL(it) && STDSKL_IT_IS_LEGAL(l, &it->impl.skl));
+
+ return it->impl.skl.node == l->end_node;
+}
+
+/************************************************************************************************
+ * stdskl_size: Return the number of key-value pairs a list contains.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdskl_size(const stdskl *l)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ return l->size;
+}
+
+/************************************************************************************************
+ * stdskl_empty: Return whether or not a list's size is zero.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdskl_empty(const stdskl *l)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ return l->size == 0;
+}
+
+/************************************************************************************************
+ * stdskl_clear: Set a lists size to zero.
+ ***********************************************************************************************/
+
+STDINLINE void stdskl_clear(stdskl *l)
+{
+ stdskl_node * curr;
+ stdskl_node * prev;
+ stdint8 lvl;
+
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ /* run through list destroying all nodes */
+
+ for (curr = l->end_node->nexts[0]; curr != l->end_node; ) {
+ prev = curr;
+ curr = curr->nexts[0];
+ free(prev);
+ }
+
+ /* fix list entries: end_node and size */
+
+ curr = l->end_node;
+ lvl = l->end_node->height;
+
+ do {
+ curr->prevs[lvl] = curr;
+ curr->nexts[lvl] = curr;
+
+ } while (lvl-- != 0);
+
+ l->size = 0;
+}
+
+/************************************************************************************************
+ * stdskl_find: Find a key-value pair in a list.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdskl_find(const stdskl *l, stdit *it, const void *key)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ if (!stdskl_low_find_right(l, key, STDTRUE, &it->impl.skl.node)) {
+ it->impl.skl.node = l->end_node;
+ }
+
+ it->type_id = STDSKL_IT_ID;
+ it->impl.skl.ksize = l->ksize;
+ it->impl.skl.vsize = l->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdskl_lowerb: Find the least element for which kcmp(key, elem) >= 0.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdskl_lowerb(const stdskl *l, stdit *it, const void *key)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ stdskl_low_find_right(l, key, STDFALSE, &it->impl.skl.node);
+
+ it->type_id = STDSKL_IT_ID;
+ it->impl.skl.ksize = l->ksize;
+ it->impl.skl.vsize = l->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdskl_upperb: Find the least element for which kcmp(key, elem) > 0.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdskl_upperb(const stdskl *l, stdit *it, const void *key)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ stdskl_low_find_left(l, key, STDFALSE, &it->impl.skl.node);
+ it->impl.skl.node = it->impl.skl.node->nexts[0]; /* found either the last entry for key or the prev entry if none: so get next */
+
+ it->type_id = STDSKL_IT_ID;
+ it->impl.skl.ksize = l->ksize;
+ it->impl.skl.vsize = l->vsize;
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdskl_contains: Return whether or not a list contains a certain key.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdskl_contains(const stdskl *l, const void *key)
+{
+ stdskl_node * n;
+
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ return stdskl_low_find_right(l, key, STDTRUE, &n);
+}
+
+/************************************************************************************************
+ * stdskl_put: If 'key' already exists in the list, overwrite such an
+ * entry with 'key' and 'value;' otherwise insert 'key' and 'value'
+ * into the list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_put(stdskl *l, stdit *it, const void *key, const void *val, stdbool hint)
+{
+ return stdskl_put_n(l, it, key, val, 1, hint);
+}
+
+/************************************************************************************************
+ * stdskl_put_n: For each (key, val) in [(keys, vals), (keys+num_put, vals+num_put))
+ * perform stdskl_put(l, it, key, val).
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_put_n(stdskl *l, stdit *it, const void *keys, const void *vals, stdsize num_put, stdbool hint)
+{
+ stdit b;
+
+ return stdskl_put_seq_n(l, it, stdit_pptr(&b, keys, vals, l->ksize, l->vsize), num_put, hint);
+}
+
+/************************************************************************************************
+ * stdskl_put_seq: For each (key, val) in [b, e) perform
+ * stdskl_put(l, it, key, val).
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_put_seq(stdskl *l, stdit *it, const stdit *b, const stdit *e, stdbool hint)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) && (stdit_eq(b, e) || STDTRUE) &&
+ (!hint || (it != NULL && STDIT_SKL_IS_LEGAL(it) && STDSKL_IT_IS_LEGAL(l, &it->impl.skl))) &&
+ (stdit_key_size(b) == l->ksize || (stdit_key_size(b) == 0 && stdit_val_size(b) == l->ksize)) &&
+ (stdit_val_size(b) == l->vsize || l->vsize == 0));
+
+ return stdskl_low_insert(l, it, b, e, (stdsize) -1, hint, STDTRUE, STDTRUE);
+}
+
+/************************************************************************************************
+ * stdskl_put_seq_n: For each (key, val) in [b, b+num_put) perform
+ * stdskl_put(l, it, key, val).
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_put_seq_n(stdskl *l, stdit *it, const stdit *b, stdsize num_put, stdbool hint)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) &&
+ (!hint || (it != NULL && STDIT_SKL_IS_LEGAL(it) && STDSKL_IT_IS_LEGAL(l, &it->impl.skl))) &&
+ (stdit_key_size(b) == l->ksize || (stdit_key_size(b) == 0 && stdit_val_size(b) == l->ksize)) &&
+ (stdit_val_size(b) == l->vsize || l->vsize == 0));
+
+ return stdskl_low_insert(l, it, b, NULL, num_put, hint, STDTRUE, STDTRUE);
+}
+
+/************************************************************************************************
+ * stdskl_insert: Insert a key and value into a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_insert(stdskl *l, stdit *it, const void *key, const void *val, stdbool hint)
+{
+ return stdskl_insert_n(l, it, key, val, 1, hint);
+}
+
+/************************************************************************************************
+ * stdskl_insert_n: Insert multiple keys and values into a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_insert_n(stdskl *l, stdit *it, const void *keys, const void *vals, stdsize num_insert, stdbool hint)
+{
+ stdit b;
+
+ return stdskl_insert_seq_n(l, it, stdit_pptr(&b, keys, vals, l->ksize, l->vsize), num_insert, hint);
+}
+
+/************************************************************************************************
+ * stdskl_insert_seq: Insert a sequence of key-value pairs into a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_insert_seq(stdskl *l, stdit *it, const stdit *b, const stdit *e, stdbool hint)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) && (stdit_eq(b, e) || STDTRUE) &&
+ (!hint || (it != NULL && STDIT_SKL_IS_LEGAL(it) && STDSKL_IT_IS_LEGAL(l, &it->impl.skl))) &&
+ (stdit_key_size(b) == l->ksize || (stdit_key_size(b) == 0 && stdit_val_size(b) == l->ksize)) &&
+ (stdit_val_size(b) == l->vsize || l->vsize == 0));
+
+ return stdskl_low_insert(l, it, b, e, (stdsize) -1, hint, STDFALSE, STDTRUE);
+}
+
+/************************************************************************************************
+ * stdskl_insert_seq_n: Insert a sequence of key-value pairs into a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_insert_seq_n(stdskl *l, stdit *it, const stdit *b, stdsize num_insert, stdbool hint)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) &&
+ (!hint || (it != NULL && STDIT_SKL_IS_LEGAL(it) && STDSKL_IT_IS_LEGAL(l, &it->impl.skl))) &&
+ (stdit_key_size(b) == l->ksize || (stdit_key_size(b) == 0 && stdit_val_size(b) == l->ksize)) &&
+ (stdit_val_size(b) == l->vsize || l->vsize == 0));
+
+ return stdskl_low_insert(l, it, b, NULL, num_insert, hint, STDFALSE, STDTRUE);
+}
+
+/************************************************************************************************
+ * stdskl_insert_rep: Repeatedly insert a key-value pair into a list.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdskl_insert_rep(stdskl *l, stdit *it, const void *key, const void *val, stdsize num_times, stdbool hint)
+{
+ stdit b;
+
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) && (!hint || (it != NULL && STDIT_SKL_IS_LEGAL(it) && STDSKL_IT_IS_LEGAL(l, &it->impl.skl))));
+
+ return stdskl_low_insert(l, it, stdit_pptr(&b, key, val, l->ksize, l->vsize), NULL, num_times, hint, STDFALSE, STDFALSE);
+}
+
+/************************************************************************************************
+ * stdskl_erase: Erase a key-value pair from a list.
+ ***********************************************************************************************/
+
+STDINLINE void stdskl_erase(stdskl *l, stdit *it)
+{
+ stdskl_erase_n(l, it, 1);
+}
+
+/************************************************************************************************
+ * stdskl_erase_n: Erase multiple key-value pairs from a list.
+ ***********************************************************************************************/
+
+STDINLINE void stdskl_erase_n(stdskl *l, stdit *it, stdsize num_erase)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) && STDIT_SKL_IS_LEGAL(it) && STDSKL_IT_IS_LEGAL(l, &it->impl.skl));
+
+ stdskl_low_erase(l, it, NULL, num_erase);
+}
+
+/************************************************************************************************
+ * stdskl_erase_seq: Erase a sequence from a list.
+ ***********************************************************************************************/
+
+STDINLINE void stdskl_erase_seq(stdskl *l, stdit *b, stdit *e)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) && STDIT_SKL_IS_LEGAL(b) && STDSKL_IT_IS_LEGAL(l, &b->impl.skl) && (stdit_eq(b, e) || STDTRUE));
+
+ stdskl_low_erase(l, b, e, (stdsize) -1);
+}
+
+/************************************************************************************************
+ * stdskl_erase_key: Erase all entries of a key from a list.
+ ***********************************************************************************************/
+
+STDINLINE void stdskl_erase_key(stdskl *l, const void *key)
+{
+ stdit it;
+
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ stdskl_lowerb(l, &it, key);
+
+ for (; !stdskl_is_end(l, &it) && stdskl_low_key_cmp(l, key, STDSKL_NKEY(it.impl.skl.node)) == 0;) {
+ stdskl_erase(l, &it); /* advances 'it' */
+ }
+}
+
+/************************************************************************************************
+ * stdskl_dseed: Set a skiplist's random number generator with a deterministic value.
+ ***********************************************************************************************/
+
+STDINLINE void stdskl_dseed(stdskl *l, const void *seed, stdsize sizeof_seed)
+{
+ STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
+
+ stdrand32_dseed(l->seed, stdhcode_sfh(seed, sizeof_seed));
+ l->bits_left = 0;
+}
+
+/************************************************************************************************
+ * stdit_key: Get a key from an iterator.
+ ***********************************************************************************************/
+
+STDINLINE const void *stdit_key(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
+
+ return STDSKL_NKEY(it->impl.skl.node);
+}
+
+/************************************************************************************************
+ * stdit_key_size: Get the size in bytes of the keys to which 'it' refers.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdit_key_size(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
+
+ return it->impl.skl.ksize;
+}
+
+/************************************************************************************************
+ * stdit_val: Get a value from an iterator.
+ ***********************************************************************************************/
+
+STDINLINE void *stdit_val(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
+
+ return STDSKL_NVAL(it->impl.skl.node);
+}
+
+/************************************************************************************************
+ * stdit_val_size: Get the size in bytes of the values to which 'it' refers.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdit_val_size(const stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
+
+ return it->impl.skl.vsize;
+}
+
+/************************************************************************************************
+ * stdit_eq: Compare two iterators for equality (refer to the same element).
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdit_eq(const stdit *it1, const stdit *it2)
+{
+ STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it1) && STDIT_SKL_IS_LEGAL(it2) &&
+ it1->impl.skl.ksize == it2->impl.skl.ksize &&
+ it1->impl.skl.vsize == it2->impl.skl.vsize);
+
+ return it1->impl.skl.node == it2->impl.skl.node;
+}
+
+/************************************************************************************************
+ * stdit_next: Advance 'it' towards end by one position.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_next(stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
+
+ it->impl.skl.node = it->impl.skl.node->nexts[0];
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_advance: Advance 'it' towards end by 'num_advance' positions.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_advance(stdit *it, stdsize num_advance)
+{
+ STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
+
+ while (num_advance-- != 0) {
+ it->impl.skl.node = it->impl.skl.node->nexts[0];
+ }
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_prev: Advance 'it' towards begin by one position.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_prev(stdit *it)
+{
+ STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
+
+ it->impl.skl.node = it->impl.skl.node->prevs[0];
+
+ return it;
+}
+
+/************************************************************************************************
+ * stdit_retreat: Advance 'it' towards end by 'num_retreat' positions.
+ ***********************************************************************************************/
+
+STDINLINE stdit *stdit_retreat(stdit *it, stdsize num_retreat)
+{
+ STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
+
+ while (num_retreat-- != 0) {
+ it->impl.skl.node = it->impl.skl.node->prevs[0];
+ }
+
+ return it;
+}
Added: vendor/stdutil/current/src/stdtest/stdarr_test.c
===================================================================
--- vendor/stdutil/current/src/stdtest/stdarr_test.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdtest/stdarr_test.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,761 @@
+/* Copyright (c) 2000, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <time.h>
+#include <stdutil/stdarr.h>
+#include <stdutil/stddll.h>
+#include <stdutil/stderror.h>
+
+/* This program runs a probabilistic test of the stdarr data
+ structure. It picks a stdarr operation to perform randomly (see
+ probabilities of operations below) and then performs the same
+ operation on a stdarr and also on a stddll. A stddll has almost the
+ exact same interface as a stdarr, but has been tested elsewhere and
+ is considered to be correctly implemented. As different operations
+ change the stdarr it is compared, occasionally, against the stddll
+ to see that they are still exactly the same. The most obvious of
+ these equality checks is performed in the TOTAL_CHECK_OP operation.
+*/
+
+/* TODO: don't use rand() use stdrand32() and report what the seed
+ was. This should help with reproducibility on different systems, where
+ rand() may be implemented differently.
+*/
+
+/* uncomment and comment other line to turn debug printfs on or off */
+/* # define DEBUG(x) x */
+# define DEBUG(x)
+
+/* parameters for running tests:
+ Num_ops - how many operations should be run
+ Max_size - maximum size to which the sequences should grow
+ Max_delta - maximum number of values added or removed in one operation
+ Rand_seed - seed used for random number generator (see usage())
+*/
+static long Num_ops, Max_size, Max_delta, Rand_seed;
+
+/* defaults for running test if command line parameters aren't passed */
+#define DEFAULT_NUM_OPS 100000L
+#define DEFAULT_MAX_SIZE 10000L
+#define DEFAULT_MAX_DELTA 2000L
+#define DEFAULT_RAND_SEED -1L
+
+/* global used for multi-inserts and repeat-inserts, Tmp_array is
+ allocated to contain Max_delta values by usage(). Tmp_array[0] is
+ used for repeat inserts (see handle_structural_op()).
+*/
+static int *Tmp_array = 0;
+
+/* types of basic operations to perform - also offset into base_ops_probs probability array */
+typedef enum {
+ STRUCTURAL_OP = 0, TOTAL_CHECK_OP, ITERATOR_OP, CONSTRUCT_OP, NUM_BASE_OPS
+} base_op_type;
+
+/* probabilites of basic operations being performed */
+static float base_ops_probs[NUM_BASE_OPS] = { .7, .05, .248, .002 };
+/* for debugging */
+/* static float base_ops_probs[NUM_BASE_OPS] = { 1.0 }; */
+
+/* pre-declarations of handler fcns for each of the base operations */
+static void handle_structural_op(stdarr *arr, stdarr_it *arr_it, stddll *list,
+ stddll_it *list_it, int *it_index, stdbool *it_good);
+
+static void handle_total_op(const stdarr *arr, const stddll *list);
+
+static void handle_iterator_op(stdarr *arr, stdarr_it *arr_it, stddll *list,
+ stddll_it *list_it, int *it_index, stdbool *it_good);
+
+static void handle_construct_op(stdarr *arr_dst, const stdarr *arr_src, stdarr_it *arr_it,
+ stddll *list_dst, const stddll *list_src, stddll_it *list_it,
+ int *it_index, stdbool *it_good);
+
+/* types of structural operations to perform - also offset into structural_ops_probs probability array */
+/* based on assumption that non-multi operations are performed by calling multi operations or vice-versa */
+typedef enum {
+ MERASE = 0, MINSERT, RINSERT, MPUSH_FRONT, MPOP_FRONT,
+ MPUSH_BACK, MPOP_BACK, RESIZE, CLEAR, NUM_STRUCTURAL_OPS
+} structural_op_type;
+
+/* probabilites of structural ops being performed */
+static float structural_ops_probs[NUM_STRUCTURAL_OPS] = { .3, .15, .15, .095, .095,
+ .063, .063, .064, .02 };
+
+/* types of iterator operations to perform - also offset into iterator_ops_probs probability array */
+typedef enum {
+ IT_ADVANCE = 0, IT_RETREAT, IT_NEXT, IT_PREV, IT_BEGIN,
+ IT_END, IT_LAST, IT_SEEK_BEGIN, IT_SEEK_END, NUM_ITERATOR_OPS
+} iterator_op_type;
+
+/* probabilites of iterator operations being performed */
+static float iterator_ops_probs[NUM_ITERATOR_OPS] = { .3, .3, .175, .175, .01, .01, .01, .01, .01 };
+
+/* types of construct operations to perform - also offset into construct_ops_probs probability array */
+typedef enum {
+ CONSTRUCT = 0, COPY_CONSTRUCT, NUM_CONSTRUCT_OPS
+} construct_op_type;
+
+/* probabilites of constructor operations being performed */
+static float construct_ops_probs[NUM_CONSTRUCT_OPS] = { .5, .5 };
+
+/* get_event - based on the probabilties in a probability array and the random number prob, this fcn
+ will return a number in the range [0, probs_size) signifying which event was chosen to occur
+ probs_array - a float array of probs_size independent probabilites for events to occur
+ - the sum of probabilities of the first (probs_size - 1) events should sum to <= 1.0, if not exit()
+ - the probability of the last event in the array occurring is defined to be 1.0 - (sum of prev
+ events), meaning that the probability of the last event in the array is ignored
+ probs_size - positive integer (zero is illegal) of how many events can occur
+ prob - a uniform random float in range [0.0, 1.0]
+*/
+static inline int get_event(float *probs_array, int probs_size, float prob) {
+ float run_tot = 0.0;
+ int i;
+
+ if (probs_size <= 0)
+ exit(fprintf(stderr, "get_event: probability array size must be a positive integer, probs_size: %d\n",
+ probs_size));
+
+ if (prob < 0.0 || prob > 1.0)
+ exit(fprintf(stderr, "get_event: passed probability not in range [0.0, 1.0] was %f\n", prob));
+
+ probs_size -= 1;
+ for (i = 0; i < probs_size; ++i) {
+ if ((run_tot += probs_array[i]) > 1.0)
+ exit(fprintf(stderr, "get_event: illegal probability array!\n"
+ "\tSum of probs of first %d events greather than 1.0! Sum prob was %f\n", i, run_tot));
+
+ if (run_tot >= prob)
+ return i;
+ }
+ return i;
+}
+
+/* same as get_event except it generates a random number (rand()) for the event probability */
+static inline int get_rand_event(float *probs_array, int probs_size) {
+ return get_event(probs_array, probs_size, (float) rand() / RAND_MAX);
+}
+
+/* return a random base_op_type based off of probabilties in base_ops_probs */
+static inline base_op_type get_rand_base_op() {
+ return (base_op_type) get_rand_event(base_ops_probs, NUM_BASE_OPS);
+}
+
+/* return a random structural_op_type based off of probabilties in structural_ops_probs */
+static inline structural_op_type get_rand_structural_op() {
+ return (structural_op_type) get_rand_event(structural_ops_probs, NUM_STRUCTURAL_OPS);
+}
+
+/* return a random iterator_op_type based off of probabilties in iterator_ops_probs */
+static inline iterator_op_type get_rand_iterator_op() {
+ return (iterator_op_type) get_rand_event(iterator_ops_probs, NUM_ITERATOR_OPS);
+}
+
+/* return a random construct_op_type based off of probabilties in construct_ops_probs */
+static inline construct_op_type get_rand_construct_op() {
+ return (construct_op_type) get_rand_event(construct_ops_probs, NUM_CONSTRUCT_OPS);
+}
+
+/* simply print how to run the program to stderr and then exit */
+static void usage_and_exit(const char *exe) {
+ exit(fprintf(stderr,
+ "\nUsage: %s [NUM_OPS=%ld] [MAX_SIZE=%ld] [MAX_DELTA=%ld] [RAND_SEED=%ld]\n"
+ "\tTo set later parameters you must set all previous parameters.\n\n"
+ "\tNUM_OPS - how many random operations should be performed.\n"
+ "\tMAX_SIZE - the maximum number of values the sequences should ever contain.\n"
+ "\tMAX_DELTA - the maximum number of values ever inserted or deleted at once.\n"
+ "\tRAND_SEED - seed for random number generator; -1 means use time(0).\n\n",
+ exe, DEFAULT_NUM_OPS, DEFAULT_MAX_SIZE, DEFAULT_MAX_DELTA, DEFAULT_RAND_SEED));
+}
+
+/* given the command line parameters, check the input for legality: if illegal, print
+ usage and exit; if legal, initialize the global running parameters (top of file) */
+static void usage(int argc, char **argv) {
+ char *convert;
+
+ if (argc > 1) {
+ Num_ops = strtol(argv[1], &convert, 0);
+ if (errno == ERANGE || convert != argv[1] + strlen(argv[1])) {
+ fprintf(stderr, "Error converting NUM_OPS: `%s' %s\n", argv[1],
+ errno == ERANGE ? strerror(errno) : "");
+ usage_and_exit(argv[0]);
+ }
+ } else
+ Num_ops = DEFAULT_NUM_OPS;
+
+ if (Num_ops < 0) {
+ fprintf(stderr, "Illegal NUM_OPS: %ld < 0!\n", Num_ops);
+ usage_and_exit(argv[0]);
+ }
+
+ if (argc > 2) {
+ Max_size = strtol(argv[2], &convert, 0);
+ if (errno == ERANGE || convert != argv[2] + strlen(argv[2])) {
+ fprintf(stderr, "Error converting MAX_SIZE: `%s' %s\n", argv[2],
+ errno == ERANGE ? strerror(errno) : "");
+ usage_and_exit(argv[0]);
+ }
+ } else
+ Max_size = DEFAULT_MAX_SIZE;
+
+ if (Max_size <= 0) {
+ fprintf(stderr, "Illegal MAX_SIZE: %ld <= 0!\n", Max_size);
+ usage_and_exit(argv[0]);
+ }
+
+ if (argc > 3) {
+ Max_delta = strtol(argv[3], &convert, 0);
+ if (errno == ERANGE || convert != argv[3] + strlen(argv[3])) {
+ fprintf(stderr, "Error converting MAX_DELTA: `%s' %s\n", argv[3],
+ errno == ERANGE ? strerror(errno) : "");
+ usage_and_exit(argv[0]);
+ }
+ } else
+ Max_delta = DEFAULT_MAX_DELTA;
+
+ if (Max_delta <= 0) {
+ fprintf(stderr, "Illegal MAX_DELTA: %ld <= 0!\n", Max_delta);
+ usage_and_exit(argv[0]);
+ }
+
+ if (!(Tmp_array = (int*) malloc(Max_delta * sizeof(int))))
+ stderr_pabort(__FILE__, __LINE__, "couldn't malloc(%d) Tmp_array!\n", Max_delta * sizeof(int));
+
+ if (argc > 4) {
+ Rand_seed = strtol(argv[4], &convert, 0);
+ if (convert != argv[4] + strlen(argv[4])) {
+ fprintf(stderr, "Error converting RAND_SEED: `%s'\n", argv[4]);
+ usage_and_exit(argv[0]);
+ }
+ } else
+ Rand_seed = DEFAULT_RAND_SEED;
+
+ /* seed random number generator: convert to unsigned int which srand() takes */
+ if (Rand_seed != -1)
+ srand((Rand_seed = (unsigned int) Rand_seed));
+ else
+ srand((Rand_seed = (unsigned int) time(0)));
+
+ if (argc > 5)
+ fprintf(stderr, "WARNING: all parameters beyond the fourth were ignored!");
+}
+
+int main(int argc, char **argv) {
+ stdarr arr1, arr2, *arr;
+ stdarr_it arr_it1, arr_it2, *arr_it;
+
+ stddll list1, list2, *list;
+ stddll_it list_it1, list_it2, *list_it;
+
+ int it1_index, it2_index, *it_index;
+ stdbool it1_good, it2_good, *it_good;
+
+ int i, tmp, twentieth_num_ops;
+
+ /* initialize globals from command line parameters */
+ usage(argc, argv);
+ twentieth_num_ops = Num_ops / 20; /* used for printing progress notifications */
+
+ /* initialize data structures and iterators */
+ if (stdarr_construct(&arr1, sizeof(int)) ||
+ stdarr_construct(&arr2, sizeof(int)) ||
+ stddll_construct(&list1, sizeof(int)) ||
+ stddll_construct(&list2, sizeof(int)))
+ stderr_pabort(__FILE__, __LINE__, "constructor failure!");
+
+ stdarr_begin(&arr1, &arr_it1);
+ stdarr_begin(&arr2, &arr_it2);
+ stddll_begin(&list1, &list_it1);
+ stddll_begin(&list2, &list_it2);
+ it1_good = it2_good = stdtrue;
+ it1_index = it2_index = 0;
+
+ printf("Begining run: Num_ops: %ld, Max_size: %ld, Max_delta: %ld, Rand_seed: %ld\n\n",
+ Num_ops, Max_size, Max_delta, Rand_seed);
+
+ /* perform Num_ops random operations on the two sets of sequences */
+ for (i = 1; i <= Num_ops; ++i) {
+ if ((float) rand() / RAND_MAX <= .5) { /* choose to work with arr1 or arr2 */
+ arr = &arr1;
+ arr_it = &arr_it1;
+ list = &list1;
+ list_it = &list_it1;
+ it_index = &it1_index;
+ it_good = &it1_good;
+ } else {
+ arr = &arr2;
+ arr_it = &arr_it2;
+ list = &list2;
+ list_it = &list_it2;
+ it_index = &it2_index;
+ it_good = &it2_good;
+ }
+
+ /* choose a basic operation at random to perform */
+ switch ((tmp = get_rand_base_op())) {
+ case STRUCTURAL_OP:
+ DEBUG(printf("executing STRUCTURAL_OP\n"));
+ handle_structural_op(arr, arr_it, list, list_it, it_index, it_good);
+ break;
+ case TOTAL_CHECK_OP:
+ DEBUG(printf("executing TOTAL_CHECK_OP 1\n"));
+ handle_total_op(arr, list);
+ break;
+ case ITERATOR_OP:
+ DEBUG(printf("executing ITERATOR_OP\n"));
+ handle_iterator_op(arr, arr_it, list, list_it, it_index, it_good);
+ break;
+ case CONSTRUCT_OP:
+ DEBUG(printf("executing CONSTRUCT_OP\n"));
+ if (arr == &arr1)
+ handle_construct_op(arr, &arr2, arr_it, list, &list2, list_it, it_index, it_good);
+ else
+ handle_construct_op(arr, &arr1, arr_it, list, &list1, list_it, it_index, it_good);
+ break;
+ default:
+ stderr_pabort(__FILE__, __LINE__, "base op switch failed, returned %d, unknown op\n", tmp);
+ break;
+ }
+ DEBUG(printf("executing TOTAL_CHECK_OP 2\n"));
+ DEBUG(handle_total_op(carr, list));
+ /* print progress notification */
+ if (i % twentieth_num_ops == 0)
+ printf("Run %.1f%% complete...\n", (float) i / Num_ops * 100);
+ }
+
+ /* free all resources (memory) */
+ stdarr_destruct(&arr1);
+ stdarr_destruct(&arr2);
+ stddll_destruct(&list1);
+ stddll_destruct(&list2);
+
+ if (Tmp_array != 0)
+ free(Tmp_array);
+
+ printf("\nstdarr_test run successful!\n\n");
+
+ return 0;
+}
+
+/* this fcn chooses a structural operation at random (based on the structural ops probabilities)
+ and performs it on the passed sequences */
+static void handle_structural_op(stdarr *arr, stdarr_it *arr_it, stddll *list,
+ stddll_it *list_it, int *it_index, stdbool *it_good) {
+ int tmp, i;
+
+ switch ((tmp = get_rand_structural_op())) {
+ case MERASE:
+ if (!*it_good) { /* if iterator is no good, pick a random position */
+ *it_index = rand() % (stddll_size(list) + 1);
+ DEBUG(printf("%p: it wasn't good: %d, choose new index of %d, it_good: %d\n",
+ arr, *it_good, *it_index, stdtrue));
+ *it_good = stdtrue;
+ stddll_get(list, list_it, *it_index);
+ stdarr_get(arr, arr_it, *it_index);
+ }
+ tmp = rand() % (Max_delta + 1); /* pick how many to erase */
+ tmp = STDMIN(tmp, stddll_size(list) - *it_index); /* limit the size of the erase */
+
+ DEBUG(printf("%p: executing multi-erase at index %d of size %d, old_size %d\n",
+ arr, *it_index, tmp, stddll_size(list)));
+
+ if (!stddll_multi_erase(list_it, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-erase failure!");
+
+ if (!stdarr_multi_erase(arr_it, tmp))
+ stderr_pabort(__FILE__, __LINE__, "array multi-erase failure!");
+ break;
+
+ case MINSERT:
+ if (!*it_good) { /* if iterator is no good, pick a random position */
+ *it_index = rand() % (stddll_size(list) + 1);
+ DEBUG(printf("%p: it wasn't good: %d, choose new index of %d, it_good: %d\n",
+ arr, *it_good, *it_index, stdtrue));
+ *it_good = stdtrue;
+ stddll_get(list, list_it, *it_index);
+ stdarr_get(arr, arr_it, *it_index);
+ }
+ tmp = rand() % (Max_delta + 1); /* pick how many to insert */
+ if (stddll_size(list) + tmp > Max_size) /* limit the size of the insert */
+ tmp = Max_size - stddll_size(list);
+
+ for (i = 0; i < tmp; ++i) /* use random data to insert */
+ Tmp_array[i] = rand();
+
+ DEBUG(printf("%p: executing multi-insert at index %d of size %d, old_size %d\n",
+ arr, *it_index, tmp, stddll_size(list)));
+
+ if (!stddll_multi_insert(list_it, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-insert failure!");
+
+ if (!stdarr_multi_insert(arr_it, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "array multi-insert failure!");
+ break;
+
+ case RINSERT:
+ if (!*it_good) { /* if iterator is no good, pick a random position */
+ *it_index = rand() % (stddll_size(list) + 1);
+ DEBUG(printf("%p: it wasn't good: %d, choose new index of %d, it_good: %d\n",
+ arr, *it_good, *it_index, stdtrue));
+ *it_good = stdtrue;
+ stddll_get(list, list_it, *it_index);
+ stdarr_get(arr, arr_it, *it_index);
+ }
+ tmp = rand() % (Max_delta + 1); /* pick how many to insert */
+ if (stddll_size(list) + tmp > Max_size) /* limit the size of the insert */
+ tmp = Max_size - stddll_size(list);
+
+ Tmp_array[0] = rand(); /* use random data to insert */
+
+ DEBUG(printf("%p: executing repeat_insert at index %d of size %d, old_size %d\n",
+ arr, *it_index, tmp, stddll_size(list)));
+
+ if (!stddll_repeat_insert(list_it, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-insert failure!");
+
+ if (!stdarr_repeat_insert(arr_it, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "array multi-insert failure!");
+ break;
+
+ case MPUSH_FRONT:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ tmp = rand() % (Max_delta + 1); /* pick how many to insert */
+ if (stddll_size(list) + tmp > Max_size) /* limit the size of the push */
+ tmp = Max_size - stddll_size(list);
+
+ for (i = 0; i < tmp; ++i) /* use random data to push */
+ Tmp_array[i] = rand();
+
+ DEBUG(printf("%p: executing multi-push front of size %d, old_size %d\n",
+ arr, tmp, stddll_size(list)));
+
+ if (stddll_multi_push_front(list, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-push front failure!");
+
+ /* stdarr doesn't have a push front, so we simulate by inserting at begin */
+ stdarr_begin(arr, arr_it);
+ if (!stdarr_multi_insert(arr_it, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "array multi-\"push front\" failure!");
+ break;
+
+ case MPOP_FRONT:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ tmp = rand() % (Max_delta + 1); /* pick how many to pop */
+ tmp = STDMIN(tmp, stddll_size(list)); /* limit the size of the pop */
+
+ DEBUG(printf("%p: executing multi-pop front of size %d, old_size %d\n",
+ arr, tmp, stddll_size(list)));
+
+ if (stddll_multi_pop_front(list, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-pop front failure!");
+
+ /* stdarr doesn't have a pop front, so we simulate by erasing at begin */
+ stdarr_begin(arr, arr_it);
+ if (!stdarr_multi_erase(arr_it, tmp))
+ stderr_pabort(__FILE__, __LINE__, "array multi-\"pop front\" failure!");
+ break;
+
+ case MPUSH_BACK:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ tmp = rand() % (Max_delta + 1); /* pick how many to push */
+ if (stddll_size(list) + tmp > Max_size) /* limit the size of the push */
+ tmp = Max_size - stddll_size(list);
+
+ for (i = 0; i < tmp; ++i) /* use random data to push */
+ Tmp_array[i] = rand();
+
+ DEBUG(printf("%p: executing multi-push back of size %d, old_size %d\n",
+ arr, tmp, stddll_size(list)));
+
+ if (stddll_multi_push_back(list, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-push back failure!");
+
+ if (stdarr_multi_push_back(arr, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "array multi-push back failure!");
+ break;
+
+ case MPOP_BACK:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ tmp = rand() % (Max_delta + 1); /* pick how many to pop */
+ tmp = STDMIN(tmp, stddll_size(list)); /* limit the size of the pop */
+
+ DEBUG(printf("%p: executing multi-pop back of size %d: old_size %d\n",
+ arr, tmp, stddll_size(list)));
+
+ if (stddll_multi_pop_back(list, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-pop back failure!");
+
+ if (stdarr_multi_pop_back(arr, tmp))
+ stderr_pabort(__FILE__, __LINE__, "array multi-pop back failure!");
+ break;
+
+ case RESIZE:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ /* pick randomly uniformly in range [-Max_delta, Max_delta] */
+ tmp = 2 * (rand() % (Max_delta + 1)) - Max_delta; /* pick a delta in size */
+
+ if (tmp >= 0) { /* tmp is non-negative -> grow or stay the same */
+ int delta = tmp; /* how many elements are being added? */
+
+ /* set tmp to reflect absolute size of sequence after growth */
+ if ((tmp = stddll_size(list) + tmp) > Max_size) { /* if growth is too big, set to max */
+ tmp = Max_size;
+ delta = Max_size - stddll_size(list);
+ }
+
+ DEBUG(printf("%p: executing grow resize %d -> %d\n",
+ arr, stddll_size(list), tmp));
+
+ if (stddll_resize(list, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list grow resize(%d -> %d) failure!",
+ stddll_size(list), tmp);
+
+ if (stdarr_resize(arr, tmp))
+ stderr_pabort(__FILE__, __LINE__, "array grow resize(%d -> %d) failure!",
+ stdarr_size(arr), tmp);
+
+ /* not done yet: need to fill in uninited values appended (if any)
+ to end so that arr and list match in the values they contain */
+ if (delta > 0) {
+ stddll_end(list, list_it); /* start from last value setting uninited values */
+ stdarr_end(arr, arr_it); /* moving backwards */
+
+ for (i = 0; i < delta; ++i) {
+ tmp = rand(); /* use random data */
+ stddll_it_prev(list_it);
+ stdarr_it_prev(arr_it);
+ *(int*) stddll_it_val(list_it) = tmp; /* set both to use random data */
+ *(int*) stdarr_it_val(arr_it) = tmp;
+ }
+ }
+ } else { /* tmp is negative -> shrink */
+ /* set tmp to reflect absolute size of sequence after shrinking */
+ if ((tmp = stddll_size(list) + tmp) < 0) /* if shrink is too big set to zero */
+ tmp = 0;
+
+ DEBUG(printf("%p: executing shrink resize %d -> %d\n",
+ arr, stddll_size(list), tmp));
+
+ if (stddll_resize(list, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list shrink resize(%d -> %d) failure!",
+ stddll_size(list), tmp);
+
+ if (stdarr_resize(arr, tmp))
+ stderr_pabort(__FILE__, __LINE__, "array shrink resize(%d -> %d) failure!",
+ stdarr_size(arr), tmp);
+ }
+ break;
+
+ case CLEAR:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ DEBUG(printf("%p: executing clear, old_size %d\n", arr, stddll_size(list)));
+
+ if (stddll_clear(list))
+ stderr_pabort(__FILE__, __LINE__, "list clear failure!");
+
+ if (stdarr_clear(arr))
+ stderr_pabort(__FILE__, __LINE__, "array clear failure!");
+ break;
+
+ default:
+ stderr_pabort(__FILE__, __LINE__, "structural op switch failed, returned %d, unknown op\n", tmp);
+ break;
+ }
+}
+
+/* do a check from begin to end to see that the contained sequences match exactly */
+static void handle_total_op(const stdarr *arr, const stddll *list) {
+ stdarr_it ait, *aitp = &ait;
+ stddll_it lit, *litp = &lit;
+ int i;
+
+ if (stdarr_size(arr) != stddll_size(list) || stdarr_empty(arr) != stddll_empty(list))
+ stderr_pabort(__FILE__, __LINE__, "size() or empty() disagreed!\n");
+
+ stdarr_begin(arr, aitp);
+ stddll_begin(list, litp);
+
+ for (i = 0; !stddll_it_is_end(litp); stdarr_it_next(aitp), stddll_it_next(litp), ++i) {
+ if (*(int*) stddll_it_val(litp) != *(int*) stdarr_it_val(aitp))
+ stderr_pabort(__FILE__, __LINE__, "array and list differed at index %d: list(%d) != array(%d)!\n",
+ i, *(int*) stddll_it_val(litp), *(int*) stdarr_it_val(aitp));
+ }
+ if (!stdarr_it_is_end(aitp))
+ stderr_pabort(__FILE__, __LINE__, "array wasn't at end and list was!\n");
+}
+
+static void handle_iterator_op(stdarr *arr, stdarr_it *arr_it, stddll *list,
+ stddll_it *list_it, int *it_index, stdbool *it_good) {
+ int tmp = get_rand_iterator_op();
+
+ /* if iterator is no good and doing a relative offset, then choose an iterator at random */
+ if (!*it_good && (tmp == IT_ADVANCE || tmp == IT_RETREAT || tmp == IT_PREV || tmp == IT_NEXT)) {
+ *it_index = rand() % (stddll_size(list) + 1);
+ *it_good = stdtrue;
+ stddll_get(list, list_it, *it_index);
+ stdarr_get(arr, arr_it, *it_index);
+ }
+
+ switch (tmp) {
+ case IT_ADVANCE:
+ tmp = rand() % (Max_delta + 1); /* pick random # to advance */
+ if (*it_index + tmp > stddll_size(list)) /* limit advance to end */
+ tmp = stddll_size(list) - *it_index;
+
+ stddll_it_advance(list_it, tmp);
+ stdarr_it_advance(arr_it, tmp);
+
+ *it_index += tmp;
+ break;
+
+ case IT_RETREAT:
+ tmp = rand() % (Max_delta + 1); /* pick random # to retreat */
+ if (tmp > *it_index) /* limit retreat to begin */
+ tmp = *it_index;
+
+ stddll_it_retreat(list_it, tmp);
+ stdarr_it_retreat(arr_it, tmp);
+
+ *it_index -= tmp;
+ break;
+
+ case IT_NEXT:
+ if (!stddll_it_is_end(list_it)) { /* don't do op if at end */
+ stddll_it_next(list_it);
+ stdarr_it_next(arr_it);
+ *it_index += 1;
+ }
+ break;
+
+ case IT_PREV:
+ if (!stddll_it_is_begin(list_it)) { /* don't do op if at begin */
+ stddll_it_prev(list_it);
+ stdarr_it_prev(arr_it);
+ *it_index -= 1;
+ }
+ break;
+
+ case IT_BEGIN:
+ stddll_begin(list, list_it);
+ stdarr_begin(arr, arr_it);
+ *it_index = 0;
+ break;
+
+ case IT_LAST:
+ if (!stddll_empty(list)) { /* if there are values contained */
+ stddll_last(list, list_it);
+ stdarr_last(arr, arr_it);
+ *it_index = stddll_size(list) - 1;
+ break;
+ }
+ /* else fall through to case END:!!!! */
+
+ case IT_END:
+ stddll_end(list, list_it);
+ stdarr_end(arr, arr_it);
+ *it_index = stddll_size(list);
+ break;
+
+ case IT_SEEK_BEGIN:
+ stddll_it_seek_begin(list_it);
+ stdarr_it_seek_begin(arr_it);
+ *it_index = 0;
+ break;
+
+ case IT_SEEK_END:
+ stddll_it_seek_end(list_it);
+ stdarr_it_seek_end(arr_it);
+ *it_index = stddll_size(list);
+ break;
+
+ default:
+ stderr_pabort(__FILE__, __LINE__, "iterator op switch failed, returned %d, unknown op\n", tmp);
+ break;
+ }
+ *it_good = stdtrue;
+
+ /* check that list and arr agree on that position's value (if it isn't end) */
+ if (!stddll_it_is_end(list_it) &&
+ *(int*) stddll_it_val(list_it) != *(int*) stdarr_it_val(arr_it))
+ stderr_pabort(__FILE__, __LINE__, "array and list differed at index %d: list(%d) != array(%d)!\n",
+ *it_index, *(int*) stddll_it_val(list_it), *(int*) stdarr_it_val(arr_it));
+}
+
+static void handle_construct_op(stdarr *arr_dst, const stdarr *arr_src, stdarr_it *arr_it,
+ stddll *list_dst, const stddll *list_src, stddll_it *list_it,
+ int *it_index, stdbool *it_good) {
+ int tmp;
+
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ stddll_destruct(list_dst);
+ stdarr_destruct(arr_dst);
+
+ switch ((tmp = get_rand_construct_op())) {
+ case CONSTRUCT:
+ if (stddll_construct(list_dst, sizeof(int)))
+ stderr_pabort(__FILE__, __LINE__, "list construct failed!");
+
+ if (stdarr_construct(arr_dst, sizeof(int)))
+ stderr_pabort(__FILE__, __LINE__, "array construct failed!");
+ break;
+
+ case COPY_CONSTRUCT:
+ if (stddll_copy_construct(list_dst, list_src))
+ stderr_pabort(__FILE__, __LINE__, "list copy construct failed!");
+
+ if (stdarr_copy_construct(arr_dst, arr_src))
+ stderr_pabort(__FILE__, __LINE__, "array copy construct failed!");
+ break;
+
+ default:
+ stderr_pabort(__FILE__, __LINE__, "construct op switch failed, returned %d, unknown op\n", tmp);
+ break;
+ }
+}
Added: vendor/stdutil/current/src/stdtest/stdcarr_test.c
===================================================================
--- vendor/stdutil/current/src/stdtest/stdcarr_test.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdtest/stdcarr_test.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,757 @@
+/* Copyright (c) 2000, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <time.h>
+#include <stdutil/stdcarr.h>
+#include <stdutil/stddll.h>
+#include <stdutil/stderror.h>
+
+/* This program runs a probabilistic test of the stdcarr data
+ structure. It picks a stdcarr operation to perform randomly (see
+ probabilities of operations below) and then performs the same
+ operation on a stdcarr and also on a stddll. A stddll has almost the
+ exact same interface as a stdcarr, but has been tested elsewhere and
+ is considered to be correctly implemented. As different operations
+ change the stdcarr it is compared, occasionally, against the stddll
+ to see that they are still exactly the same. The most obvious of
+ these equality checks is performed in the TOTAL_CHECK_OP operation.
+*/
+
+/* TODO: don't use rand() use stdrand32() and report what the seed
+ was. This should help with reproducibility on different systems, where
+ rand() may be implemented differently.
+*/
+
+/* uncomment and comment other line to turn debug printfs on or off */
+/* #define DEBUG(x) x */
+#define DEBUG(x)
+
+/* parameters for running tests:
+ Num_ops - how many operations should be run
+ Max_size - maximum size to which the sequences should grow
+ Max_delta - maximum number of values added or removed in one operation
+ Rand_seed - seed used for random number generator (see usage())
+*/
+static long Num_ops, Max_size, Max_delta, Rand_seed;
+
+/* defaults for running test if command line parameters aren't passed */
+#define DEFAULT_NUM_OPS 100000L
+#define DEFAULT_MAX_SIZE 10000L
+#define DEFAULT_MAX_DELTA 2000L
+#define DEFAULT_RAND_SEED -1L
+
+/* global used for multi-inserts and repeat-inserts, Tmp_array is
+ allocated to contain Max_delta values by usage(). Tmp_array[0] is
+ used for repeat inserts (see handle_structural_op()).
+*/
+static int *Tmp_array = 0;
+
+/* types of basic operations to perform - also offset into base_ops_probs probability array */
+typedef enum {
+ STRUCTURAL_OP = 0, TOTAL_CHECK_OP, ITERATOR_OP, CONSTRUCT_OP, NUM_BASE_OPS
+} base_op_type;
+
+/* probabilites of basic operations being performed */
+static float base_ops_probs[NUM_BASE_OPS] = { .7, .05, .248, .002 };
+/* for debugging */
+/* static float base_ops_probs[NUM_BASE_OPS] = { 1.0 }; */
+
+/* pre-declarations of handler fcns for each of the base operations */
+static void handle_structural_op(stdcarr *carr, stdcarr_it *carr_it, stddll *list,
+ stddll_it *list_it, int *it_index, stdbool *it_good);
+
+static void handle_total_op(const stdcarr *carr, const stddll *list);
+
+static void handle_iterator_op(stdcarr *carr, stdcarr_it *carr_it, stddll *list,
+ stddll_it *list_it, int *it_index, stdbool *it_good);
+
+static void handle_construct_op(stdcarr *carr_dst, const stdcarr *carr_src, stdcarr_it *carr_it,
+ stddll *list_dst, const stddll *list_src, stddll_it *list_it,
+ int *it_index, stdbool *it_good);
+
+/* types of structural operations to perform - also offset into structural_ops_probs probability array */
+/* based on assumption that non-multi operations are performed by calling multi operations or vice-versa */
+typedef enum {
+ MERASE = 0, MINSERT, RINSERT, MPUSH_FRONT, MPOP_FRONT,
+ MPUSH_BACK, MPOP_BACK, RESIZE, CLEAR, NUM_STRUCTURAL_OPS
+} structural_op_type;
+
+/* probabilites of structural ops being performed */
+static float structural_ops_probs[NUM_STRUCTURAL_OPS] = { .3, .15, .15, .095, .095,
+ .063, .063, .064, .02 };
+
+/* types of iterator operations to perform - also offset into iterator_ops_probs probability array */
+typedef enum {
+ IT_ADVANCE = 0, IT_RETREAT, IT_NEXT, IT_PREV, IT_BEGIN,
+ IT_END, IT_LAST, IT_SEEK_BEGIN, IT_SEEK_END, NUM_ITERATOR_OPS
+} iterator_op_type;
+
+/* probabilites of iterator operations being performed */
+static float iterator_ops_probs[NUM_ITERATOR_OPS] = { .3, .3, .175, .175, .01, .01, .01, .01, .01 };
+
+/* types of construct operations to perform - also offset into construct_ops_probs probability array */
+typedef enum {
+ CONSTRUCT = 0, COPY_CONSTRUCT, NUM_CONSTRUCT_OPS
+} construct_op_type;
+
+/* probabilites of constructor operations being performed */
+static float construct_ops_probs[NUM_CONSTRUCT_OPS] = { .5, .5 };
+
+/* get_event - based on the probabilties in a probability array and the random number prob, this fcn
+ will return a number in the range [0, probs_size) signifying which event was chosen to occur
+ probs_array - a float array of probs_size independent probabilites for events to occur
+ - the sum of probabilities of the first (probs_size - 1) events should sum to <= 1.0, if not exit()
+ - the probability of the last event in the array occurring is defined to be 1.0 - (sum of prev
+ events), meaning that the probability of the last event in the array is ignored
+ probs_size - positive integer (zero is illegal) of how many events can occur
+ prob - a uniform random float in range [0.0, 1.0]
+*/
+static inline int get_event(float *probs_array, int probs_size, float prob) {
+ float run_tot = 0.0;
+ int i;
+
+ if (probs_size <= 0)
+ exit(fprintf(stderr, "get_event: probability array size must be a positive integer, probs_size: %d\n",
+ probs_size));
+
+ if (prob < 0.0 || prob > 1.0)
+ exit(fprintf(stderr, "get_event: passed probability not in range [0.0, 1.0] was %f\n", prob));
+
+ probs_size -= 1;
+ for (i = 0; i < probs_size; ++i) {
+ if ((run_tot += probs_array[i]) > 1.0)
+ exit(fprintf(stderr, "get_event: illegal probability array!\n"
+ "\tSum of probs of first %d events greather than 1.0! Sum prob was %f\n", i, run_tot));
+
+ if (run_tot >= prob)
+ return i;
+ }
+ return i;
+}
+
+/* same as get_event except it generates a random number (rand()) for the event probability */
+static inline int get_rand_event(float *probs_array, int probs_size) {
+ return get_event(probs_array, probs_size, (float) rand() / RAND_MAX);
+}
+
+/* return a random base_op_type based off of probabilties in base_ops_probs */
+static inline base_op_type get_rand_base_op() {
+ return (base_op_type) get_rand_event(base_ops_probs, NUM_BASE_OPS);
+}
+
+/* return a random structural_op_type based off of probabilties in structural_ops_probs */
+static inline structural_op_type get_rand_structural_op() {
+ return (structural_op_type) get_rand_event(structural_ops_probs, NUM_STRUCTURAL_OPS);
+}
+
+/* return a random iterator_op_type based off of probabilties in iterator_ops_probs */
+static inline iterator_op_type get_rand_iterator_op() {
+ return (iterator_op_type) get_rand_event(iterator_ops_probs, NUM_ITERATOR_OPS);
+}
+
+/* return a random construct_op_type based off of probabilties in construct_ops_probs */
+static inline construct_op_type get_rand_construct_op() {
+ return (construct_op_type) get_rand_event(construct_ops_probs, NUM_CONSTRUCT_OPS);
+}
+
+/* simply print how to run the program to stderr and then exit */
+static void usage_and_exit(const char *exe) {
+ exit(fprintf(stderr,
+ "\nUsage: %s [NUM_OPS=%ld] [MAX_SIZE=%ld] [MAX_DELTA=%ld] [RAND_SEED=%ld]\n"
+ "\tTo set later parameters you must set all previous parameters.\n\n"
+ "\tNUM_OPS - how many random operations should be performed.\n"
+ "\tMAX_SIZE - the maximum number of values the sequences should ever contain.\n"
+ "\tMAX_DELTA - the maximum number of values ever inserted or deleted at once.\n"
+ "\tRAND_SEED - seed for random number generator; -1 means use time(0).\n\n",
+ exe, DEFAULT_NUM_OPS, DEFAULT_MAX_SIZE, DEFAULT_MAX_DELTA, DEFAULT_RAND_SEED));
+}
+
+/* given the command line parameters, check the input for legality: if illegal, print
+ usage and exit; if legal, initialize the global running parameters (top of file) */
+static void usage(int argc, char **argv) {
+ char *convert;
+
+ if (argc > 1) {
+ Num_ops = strtol(argv[1], &convert, 0);
+ if (errno == ERANGE || convert != argv[1] + strlen(argv[1])) {
+ fprintf(stderr, "Error converting NUM_OPS: `%s' %s\n", argv[1],
+ errno == ERANGE ? strerror(errno) : "");
+ usage_and_exit(argv[0]);
+ }
+ } else
+ Num_ops = DEFAULT_NUM_OPS;
+
+ if (Num_ops < 0) {
+ fprintf(stderr, "Illegal NUM_OPS: %ld < 0!\n", Num_ops);
+ usage_and_exit(argv[0]);
+ }
+
+ if (argc > 2) {
+ Max_size = strtol(argv[2], &convert, 0);
+ if (errno == ERANGE || convert != argv[2] + strlen(argv[2])) {
+ fprintf(stderr, "Error converting MAX_SIZE: `%s' %s\n", argv[2],
+ errno == ERANGE ? strerror(errno) : "");
+ usage_and_exit(argv[0]);
+ }
+ } else
+ Max_size = DEFAULT_MAX_SIZE;
+
+ if (Max_size <= 0) {
+ fprintf(stderr, "Illegal MAX_SIZE: %ld <= 0!\n", Max_size);
+ usage_and_exit(argv[0]);
+ }
+
+ if (argc > 3) {
+ Max_delta = strtol(argv[3], &convert, 0);
+ if (errno == ERANGE || convert != argv[3] + strlen(argv[3])) {
+ fprintf(stderr, "Error converting MAX_DELTA: `%s' %s\n", argv[3],
+ errno == ERANGE ? strerror(errno) : "");
+ usage_and_exit(argv[0]);
+ }
+ } else
+ Max_delta = DEFAULT_MAX_DELTA;
+
+ if (Max_delta <= 0) {
+ fprintf(stderr, "Illegal MAX_DELTA: %ld <= 0!\n", Max_delta);
+ usage_and_exit(argv[0]);
+ }
+
+ if (!(Tmp_array = (int*) malloc(Max_delta * sizeof(int))))
+ stderr_pabort(__FILE__, __LINE__, "couldn't malloc(%d) Tmp_array!\n", Max_delta * sizeof(int));
+
+ if (argc > 4) {
+ Rand_seed = strtol(argv[4], &convert, 0);
+ if (convert != argv[4] + strlen(argv[4])) {
+ fprintf(stderr, "Error converting RAND_SEED: `%s'\n", argv[4]);
+ usage_and_exit(argv[0]);
+ }
+ } else
+ Rand_seed = DEFAULT_RAND_SEED;
+
+ /* seed random number generator: convert to unsigned int which srand() takes */
+ if (Rand_seed != -1)
+ srand((Rand_seed = (unsigned int) Rand_seed));
+ else
+ srand((Rand_seed = (unsigned int) time(0)));
+
+ if (argc > 5)
+ fprintf(stderr, "WARNING: all parameters beyond the fourth were ignored!");
+}
+
+int main(int argc, char **argv) {
+ stdcarr carr1, carr2, *carr;
+ stdcarr_it carr_it1, carr_it2, *carr_it;
+
+ stddll list1, list2, *list;
+ stddll_it list_it1, list_it2, *list_it;
+
+ int it1_index, it2_index, *it_index;
+ stdbool it1_good, it2_good, *it_good;
+
+ int i, tmp, twentieth_num_ops;
+
+ /* initialize globals from command line parameters */
+ usage(argc, argv);
+ twentieth_num_ops = Num_ops / 20; /* used for printing progress notifications */
+
+ /* initialize data structures and iterators */
+ if (stdcarr_construct(&carr1, sizeof(int)) ||
+ stdcarr_construct(&carr2, sizeof(int)) ||
+ stddll_construct(&list1, sizeof(int)) ||
+ stddll_construct(&list2, sizeof(int)))
+ stderr_pabort(__FILE__, __LINE__, "constructor failure!");
+
+ stdcarr_begin(&carr1, &carr_it1);
+ stdcarr_begin(&carr2, &carr_it2);
+ stddll_begin(&list1, &list_it1);
+ stddll_begin(&list2, &list_it2);
+ it1_good = it2_good = stdtrue;
+ it1_index = it2_index = 0;
+
+ printf("Begining run: Num_ops: %ld, Max_size: %ld, Max_delta: %ld, Rand_seed: %ld\n\n",
+ Num_ops, Max_size, Max_delta, Rand_seed);
+
+ /* perform Num_ops random operations on the two sets of sequences */
+ for (i = 1; i <= Num_ops; ++i) {
+ if ((float) rand() / RAND_MAX <= .5) { /* choose to work with carr1 or carr2 */
+ carr = &carr1;
+ carr_it = &carr_it1;
+ list = &list1;
+ list_it = &list_it1;
+ it_index = &it1_index;
+ it_good = &it1_good;
+ } else {
+ carr = &carr2;
+ carr_it = &carr_it2;
+ list = &list2;
+ list_it = &list_it2;
+ it_index = &it2_index;
+ it_good = &it2_good;
+ }
+
+ /* choose a basic operation at random to perform */
+ switch ((tmp = get_rand_base_op())) {
+ case STRUCTURAL_OP:
+ DEBUG(printf("executing STRUCTURAL_OP\n"));
+ handle_structural_op(carr, carr_it, list, list_it, it_index, it_good);
+ break;
+ case TOTAL_CHECK_OP:
+ DEBUG(printf("executing TOTAL_CHECK_OP 1\n"));
+ handle_total_op(carr, list);
+ break;
+ case ITERATOR_OP:
+ DEBUG(printf("executing ITERATOR_OP\n"));
+ handle_iterator_op(carr, carr_it, list, list_it, it_index, it_good);
+ break;
+ case CONSTRUCT_OP:
+ DEBUG(printf("executing CONSTRUCT_OP\n"));
+ if (carr == &carr1)
+ handle_construct_op(carr, &carr2, carr_it, list, &list2, list_it, it_index, it_good);
+ else
+ handle_construct_op(carr, &carr1, carr_it, list, &list1, list_it, it_index, it_good);
+ break;
+ default:
+ stderr_pabort(__FILE__, __LINE__, "base op switch failed, returned %d, unknown op\n", tmp);
+ break;
+ }
+ DEBUG(printf("executing TOTAL_CHECK_OP 2\n"));
+ DEBUG(handle_total_op(carr, list));
+ /* print progress notification */
+ if (i % twentieth_num_ops == 0)
+ printf("Run %.1f%% complete...\n", (float) i / Num_ops * 100);
+ }
+
+ /* free all resources (memory) */
+ stdcarr_destruct(&carr1);
+ stdcarr_destruct(&carr2);
+ stddll_destruct(&list1);
+ stddll_destruct(&list2);
+
+ if (Tmp_array != 0)
+ free(Tmp_array);
+
+ printf("\nstdcarr_test run successful!\n\n");
+
+ return 0;
+}
+
+/* this fcn chooses a structural operation at random (based on the structural ops probabilities)
+ and performs it on the passed sequences */
+static void handle_structural_op(stdcarr *carr, stdcarr_it *carr_it, stddll *list,
+ stddll_it *list_it, int *it_index, stdbool *it_good) {
+ int tmp, i;
+
+ switch ((tmp = get_rand_structural_op())) {
+ case MERASE:
+ if (!*it_good) { /* if iterator is no good, pick a random position */
+ *it_index = rand() % (stddll_size(list) + 1);
+ DEBUG(printf("%p: it wasn't good: %d, choose new index of %d, it_good: %d\n",
+ carr, *it_good, *it_index, stdtrue));
+ *it_good = stdtrue;
+ stddll_get(list, list_it, *it_index);
+ stdcarr_get(carr, carr_it, *it_index);
+ }
+ tmp = rand() % (Max_delta + 1); /* pick how many to erase */
+ tmp = STDMIN(tmp, stddll_size(list) - *it_index); /* limit the size of the erase */
+
+ DEBUG(printf("%p: executing multi-erase at index %d of size %d, old_size %d\n",
+ carr, *it_index, tmp, stddll_size(list)));
+
+ if (!stddll_multi_erase(list_it, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-erase failure!");
+
+ if (!stdcarr_multi_erase(carr_it, tmp))
+ stderr_pabort(__FILE__, __LINE__, "carray multi-erase failure!");
+ break;
+
+ case MINSERT:
+ if (!*it_good) { /* if iterator is no good, pick a random position */
+ *it_index = rand() % (stddll_size(list) + 1);
+ DEBUG(printf("%p: it wasn't good: %d, choose new index of %d, it_good: %d\n",
+ carr, *it_good, *it_index, stdtrue));
+ *it_good = stdtrue;
+ stddll_get(list, list_it, *it_index);
+ stdcarr_get(carr, carr_it, *it_index);
+ }
+ tmp = rand() % (Max_delta + 1); /* pick how many to insert */
+ if (stddll_size(list) + tmp > Max_size) /* limit the size of the insert */
+ tmp = Max_size - stddll_size(list);
+
+ for (i = 0; i < tmp; ++i) /* use random data to insert */
+ Tmp_array[i] = rand();
+
+ DEBUG(printf("%p: executing multi-insert at index %d of size %d, old_size %d\n",
+ carr, *it_index, tmp, stddll_size(list)));
+
+ if (!stddll_multi_insert(list_it, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-insert failure!");
+
+ if (!stdcarr_multi_insert(carr_it, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "carray multi-insert failure!");
+ break;
+
+ case RINSERT:
+ if (!*it_good) { /* if iterator is no good, pick a random position */
+ *it_index = rand() % (stddll_size(list) + 1);
+ DEBUG(printf("%p: it wasn't good: %d, choose new index of %d, it_good: %d\n",
+ carr, *it_good, *it_index, stdtrue));
+ *it_good = stdtrue;
+ stddll_get(list, list_it, *it_index);
+ stdcarr_get(carr, carr_it, *it_index);
+ }
+ tmp = rand() % (Max_delta + 1); /* pick how many to insert */
+ if (stddll_size(list) + tmp > Max_size) /* limit the size of the insert */
+ tmp = Max_size - stddll_size(list);
+
+ Tmp_array[0] = rand(); /* use random data to insert */
+
+ DEBUG(printf("%p: executing repeat_insert at index %d of size %d, old_size %d\n",
+ carr, *it_index, tmp, stddll_size(list)));
+
+ if (!stddll_repeat_insert(list_it, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-insert failure!");
+
+ if (!stdcarr_repeat_insert(carr_it, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "carray multi-insert failure!");
+ break;
+
+ case MPUSH_FRONT:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ tmp = rand() % (Max_delta + 1); /* pick how many to insert */
+ if (stddll_size(list) + tmp > Max_size) /* limit the size of the push */
+ tmp = Max_size - stddll_size(list);
+
+ for (i = 0; i < tmp; ++i) /* use random data to push */
+ Tmp_array[i] = rand();
+
+ DEBUG(printf("%p: executing multi-push front of size %d, old_size %d\n",
+ carr, tmp, stddll_size(list)));
+
+ if (stddll_multi_push_front(list, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-push front failure!");
+
+ if (stdcarr_multi_push_front(carr, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "carray multi-push front failure!");
+ break;
+
+ case MPOP_FRONT:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ tmp = rand() % (Max_delta + 1); /* pick how many to pop */
+ tmp = STDMIN(tmp, stddll_size(list)); /* limit the size of the pop */
+
+ DEBUG(printf("%p: executing multi-pop front of size %d, old_size %d\n",
+ carr, tmp, stddll_size(list)));
+
+ if (stddll_multi_pop_front(list, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-pop front failure!");
+
+ if (stdcarr_multi_pop_front(carr, tmp))
+ stderr_pabort(__FILE__, __LINE__, "carray multi-pop front failure!");
+ break;
+
+ case MPUSH_BACK:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ tmp = rand() % (Max_delta + 1); /* pick how many to push */
+ if (stddll_size(list) + tmp > Max_size) /* limit the size of the push */
+ tmp = Max_size - stddll_size(list);
+
+ for (i = 0; i < tmp; ++i) /* use random data to push */
+ Tmp_array[i] = rand();
+
+ DEBUG(printf("%p: executing multi-push back of size %d, old_size %d\n",
+ carr, tmp, stddll_size(list)));
+
+ if (stddll_multi_push_back(list, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-push back failure!");
+
+ if (stdcarr_multi_push_back(carr, Tmp_array, tmp))
+ stderr_pabort(__FILE__, __LINE__, "carray multi-push back failure!");
+ break;
+
+ case MPOP_BACK:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ tmp = rand() % (Max_delta + 1); /* pick how many to pop */
+ tmp = STDMIN(tmp, stddll_size(list)); /* limit the size of the pop */
+
+ DEBUG(printf("%p: executing multi-pop back of size %d: old_size %d\n",
+ carr, tmp, stddll_size(list)));
+
+ if (stddll_multi_pop_back(list, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list multi-pop back failure!");
+
+ if (stdcarr_multi_pop_back(carr, tmp))
+ stderr_pabort(__FILE__, __LINE__, "carray multi-pop back failure!");
+ break;
+
+ case RESIZE:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ /* pick randomly uniformly in range [-Max_delta, Max_delta] */
+ tmp = 2 * (rand() % (Max_delta + 1)) - Max_delta; /* pick a delta in size */
+
+ if (tmp >= 0) { /* tmp is non-negative -> grow or stay the same */
+ int delta = tmp; /* how many elements are being added? */
+
+ /* set tmp to reflect absolute size of sequence after growth */
+ if ((tmp = stddll_size(list) + tmp) > Max_size) { /* if growth is too big, set to max */
+ tmp = Max_size;
+ delta = Max_size - stddll_size(list);
+ }
+
+ DEBUG(printf("%p: executing grow resize %d -> %d\n",
+ carr, stddll_size(list), tmp));
+
+ if (stddll_resize(list, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list grow resize(%d -> %d) failure!",
+ stddll_size(list), tmp);
+
+ if (stdcarr_resize(carr, tmp))
+ stderr_pabort(__FILE__, __LINE__, "carray grow resize(%d -> %d) failure!",
+ stdcarr_size(carr), tmp);
+
+ /* not done yet: need to fill in uninited values appended (if any)
+ to end so that carr and list match in the values they contain */
+ if (delta > 0) {
+ stddll_end(list, list_it); /* start from last value setting uninited values */
+ stdcarr_end(carr, carr_it); /* moving backwards */
+
+ for (i = 0; i < delta; ++i) {
+ tmp = rand(); /* use random data */
+ stddll_it_prev(list_it);
+ stdcarr_it_prev(carr_it);
+ *(int*) stddll_it_val(list_it) = tmp; /* set both to use random data */
+ *(int*) stdcarr_it_val(carr_it) = tmp;
+ }
+ }
+ } else { /* tmp is negative -> shrink */
+ /* set tmp to reflect absolute size of sequence after shrinking */
+ if ((tmp = stddll_size(list) + tmp) < 0) /* if shrink is too big set to zero */
+ tmp = 0;
+
+ DEBUG(printf("%p: executing shrink resize %d -> %d\n",
+ carr, stddll_size(list), tmp));
+
+ if (stddll_resize(list, tmp))
+ stderr_pabort(__FILE__, __LINE__, "list shrink resize(%d -> %d) failure!",
+ stddll_size(list), tmp);
+
+ if (stdcarr_resize(carr, tmp))
+ stderr_pabort(__FILE__, __LINE__, "carray shrink resize(%d -> %d) failure!",
+ stdcarr_size(carr), tmp);
+ }
+ break;
+
+ case CLEAR:
+ /* structural operations usually only _guarantee_ iterators' validness after the
+ operation if the iterator is used (i.e. - passed to the fcn) in that operation */
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ DEBUG(printf("%p: executing clear, old_size %d\n", carr, stddll_size(list)));
+
+ if (stddll_clear(list))
+ stderr_pabort(__FILE__, __LINE__, "list clear failure!");
+
+ if (stdcarr_clear(carr))
+ stderr_pabort(__FILE__, __LINE__, "carray clear failure!");
+ break;
+
+ default:
+ stderr_pabort(__FILE__, __LINE__, "structural op switch failed, returned %d, unknown op\n", tmp);
+ break;
+ }
+}
+
+/* do a check from begin to end to see that the contained sequences match exactly */
+static void handle_total_op(const stdcarr *carr, const stddll *list) {
+ stdcarr_it ait, *aitp = &ait;
+ stddll_it lit, *litp = &lit;
+ int i;
+
+ if (stdcarr_size(carr) != stddll_size(list) || stdcarr_empty(carr) != stddll_empty(list))
+ stderr_pabort(__FILE__, __LINE__, "size() or empty() disagreed!\n");
+
+ stdcarr_begin(carr, aitp);
+ stddll_begin(list, litp);
+
+ for (i = 0; !stddll_it_is_end(litp); stdcarr_it_next(aitp), stddll_it_next(litp), ++i) {
+ if (*(int*) stddll_it_val(litp) != *(int*) stdcarr_it_val(aitp))
+ stderr_pabort(__FILE__, __LINE__, "carray and list differed at index %d: list(%d) != carray(%d)!\n",
+ i, *(int*) stddll_it_val(litp), *(int*) stdcarr_it_val(aitp));
+ }
+ if (!stdcarr_it_is_end(aitp))
+ stderr_pabort(__FILE__, __LINE__, "carray wasn't at end and list was!\n");
+}
+
+static void handle_iterator_op(stdcarr *carr, stdcarr_it *carr_it, stddll *list,
+ stddll_it *list_it, int *it_index, stdbool *it_good) {
+ int tmp = get_rand_iterator_op();
+
+ /* if iterator is no good and doing a relative offset, then choose an iterator at random */
+ if (!*it_good && (tmp == IT_ADVANCE || tmp == IT_RETREAT || tmp == IT_PREV || tmp == IT_NEXT)) {
+ *it_index = rand() % (stddll_size(list) + 1);
+ *it_good = stdtrue;
+ stddll_get(list, list_it, *it_index);
+ stdcarr_get(carr, carr_it, *it_index);
+ }
+
+ switch (tmp) {
+ case IT_ADVANCE:
+ tmp = rand() % (Max_delta + 1); /* pick random # to advance */
+ if (*it_index + tmp > stddll_size(list)) /* limit advance to end */
+ tmp = stddll_size(list) - *it_index;
+
+ stddll_it_advance(list_it, tmp);
+ stdcarr_it_advance(carr_it, tmp);
+
+ *it_index += tmp;
+ break;
+
+ case IT_RETREAT:
+ tmp = rand() % (Max_delta + 1); /* pick random # to retreat */
+ if (tmp > *it_index) /* limit retreat to begin */
+ tmp = *it_index;
+
+ stddll_it_retreat(list_it, tmp);
+ stdcarr_it_retreat(carr_it, tmp);
+
+ *it_index -= tmp;
+ break;
+
+ case IT_NEXT:
+ if (!stddll_it_is_end(list_it)) { /* don't do op if at end */
+ stddll_it_next(list_it);
+ stdcarr_it_next(carr_it);
+ *it_index += 1;
+ }
+ break;
+
+ case IT_PREV:
+ if (!stddll_it_is_begin(list_it)) { /* don't do op if at begin */
+ stddll_it_prev(list_it);
+ stdcarr_it_prev(carr_it);
+ *it_index -= 1;
+ }
+ break;
+
+ case IT_BEGIN:
+ stddll_begin(list, list_it);
+ stdcarr_begin(carr, carr_it);
+ *it_index = 0;
+ break;
+
+ case IT_LAST:
+ if (!stddll_empty(list)) { /* if there are values contained */
+ stddll_last(list, list_it);
+ stdcarr_last(carr, carr_it);
+ *it_index = stddll_size(list) - 1;
+ break;
+ }
+ /* else fall through to case END:!!!! */
+
+ case IT_END:
+ stddll_end(list, list_it);
+ stdcarr_end(carr, carr_it);
+ *it_index = stddll_size(list);
+ break;
+
+ case IT_SEEK_BEGIN:
+ stddll_it_seek_begin(list_it);
+ stdcarr_it_seek_begin(carr_it);
+ *it_index = 0;
+ break;
+
+ case IT_SEEK_END:
+ stddll_it_seek_end(list_it);
+ stdcarr_it_seek_end(carr_it);
+ *it_index = stddll_size(list);
+ break;
+
+ default:
+ stderr_pabort(__FILE__, __LINE__, "iterator op switch failed, returned %d, unknown op\n", tmp);
+ break;
+ }
+ *it_good = stdtrue;
+
+ /* check that list and carr agree on that position's value (if it isn't end) */
+ if (!stddll_it_is_end(list_it) &&
+ *(int*) stddll_it_val(list_it) != *(int*) stdcarr_it_val(carr_it))
+ stderr_pabort(__FILE__, __LINE__, "carray and list differed at index %d: list(%d) != carray(%d)!\n",
+ *it_index, *(int*) stddll_it_val(list_it), *(int*) stdcarr_it_val(carr_it));
+}
+
+static void handle_construct_op(stdcarr *carr_dst, const stdcarr *carr_src, stdcarr_it *carr_it,
+ stddll *list_dst, const stddll *list_src, stddll_it *list_it,
+ int *it_index, stdbool *it_good) {
+ int tmp;
+
+ *it_index = -1;
+ *it_good = stdfalse;
+
+ stddll_destruct(list_dst);
+ stdcarr_destruct(carr_dst);
+
+ switch ((tmp = get_rand_construct_op())) {
+ case CONSTRUCT:
+ if (stddll_construct(list_dst, sizeof(int)))
+ stderr_pabort(__FILE__, __LINE__, "list construct failed!");
+
+ if (stdcarr_construct(carr_dst, sizeof(int)))
+ stderr_pabort(__FILE__, __LINE__, "carray construct failed!");
+ break;
+
+ case COPY_CONSTRUCT:
+ if (stddll_copy_construct(list_dst, list_src))
+ stderr_pabort(__FILE__, __LINE__, "list copy construct failed!");
+
+ if (stdcarr_copy_construct(carr_dst, carr_src))
+ stderr_pabort(__FILE__, __LINE__, "carray copy construct failed!");
+ break;
+
+ default:
+ stderr_pabort(__FILE__, __LINE__, "construct op switch failed, returned %d, unknown op\n", tmp);
+ break;
+ }
+}
Added: vendor/stdutil/current/src/stdtest/stddll_test.c
===================================================================
--- vendor/stdutil/current/src/stdtest/stddll_test.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdtest/stddll_test.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,194 @@
+/* Copyright (c) 2000, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <string.h>
+
+#ifdef USE_DMALLOC
+# include <dmalloc.h>
+#endif
+
+#include <stdutil/stddll.h>
+#include <stdutil/stderror.h>
+
+// keep NUM_PUSH a multiple of 2
+#define NUM_PUSH ((size_t) 1024)
+#define NUM_END ((size_t) 6)
+#define NUM_INSERT ((size_t) 5)
+
+int main(int argc, char **argv) {
+ stddll list, list2;
+ stddll_it list_it, list_it2;
+ size_t i, j, k;
+
+ if (NUM_PUSH % 4)
+ stderr_pabort(__FILE__, __LINE__, "NUM_PUSH must be at least a multiple of 4, is %u, NUM_PUSH %% 4 = %u\n",
+ NUM_PUSH, NUM_PUSH % 4);
+
+ if (NUM_PUSH/4 < NUM_END)
+ stderr_pabort(__FILE__, __LINE__, "NUM_END (%u) is greater than NUM_PUSH/4 (%u)\n", NUM_END, NUM_PUSH/4);
+
+ if (stddll_construct(&list, sizeof(size_t))) /* list will contain size_t's */
+ stderr_pabort(__FILE__, __LINE__, "stddll_construct failed!");
+
+ if (stddll_val_size(&list) != sizeof(size_t))
+ stderr_pabort(__FILE__, __LINE__, "stddll_copy_construct failed, wrong type size!");
+
+ for (i = 0; i < NUM_PUSH; ++i) {
+ if (stddll_size(&list) != i)
+ stderr_pabort(__FILE__, __LINE__, "stddll_size not %u! is %u\n", i, stddll_size(&list));
+
+ if (stddll_push_back(&list, &i))
+ stderr_pabort(__FILE__, __LINE__, "stddll_push_back failed on i = %d"
+ ", size = %u", i, stddll_size(&list));
+ }
+
+ if (i != stddll_size(&list))
+ stderr_pabort(__FILE__, __LINE__, "i is %u! not %u\n", i, stddll_size(&list));
+
+ stddll_last(&list, &list_it);
+ /* you can modify stddll while iterating through it: not all DS's support this */
+ do {
+ --i;
+ j = *(size_t*) stddll_it_val(&list_it);
+
+ if (j != i)
+ stderr_pabort(__FILE__, __LINE__, "unexpected value! last was %u, should be %u!", j, i);
+
+ if (i != 0) /* get previous unless it is begin */
+ stddll_it_prev(&list_it);
+ else if (!stddll_it_is_begin(&list_it)) /* check and be sure is begin */
+ stderr_pabort(__FILE__, __LINE__, "isn't begin but should be i % u, j %u!", i, j);
+
+ if (stddll_pop_back(&list))
+ stderr_pabort(__FILE__, __LINE__, "stddll_pop_back failed on i = %u, size = %u", i, stddll_size(&list));
+
+ if (stddll_size(&list) != i)
+ stderr_pabort(__FILE__, __LINE__, "stddll_size not %u! is %u\n", i, stddll_size(&list));
+
+ } while (i != 0);
+
+ /* make sequence: 0, 2, 4, ..., NUM_PUSH - 3, NUM_PUSH - 1, NUMPUSH - 2, NUM_PUSH - 4, ..., 3, 1 */
+ stddll_end(&list, &list_it);
+ for (i = 0; i < NUM_PUSH; ++i) {
+ if (stddll_size(&list) != i)
+ stderr_pabort(__FILE__, __LINE__, "stddll_size not %u! is %u\n", i, stddll_size(&list));
+
+ if (!stddll_insert(&list_it, &i))
+ stderr_pabort(__FILE__, __LINE__, "stddll_insert failed on i = %u, size = %u\n", i, stddll_size(&list));
+
+ if (i % 2 == 0)
+ stddll_it_next(&list_it);
+ }
+
+ /* make a copy (by value clone) of it */
+ if (stddll_copy_construct(&list2, &list))
+ stderr_pabort(__FILE__, __LINE__, "stddll_copy_construct failed!");
+
+ if (stddll_val_size(&list2) != sizeof(size_t))
+ stderr_pabort(__FILE__, __LINE__, "stddll_copy_construct failed, wrong type size!");
+
+ /* clearing list doesn't affect list2 */
+ if (stddll_clear(&list))
+ stderr_pabort(__FILE__, __LINE__, "stddll_clear failed!");
+
+ if (stddll_size(&list) != 0 || !stddll_it_is_end(stddll_begin(&list, &list_it)))
+ stderr_pabort(__FILE__, __LINE__, "stddll_clear succeeded incorrectly!");
+
+ /* check and be sure list2 has an exact copy of the above sequence */
+ stddll_begin(&list2, &list_it);
+ stddll_last(&list2, &list_it2);
+ for (i = 0; i < NUM_PUSH; ++i) {
+ j = *(size_t*) stddll_it_val(&list_it); /* iterate through evens */
+ k = *(size_t*) stddll_it_val(&list_it2); /* iterate through odds */
+
+ if (j != i)
+ stderr_pabort(__FILE__, __LINE__, "j is %u! not %u!", j, i);
+
+ if (k != ++i)
+ stderr_pabort(__FILE__, __LINE__, "k is %u! not %u!", k, i);
+
+ stddll_it_next(&list_it);
+ stddll_it_prev(&list_it2);
+ }
+
+ /* erase the odds -- list_it should be pointing at first odd and list_it2 at last even */
+ if (!stddll_multi_erase(&list_it, NUM_PUSH / 2))
+ stderr_pabort(__FILE__, __LINE__, "multi-erase of odds failed!");
+
+ if (!stddll_it_is_end(&list_it))
+ stderr_pabort(__FILE__, __LINE__, "list_it should be end but it isn't?!");
+
+ stddll_get(&list2, &list_it, NUM_PUSH / 4);
+
+ if ((i = *(size_t*) stddll_it_val(&list_it)) != NUM_PUSH / 2) /* should be twice the seq # */
+ stderr_pabort(__FILE__, __LINE__, "wrong value for seq num %u is %u! not %u\n",
+ NUM_PUSH / 4, i, NUM_PUSH / 2);
+
+ if (!stddll_multi_erase(&list_it, NUM_PUSH / 4 - NUM_END))
+ stderr_pabort(__FILE__, __LINE__, "multi-erase of sequence range [NUM_PUSH/4, NUM_PUSH/2 - NUM_END)!");
+
+ if (stddll_size(&list2) != NUM_PUSH/4 + NUM_END)
+ stderr_pabort(__FILE__, __LINE__, "size is %u! not %u!\n", stddll_size(&list2), NUM_PUSH/4 + NUM_END);
+
+ if (NUM_END)
+ if ((i = *(size_t*) stddll_it_val(&list_it)) != NUM_PUSH - NUM_END * 2)
+ stderr_pabort(__FILE__, __LINE__, "wrong value for seq num %u is %u! not %u\n",
+ NUM_PUSH/2 - NUM_END, i, NUM_PUSH - NUM_END * 2);
+
+ j = 20000;
+ if (!stddll_repeat_insert(&list_it, &j, NUM_INSERT))
+ stderr_pabort(__FILE__, __LINE__, "repeat insert failed");
+
+ /* pop off the front of the list */
+ if (stddll_multi_pop_front(&list2, NUM_PUSH/4))
+ stderr_pabort(__FILE__, __LINE__, "multi_pop_front failed!");
+
+ i = 0;
+ for (stddll_begin(&list2, &list_it); !stddll_it_is_end(&list_it); stddll_it_next(&list_it), ++i) {
+ if (i < NUM_INSERT) {
+ if ((k = *(size_t*) stddll_it_val(&list_it)) != j)
+ stderr_pabort(__FILE__, __LINE__, "position %u: value %u incorrect should be %u!", i, k, j);
+ } else {
+ if (i == 5)
+ j = NUM_PUSH - NUM_END * 2;
+
+ if ((k = *(size_t*) stddll_it_val(&list_it)) != j)
+ stderr_pabort(__FILE__, __LINE__, "position %u: value %u incorrect should be %u!", i, k, j);
+
+ j += 2;
+ }
+ /* printf("list[%u] = %u\n", i, k); */
+ }
+ if (i != stddll_size(&list2) || i != NUM_INSERT + NUM_END)
+ stderr_pabort(__FILE__, __LINE__, "size %u! i %u! should be %u\n", stddll_size(&list2), i, NUM_INSERT + NUM_END);
+
+ stddll_destruct(&list);
+ stddll_destruct(&list2);
+
+ printf("\nstddll_test run successful!\n\n");
+
+ return 0;
+}
Added: vendor/stdutil/current/src/stdtest/stdhash_test.c
===================================================================
--- vendor/stdutil/current/src/stdtest/stdhash_test.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdtest/stdhash_test.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,77 @@
+/* Copyright (c) 2000, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <stdutil/stdhash.h>
+
+#define DEBUG(x)
+/* #define DEBUG(x) x */
+
+#define NUM_STRINGS 15000
+#define STRING_SIZE 20
+
+char strings[NUM_STRINGS][STRING_SIZE], (*str_ptr)[STRING_SIZE];
+
+int main(void) {
+ stdhash my_hash = STDHASH_STATIC_CONSTRUCT(sizeof(int), sizeof(char*),
+ stdhash_int_cmp, stdhash_int_hcode, NULL);
+ stdhash_it hit;
+ int i, j, k;
+
+ /*
+ stdhash_construct(&my_hash, sizeof(int), sizeof(char*),
+ stdhash_int_equals, stdhash_int_hashcode);
+ */
+
+ for (i = 0, str_ptr = strings; i < NUM_STRINGS; ++i, ++str_ptr)
+ sprintf((char*) str_ptr, "%d", i);
+
+ DEBUG(printf("begin insertions: time %ld\n", time(0)));
+ for (i = 0, str_ptr = strings; i < NUM_STRINGS; ++i, ++str_ptr)
+ stdhash_insert(&my_hash, 0, &i, &str_ptr);
+
+ DEBUG(printf("done insertions: time %ld\n", time(0)));
+ stdhash_begin(&my_hash, &hit); /* make the iterator valid */
+
+ DEBUG(printf("start loop overhead: time %ld\n", time(0)));
+ for (i = 0, j = 0, k = 0; i < 10000000; ++i) {
+ j = rand() % NUM_STRINGS;
+ if (stdhash_it_is_end(&hit) || *(int*) stdhash_it_key(&hit) == j)
+ ++k;
+ }
+ DEBUG(printf("end loop overhead: time %ld: j %d, k %d\n", time(0), j, k));
+
+ DEBUG(printf("start lookups: time %ld\n", time(0)));
+ for (i = 0; i < 10000000; ++i) {
+ j = rand() % NUM_STRINGS;
+ stdhash_find(&my_hash, &hit, &j);
+ if (stdhash_it_is_end(&hit) || *(int*) stdhash_it_key(&hit) != j)
+ exit(printf("got an end on it %d: %d != %d\n", i, *(int*) stdhash_it_key(&hit), j));
+ }
+ DEBUG(printf("done lookups: time %ld\n", time(0)));
+
+ printf("\nstdhash_test run successful!\n\n");
+
+ return 0;
+}
Added: vendor/stdutil/current/src/stdthread.c
===================================================================
--- vendor/stdutil/current/src/stdthread.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdthread.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,1157 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#if defined(_REENTRANT)
+
+# include <stdlib.h>
+
+# if defined(_WIN32)
+# include <process.h>
+# define STDSLEEPERS_BEGIN(cond) ((cond)->sleepers_end.next)
+# define STDSLEEPERS_LAST(cond) ((cond)->sleepers_end.prev)
+# define STDSLEEPERS_END(cond) (&(cond)->sleepers_end)
+# else
+# include <sys/time.h>
+# endif
+
+# include <stdutil/stderror.h>
+# include <stdutil/stdthread.h>
+
+/************************************************************************************************
+ * stdthread_spawn: Create a new thread and start its execution.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdthread_spawn(stdthread *thr_ptr, stdthread_id *id, stdthread_fcn thr_fcn, void *fcn_arg)
+# if defined(_WIN32)
+{
+ stdcode ret = STDESUCCESS;
+ HANDLE thr;
+ unsigned tid;
+
+ if ((thr = (HANDLE) _beginthreadex(NULL, 0, (unsigned(STDTHREAD_FCN*)(void*)) thr_fcn, fcn_arg, 0, &tid)) == NULL) {
+ ret = errno;
+ goto stdthread_spawn_end;
+ }
+
+ *thr_ptr = thr;
+ *id = tid;
+
+ stdthread_spawn_end:
+ return ret;
+}
+# else
+{
+ stdcode ret;
+ pthread_t tid;
+
+ if ((ret = pthread_create(&tid, NULL, thr_fcn, fcn_arg)) != STDESUCCESS) {
+ goto stdthread_spawn_end;
+ }
+
+ *thr_ptr = tid;
+ *id = tid;
+
+ stdthread_spawn_end:
+ return ret;
+}
+# endif
+
+/************************************************************************************************
+ * stdthread_detach: Set a thread to be in the detached state. Upon
+ * exiting, the thread's resources will be reclaimed. A detached
+ * thread cannot be joined.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdthread_detach(stdthread thr)
+# if defined(_WIN32)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (CloseHandle(thr) == 0) {
+ ret = (stdcode) GetLastError();
+ }
+
+ return ret;
+}
+# else
+{
+ return pthread_detach(thr);
+}
+# endif
+
+/************************************************************************************************
+ * stdthread_join: Wait for a thread to exit and get its return value.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdthread_join(stdthread thr, void **exitval_ptr)
+# if defined(_WIN32)
+{
+ stdcode ret = STDESUCCESS;
+ DWORD term_status;
+
+ if ((tmp = WaitForSingleObject(thr, INFINITE)) != WAIT_OBJECT_0) {
+ goto stdthread_join_fail;
+ }
+
+ if (GetExitCodeThread(thr, &term_status) == 0) {
+ goto stdthread_join_fail;
+ }
+
+ if (exitval_ptr != NULL) {
+ *exitval_ptr = (void*) term_status; /* TODO: broken if sizeof(void*) != sizeof(DWORD) */
+ }
+
+ if (CloseHandle(thr) == 0) {
+ goto stdthread_join_fail;
+ }
+
+ goto stdthread_join_end;
+
+ /* error handling and return */
+
+ stdthread_join_fail:
+ ret = (stdcode) GetLastError();
+
+ stdthread_join_end:
+ return ret;
+}
+# else
+{
+ return pthread_join(thr, exitval_ptr);
+}
+# endif
+
+/************************************************************************************************
+ * stdthread_exit: Terminate the execution of the current thread.
+ ***********************************************************************************************/
+
+STDINLINE void stdthread_exit(void *exitval)
+# if defined(_WIN32)
+{
+ _endthreadex((unsigned) exitval); /* TODO: broken if sizeof(void*) != sizeof(DWORD) */
+}
+# else
+{
+ pthread_exit(exitval);
+}
+# endif
+
+/************************************************************************************************
+ * stdthread_self: Get the ID of the running thread.
+ ***********************************************************************************************/
+
+STDINLINE stdthread_id stdthread_self(void)
+# if defined(_WIN32)
+{
+ return GetCurrentThreadId();
+}
+# else
+{
+ return pthread_self();
+}
+# endif
+
+/************************************************************************************************
+ * stdthread_eq: Compare two thread IDs for equality.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdthread_eq(stdthread_id id1, stdthread_id id2)
+#if defined(_WIN32)
+{
+ return id1 == id2;
+}
+#else
+{
+ return pthread_equal(id1, id2);
+}
+#endif
+
+/************************************************************************************************
+ * stdmutex_impl_init: Initialize an architecture dependent mutex.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_impl_init(stdmutex_impl *mut)
+#if defined(_WIN32)
+{
+ stdcode ret = STDESUCCESS;
+
+ __try {
+ InitializeCriticalSection(mut);
+
+ } __except (GetExceptionCode() == STATUS_NO_MEMORY ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
+ ret = STDENOMEM;
+ }
+
+ return ret;
+}
+#else
+{
+ return pthread_mutex_init(mut, NULL);
+}
+#endif
+
+/************************************************************************************************
+ * stdmutex_impl_fini: Reclaim an architecture dependent mutex.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_impl_fini(stdmutex_impl *mut)
+#if defined(_WIN32)
+{
+ DeleteCriticalSection(mut);
+
+ return STDESUCCESS;
+}
+#else
+{
+ return pthread_mutex_destroy(mut);
+}
+#endif
+
+/************************************************************************************************
+ * stdmutex_impl_grab: Grab an architecture dependent mutex.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_impl_grab(stdmutex_impl *mut, stdbool hardgrab)
+#if defined(_WIN32)
+{
+ stdcode ret = STDESUCCESS;
+
+ __try {
+ if (hardgrab) {
+ EnterCriticalSection(mut);
+
+ } else if (!TryEnterCriticalSection(mut)) {
+ ret = STDEBUSY;
+ }
+
+ } __except (GetExceptionCode() == STATUS_NO_MEMORY ||
+ GetExceptionCode() == STATUS_INVALID_HANDLE ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
+ ret = STDENOMEM;
+ }
+
+ return ret;
+}
+#else
+{
+ return (hardgrab ? pthread_mutex_lock(mut) : pthread_mutex_trylock(mut));
+}
+#endif
+
+/************************************************************************************************
+ * stdmutex_impl_drop: Drop an architecture dependent mutex.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_impl_drop(stdmutex_impl *mut)
+#if defined(_WIN32)
+{
+ LeaveCriticalSection(mut);
+
+ return STDESUCCESS;
+}
+#else
+{
+ return pthread_mutex_unlock(mut);
+}
+#endif
+
+/************************************************************************************************
+ * stdcond_impl_wake: Wake either 1 or all threads waiting on a condition.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdcond_impl_wake(stdcond *cond, stdbool wake_all)
+# if defined(_WIN32)
+{
+ stdcode ret;
+ stdbool woke_one = STDFALSE;
+ DWORD err = 0;
+ int loop_cnt;
+
+ if ((ret = stdmutex_impl_grab(&cond->lock, STDTRUE)) != STDESUCCESS) {
+ goto stdcond_wake_impl_end;
+ }
+
+ while ((wake_all || !woke_one) && STDSLEEPERS_BEGIN(cond) != STDSLEEPERS_END(cond)) {
+ stdcond_link * curr = STDSLEEPERS_BEGIN(cond);
+ stdcond_link * next = curr->next;
+ HANDLE sleeper = curr->sleeper;
+
+ /* wake sleeper */
+
+ woke_one = STDFALSE;
+
+ for (loop_cnt = 0; loop_cnt < 1000 && err != 1 && err != -1; ++loop_cnt) {
+ err = ResumeThread(sleeper);
+
+ if (err == 1) {
+ woke_one = STDTRUE; /* THE SLEEPER HAS AWOKEN! */
+
+ } else if (err == 0) { /* sleeper wasn't sleeping yet */
+ Sleep(0); /* yield time slice to give sleeper a chance to hit Suspend() */
+
+ } else if (err == -1) { /* error: remove from list + try next sleeper */
+ ret = (stdcode) GetLastError();
+ }
+
+ /* else suspended multiple times -> keep waking him */
+ }
+
+ /* NOTE: if loop_cnt gets to 1000; we treat it as an error: remove from list + try next sleeper */
+
+ /* unlink curr from beginning of sleepers; reclaim handle and stdcond_link */
+
+ next->prev = STDSLEEPERS_END(cond);
+ STDSLEEPERS_END(cond)->next = next;
+ CloseHandle(sleeper);
+ free(curr);
+ }
+
+ stdmutex_impl_drop(&cond->lock);
+
+ stdcond_wake_impl_end:
+ return ret;
+}
+#else
+{
+ return (wake_all ? pthread_cond_broadcast(cond) : pthread_cond_signal(cond));
+}
+#endif
+
+/************************************************************************************************
+ * stdmutex_fast_init: Initialize a mutex to be a fast mutex.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_fast_init(stdmutex *mut)
+{
+ stdcode ret;
+
+ if ((ret = stdmutex_impl_init(&mut->mut.fast)) != STDESUCCESS) {
+ goto stdmutex_fast_init_fail;
+ }
+
+ mut->mut_type = STDMUTEX_FAST;
+ goto stdmutex_fast_init_end;
+
+ /* error handling and return */
+
+ stdmutex_fast_init_fail:
+ mut->mut_type = STDMUTEX_INVAL;
+
+ stdmutex_fast_init_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_fast_fini: Reclaim a fast mutex.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_fast_fini(stdmutex *mut)
+{
+ stdcode ret;
+
+ STDSAFETY_CHECK(mut->mut_type == STDMUTEX_FAST);
+
+ if ((ret = stdmutex_impl_fini(&mut->mut.fast)) == STDESUCCESS) {
+ mut->mut_type = STDMUTEX_INVAL;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_fast_grab: Grab a fast mutex.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_fast_grab(stdmutex *mut, stdbool hardgrab)
+{
+ STDSAFETY_CHECK(mut->mut_type == STDMUTEX_FAST);
+
+ return stdmutex_impl_grab(&mut->mut.fast, hardgrab);
+}
+
+/************************************************************************************************
+ * stdmutex_fast_drop: Drop a fast mutex.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_fast_drop(stdmutex *mut)
+{
+ STDSAFETY_CHECK(mut->mut_type == STDMUTEX_FAST);
+
+ return stdmutex_impl_drop(&mut->mut.fast);
+}
+
+/************************************************************************************************
+ * stdmutex_fast_cond_wait: Wait on a condition protected by a fast mutex.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdmutex_fast_cond_wait(stdmutex *mut, stdcond *cond)
+# if defined(_WIN32)
+{
+ /* NOTE: this WIN32 code works for both fast and recursive mutexes:
+ the WIN32 stdmutex_rcrsv_cond_wait is a call through to this fcn
+ */
+ stdcode ret = STDESUCCESS;
+ HANDLE curr_proc;
+ HANDLE curr_thread;
+ unsigned grab_cnt;
+ int prev_priority;
+ int new_priority;
+ HANDLE dup_handle;
+ stdcond_link * my_link;
+ stdbool reacquire = STDFALSE;
+
+ /* check for recursive mutexes that owner only has one lock */
+
+ if (mut->mut_type == STDMUTEX_RCRSV) {
+
+ if ((ret = stdmutex_is_owner(mut, &grab_cnt)) != STDESUCCESS) {
+ goto stdmutex_fast_cond_wait_end;
+ }
+
+ if (grab_cnt == 0) {
+ ret = STDEPERM;
+ goto stdmutex_fast_cond_wait_end;
+ }
+
+ if (grab_cnt != 1) {
+ ret = STDEBUSY;
+ goto stdmutex_fast_cond_wait_end;
+ }
+
+ } else if (mut->mut_type != STDMUTEX_FAST) {
+ ret = STDEINVAL;
+ goto stdmutex_fast_cond_wait_end;
+ }
+
+ /* NOTE: we DuplicateHandle because only this thread is allowed to
+ use a handle from GetCurrentThread() and other threads will need
+ to resume this thread
+ */
+
+ curr_proc = GetCurrentProcess();
+ curr_thread = GetCurrentThread();
+
+ if (DuplicateHandle(curr_proc, curr_thread, curr_proc, &dup_handle, 0, TRUE, DUPLICATE_SAME_ACCESS) == 0) {
+ ret = (stdcode) GetLastError();
+ goto stdmutex_fast_cond_wait_end;
+ }
+
+ /* allocate a node to put in the condition's linked list of sleeping threads */
+
+ if ((my_link = (stdcond_link*) malloc(sizeof(stdcond_link))) == NULL) {
+ ret = STDENOMEM;
+ goto stdmutex_fast_cond_wait_malloc;
+ }
+
+ /* grab the condition's internal lock */
+
+ if ((ret = stdmutex_impl_grab(&cond->lock, STDTRUE)) != STDESUCCESS) {
+ goto stdmutex_fast_cond_wait_grab_cond;
+ }
+
+ /* drop mut */
+
+ if ((ret = stdmutex_drop(mut)) != STDESUCCESS) {
+ goto stdmutex_fast_cond_wait_drop_mut;
+ }
+
+ reacquire = STDTRUE; /* try to reacquire mut at end of this fcn */
+
+ /* get this thread's current priority so we can restore it after we bump it up */
+
+ if ((prev_priority = GetThreadPriority(curr_thread)) == THREAD_PRIORITY_ERROR_RETURN) {
+ ret = (stdcode) GetLastError();
+ goto stdmutex_fast_cond_wait_ThreadPriority;
+ }
+
+ /* bump up priority so that waker thread can never infinitely loop in a wake call (see below) */
+
+ if (SetThreadPriority(curr_thread, THREAD_PRIORITY_HIGHEST) == 0) {
+ ret = (stdcode) GetLastError();
+ goto stdmutex_fast_cond_wait_ThreadPriority;
+ }
+
+ /* link onto end of sleepers list */
+
+ my_link->sleeper = dup_handle;
+ my_link->prev = STDSLEEPERS_LAST(cond);
+ my_link->next = STDSLEEPERS_END(cond);
+ STDSLEEPERS_LAST(cond)->next = my_link;
+ STDSLEEPERS_END(cond)->prev = my_link;
+
+ /* NOTE: waker thread closes dup_handle, removes my_link from SLEEPERS + frees it */
+
+ /* drop the condition lock + Suspend the thread */
+
+ if (stdmutex_impl_drop(&cond->lock) != STDESUCCESS) {
+ abort();
+ }
+
+ /* This gap between releasing the lock and suspending is why we
+ bumped up the priority to the highest level -- waker will fail to
+ wake us if his attempt occurs while this thread is in this gap
+ and he is a higher priority thread. We need to bump to
+ THREAD_PRIORITY_HIGHEST to ensure that this thread will have
+ equal or better capability to run as a waker. If a waker was of
+ higher priority, then he would just loop forever waiting for this
+ thread to Suspend, which would never happen due to its lower
+ priority.
+ */
+
+ if (SuspendThread(curr_thread) == -1) {
+ abort();
+ }
+
+ /* we've been woken: restore previous thread priority if it hasn't changed while we slept */
+
+ if ((new_priority = GetThreadPriority(curr_thread)) == THREAD_PRIORITY_ERROR_RETURN ||
+ new_priority == THREAD_PRIORITY_HIGHEST) {
+ new_priority = prev_priority;
+ }
+
+ if (SetThreadPriority(curr_thread, prev_priority) == 0) {
+ ret = (stdcode) GetLastError();
+ }
+
+ goto stdmutex_fast_cond_wait_end;
+
+ /* error handling and return */
+
+ stdmutex_fast_cond_wait_ThreadPriority:
+ stdmutex_fast_cond_wait_drop_mut:
+ stdmutex_impl_drop(&cond->lock);
+
+ stdmutex_fast_cond_wait_grab_cond:
+ free(my_link);
+
+ stdmutex_fast_cond_wait_malloc:
+ CloseHandle(dup_handle);
+
+ stdmutex_fast_cond_wait_end:
+ if (reacquire) {
+ ret |= stdmutex_grab(mut);
+ }
+
+ return ret;
+}
+# else
+{
+ STDSAFETY_CHECK(mut->mut_type == STDMUTEX_FAST);
+
+ return pthread_cond_wait(cond, &mut->mut.fast);
+}
+# endif
+
+/************************************************************************************************
+ * stdmutex_rcrsv_init: Initialize a recursive mutex.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_rcrsv_init(stdmutex *mut)
+{
+ stdcode ret;
+ stdmutex_rcrsv * rmut = &mut->mut.rcrsv;
+
+ if ((ret = stdmutex_impl_init(&rmut->outer_lock)) != STDESUCCESS) {
+ goto stdmutex_rcrsv_init_fail;
+ }
+
+ if ((ret = stdmutex_impl_init(&rmut->inner_lock)) != STDESUCCESS) {
+ goto stdmutex_rcrsv_init_fail2;
+ }
+
+ rmut->num_waiting = 0;
+ rmut->owner_cnt = 0;
+ mut->mut_type = STDMUTEX_RCRSV;
+
+ goto stdmutex_rcrsv_init_end;
+
+ /* error handling and return */
+
+ stdmutex_rcrsv_init_fail2:
+ stdmutex_impl_fini(&rmut->outer_lock);
+
+ stdmutex_rcrsv_init_fail:
+ mut->mut_type = STDMUTEX_INVAL;
+
+ stdmutex_rcrsv_init_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_rcrsv_fini: Invalidate a recursive mutex and reclaim its resources.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_rcrsv_fini(stdmutex *mut)
+{
+ stdcode ret;
+ stdmutex_rcrsv * rmut = &mut->mut.rcrsv;
+
+ STDSAFETY_CHECK(mut->mut_type == STDMUTEX_RCRSV);
+
+ if ((ret = stdmutex_impl_grab(&rmut->outer_lock, STDFALSE)) != STDESUCCESS) {
+ goto stdmutex_rcrsv_fini_end;
+ }
+
+ if (mut->mut_type != STDMUTEX_RCRSV || rmut->owner_cnt < 0 || rmut->num_waiting < 0) {
+ ret = STDEINVAL;
+ goto stdmutex_rcrsv_fini_fail;
+ }
+
+ if (rmut->owner_cnt != 0 || rmut->num_waiting != 0) {
+ ret = STDEBUSY;
+ goto stdmutex_rcrsv_fini_fail;
+ }
+
+ mut->mut_type = STDMUTEX_INVAL;
+ rmut->owner_cnt = -666;
+ rmut->num_waiting = -666;
+
+ stdmutex_impl_fini(&rmut->inner_lock);
+ stdmutex_impl_drop(&rmut->outer_lock);
+ stdmutex_impl_fini(&rmut->outer_lock);
+
+ goto stdmutex_rcrsv_fini_end;
+
+ /* error handling and return */
+
+ stdmutex_rcrsv_fini_fail:
+ stdmutex_impl_drop(&rmut->outer_lock);
+
+ stdmutex_rcrsv_fini_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_rcrsv_is_owner: Get the current thread's grab count on mut.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_rcrsv_is_owner(stdmutex *mut, unsigned *grab_cnt)
+{
+ stdcode ret = STDESUCCESS;
+ stdmutex_rcrsv * rmut = &mut->mut.rcrsv;
+
+ STDSAFETY_CHECK(mut->mut_type == STDMUTEX_RCRSV);
+
+ if ((ret = stdmutex_impl_grab(&rmut->outer_lock, STDTRUE)) != STDESUCCESS) {
+ goto stdmutex_rcrsv_is_owner_end;
+ }
+
+ if (mut->mut_type != STDMUTEX_RCRSV || rmut->owner_cnt < 0 || rmut->num_waiting < 0) {
+ ret = STDEINVAL;
+ goto stdmutex_rcrsv_is_owner_drop;
+ }
+
+ if (rmut->owner_cnt != 0 && stdthread_eq(rmut->owner_id, stdthread_self())) {
+ *grab_cnt = (unsigned) rmut->owner_cnt;
+
+ } else {
+ *grab_cnt = 0;
+ }
+
+ stdmutex_rcrsv_is_owner_drop:
+ stdmutex_impl_drop(&rmut->outer_lock);
+
+ stdmutex_rcrsv_is_owner_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_rcrsv_grab: Grab a recursive mutex.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_rcrsv_grab(stdmutex *mut, stdbool hardgrab)
+{
+ stdcode ret;
+ stdmutex_rcrsv * rmut = &mut->mut.rcrsv;
+
+ STDSAFETY_CHECK(mut->mut_type == STDMUTEX_RCRSV);
+
+ if ((ret = stdmutex_impl_grab(&rmut->outer_lock, STDTRUE)) != STDESUCCESS) {
+ goto stdmutex_rcrsv_grab_end;
+ }
+
+ if (mut->mut_type != STDMUTEX_RCRSV || rmut->owner_cnt < 0 || rmut->num_waiting < 0) {
+ ret = STDEINVAL;
+ goto stdmutex_rcrsv_grab_drop;
+ }
+
+ if (rmut->owner_cnt != 0 && stdthread_eq(rmut->owner_id, stdthread_self())) {
+ ++rmut->owner_cnt; /* owner just increments count */
+
+ } else if (hardgrab) { /* need to wait on inner_lock */
+ ++rmut->num_waiting;
+
+ stdmutex_impl_drop(&rmut->outer_lock);
+ ret = stdmutex_impl_grab(&rmut->inner_lock, STDTRUE);
+ stdmutex_impl_grab(&rmut->outer_lock, STDTRUE);
+
+ --rmut->num_waiting;
+
+ if (ret == STDESUCCESS) {
+ rmut->owner_cnt = 1;
+ rmut->owner_id = stdthread_self(); /* it's mine! */
+ }
+
+ } else {
+ ret = STDEBUSY; /* caller doesn't want to potentially block */
+ goto stdmutex_rcrsv_grab_drop;
+ }
+
+ stdmutex_rcrsv_grab_drop:
+ stdmutex_impl_drop(&rmut->outer_lock);
+
+ stdmutex_rcrsv_grab_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_rcrsv_drop: Drop a recursive mutex.
+ ***********************************************************************************************/
+
+STDINLINE static stdcode stdmutex_rcrsv_drop(stdmutex *mut)
+{
+ stdcode ret;
+ stdmutex_rcrsv * rmut = &mut->mut.rcrsv;
+
+ STDSAFETY_CHECK(mut->mut_type == STDMUTEX_RCRSV);
+
+ if ((ret = stdmutex_impl_grab(&rmut->outer_lock, STDTRUE)) != STDESUCCESS) {
+ goto stdmutex_rcrsv_drop_end;
+ }
+
+ if (mut->mut_type != STDMUTEX_RCRSV || rmut->owner_cnt < 0 || rmut->num_waiting < 0) {
+ ret = STDEINVAL;
+ goto stdmutex_rcrsv_drop_drop;
+ }
+
+ if (rmut->owner_cnt == 0 || !stdthread_eq(rmut->owner_id, stdthread_self())) {
+ ret = STDEPERM;
+ goto stdmutex_rcrsv_drop_drop;
+ }
+
+ if (--rmut->owner_cnt == 0) {
+ stdmutex_impl_drop(&rmut->inner_lock);
+ }
+
+ stdmutex_rcrsv_drop_drop:
+ stdmutex_impl_drop(&rmut->outer_lock);
+
+ stdmutex_rcrsv_drop_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_rcrsv_cond_wait: Atomically unlock a 'mut' and wait on 'cond.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdmutex_rcrsv_cond_wait(stdmutex *mut, stdcond *cond)
+
+# if defined(_WIN32)
+{
+ /* NOTE: the WIN32 code works for both fast and recursive mutexes:
+ currently stdmutex_rcrsv_cond_wait is just a call through
+ */
+
+ return stdmutex_fast_cond_wait(mut, cond);
+}
+# else
+{
+ stdcode ret;
+ stdmutex_rcrsv * rmut = &mut->mut.rcrsv;
+
+ STDSAFETY_CHECK(mut->mut_type == STDMUTEX_RCRSV);
+
+ if ((ret = stdmutex_impl_grab(&rmut->outer_lock, STDTRUE)) != STDESUCCESS) {
+ goto stdmutex_rcrsv_cond_wait_end;
+ }
+
+ if (mut->mut_type != STDMUTEX_RCRSV || rmut->owner_cnt < 0 || rmut->num_waiting < 0) {
+ ret = STDEINVAL;
+ goto stdmutex_rcrsv_cond_wait_drop;
+ }
+
+ if (rmut->owner_cnt == 0 || !stdthread_eq(rmut->owner_id, stdthread_self())) {
+ ret = STDEPERM;
+ goto stdmutex_rcrsv_cond_wait_drop;
+ }
+
+ if (rmut->owner_cnt != 1) {
+ ret = STDEBUSY;
+ goto stdmutex_rcrsv_cond_wait_drop;
+ }
+
+ ++rmut->num_waiting;
+ rmut->owner_cnt = 0;
+
+ stdmutex_impl_drop(&rmut->outer_lock);
+ pthread_cond_wait(cond, &rmut->inner_lock);
+ stdmutex_impl_grab(&rmut->outer_lock, STDTRUE);
+
+ --rmut->num_waiting;
+ rmut->owner_cnt = 1;
+ rmut->owner_id = stdthread_self();
+
+ stdmutex_rcrsv_cond_wait_drop:
+ stdmutex_impl_drop(&rmut->outer_lock);
+
+ stdmutex_rcrsv_cond_wait_end:
+ return ret;
+}
+# endif
+
+/************************************************************************************************
+ * stdmutex_init: Initialize a mutex.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdmutex_init(stdmutex *mut, stdmutex_type t)
+{
+ stdcode ret = STDEINVAL;
+
+ switch (t) {
+ case STDMUTEX_FAST:
+ ret = stdmutex_fast_init(mut);
+ break;
+
+ case STDMUTEX_RCRSV:
+ ret = stdmutex_rcrsv_init(mut);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_fini: Invalidate a mutex and reclaim its resources.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdmutex_fini(stdmutex *mut)
+{
+ stdcode ret = STDEINVAL;
+
+ switch (mut->mut_type) {
+ case STDMUTEX_FAST:
+ ret = stdmutex_fast_fini(mut);
+ break;
+
+ case STDMUTEX_RCRSV:
+ ret = stdmutex_rcrsv_fini(mut);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_grab: Grab a mutex.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdmutex_grab(stdmutex *mut)
+{
+ stdcode ret = STDEINVAL;
+
+ switch (mut->mut_type) {
+ case STDMUTEX_FAST:
+ ret = stdmutex_fast_grab(mut, STDTRUE);
+ break;
+
+ case STDMUTEX_RCRSV:
+ ret = stdmutex_rcrsv_grab(mut, STDTRUE);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_trygrab: Try to grab a mutex without blocking.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdmutex_trygrab(stdmutex *mut)
+{
+ stdcode ret = STDEINVAL;
+
+ switch (mut->mut_type) {
+ case STDMUTEX_FAST:
+ ret = stdmutex_fast_grab(mut, STDFALSE);
+ break;
+
+ case STDMUTEX_RCRSV:
+ ret = stdmutex_rcrsv_grab(mut, STDFALSE);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_drop: Drop a mutex.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdmutex_drop(stdmutex *mut)
+{
+ stdcode ret = STDEINVAL;
+
+ switch (mut->mut_type) {
+ case STDMUTEX_FAST:
+ ret = stdmutex_fast_drop(mut);
+ break;
+
+ case STDMUTEX_RCRSV:
+ ret = stdmutex_rcrsv_drop(mut);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmutex_is_owner: Get the grab count on a recursive mutex.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdmutex_is_owner(stdmutex *mut, unsigned *grab_cnt)
+{
+ stdcode ret = STDEINVAL;
+
+ switch (mut->mut_type) {
+ case STDMUTEX_FAST:
+ ret = STDENOSYS;
+ break;
+
+ case STDMUTEX_RCRSV:
+ ret = stdmutex_rcrsv_is_owner(mut, grab_cnt);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcond_init: Initialize a condition variable.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcond_init(stdcond *cond)
+# if defined(_WIN32)
+{
+ stdcode ret;
+
+ if ((ret = stdmutex_impl_init(&cond->lock)) != STDESUCCESS) {
+ goto stdcond_init_end;
+ }
+
+ cond->sleepers_end.sleeper = NULL;
+ cond->sleepers_end.next = STDSLEEPERS_END(cond);
+ cond->sleepers_end.prev = STDSLEEPERS_END(cond);
+
+ stdcond_init_end:
+ return ret;
+}
+# else
+{
+ return pthread_cond_init(cond, NULL);
+}
+# endif
+
+/************************************************************************************************
+ * stdcond_fini: Invalidate a condition variable and reclaim its resources.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcond_fini(stdcond *cond)
+# if defined(_WIN32)
+{
+ stdcode ret;
+
+ if ((ret = stdmutex_impl_grab(&cond->lock, STDFALSE)) != STDESUCCESS) {
+ goto stdcond_fini_end;
+ }
+
+ if (STDSLEEPERS_BEGIN(cond) != STDSLEEPERS_END(cond)) { /* sleepers list not empty */
+ ret = STDEBUSY;
+ goto stdcond_fini_fail;
+ }
+
+ stdmutex_impl_drop(&cond->lock);
+ stdmutex_impl_fini(&cond->lock);
+
+ goto stdcond_fini_end;
+
+ /* error handling and return */
+
+ stdcond_fini_fail:
+ stdmutex_impl_drop(&cond->lock);
+
+ stdcond_fini_end:
+ return ret;
+}
+# else
+{
+ return pthread_cond_destroy(cond);
+}
+# endif
+
+/************************************************************************************************
+ * stdcond_wake_one: Wake at most a single thread waiting on a condition variable.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcond_wake_one(stdcond * cond)
+{
+ return stdcond_impl_wake(cond, STDFALSE);
+}
+
+/************************************************************************************************
+ * stdcond_wake_all: Wake all threads currently waiting on a condition variable.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcond_wake_all(stdcond * cond)
+{
+ return stdcond_impl_wake(cond, STDTRUE);
+}
+
+/************************************************************************************************
+ * stdcond_wait: Wait on a condition variable until woken.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcond_wait(stdcond *cond, stdmutex *mut)
+{
+ stdcode ret = STDEINVAL;
+
+ switch (mut->mut_type) {
+ case STDMUTEX_FAST:
+ ret = stdmutex_fast_cond_wait(mut, cond);
+ break;
+
+ case STDMUTEX_RCRSV:
+ ret = stdmutex_rcrsv_cond_wait(mut, cond);
+ break;
+ }
+
+ return ret;
+}
+
+#if 0 /* comment out stdcond_wait_timed */
+
+/************************************************************************************************
+ * stdcond_wait_timed:
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcond_wait_timed(stdcond * cond,
+ stdmutex * mut)
+{
+ stdcode ret = STDEINVAL;
+
+ switch (mut->mut_type) {
+ case STDMUTEX_FAST:
+ ret = stdmutex_fast_cond_wait_timed(mut, cond);
+ break;
+
+ case STDMUTEX_RCRSV:
+ ret = stdmutex_rcrsv_cond_wait_timed(mut, cond);
+ break;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdcond_wait_timed:
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdcond_wait_timed(stdcond *cond, stdmutex *mut, const stdtime *abs_time)
+# if defined(_WIN32)
+{
+ /* TODO: figure out how + implement me! */
+ return ENOSYS;
+}
+# else
+{
+ /* TODO: needs work; make it look like stdmutex_*_cond_wait */
+ struct timespec timeout;
+ stdmutex_impl * mut_impl = NULL;
+ long grab_cnt = 0;
+ stdcode ret;
+
+ timeout.tv_sec = abs_time->m_Sec;
+ timeout.tv_nsec = abs_time->m_Nsec;
+
+ if ((ret = stdmutex_is_owner(mut, &grab_cnt)) != STDESUCCESS) {
+ assert(STDFALSE /* stdcond_wait_timed: user race condition on mut, protect calls to fini! */);
+ goto stdcond_wait_timed_fail;
+ }
+
+ if (grab_cnt == 0) {
+ assert(STDFALSE /* stdcond_wait_timed: user doesn't own mut! */);
+ ret = EPERM;
+ goto stdcond_wait_timed_EPERM;
+ }
+
+ if (grab_cnt != 1) {
+ assert(STDFALSE /* stdcond_wait: recursive mutex must have a grab_cnt of 1! */);
+ ret = EINVAL;
+ goto stdcond_wait_timed_EINVAL;
+ }
+
+ switch (mut->mut_type) {
+ case STDMUTEX_FAST:
+ {
+ stdmutex_fast * fmut = &mut->m_Mutex.m_Fast;
+
+ fmut->owner_cnt = 0;
+ mut_impl = &fmut->m_Lock;
+ }
+ break;
+
+ case STDMUTEX_RCRSV:
+ {
+ stdmutex_rcrsv * rmut = &mut->mut.rcrsv;
+
+ rmut->owner_cnt = 0;
+ mut_impl = &rmut->inner_lock;
+ }
+ break;
+
+ default:
+ assert(STDFALSE);
+ ret = EINVAL;
+ goto stdcond_wait_timed_EINVAL;
+ }
+
+ if ((ret = pthread_cond_timedwait(cond, mut_impl, &timeout)) != STDESUCCESS) {
+ goto stdcond_wait_timed_pcond_timedwait;
+ }
+
+ assert(ret == STDESUCCESS);
+ goto stdcond_wait_timed_end;
+
+ /* error handling and return */
+
+ stdcond_wait_timed_pcond_timedwait:
+ stdcond_wait_timed_EINVAL:
+ stdcond_wait_timed_fail:
+ assert(ret != STDESUCCESS);
+
+ stdcond_wait_timed_end:
+ return ret;
+}
+# endif
+#endif
+
+#else
+int stdthread_trnsl_dummy; /* avoids empty translation unit error #if !defined(_REENTRANT) */
+#endif
Added: vendor/stdutil/current/src/stdtime.c
===================================================================
--- vendor/stdutil/current/src/stdtime.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdtime.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,324 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#if defined(_WIN32)
+# include <windows.h>
+# include <sys/types.h>
+# include <sys/timeb.h>
+#else
+# include <time.h>
+# include <sys/time.h>
+#endif
+
+#include <stdutil/stderror.h>
+#include <stdutil/stdtime.h>
+
+/* stdtime: sec == STDINT64_MIN -> nano == 0
+ sec > 0 -> 0 <= nano < STD1BILLION
+ sec == 0 -> -STD1BILLION < nano < STD1BILLION
+ sec < 0 -> -STD1BILLION < nano <= 0
+*/
+
+#define STDTIME_IS_LEGAL(t) ( ((t).sec != STDINT64_MIN || (t).nano == 0) && \
+ (((t).sec >= 0 && (t).nano >= 0 && (t).nano < STD1BILLION) || \
+ ((t).sec <= 0 && (t).nano <= 0 && (t).nano > -STD1BILLION)) )
+
+/************************************************************************************************
+ * stdtime: Get the current system time since UTC 00:00:00, Jan 1, 1970.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdtime_now(stdtime * abs_time)
+#if defined(_WIN32)
+{
+ struct _timeb t;
+
+ _ftime(&t);
+
+ abs_time->sec = t.time;
+ abs_time->nano = t.millitm * STD1MILLION;
+
+ return STDESUCCESS;
+}
+#else
+{
+ stdcode ret = STDESUCCESS;
+ struct timeval t;
+
+ if (gettimeofday(&t, NULL) != STDESUCCESS) {
+ ret = errno;
+ goto stdtime_now_end;
+ }
+
+ abs_time->sec = t.tv_sec;
+ abs_time->nano = t.tv_usec * STD1THOUSAND;
+
+stdtime_now_end:
+ return ret;
+}
+#endif
+
+/************************************************************************************************
+ * stdtime_time64: Return a stdtime created from a stdtime_time64.
+ *
+ * NOTE: '/' and '%' aren't uniformly defined for negative operands so we negate as needed
+ ***********************************************************************************************/
+
+STDINLINE stdtime stdtime_time64(stdtime64 src)
+{
+ stdtime64 cpy = (src >= 0 ? src : -src);
+ stdtime ret;
+
+ ret.sec = cpy / STD1BILLION;
+ ret.nano = (stdint32) cpy % (stdint32) STD1BILLION;
+
+ if (src < 0) {
+ ret.sec = -ret.sec;
+ ret.nano = -ret.nano;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdtime_cmp: Compare two stdtimes.
+ ***********************************************************************************************/
+
+STDINLINE int stdtime_cmp(stdtime ls, stdtime rs)
+{
+ STDSAFETY_CHECK(STDTIME_IS_LEGAL(ls) && STDTIME_IS_LEGAL(rs));
+
+ if (ls.sec == rs.sec) {
+
+ if (ls.nano == rs.nano) {
+ return 0;
+ }
+
+ return (ls.nano < rs.nano ? -1 : 1);
+ }
+
+ return (ls.sec < rs.sec ? -1 : 1);
+}
+
+/************************************************************************************************
+ * stdtime_sign: Get the sign (-1: negative, 0: none, 1: positive) of a stdtime.
+ ***********************************************************************************************/
+
+STDINLINE int stdtime_sign(stdtime t)
+{
+ stdtime t2 = { 0, 0 };
+
+ return stdtime_cmp(t, t2);
+}
+
+/************************************************************************************************
+ * stdtime_neg: Return the negation of a stdtime.
+ ***********************************************************************************************/
+
+STDINLINE stdtime stdtime_neg(stdtime t)
+{
+ STDSAFETY_CHECK(STDTIME_IS_LEGAL(t));
+
+ t.sec = -t.sec;
+ t.nano = -t.nano;
+
+ return t;
+}
+
+/************************************************************************************************
+ * stdtime_add: Return the addition of two stdtimes.
+ ***********************************************************************************************/
+
+STDINLINE stdtime stdtime_add(stdtime ls, stdtime rs)
+{
+ stdtime ret;
+
+ STDSAFETY_CHECK(STDTIME_IS_LEGAL(ls) && STDTIME_IS_LEGAL(rs));
+
+ /* do the addition */
+
+ ret.sec = ls.sec + rs.sec;
+ ret.nano = ls.nano + rs.nano;
+
+ /* ensure -STD1BILLION < nano < STD1BILLION */
+
+ if (ret.nano >= STD1BILLION) {
+ ++ret.sec;
+ ret.nano -= STD1BILLION;
+
+ } else if (ret.nano <= -STD1BILLION) {
+ --ret.sec;
+ ret.nano += STD1BILLION;
+ }
+
+ /* check for non-agreement in signs */
+
+ if (ret.sec > 0) {
+
+ if (ret.nano < 0) {
+ --ret.sec;
+ ret.nano += STD1BILLION;
+ }
+
+ } else if (ret.sec != 0) {
+
+ if (ret.nano > 0) {
+ ++ret.sec;
+ ret.nano -= STD1BILLION;
+ }
+ }
+
+ /* check for nasty edge case and wrap around if not exactly minimum representation */
+
+ if (ret.sec == STDINT64_MIN && ret.nano != 0) {
+ --ret.sec;
+ ret.nano += STD1BILLION;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdtime_sub: Return the difference of two stdtimes.
+ ***********************************************************************************************/
+
+STDINLINE stdtime stdtime_sub(stdtime ls, stdtime rs)
+{
+ return stdtime_add(ls, stdtime_neg(rs));
+}
+
+/************************************************************************************************
+ * stdtime64_now: Get the current system time since UTC 00:00:00, Jan 1, 1970.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdtime64_now(stdtime64 * abs_time)
+{
+ stdtime t;
+ stdcode ret = stdtime_now(&t);
+
+ if (ret == STDESUCCESS) {
+ *abs_time = stdtime64_time(t);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdtime64_time: Return a stdtime64 from a stdtime.
+ ***********************************************************************************************/
+
+STDINLINE stdtime64 stdtime64_time(stdtime t)
+{
+ STDSAFETY_CHECK(STDTIME_IS_LEGAL(t));
+
+ return (stdtime64) t.sec * STD1BILLION + t.nano;
+}
+
+/************************************************************************************************
+ * stdsleep: Sleep for a period of time.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdsleep(stdtime delta, stdtime *remndr)
+# if defined(_WIN32)
+{
+ stdcode ret = STDESUCCESS;
+ stdtime start_time = { 0, 0 };
+ stdtime end_time = { 0, 0 };
+ DWORD sleep_amnt;
+
+ if (delta.sec < 0 || delta.nano < 0 || delta.nano >= STD1BILLION) {
+ ret = STDEINVAL;
+ goto stdsleep_fail;
+ }
+
+ /* conditional +1 for possible nanosecond division trunctation */
+
+ sleep_amnt = (DWORD) (delta.sec * STD1THOUSAND + delta.nano / STD1MILLION) + (delta.nano != 0 ? 1 : 0);
+
+ Sleep(sleep_amnt);
+
+ goto stdsleep_end;
+
+ /* error handling and return */
+
+ stdsleep_fail:
+ if (remndr != NULL) {
+ *remndr = delta;
+ }
+
+ stdsleep_end:
+ return ret;
+}
+#else
+{
+ stdcode ret;
+ struct timespec d;
+ struct timespec r;
+
+ if (delta.sec < 0 || delta.nano < 0 || delta.nano >= STD1BILLION) {
+ ret = STDEINVAL;
+ goto stdsleep_fail;
+ }
+
+ d.tv_sec = (time_t) delta.sec;
+ d.tv_nsec = delta.nano;
+
+ if ((ret = nanosleep(&d, &r)) != STDESUCCESS) {
+ ret = errno;
+
+ if (remndr != NULL) {
+ remndr->sec = r.tv_sec;
+ remndr->nano = r.tv_nsec;
+ }
+ }
+
+ goto stdsleep_end;
+
+ /* error handling and return */
+
+ stdsleep_fail:
+ if (remndr != NULL) {
+ *remndr = delta;
+ }
+
+ stdsleep_end:
+ return ret;
+}
+#endif
+
+/************************************************************************************************
+ * stdsleep64: Sleep for a number of nanoseconds.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdsleep64(stdtime64 delta, stdtime64 *remndr)
+{
+ stdcode ret;
+ stdtime t_delta = stdtime_time64(delta);
+ stdtime t_remndr;
+
+ ret = stdsleep(t_delta, (remndr != NULL ? &t_remndr : NULL));
+
+ if (ret != STDESUCCESS && remndr != NULL) {
+ *remndr = stdtime64_time(t_remndr);
+ }
+
+ return ret;
+}
Added: vendor/stdutil/current/src/stdutil/private/stdarch.h
===================================================================
--- vendor/stdutil/current/src/stdutil/private/stdarch.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/private/stdarch.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,174 @@
+/* stdutil/private/stdarch.h. Generated by configure. */
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdarch_h_2005_07_12_00_51_28_jschultz_at_cnds_jhu_edu
+#define stdarch_h_2005_07_12_00_51_28_jschultz_at_cnds_jhu_edu
+
+#include <stddef.h>
+#include <limits.h>
+
+/* the following #undef's are filled in by the configure script */
+
+#define SIZEOF_CHAR 1
+#define SIZEOF_SHORT 2
+#define SIZEOF_INT 4
+#define SIZEOF_LONG 4
+#define SIZEOF_LONG_LONG 8
+#define SIZEOF_SIZE_T 4
+#define SIZEOF_VOID_P 4
+
+/* STDARCH_MAX_BYTE_ALIGNMENT must be a power of 2 (e.g. - 1, 2, 4, 8)
+ and must be the most stringent byte alignment that your
+ architecture requires for any basic type; 4 should be good enough
+ for any 32 bit or smaller architectures, 8 should be good enough
+ for any 64 bit or smaller architectures, etc.
+*/
+
+/* #undef STDARCH_MAX_BYTE_ALIGNMENT */
+#define STDARCH_MAX_BYTE_ALIGNMENT 4
+
+/* check if a NULL char * is all zero in memory */
+
+/* #undef STDARCH_NULL_IS_ZERO */
+#define STDARCH_NULL_IS_ZERO 1
+
+/* endian reorder mapping */
+
+#define STDENDIAN16_SWAP 1
+
+#define STDENDIAN32_NET0_FROM_HOST 3
+#define STDENDIAN32_NET1_FROM_HOST 2
+#define STDENDIAN32_NET2_FROM_HOST 1
+#define STDENDIAN32_NET3_FROM_HOST 0
+
+#define STDENDIAN32_HOST0_FROM_NET 3
+#define STDENDIAN32_HOST1_FROM_NET 2
+#define STDENDIAN32_HOST2_FROM_NET 1
+#define STDENDIAN32_HOST3_FROM_NET 0
+
+#define STDENDIAN64_NET0_FROM_HOST 7
+#define STDENDIAN64_NET1_FROM_HOST 6
+#define STDENDIAN64_NET2_FROM_HOST 5
+#define STDENDIAN64_NET3_FROM_HOST 4
+#define STDENDIAN64_NET4_FROM_HOST 3
+#define STDENDIAN64_NET5_FROM_HOST 2
+#define STDENDIAN64_NET6_FROM_HOST 1
+#define STDENDIAN64_NET7_FROM_HOST 0
+
+#define STDENDIAN64_HOST0_FROM_NET 7
+#define STDENDIAN64_HOST1_FROM_NET 6
+#define STDENDIAN64_HOST2_FROM_NET 5
+#define STDENDIAN64_HOST3_FROM_NET 4
+#define STDENDIAN64_HOST4_FROM_NET 3
+#define STDENDIAN64_HOST5_FROM_NET 2
+#define STDENDIAN64_HOST6_FROM_NET 1
+#define STDENDIAN64_HOST7_FROM_NET 0
+
+/* define std(u)int32, std(u)int64 and min/max constants */
+
+#if (SIZEOF_CHAR != 1)
+# error No 1 byte integer type found!
+#endif
+
+#if (SIZEOF_SHORT != 2)
+# error No 2 byte integer type found!
+#endif
+
+#if (SIZEOF_INT == 4)
+
+typedef int stdint32;
+typedef unsigned int stduint32;
+
+# define STDINT32_MAX INT_MAX
+# define STDINT32_MIN INT_MIN
+# define STDUINT32_MAX UINT_MAX
+
+#elif (SIZEOF_LONG == 4)
+
+typedef long stdint32;
+typedef unsigned long stduint32;
+
+#define STDINT32_MAX LONG_MAX
+#define STDINT32_MIN LONG_MIN
+#define STDUINT32_MAX ULONG_MAX
+
+#else
+# error No 4 byte integer type found!
+#endif
+
+#if defined(_WIN32)
+
+typedef __int64 stdint64;
+typedef unsigned __int64 stduint64;
+
+#elif (SIZEOF_LONG == 8)
+
+typedef long stdint64;
+typedef unsigned long stduint64;
+
+#elif (SIZEOF_LONG_LONG == 8)
+
+typedef long long stdint64;
+typedef unsigned long long stduint64;
+
+#else
+# error No 8 byte integeral type found!
+#endif
+
+#define STDINT64_MAX (~STDINT64_MIN)
+#define STDINT64_MIN ((stdint64) 0x1 << 63)
+#define STDUINT64_MAX ((stduint64) -1)
+
+/* define stdssize type and min/max constants */
+
+#if (SIZEOF_SIZE_T == 2)
+
+typedef short stdssize;
+
+# define STDSSIZE_MAX SHRT_MAX
+# define STDSSIZE_MIN SHRT_MIN
+
+#elif (SIZEOF_SIZE_T == 4)
+
+typedef stdint32 stdssize;
+
+# define STDSSIZE_MAX STDINT32_MAX
+# define STDSSIZE_MIN STDINT32_MIN
+
+#elif (SIZEOF_SIZE_T == 8)
+
+typedef stdint64 stdssize;
+
+# define STDSSIZE_MAX STDINT64_MAX
+# define STDSSIZE_MIN STDINT64_MIN
+
+#else
+# error No integral type of same size as size_t!
+#endif
+
+/* macros used for ensuring proper byte alignment of types in memory */
+
+#define STDARCH_PADDING(x) ((STDARCH_MAX_BYTE_ALIGNMENT - ((x) & (STDARCH_MAX_BYTE_ALIGNMENT - 1))) & (STDARCH_MAX_BYTE_ALIGNMENT - 1))
+#define STDARCH_PADDED_SIZE(x) ((x) + STDARCH_PADDING(x))
+
+#endif
Added: vendor/stdutil/current/src/stdutil/private/stdarch.h.in
===================================================================
--- vendor/stdutil/current/src/stdutil/private/stdarch.h.in 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/private/stdarch.h.in 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,173 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdarch_h_2005_07_12_00_51_28_jschultz_at_cnds_jhu_edu
+#define stdarch_h_2005_07_12_00_51_28_jschultz_at_cnds_jhu_edu
+
+#include <stddef.h>
+#include <limits.h>
+
+/* the following #undef's are filled in by the configure script */
+
+#undef SIZEOF_CHAR
+#undef SIZEOF_SHORT
+#undef SIZEOF_INT
+#undef SIZEOF_LONG
+#undef SIZEOF_LONG_LONG
+#undef SIZEOF_SIZE_T
+#undef SIZEOF_VOID_P
+
+/* STDARCH_MAX_BYTE_ALIGNMENT must be a power of 2 (e.g. - 1, 2, 4, 8)
+ and must be the most stringent byte alignment that your
+ architecture requires for any basic type; 4 should be good enough
+ for any 32 bit or smaller architectures, 8 should be good enough
+ for any 64 bit or smaller architectures, etc.
+*/
+
+#undef STDARCH_MAX_BYTE_ALIGNMENT
+#define STDARCH_MAX_BYTE_ALIGNMENT 4
+
+/* check if a NULL char * is all zero in memory */
+
+#undef STDARCH_NULL_IS_ZERO
+#define STDARCH_NULL_IS_ZERO 1
+
+/* endian reorder mapping */
+
+#undef STDENDIAN16_SWAP
+
+#undef STDENDIAN32_NET0_FROM_HOST
+#undef STDENDIAN32_NET1_FROM_HOST
+#undef STDENDIAN32_NET2_FROM_HOST
+#undef STDENDIAN32_NET3_FROM_HOST
+
+#undef STDENDIAN32_HOST0_FROM_NET
+#undef STDENDIAN32_HOST1_FROM_NET
+#undef STDENDIAN32_HOST2_FROM_NET
+#undef STDENDIAN32_HOST3_FROM_NET
+
+#undef STDENDIAN64_NET0_FROM_HOST
+#undef STDENDIAN64_NET1_FROM_HOST
+#undef STDENDIAN64_NET2_FROM_HOST
+#undef STDENDIAN64_NET3_FROM_HOST
+#undef STDENDIAN64_NET4_FROM_HOST
+#undef STDENDIAN64_NET5_FROM_HOST
+#undef STDENDIAN64_NET6_FROM_HOST
+#undef STDENDIAN64_NET7_FROM_HOST
+
+#undef STDENDIAN64_HOST0_FROM_NET
+#undef STDENDIAN64_HOST1_FROM_NET
+#undef STDENDIAN64_HOST2_FROM_NET
+#undef STDENDIAN64_HOST3_FROM_NET
+#undef STDENDIAN64_HOST4_FROM_NET
+#undef STDENDIAN64_HOST5_FROM_NET
+#undef STDENDIAN64_HOST6_FROM_NET
+#undef STDENDIAN64_HOST7_FROM_NET
+
+/* define std(u)int32, std(u)int64 and min/max constants */
+
+#if (SIZEOF_CHAR != 1)
+# error No 1 byte integer type found!
+#endif
+
+#if (SIZEOF_SHORT != 2)
+# error No 2 byte integer type found!
+#endif
+
+#if (SIZEOF_INT == 4)
+
+typedef int stdint32;
+typedef unsigned int stduint32;
+
+# define STDINT32_MAX INT_MAX
+# define STDINT32_MIN INT_MIN
+# define STDUINT32_MAX UINT_MAX
+
+#elif (SIZEOF_LONG == 4)
+
+typedef long stdint32;
+typedef unsigned long stduint32;
+
+#define STDINT32_MAX LONG_MAX
+#define STDINT32_MIN LONG_MIN
+#define STDUINT32_MAX ULONG_MAX
+
+#else
+# error No 4 byte integer type found!
+#endif
+
+#if defined(_WIN32)
+
+typedef __int64 stdint64;
+typedef unsigned __int64 stduint64;
+
+#elif (SIZEOF_LONG == 8)
+
+typedef long stdint64;
+typedef unsigned long stduint64;
+
+#elif (SIZEOF_LONG_LONG == 8)
+
+typedef long long stdint64;
+typedef unsigned long long stduint64;
+
+#else
+# error No 8 byte integeral type found!
+#endif
+
+#define STDINT64_MAX (~STDINT64_MIN)
+#define STDINT64_MIN ((stdint64) 0x1 << 63)
+#define STDUINT64_MAX ((stduint64) -1)
+
+/* define stdssize type and min/max constants */
+
+#if (SIZEOF_SIZE_T == 2)
+
+typedef short stdssize;
+
+# define STDSSIZE_MAX SHRT_MAX
+# define STDSSIZE_MIN SHRT_MIN
+
+#elif (SIZEOF_SIZE_T == 4)
+
+typedef stdint32 stdssize;
+
+# define STDSSIZE_MAX STDINT32_MAX
+# define STDSSIZE_MIN STDINT32_MIN
+
+#elif (SIZEOF_SIZE_T == 8)
+
+typedef stdint64 stdssize;
+
+# define STDSSIZE_MAX STDINT64_MAX
+# define STDSSIZE_MIN STDINT64_MIN
+
+#else
+# error No integral type of same size as size_t!
+#endif
+
+/* macros used for ensuring proper byte alignment of types in memory */
+
+#define STDARCH_PADDING(x) ((STDARCH_MAX_BYTE_ALIGNMENT - ((x) & (STDARCH_MAX_BYTE_ALIGNMENT - 1))) & (STDARCH_MAX_BYTE_ALIGNMENT - 1))
+#define STDARCH_PADDED_SIZE(x) ((x) + STDARCH_PADDING(x))
+
+#endif
Added: vendor/stdutil/current/src/stdutil/private/stdarr_p.h
===================================================================
--- vendor/stdutil/current/src/stdutil/private/stdarr_p.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/private/stdarr_p.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,65 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdarr_p_h_2000_05_13_19_35_29_jschultz_at_cnds_jhu_edu
+#define stdarr_p_h_2000_05_13_19_35_29_jschultz_at_cnds_jhu_edu
+
+/* stdarr: An array-based sequence: a growable array. Stores elements
+ by value, contiguously in memory starting at the base
+ address.
+
+ begin - address of the lowest byte of the array's alloc'ed memory, NULL if none alloc'ed
+ end - address of the first byte past the last value stored in the array, same as begin if empty
+ size - number of values this array is storing
+ cap - number of values that can legally fit in alloc'ed memory
+ vsize - size, in bytes, of the type of values this array is storing
+ opts - user flags affecting default operation
+*/
+
+typedef struct
+{
+ char * begin;
+ char * end;
+
+ stdsize cap;
+ stdsize size;
+
+ stdsize vsize;
+
+ stduint8 opts;
+
+} stdarr;
+
+/* stdarr_it: A stdarr iterator.
+
+ val - address of the value this iterator is referencing
+ vsize - size of the value this iterator is referencing
+*/
+
+typedef struct
+{
+ char * val;
+ stdsize vsize;
+
+} stdarr_it;
+
+#endif
Added: vendor/stdutil/current/src/stdutil/private/stdcarr_p.h
===================================================================
--- vendor/stdutil/current/src/stdutil/private/stdcarr_p.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/private/stdcarr_p.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,86 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdcarr_p_h_2000_05_15_18_35_08_jschultz_at_cnds_jhu_edu
+#define stdcarr_p_h_2000_05_15_18_35_08_jschultz_at_cnds_jhu_edu
+
+/* stdcarr: A circular array-based sequence: a growable circular array
+ or vector. Stores element by value, contiguously in
+ memory modulo the size of the array. Always maintains at
+ least one empty element in a non-empty array to act as a
+ sentinel position and to remove the amibiguous of case
+ when begin == end -- Is the array full or empty? In
+ particular, this allows for the test begin <= end ? (data
+ doesn't wrap around) : (data wraps around)
+
+ base - address of the lowest byte of the array's alloc'ed memory, NULL if none
+ endbase - address of the first byte past the end of the array's alloc'ed memory, NULL if none
+ begin - address of the first byte of the first value stored in the array; [base, endbase) if none
+ end - address of the first byte past the last value stored in the array, begin if none
+ cap - number of values that could legally fit in alloc'ed memory: is one more than the #
+ of elements that will be allowed in the array before reallocating to a larger array
+ size - number of values this array is storing
+ vsize - size, in bytes, of the type of values this array is storing
+ opts - user flags affecting default operation
+*/
+
+typedef struct
+{
+ char * base;
+ char * endbase;
+
+ char * begin;
+ char * end;
+
+ stdsize cap;
+ stdsize size;
+
+ stdsize vsize;
+
+ stduint8 opts;
+
+} stdcarr;
+
+/* stdcarr_it: Iterator for stdcarrs.
+
+ val - address of the value in carr this iterator is referencing
+ base - base of the stdcarr at time of initialization
+ endbase - endbase of the stdcarr at time of initialization
+ begin - begin of the stdcarr at time of initialization
+ vsize - size in bytes of the value this iterator references
+*/
+
+typedef struct
+{
+ char * val;
+
+ char * base;
+ char * endbase;
+
+ char * begin;
+ char * end;
+
+ stdsize vsize;
+
+} stdcarr_it;
+
+#endif
Added: vendor/stdutil/current/src/stdutil/private/stddll_p.h
===================================================================
--- vendor/stdutil/current/src/stdutil/private/stddll_p.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/private/stddll_p.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,72 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stddll_p_h_2000_05_16_18_07_15_jschultz_at_cnds_jhu_edu
+#define stddll_p_h_2000_05_16_18_07_15_jschultz_at_cnds_jhu_edu
+
+/* stddll_node: A node within a doubly linked list.
+
+ prev - pointer to previous stddll_node on list
+ next - pointer to next stddll_node on list
+
+ NOTE: the element is appended (with padding as necessary) onto the
+ end of the node in memory.
+*/
+
+typedef struct stddll_node
+{
+ struct stddll_node * prev;
+ struct stddll_node * next;
+
+} stddll_node;
+
+/* stddll: A doubly linked list of values contained by value.
+
+ end_node - pointer to the sentinel end node of a list
+ size - number of elements this list is storing
+ vsize - size, in bytes, of the type of elements this list stores
+*/
+
+typedef struct
+{
+ stddll_node * end_node;
+ stdsize size;
+ stdsize vsize;
+
+} stddll;
+
+/* stddll_it: An iterator for a stddll.
+
+ node - address of a node in a stddll sequence
+ end_node - the sentinel end node of a stddll
+ vsize - size, in bytes, of the values that this iterator references
+*/
+
+typedef struct
+{
+ stddll_node * node;
+ stddll_node * end_node;
+ stdsize vsize;
+
+} stddll_it;
+
+#endif
Added: vendor/stdutil/current/src/stdutil/private/stdhash_p.h
===================================================================
--- vendor/stdutil/current/src/stdutil/private/stdhash_p.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/private/stdhash_p.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,99 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdhash_p_h_2000_05_17_18_02_31_jschultz_at_cnds_jhu_edu
+#define stdhash_p_h_2000_05_17_18_02_31_jschultz_at_cnds_jhu_edu
+
+/* stdhash_node: A type that contains a key-value pair and a cache of
+ the key's hashcode.
+
+ hcode - a cached copy of the hashcode of the key for this key-val pair.
+
+ NOTE: The key and value are appended onto the end of this node in
+ memory (w/ padding as necessary).
+*/
+
+typedef struct
+{
+ stdhcode hcode;
+
+} stdhash_node;
+
+/* stdhash: An array based dictionary that maps non-unique keys to values.
+
+ table - pointer to the base of an alloc'ed array of node*'s, NULL if none
+ table_end - pointer to one past the last of the alloc'ed array of node*'s, NULL if none
+ begin - pointer to the first active node in the table, table_end if none
+ cap_min1 - number (power of 2) of node*'s that could fit in table minus 1 (bitmask for modulo)
+ cap_lg - the log base 2 of cap_min1 + 1
+ num_nodes - the number of alloc'ed nodes contained in table (counts inactive nodes too)
+ size - number of active key-val pairs the hash currently contains
+ ksize - size, in bytes, of the key type
+ vsize - size, in bytes, of the value type
+ cmp_fcn - user defined fcn for comparing keys
+ hcode_fcn - user defined fcn for generating hashcodes for keys
+ opts - user defined options
+*/
+
+typedef struct
+{
+ stdhash_node ** table;
+ stdhash_node ** table_end;
+ stdhash_node ** begin;
+
+ stdsize cap_min1;
+ stdsize cap_lg;
+ stdsize num_nodes;
+ stdsize size;
+
+ stdsize ksize;
+ stdsize vsize;
+
+ stdcmp_fcn cmp_fcn;
+ stdhcode_fcn hcode_fcn;
+
+ stduint8 opts;
+
+} stdhash;
+
+/* stdhash_it: An iterator for a stdhash.
+
+ node_pos - address of the position in the array of node*'s this iterator is currently referencing
+ table - the hash's table
+ table_end - the end of the hash's table
+ ksize - the size of the keys to which the iterator points
+ vsize - the size of the vals to which the iterator points
+*/
+
+typedef struct
+{
+ stdhash_node ** node_pos;
+
+ stdhash_node ** table;
+ stdhash_node ** table_end;
+
+ stdsize ksize;
+ stdsize vsize;
+
+} stdhash_it;
+
+#endif
Added: vendor/stdutil/current/src/stdutil/private/stdit_p.h
===================================================================
--- vendor/stdutil/current/src/stdutil/private/stdit_p.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/private/stdit_p.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,77 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdit_p_h_2005_06_11_12_37_56_jschultz_at_cnds_jhu_edu
+#define stdit_p_h_2005_06_11_12_37_56_jschultz_at_cnds_jhu_edu
+
+#define STDPTR_IT_ID ((stduint32) 0x86958034UL)
+#define STDPPTR_IT_ID ((stduint32) 0xcc2f9985UL)
+#define STDARR_IT_ID ((stduint32) 0x85edb072UL)
+#define STDCARR_IT_ID ((stduint32) 0x6c248dc2UL)
+#define STDDLL_IT_ID ((stduint32) 0x7b868dfdUL)
+#define STDHASH_IT_ID ((stduint32) 0xdc01b2d1UL)
+#define STDHASH_IT_KEY_ID ((stduint32) 0x7e78a0fdUL)
+#define STDSKL_IT_ID ((stduint32) 0x7abf271bUL)
+#define STDSKL_IT_KEY_ID ((stduint32) 0x1ac2ee79UL)
+
+#include <stdutil/private/stdarr_p.h>
+#include <stdutil/private/stdcarr_p.h>
+#include <stdutil/private/stddll_p.h>
+#include <stdutil/private/stdhash_p.h>
+#include <stdutil/private/stdskl_p.h>
+
+typedef struct
+{
+ char * val;
+ stdsize vsize;
+
+} stdptr_it;
+
+typedef struct
+{
+ char * key;
+ char * val;
+
+ stdsize ksize;
+ stdsize vsize;
+
+} stdpptr_it;
+
+typedef struct
+{
+ union
+ {
+ stdptr_it ptr;
+ stdpptr_it pptr;
+ stdarr_it arr;
+ stdcarr_it carr;
+ stddll_it dll;
+ stdhash_it hash;
+ stdskl_it skl;
+
+ } impl;
+
+ stduint32 type_id;
+
+} stdit;
+
+#endif
Added: vendor/stdutil/current/src/stdutil/private/stdskl_p.h
===================================================================
--- vendor/stdutil/current/src/stdutil/private/stdskl_p.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/private/stdskl_p.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,96 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdskl_p_h_2005_06_07_15_09_42_jschultz_at_cnds_jhu_edu
+#define stdskl_p_h_2005_06_07_15_09_42_jschultz_at_cnds_jhu_edu
+
+/* stdskl_node: A type that contains a key-value pair and node linking information.
+
+ height - 0 based height of this node; size of (prevs, nexts) arrays minus 1
+ prevs - an array of pointers to previous elements in the list
+ nexts - an array of pointers to later elements in the list
+ key - pointer to the node's key
+ val - pointer to the node's val
+
+ NOTE: The prevs and nexts arrays are appended onto the end of the
+ node in memory.
+
+ NOTE: The key and value are then appended onto the end of this node in
+ memory after the prevs and nexts arrays (w/ padding as necessary).
+*/
+
+typedef struct stdskl_node
+{
+ stdint8 height;
+ struct stdskl_node ** prevs;
+ struct stdskl_node ** nexts;
+
+ const void * key;
+ void * val;
+
+} stdskl_node;
+
+/* stdskl: A tree based dictionary that maps non-unique keys to values.
+
+ end_node - pointer to sentinel end node of list
+ size - number of key-value pairs contained
+ ksize - size in bytes of key type contained
+ vsize - size in bytes of value type contained
+ cmp_fcn - user defined key comparison function
+ seed - state used to generate pseudo-random numbers
+ rand_bits - a random number that contains random bits
+ bits_left - how many unused bits remain in rand_bits
+*/
+
+typedef struct stdskl
+{
+ stdskl_node * end_node;
+
+ stdsize size;
+
+ stdsize ksize;
+ stdsize vsize;
+
+ stdcmp_fcn cmp_fcn;
+
+ stduint16 seed[3];
+ stduint32 rand_bits;
+ stduint8 bits_left;
+
+} stdskl;
+
+/* stdskl_it: An iterator for a stdskl.
+
+ node - pointer to the reference node in the list
+ ksize - size in bytes of referenced key type
+ vsize - size in bytes of referenced value type
+*/
+
+typedef struct
+{
+ stdskl_node * node;
+ stdsize ksize;
+ stdsize vsize;
+
+} stdskl_it;
+
+#endif
Added: vendor/stdutil/current/src/stdutil/private/stdthread_p.h
===================================================================
--- vendor/stdutil/current/src/stdutil/private/stdthread_p.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/private/stdthread_p.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,102 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdthread_p_h_2000_05_18_12_57_48_jschultz_at_cnds_jhu_edu
+#define stdthread_p_h_2000_05_18_12_57_48_jschultz_at_cnds_jhu_edu
+
+#if defined(_WIN32)
+# include <windows.h>
+# define STDTHREAD_FCN __stdcall
+
+typedef HANDLE stdthread;
+typedef DWORD stdthread_id;
+typedef CRITICAL_SECTION stdmutex_impl;
+
+typedef struct stdcond_link
+{
+ HANDLE sleeper;
+ struct stdcond_link * prev;
+ struct stdcond_link * next;
+
+} stdcond_link;
+
+typedef struct
+{
+ stdmutex_impl lock;
+ stdcond_link sleepers_end; /* linked list of suspended threads */
+
+} stdcond_impl;
+
+/* NOTE: we use CRITICAL_SECTION for mutexes and SuspendThread and
+ ResumeThread for conditions rather than MUTEX, EVENT and
+ SignalObjectAndWait due to backwards compatability. The ones we use
+ are available all the way back to Windows 95, whereas
+ SignalObjectAndWait is only available in NT 4.0 and later. MUTEXes
+ are more expensive than CRITICAL_SECTIONs. Also, with
+ SignalObjectAndWait the only way to get both wake 1 and wake all
+ semantics is to have an auto-reset EVENT that you PulseEvent N
+ times for each sleeping thread for wake all. If you do that you
+ can have a timed sleep, whereas we can't easily do that with
+ SuspendThread and ResumeThread.
+*/
+
+#else
+# include <pthread.h>
+# define STDTHREAD_FCN
+
+typedef pthread_t stdthread;
+typedef pthread_t stdthread_id;
+typedef pthread_mutex_t stdmutex_impl;
+typedef pthread_cond_t stdcond_impl;
+
+#endif
+
+#define STDMUTEX_INVAL -1UL
+
+typedef stdulong stdmutex_type;
+typedef stdmutex_impl stdmutex_fast;
+
+typedef struct
+{
+ stdmutex_impl outer_lock;
+ int num_waiting;
+ int owner_cnt;
+ stdthread_id owner_id;
+ stdmutex_impl inner_lock;
+
+} stdmutex_rcrsv;
+
+typedef struct stdmutex
+{
+ volatile stdmutex_type mut_type;
+
+ union {
+ stdmutex_fast fast;
+ stdmutex_rcrsv rcrsv;
+
+ } mut;
+
+} stdmutex;
+
+typedef stdcond_impl stdcond;
+
+# endif
Added: vendor/stdutil/current/src/stdutil/stdarr.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stdarr.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stdarr.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,127 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdarr_h_2000_01_26_11_38_04_jschultz_at_cnds_jhu_edu
+#define stdarr_h_2000_01_26_11_38_04_jschultz_at_cnds_jhu_edu
+
+#include <stdutil/stdit.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef STDARR_MIN_AUTO_ALLOC /* minimum allocation size in # of elements */
+# define STDARR_MIN_AUTO_ALLOC 16
+#endif
+
+/* Structors */
+
+#define STDARR_STATIC_CONSTRUCT(vsize, opts) { NULL, NULL, 0, 0, (vsize), (opts) }
+
+STDINLINE stdcode stdarr_construct(stdarr *arr, stdsize vsize, stduint8 opts);
+STDINLINE stdcode stdarr_copy_construct(stdarr *dst, const stdarr *src);
+STDINLINE void stdarr_destruct(stdarr *arr);
+
+/* Assigners */
+
+STDINLINE stdcode stdarr_set_eq(stdarr *dst, const stdarr *src);
+STDINLINE void stdarr_swap(stdarr *arr1, stdarr *arr2);
+
+/* Iterators */
+
+STDINLINE stdit * stdarr_begin(const stdarr *arr, stdit *it);
+STDINLINE stdit * stdarr_last(const stdarr *arr, stdit *it);
+STDINLINE stdit * stdarr_end(const stdarr *arr, stdit *it);
+STDINLINE stdit * stdarr_get(const stdarr *arr, stdit *it, stdsize elem_num);
+
+STDINLINE stdbool stdarr_is_begin(const stdarr *arr, const stdit *it);
+STDINLINE stdbool stdarr_is_end(const stdarr *arr, const stdit *it);
+STDINLINE stdsize stdarr_rank(const stdarr *arr, const stdit *it);
+
+/* Size and Capacity Information */
+
+STDINLINE stdsize stdarr_size(const stdarr *arr);
+STDINLINE stdbool stdarr_empty(const stdarr *arr);
+STDINLINE stdsize stdarr_high_capacity(const stdarr *arr);
+STDINLINE stdsize stdarr_low_capacity(const stdarr *arr);
+
+STDINLINE stdsize stdarr_max_size(const stdarr *arr);
+STDINLINE stdsize stdarr_val_size(const stdarr *arr);
+
+/* Size and Capacity Operations */
+
+STDINLINE stdcode stdarr_resize(stdarr *arr, stdsize num_elems);
+STDINLINE void stdarr_clear(stdarr *arr);
+
+STDINLINE stdcode stdarr_set_capacity(stdarr *arr, stdsize num_elems);
+STDINLINE stdcode stdarr_reserve(stdarr *arr, stdsize num_elems);
+STDINLINE stdcode stdarr_shrink_fit(stdarr *arr);
+
+/* Stack Operations: amoritized O(1) operations, worst case O(n) */
+
+STDINLINE stdcode stdarr_push_back(stdarr *arr, const void *val);
+STDINLINE stdcode stdarr_push_back_n(stdarr *arr, const void *vals, stdsize num_push);
+STDINLINE stdcode stdarr_push_back_seq(stdarr *arr, const stdit *b, const stdit *e);
+STDINLINE stdcode stdarr_push_back_seq_n(stdarr *arr, const stdit *b, stdsize num_push);
+STDINLINE stdcode stdarr_push_back_rep(stdarr *arr, const void *val, stdsize num_times);
+
+STDINLINE void stdarr_pop_back(stdarr *arr);
+STDINLINE void stdarr_pop_back_n(stdarr *arr, stdsize num_pop);
+
+/* List Operations: O(n) operations */
+
+STDINLINE stdcode stdarr_insert(stdarr *arr, stdit *it, const void *val);
+STDINLINE stdcode stdarr_insert_n(stdarr *arr, stdit *it, const void *vals, stdsize num_insert);
+STDINLINE stdcode stdarr_insert_seq(stdarr *arr, stdit *it, const stdit *b, const stdit *e);
+STDINLINE stdcode stdarr_insert_seq_n(stdarr *arr, stdit *it, const stdit *b, stdsize num_push);
+STDINLINE stdcode stdarr_insert_rep(stdarr *arr, stdit *it, const void *val, stdsize num_times);
+
+STDINLINE void stdarr_erase(stdarr *arr, stdit *it);
+STDINLINE void stdarr_erase_n(stdarr *arr, stdit *it, stdsize num_erase);
+STDINLINE void stdarr_erase_seq(stdarr *arr, stdit *b, stdit *e);
+
+/* Options */
+
+#define STDARR_OPTS_NO_AUTO_GROW 0x1
+#define STDARR_OPTS_NO_AUTO_SHRINK 0x2
+
+STDINLINE stduint8 stdarr_get_opts(const stdarr *arr);
+STDINLINE stdcode stdarr_set_opts(stdarr *arr, stduint8 opts);
+
+/* Iterator Fcns */
+
+STDINLINE void * stdarr_it_val(const stdit *it);
+STDINLINE stdsize stdarr_it_val_size(const stdit *it);
+STDINLINE stdbool stdarr_it_eq(const stdit *it1, const stdit *it2);
+STDINLINE stdssize stdarr_it_cmp(const stdit *it1, const stdit *it2);
+
+STDINLINE stdit * stdarr_it_next(stdit *it);
+STDINLINE stdit * stdarr_it_advance(stdit *it, stdsize num_advance);
+STDINLINE stdit * stdarr_it_prev(stdit *it);
+STDINLINE stdit * stdarr_it_retreat(stdit *it, stdsize num_retreat);
+STDINLINE stdit * stdarr_it_offset(stdit *it, stdssize offset);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Added: vendor/stdutil/current/src/stdutil/stdcarr.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stdcarr.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stdcarr.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,136 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdcarr_h_2000_01_30_23_42_05_jschultz_at_cnds_jhu_edu
+#define stdcarr_h_2000_01_30_23_42_05_jschultz_at_cnds_jhu_edu
+
+#include <stdutil/stdit.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef STDCARR_MIN_AUTO_ALLOC /* minimum allocation size in # of elements */
+# define STDCARR_MIN_AUTO_ALLOC 16
+#endif
+
+/* Structors */
+
+#define STDCARR_STATIC_CONSTRUCT(vsize, opts) { NULL, NULL, NULL, NULL, 0, 0, (vsize), (opts) }
+
+STDINLINE stdcode stdcarr_construct(stdcarr *carr, stdsize vsize, stduint8 opts);
+STDINLINE stdcode stdcarr_copy_construct(stdcarr *dst, const stdcarr *src);
+STDINLINE void stdcarr_destruct(stdcarr *carr);
+
+/* Assigners */
+
+STDINLINE stdcode stdcarr_set_eq(stdcarr *dst, stdcarr *src);
+STDINLINE void stdcarr_swap(stdcarr *carr1, stdcarr *carr2);
+
+/* Iterators */
+
+STDINLINE stdit * stdcarr_begin(const stdcarr *carr, stdit *it);
+STDINLINE stdit * stdcarr_last(const stdcarr *carr, stdit *it);
+STDINLINE stdit * stdcarr_end(const stdcarr *carr, stdit *it);
+STDINLINE stdit * stdcarr_get(const stdcarr *carr, stdit *it, stdsize elem_num);
+
+STDINLINE stdbool stdcarr_is_begin(const stdcarr *carr, const stdit *it);
+STDINLINE stdbool stdcarr_is_end(const stdcarr *carr, const stdit *it);
+STDINLINE stdsize stdcarr_rank(const stdcarr *carr, const stdit *it);
+
+/* Size and Capacity Information */
+
+STDINLINE stdsize stdcarr_size(const stdcarr *carr);
+STDINLINE stdbool stdcarr_empty(const stdcarr *carr);
+STDINLINE stdsize stdcarr_high_capacity(const stdcarr *carr);
+STDINLINE stdsize stdcarr_low_capacity(const stdcarr *carr);
+
+STDINLINE stdsize stdcarr_max_size(const stdcarr *carr);
+STDINLINE stdsize stdcarr_val_size(const stdcarr *carr);
+
+/* Size and Capacity Operations */
+
+STDINLINE stdcode stdcarr_resize(stdcarr *carr, stdsize num_elems);
+STDINLINE void stdcarr_clear(stdcarr *carr);
+
+STDINLINE stdcode stdcarr_set_capacity(stdcarr *carr, stdsize num_elems);
+STDINLINE stdcode stdcarr_reserve(stdcarr *carr, stdsize num_elems);
+STDINLINE stdcode stdcarr_shrink_fit(stdcarr *carr);
+
+/* Stack Operations: amoritized O(1) operations, worst case O(n) */
+
+STDINLINE stdcode stdcarr_push_front(stdcarr *carr, const void *val);
+STDINLINE stdcode stdcarr_push_front_n(stdcarr *carr, const void *vals, stdsize num_push);
+STDINLINE stdcode stdcarr_push_front_seq(stdcarr *carr, const stdit *b, const stdit *e);
+STDINLINE stdcode stdcarr_push_front_seq_n(stdcarr *carr, const stdit *b, stdsize num_push);
+STDINLINE stdcode stdcarr_push_front_rep(stdcarr *carr, const void *val, stdsize num_times);
+
+STDINLINE void stdcarr_pop_front(stdcarr *carr);
+STDINLINE void stdcarr_pop_front_n(stdcarr *carr, stdsize num_pop);
+
+STDINLINE stdcode stdcarr_push_back(stdcarr *carr, const void *val);
+STDINLINE stdcode stdcarr_push_back_n(stdcarr *carr, const void *vals, stdsize num_push);
+STDINLINE stdcode stdcarr_push_back_seq(stdcarr *carr, const stdit *b, const stdit *e);
+STDINLINE stdcode stdcarr_push_back_seq_n(stdcarr *carr, const stdit *b, stdsize num_push);
+STDINLINE stdcode stdcarr_push_back_rep(stdcarr *carr, const void *val, stdsize num_times);
+
+STDINLINE void stdcarr_pop_back(stdcarr *carr);
+STDINLINE void stdcarr_pop_back_n(stdcarr *carr, stdsize num_pop);
+
+/* List Operations: O(n) operations */
+
+STDINLINE stdcode stdcarr_insert(stdcarr *carr, stdit *it, const void *val);
+STDINLINE stdcode stdcarr_insert_n(stdcarr *carr, stdit *it, const void *vals, stdsize num_insert);
+STDINLINE stdcode stdcarr_insert_seq(stdcarr *carr, stdit *it, const stdit *b, const stdit *e);
+STDINLINE stdcode stdcarr_insert_seq_n(stdcarr *carr, stdit *it, const stdit *b, stdsize num_insert);
+STDINLINE stdcode stdcarr_insert_rep(stdcarr *carr, stdit *it, const void *val, stdsize num_times);
+
+STDINLINE void stdcarr_erase(stdcarr *carr, stdit *it);
+STDINLINE void stdcarr_erase_n(stdcarr *carr, stdit *it, stdsize num_erase);
+STDINLINE void stdcarr_erase_seq(stdcarr *carr, stdit *b, stdit *e);
+
+/* Data Structure Options */
+
+#define STDCARR_OPTS_NO_AUTO_GROW 0x1
+#define STDCARR_OPTS_NO_AUTO_SHRINK 0x2
+
+STDINLINE stduint8 stdcarr_get_opts(const stdcarr *carr);
+STDINLINE stdcode stdcarr_set_opts(stdcarr *carr, stduint8 opts);
+
+/* Iterator Fcns */
+
+STDINLINE void * stdcarr_it_val(const stdit *it);
+STDINLINE stdsize stdcarr_it_val_size(const stdit *it);
+STDINLINE stdbool stdcarr_it_eq(const stdit *it1, const stdit *it2);
+STDINLINE stdssize stdcarr_it_cmp(const stdit *it1, const stdit *it2);
+
+STDINLINE stdit * stdcarr_it_next(stdit *it);
+STDINLINE stdit * stdcarr_it_advance(stdit *it, stdsize num_advance);
+STDINLINE stdit * stdcarr_it_prev(stdit *it);
+STDINLINE stdit * stdcarr_it_retreat(stdit *it, stdsize num_retreat);
+STDINLINE stdit * stdcarr_it_offset(stdit *it, stdssize offset);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Added: vendor/stdutil/current/src/stdutil/stddefines.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stddefines.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stddefines.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,109 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stddefines_h_2000_10_22_18_20_30_jschultz_at_cnds_jhu_edu
+#define stddefines_h_2000_10_22_18_20_30_jschultz_at_cnds_jhu_edu
+
+#include <stdutil/private/stdarch.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* define some useful basic types */
+
+typedef int stdbool;
+
+#define stdtrue 1
+#define STDTRUE 1
+
+#define stdfalse 0
+#define STDFALSE 0
+
+typedef int stdcode; /* a return code (non-zero -> abnormal operation) */
+
+typedef signed char stdschar;
+typedef unsigned char stduchar;
+
+typedef unsigned short stdushort;
+typedef unsigned int stduint;
+typedef unsigned long stdulong;
+
+typedef signed char stdint8;
+typedef unsigned char stduint8;
+
+#define STDINT8_MAX SCHAR_MAX
+#define STDINT8_MIN SCHAR_MIN
+#define STDUINT8_MAX UCHAR_MAX
+
+typedef short stdint16;
+typedef unsigned short stduint16;
+
+#define STDINT16_MAX SHRT_MAX
+#define STDINT16_MIN SHRT_MIN
+#define STDUINT16_MAX USHRT_MAX
+
+typedef size_t stdsize;
+#define STDSIZE_MAX ((stdsize) -1)
+
+/* stdarch.h similiarly defines std(u)int32, std(u)int64, stdssize (a
+ signed verion of stdsize) and associated min and max constants
+*/
+
+/* define comparison fcn types */
+
+typedef stduint32 stdhcode;
+
+typedef int (*stdcmp_fcn)(const void *v1, const void *v2);
+typedef stdhcode (*stdhcode_fcn)(const void *v);
+
+/* define some common, if dangerous, macros */
+
+#define STDSWAP(x, y, t) ((t) = (x), (x) = (y), (y) = (t))
+#define STDMAX(x, y) ((x) > (y) ? (x) : (y))
+#define STDMIN(x, y) ((x) < (y) ? (x) : (y))
+
+/* define some useful constants */
+
+#define STD1THOUSAND 1000
+#define STD1MILLION 1000000L
+#define STD1BILLION 1000000000L
+
+/* inline rules vary too much from language to language (C89, C99,
+ C++) and compiler to compiler (gcc, .NET, etc.) in non-standard
+ usage (i.e. - inline in C89) for stdutil to use any one inline
+ syntax. The way to get inline to work as expected with stdutil is
+ to have one translation unit that first #includes all of stdutil's
+ .c files and then all of your app's .c files. Then #define or -D
+ STDINLINE as the appropriate value for your compiler/language combo
+ to get fcn inlining to work.
+*/
+
+#ifndef STDINLINE
+# define STDINLINE
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Added: vendor/stdutil/current/src/stdutil/stddll.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stddll.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stddll.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,113 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stddll_h_2000_02_14_16_22_38_jschultz_at_cnds_jhu_edu
+#define stddll_h_2000_02_14_16_22_38_jschultz_at_cnds_jhu_edu
+
+#include <stdutil/stdit.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Structors */
+
+STDINLINE stdcode stddll_construct(stddll *l, stdsize vsize);
+STDINLINE stdcode stddll_copy_construct(stddll *dst, const stddll *src);
+STDINLINE void stddll_destruct(stddll *l);
+
+/* Assigners */
+
+STDINLINE stdcode stddll_set_eq(stddll *dst, const stddll *src);
+STDINLINE void stddll_swap(stddll *l1, stddll *l2);
+
+/* Iterators */
+
+STDINLINE stdit * stddll_begin(const stddll *l, stdit *it);
+STDINLINE stdit * stddll_last(const stddll *l, stdit *it);
+STDINLINE stdit * stddll_end(const stddll *l, stdit *it);
+STDINLINE stdit * stddll_get(const stddll *l, stdit *it, stdsize elem_num); /* O(n) */
+
+STDINLINE stdbool stddll_is_begin(const stddll *l, const stdit *it);
+STDINLINE stdbool stddll_is_end(const stddll *l, const stdit *it);
+
+/* Size Information */
+
+STDINLINE stdsize stddll_size(const stddll *l);
+STDINLINE stdbool stddll_empty(const stddll *l);
+
+STDINLINE stdsize stddll_max_size(const stddll *l);
+STDINLINE stdsize stddll_val_size(const stddll *l);
+
+/* Size Operations */
+
+STDINLINE stdcode stddll_resize(stddll *l, stdsize num_elems);
+STDINLINE void stddll_clear(stddll *l);
+
+/* Stack Operations: O(1) operations */
+
+STDINLINE stdcode stddll_push_front(stddll *l, const void *val);
+STDINLINE stdcode stddll_push_front_n(stddll *l, const void *vals, stdsize num_push);
+STDINLINE stdcode stddll_push_front_seq(stddll *l, const stdit *b, const stdit *e);
+STDINLINE stdcode stddll_push_front_seq_n(stddll *l, const stdit *b, stdsize num_push);
+STDINLINE stdcode stddll_push_front_rep(stddll *l, const void *val, stdsize num_times);
+
+STDINLINE void stddll_pop_front(stddll *l);
+STDINLINE void stddll_pop_front_n(stddll *l, stdsize num_pop);
+
+STDINLINE stdcode stddll_push_back(stddll *l, const void *val);
+STDINLINE stdcode stddll_push_back_n(stddll *l, const void *vals, stdsize num_push);
+STDINLINE stdcode stddll_push_back_seq(stddll *l, const stdit *b, const stdit *e);
+STDINLINE stdcode stddll_push_back_seq_n(stddll *l, const stdit *b, stdsize num_push);
+STDINLINE stdcode stddll_push_back_rep(stddll *l, const void *val, stdsize num_times);
+
+STDINLINE void stddll_pop_back(stddll *l);
+STDINLINE void stddll_pop_back_n(stddll *l, stdsize num_pop);
+
+/* List Operations: O(1) operations */
+
+STDINLINE stdcode stddll_insert(stddll *l, stdit *it, const void *val);
+STDINLINE stdcode stddll_insert_n(stddll *l, stdit *it, const void *vals, stdsize num_insert);
+STDINLINE stdcode stddll_insert_seq(stddll *l, stdit *it, const stdit *b, const stdit *e);
+STDINLINE stdcode stddll_insert_seq_n(stddll *l, stdit *it, const stdit *b, stdsize num_insert);
+STDINLINE stdcode stddll_insert_rep(stddll *l, stdit *it, const void *val, stdsize num_times);
+
+STDINLINE void stddll_erase(stddll *l, stdit *it);
+STDINLINE void stddll_erase_n(stddll *l, stdit *it, stdsize num_erase);
+STDINLINE void stddll_erase_seq(stddll *l, stdit *b, stdit *e);
+
+/* Iterator Fcns */
+
+STDINLINE void * stddll_it_val(const stdit *it);
+STDINLINE stdsize stddll_it_val_size(const stdit *it);
+STDINLINE stdbool stddll_it_eq(const stdit *it1, const stdit *it2);
+
+STDINLINE stdit * stddll_it_next(stdit *it);
+STDINLINE stdit * stddll_it_advance(stdit *it, stdsize num_advance);
+STDINLINE stdit * stddll_it_prev(stdit *it);
+STDINLINE stdit * stddll_it_retreat(stdit *it, stdsize num_retreat);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Added: vendor/stdutil/current/src/stdutil/stderror.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stderror.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stderror.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,115 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stderror_h_2000_05_15_14_04_16_jschultz_at_cnds_jhu_edu
+#define stderror_h_2000_05_15_14_04_16_jschultz_at_cnds_jhu_edu
+
+#include <errno.h>
+#include <stdio.h>
+
+#include <stdutil/stddefines.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* stderr error routines */
+
+#ifndef STDERR_MAX_ERR_MSG_LEN
+# define STDERR_MAX_ERR_MSG_LEN 1024
+#endif
+
+int stderr_msg(const char *fmt, ...);
+int stderr_ret(const char *fmt, ...);
+void stderr_quit(const char *fmt, ...);
+void stderr_abort(const char *fmt, ...);
+void stderr_sys(const char *fmt, ...);
+void stderr_dump(const char *fmt, ...);
+
+STDINLINE const char *stderr_strerr(stdcode code);
+
+/* error macros */
+
+#define STDEXCEPTION(x) stderr_abort("STDEXCEPTION: File: %s; Line: %d: %s", __FILE__, __LINE__, #x)
+
+#if defined(STDSAFETY_CHECKS)
+# define STDSAFETY_CHECK(x) { if (!(x)) { STDEXCEPTION(safety check (x) failed); } }
+#else
+# define STDSAFETY_CHECK(x)
+#endif
+
+#if defined(STDBOUNDS_CHECKS)
+# define STDBOUNDS_CHECK(x) { if (!(x)) { STDEXCEPTION(bounds check (x) failed); } }
+#else
+# define STDBOUNDS_CHECK(x)
+#endif
+
+#define STDESUCCESS 0
+#define STDEOF EOF
+
+#if defined(EUNKNOWN)
+# define STDEUNKNOWN EUNKNOWN
+#else
+# define STDEUNKNOWN 500
+#endif
+
+#if defined(EINVAL)
+# define STDEINVAL EINVAL
+#else
+# define STDEINVAL 501
+#endif
+
+#if defined(ENOMEM)
+# define STDENOMEM ENOMEM
+#else
+# define STDENOMEM 502
+#endif
+
+#if defined(EACCES)
+# define STDEACCES EACCES
+#else
+# define STDEACCES 503
+#endif
+
+#if defined(EBUSY)
+# define STDEBUSY EBUSY
+#else
+# define STDEBUSY 504
+#endif
+
+#if defined(EPERM)
+# define STDEPERM EPERM
+#else
+# define STDEPERM 505
+#endif
+
+#if defined(ENOSYS)
+# define STDENOSYS ENOSYS
+#else
+# define STDENOSYS 506
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Added: vendor/stdutil/current/src/stdutil/stdfd.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stdfd.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stdfd.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,81 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdfd_h_2003_10_20_13_49_08_jschultz_at_cnds_jhu_edu
+#define stdfd_h_2003_10_20_13_49_08_jschultz_at_cnds_jhu_edu
+
+#include <stdio.h>
+#include <stdutil/stddefines.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ int fd;
+ FILE * stream;
+
+} stdfd;
+
+/* File Descriptor Operations */
+
+#define STDFD_STATIC_CONSTRUCT { -1, NULL }
+
+STDINLINE stdcode stdfd_open(stdfd *fd, const char *path, const char *mode);
+STDINLINE stdcode stdfd_close(stdfd *fd);
+
+STDINLINE stdcode stdfd_read(stdfd *fd, void *ptr, stdsize nsize, stdsize nmemb, stdsize *num);
+STDINLINE stdcode stdfd_write(stdfd *fd, const void *ptr, stdsize nsize, stdsize nmemb, stdsize *num);
+
+STDINLINE stdcode stdfd_flush(stdfd *fd);
+STDINLINE stdcode stdfd_sync(stdfd *fd);
+
+typedef long stdfd_pos;
+
+typedef enum
+{
+ STDSEEK_SET = SEEK_SET,
+ STDSEEK_CUR = SEEK_CUR,
+ STDSEEK_END = SEEK_END
+
+} stdfd_whence;
+
+STDINLINE stdcode stdfd_seek(stdfd *fd, stdfd_pos offset, stdfd_whence whence);
+STDINLINE stdcode stdfd_get_pos(stdfd *fd, stdfd_pos *pos);
+
+STDINLINE stdbool stdfd_eof(stdfd *fd);
+STDINLINE stdbool stdfd_err(stdfd *fd);
+STDINLINE void stdfd_clr_err(stdfd *fd);
+
+STDINLINE stdcode stdfd_trylock(stdfd *fd);
+STDINLINE stdcode stdfd_unlock(stdfd *fd);
+
+/* File Operations */
+
+STDINLINE stdcode stdfile_unlink(const char * path);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Added: vendor/stdutil/current/src/stdutil/stdhash.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stdhash.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stdhash.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,127 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdhash_h_2000_02_14_16_22_38_jschultz_at_cnds_jhu_edu
+#define stdhash_h_2000_02_14_16_22_38_jschultz_at_cnds_jhu_edu
+
+#include <stdutil/stdit.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef STDHASH_MIN_AUTO_ALLOC /* minimum allocation size in # of elements: MUST be a power of 2 or zero! */
+# define STDHASH_MIN_AUTO_ALLOC 16
+#endif
+
+/* Structors */
+
+#define STDHASH_STATIC_CONSTRUCT(ksize, vsize, kcmp, khcode, opts) \
+{ NULL, NULL, NULL, (stdsize) -1, (stdsize) -1, 0, 0, (ksize), (vsize), (kcmp), (khcode), (opts) }
+
+STDINLINE stdcode stdhash_construct(stdhash *h, stdsize ksize, stdsize vsize, stdcmp_fcn kcmp, stdhcode_fcn khcode, stduint8 opts);
+STDINLINE stdcode stdhash_copy_construct(stdhash *dst, const stdhash *src);
+STDINLINE void stdhash_destruct(stdhash *h);
+
+/* Assigners */
+
+STDINLINE stdcode stdhash_set_eq(stdhash *dst, const stdhash *src);
+STDINLINE void stdhash_swap(stdhash *h1, stdhash *h2);
+
+/* Iterators */
+
+STDINLINE stdit * stdhash_begin(const stdhash *h, stdit *it);
+STDINLINE stdit * stdhash_last(const stdhash *h, stdit *it);
+STDINLINE stdit * stdhash_end(const stdhash *h, stdit *it);
+STDINLINE stdit * stdhash_get(const stdhash *h, stdit *it, stdsize elem_num); /* O(n) */
+
+STDINLINE stdbool stdhash_is_begin(const stdhash *h, const stdit *it);
+STDINLINE stdbool stdhash_is_end(const stdhash *h, const stdit *it);
+
+STDINLINE stdit * stdhash_keyed_next(const stdhash *h, stdit *it);
+STDINLINE stdit * stdhash_keyed_prev(const stdhash *h, stdit *it);
+
+/* Size and Table Load Information */
+
+STDINLINE stdsize stdhash_size(const stdhash *h);
+STDINLINE stdbool stdhash_empty(const stdhash *h);
+STDINLINE stdsize stdhash_curr_load(const stdhash *h);
+
+STDINLINE stdsize stdhash_high_thresh(const stdhash *h);
+STDINLINE stdsize stdhash_low_thresh(const stdhash *h);
+
+STDINLINE stdsize stdhash_max_size(const stdhash *h);
+STDINLINE stdsize stdhash_key_size(const stdhash *h);
+STDINLINE stdsize stdhash_val_size(const stdhash *h);
+
+/* Size and Capacity Operations */
+
+STDINLINE void stdhash_clear(stdhash *h);
+
+STDINLINE stdcode stdhash_reserve(stdhash *h, stdsize num_elems);
+STDINLINE stdcode stdhash_rehash(stdhash *h);
+
+/* Dictionary Operations: O(1) expected, O(n) worst case */
+
+STDINLINE stdit * stdhash_find(const stdhash *h, stdit *it, const void *key);
+STDINLINE stdbool stdhash_contains(const stdhash *h, const void *key);
+
+STDINLINE stdcode stdhash_put(stdhash *h, stdit *it, const void *key, const void *val);
+STDINLINE stdcode stdhash_put_n(stdhash *h, stdit *it, const void *keys, const void *vals, stdsize num_put);
+STDINLINE stdcode stdhash_put_seq(stdhash *h, stdit *it, const stdit *b, const stdit *e);
+STDINLINE stdcode stdhash_put_seq_n(stdhash *h, stdit *it, const stdit *b, stdsize num_put);
+
+STDINLINE stdcode stdhash_insert(stdhash *h, stdit *it, const void *key, const void *val);
+STDINLINE stdcode stdhash_insert_n(stdhash *h, stdit *it, const void *keys, const void *vals, stdsize num_insert);
+STDINLINE stdcode stdhash_insert_seq(stdhash *h, stdit *it, const stdit *b, const stdit *e);
+STDINLINE stdcode stdhash_insert_seq_n(stdhash *h, stdit *it, const stdit *b, stdsize num_insert);
+STDINLINE stdcode stdhash_insert_rep(stdhash *h, stdit *it, const void *key, const void *val, stdsize num_times);
+
+STDINLINE void stdhash_erase(stdhash *h, stdit *it);
+STDINLINE void stdhash_erase_key(stdhash *h, const void *key);
+
+/* Options */
+
+#define STDHASH_OPTS_NO_AUTO_GROW 0x1
+#define STDHASH_OPTS_NO_AUTO_SHRINK 0x2
+
+STDINLINE stduint8 stdhash_get_opts(const stdhash *h);
+STDINLINE stdcode stdhash_set_opts(stdhash *h, stduint8 opts);
+
+/* Iterator Fcns */
+
+STDINLINE const void * stdhash_it_key(const stdit *it);
+STDINLINE stdsize stdhash_it_key_size(const stdit *it);
+STDINLINE void * stdhash_it_val(const stdit *it);
+STDINLINE stdsize stdhash_it_val_size(const stdit *it);
+STDINLINE stdbool stdhash_it_eq(const stdit *it1, const stdit *it2);
+
+STDINLINE stdit * stdhash_it_next(stdit *it);
+STDINLINE stdit * stdhash_it_advance(stdit *it, stdsize num_advance);
+STDINLINE stdit * stdhash_it_prev(stdit *it);
+STDINLINE stdit * stdhash_it_retreat(stdit *it, stdsize num_retreat);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
Added: vendor/stdutil/current/src/stdutil/stdit.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stdit.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stdit.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,81 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdit_h_2005_06_11_12_08_51_jschultz_at_cnds_jhu_edu
+#define stdit_h_2005_06_11_12_08_51_jschultz_at_cnds_jhu_edu
+
+#include <stdutil/stddefines.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdutil/private/stdit_p.h>
+
+typedef enum
+{
+ STDIT_FORWARD = 0x1,
+ STDIT_BIDIRECTIONAL = 0x3,
+ STDIT_RANDOM_ACCESS = 0x7
+
+} stdit_type;
+
+/* Forward Iterators */
+
+STDINLINE stdit_type stdit_get_type(const stdit *it);
+
+STDINLINE const void * stdit_key(const stdit *it); /* returns NULL for non-dictionary iterators */
+STDINLINE stdsize stdit_key_size(const stdit *it); /* returns zero for non-dictionary iterators */
+
+STDINLINE void * stdit_val(const stdit *it);
+STDINLINE stdsize stdit_val_size(const stdit *it);
+
+STDINLINE stdbool stdit_eq(const stdit *it1, const stdit *it2);
+
+STDINLINE stdit * stdit_next(stdit *it);
+STDINLINE stdit * stdit_advance(stdit *it, stdsize num_advance);
+
+STDINLINE stdssize stdit_distance(const stdit *b, const stdit *e);
+
+/* Bidirectional Iterators */
+
+STDINLINE stdit * stdit_prev(stdit *it);
+STDINLINE stdit * stdit_retreat(stdit *it, stdsize num_retreat);
+
+/* Random Access Iterators */
+
+STDINLINE stdssize stdit_cmp(const stdit *it1, const stdit *it2);
+STDINLINE stdit * stdit_offset(stdit *it, stdssize offset);
+
+/* Pointer/C-Array Iterator Constructor */
+
+STDINLINE stdit * stdit_ptr(stdit *it, const void * val, stdsize vsize);
+
+/* Parallel Pointer/C-Array Constructor */
+
+STDINLINE stdit * stdit_pptr(stdit *it, const void *key, const void *val, stdsize ksize, stdsize vsize);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Added: vendor/stdutil/current/src/stdutil/stdskl.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stdskl.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stdskl.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,106 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdskl_h_2004_07_24_13_13_49_jschultz_at_cnds_jhu_edu
+#define stdskl_h_2004_07_24_13_13_49_jschultz_at_cnds_jhu_edu
+
+#include <stdutil/stdit.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/* Structors */
+
+STDINLINE stdcode stdskl_construct(stdskl *l, stdsize ksize, stdsize vsize, stdcmp_fcn kcmp);
+STDINLINE stdcode stdskl_copy_construct(stdskl *dst, const stdskl *src);
+STDINLINE void stdskl_destruct(stdskl *l);
+
+/* Assigners */
+
+STDINLINE stdcode stdskl_set_eq(stdskl *dst, const stdskl *src);
+STDINLINE void stdskl_swap(stdskl *l1, stdskl *l2);
+
+/* Iterators */
+
+STDINLINE stdit * stdskl_begin(const stdskl *l, stdit *it);
+STDINLINE stdit * stdskl_last(const stdskl *l, stdit *it);
+STDINLINE stdit * stdskl_end(const stdskl *l, stdit *it);
+STDINLINE stdit * stdskl_get(const stdskl *l, stdit *it, size_t elem_num); /* O(n) */
+
+STDINLINE stdbool stdskl_is_begin(const stdskl *l, const stdit *it);
+STDINLINE stdbool stdskl_is_end(const stdskl *l, const stdit *it);
+
+/* Size Information */
+
+STDINLINE stdsize stdskl_size(const stdskl *l);
+STDINLINE stdbool stdskl_empty(const stdskl *l);
+
+/* Size Operations */
+
+STDINLINE void stdskl_clear(stdskl *l);
+
+/* Dictionary Operations: O(lg n) */
+
+STDINLINE stdit * stdskl_find(const stdskl *l, stdit *it, const void *key);
+STDINLINE stdit * stdskl_lowerb(const stdskl *l, stdit *it, const void *key);
+STDINLINE stdit * stdskl_upperb(const stdskl *l, stdit *it, const void *key);
+STDINLINE stdbool stdskl_contains(const stdskl *l, const void *key);
+
+STDINLINE stdcode stdskl_put(stdskl *l, stdit *it, const void *key, const void *val, stdbool hint);
+STDINLINE stdcode stdskl_put_n(stdskl *l, stdit *it, const void *keys, const void *vals, stdsize num_put, stdbool hint);
+STDINLINE stdcode stdskl_put_seq(stdskl *l, stdit *it, const stdit *b, const stdit *e, stdbool hint);
+STDINLINE stdcode stdskl_put_seq_n(stdskl *l, stdit *it, const stdit *b, stdsize num_put, stdbool hint);
+
+STDINLINE stdcode stdskl_insert(stdskl *l, stdit *it, const void *key, const void *val, stdbool hint);
+STDINLINE stdcode stdskl_insert_n(stdskl *l, stdit *it, const void *keys, const void *vals, stdsize num_insert, stdbool hint);
+STDINLINE stdcode stdskl_insert_seq(stdskl *l, stdit *it, const stdit *b, const stdit *e, stdbool hint);
+STDINLINE stdcode stdskl_insert_seq_n(stdskl *l, stdit *it, const stdit *b, stdsize num_insert, stdbool hint);
+STDINLINE stdcode stdskl_insert_rep(stdskl *l, stdit *it, const void *key, const void *val, stdsize num_times, stdbool hint);
+
+STDINLINE void stdskl_erase(stdskl *l, stdit *it);
+STDINLINE void stdskl_erase_n(stdskl *l, stdit *it, stdsize num_erase);
+STDINLINE void stdskl_erase_seq(stdskl *l, stdit *b, stdit *e);
+STDINLINE void stdskl_erase_key(stdskl *l, const void *key);
+
+/* Randomization */
+
+STDINLINE void stdskl_dseed(stdskl *l, const void *seed, stdsize sizeof_seed);
+
+/* Iterator Fcns */
+
+STDINLINE const void * stdskl_it_key(const stdit *it);
+STDINLINE stdsize stdskl_it_key_size(const stdit *it);
+STDINLINE void * stdskl_it_val(const stdit *it);
+STDINLINE stdsize stdskl_it_val_size(const stdit *it);
+STDINLINE stdbool stdskl_it_eq(const stdit *it1, const stdit *it2);
+
+STDINLINE stdit * stdskl_it_next(stdit *it);
+STDINLINE stdit * stdskl_it_advance(stdit *it, stdsize num_advance);
+STDINLINE stdit * stdskl_it_prev(stdit *it);
+STDINLINE stdit * stdskl_it_retreat(stdit *it, stdsize num_retreat);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
Added: vendor/stdutil/current/src/stdutil/stdthread.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stdthread.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stdthread.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,80 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdthread_h_2000_03_14_12_28_17_jschultz_at_cnds_jhu_edu
+#define stdthread_h_2000_03_14_12_28_17_jschultz_at_cnds_jhu_edu
+
+#if defined(_REENTRANT) /* NOTE: these types and functions are only declared+defined when _REENTRANT is defined */
+
+# include <stdutil/stddefines.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# include <stdutil/private/stdthread_p.h>
+
+/* Declare thread entry functions like this: void * STDTHREAD_FCN foo(void * arg); */
+
+typedef void *(STDTHREAD_FCN *stdthread_fcn)(void *arg);
+
+/* Thread Management */
+
+STDINLINE stdcode stdthread_spawn(stdthread * thr_ptr, stdthread_id * id,
+ stdthread_fcn thr_fcn, void * fcn_arg);
+
+STDINLINE stdcode stdthread_detach(stdthread thr);
+STDINLINE stdcode stdthread_join(stdthread thr, void ** exitval_ptr);
+STDINLINE void stdthread_exit(void * exitval);
+STDINLINE stdthread_id stdthread_self(void);
+STDINLINE stdbool stdthread_eq(stdthread_id id1, stdthread_id id2);
+
+/* Mutual Exclusion Locks */
+
+# define STDMUTEX_FAST 0xa720c831UL
+# define STDMUTEX_RCRSV 0x3f6c20deUL
+
+STDINLINE stdcode stdmutex_construct(stdmutex *mut, stdmutex_type t);
+STDINLINE stdcode stdmutex_destruct(stdmutex *mut);
+
+STDINLINE stdcode stdmutex_grab(stdmutex *mut);
+STDINLINE stdcode stdmutex_trygrab(stdmutex *mut);
+STDINLINE stdcode stdmutex_drop(stdmutex *mut);
+STDINLINE stdcode stdmutex_is_owner(stdmutex *mut, unsigned * grab_cnt);
+
+/* Condition Variables */
+
+STDINLINE stdcode stdcond_construct(stdcond *cond);
+STDINLINE stdcode stdcond_destruct(stdcond *cond);
+
+STDINLINE stdcode stdcond_wake_one(stdcond *cond);
+STDINLINE stdcode stdcond_wake_all(stdcond *cond);
+
+STDINLINE stdcode stdcond_wait(stdcond *cond, stdmutex *mut);
+/*STDINLINE stdcode stdcond_timedwait(stdcond *cond, stdmutex *mut, long ns);*/
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+#endif
Added: vendor/stdutil/current/src/stdutil/stdtime.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stdtime.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stdtime.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,63 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdtime_h_2003_12_18_18_09_56_jschultz_at_cnds_jhu_edu
+#define stdtime_h_2003_12_18_18_09_56_jschultz_at_cnds_jhu_edu
+
+#include <stdutil/stddefines.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ stdint64 sec;
+ stdint32 nano;
+
+} stdtime;
+
+typedef stdint64 stdtime64; /* time represented in nanoseconds */
+
+STDINLINE stdcode stdtime_now(stdtime *abs_time);
+STDINLINE stdtime stdtime_time64(stdtime64 src);
+
+STDINLINE int stdtime_cmp(stdtime ls, stdtime rs);
+STDINLINE int stdtime_sign(stdtime t);
+
+STDINLINE stdtime stdtime_neg(stdtime t);
+STDINLINE stdtime stdtime_add(stdtime ls, stdtime rs);
+STDINLINE stdtime stdtime_sub(stdtime ls, stdtime rs);
+
+STDINLINE stdcode stdtime64_now(stdtime64 *abs_time);
+STDINLINE stdtime64 stdtime64_time(stdtime t); /* conversion can over/under flow */
+
+/* sleep fcns */
+
+STDINLINE stdcode stdsleep(stdtime delta, stdtime * rem);
+STDINLINE stdcode stdsleep64(stdtime64 delta, stdtime64 * rem);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Added: vendor/stdutil/current/src/stdutil/stdutil.h
===================================================================
--- vendor/stdutil/current/src/stdutil/stdutil.h 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil/stdutil.h 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,98 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdutil_h_2000_01_17_16_00_08_jschultz_at_cnds_jhu_edu
+#define stdutil_h_2000_01_17_16_00_08_jschultz_at_cnds_jhu_edu
+
+#include <stdutil/stddefines.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* string+memory fcns */
+
+STDINLINE stdsize stdstrcpy(char *dst, const char *src);
+STDINLINE stdsize stdstrcpy_n(char *dst, const char *src, stdsize n);
+
+STDINLINE char * stdstrdup(const char *dupme, stdsize *duplen);
+STDINLINE char * stdstrdup_n(const char *dupme, stdsize *duplen, stdsize n);
+
+STDINLINE void * stdmemdup(const void *dupme, stdsize n);
+
+/* hcode fcns */
+
+STDINLINE stduint32 stdhcode_oaat(const void * buf, stdsize buf_len);
+
+STDINLINE void stdhcode_oaat_start(stduint32 *hsh, stdsize tot_len);
+STDINLINE void stdhcode_oaat_churn(stduint32 *hsh, const void * buf, stdsize buf_len);
+STDINLINE void stdhcode_oaat_stop(stduint32 *hsh);
+
+STDINLINE stduint32 stdhcode_sfh(const void * buf, stdsize buf_len);
+
+STDINLINE void stdhcode_sfh_start(stduint32 *hsh, stdsize tot_len);
+STDINLINE void stdhcode_sfh_churn(stduint32 *hsh, const void * buf, stdsize buf_len);
+STDINLINE void stdhcode_sfh_stop(stduint32 *hsh);
+
+/* uniform random number generators */
+
+STDINLINE stduint32 stdrand32(stduint16 x[3]);
+STDINLINE void stdrand32_seed(stduint16 x[3], stduint32 seed);
+STDINLINE void stdrand32_dseed(stduint16 x[3], stduint32 seed);
+
+STDINLINE stduint64 stdrand64(stduint32 x[3]);
+STDINLINE void stdrand64_seed(stduint32 x[3], stduint64 seed);
+STDINLINE void stdrand64_dseed(stduint32 x[3], stduint64 seed);
+
+/* in-place host <-> network byte order (endian) flippers */
+
+STDINLINE void stdhton16(void *io);
+STDINLINE void stdhton32(void *io);
+STDINLINE void stdhton64(void *io);
+STDINLINE stdcode stdhton_n(void *io, size_t n);
+
+STDINLINE void stdntoh16(void *io);
+STDINLINE void stdntoh32(void *io);
+STDINLINE void stdntoh64(void *io);
+STDINLINE stdcode stdntoh_n(void *io, size_t n);
+
+/* unconditional in-place big <-> little byte order (endian) flippers */
+
+STDINLINE void stdflip16(void *io);
+STDINLINE void stdflip32(void *io);
+STDINLINE void stdflip64(void *io);
+STDINLINE void stdflip_n(void *io, size_t n);
+
+/* powers of 2 utilities */
+
+STDINLINE stduint32 stdlg_down(stduint64 x);
+STDINLINE stduint32 stdlg_up(stduint64 x);
+
+STDINLINE stduint64 stdpow2_down(stduint64 x);
+STDINLINE stduint64 stdpow2_up(stduint64 x);
+STDINLINE stduint64 stdpow2_cap(stduint64 x);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Added: vendor/stdutil/current/src/stdutil.c
===================================================================
--- vendor/stdutil/current/src/stdutil.c 2005-07-09 22:49:04 UTC (rev 240)
+++ vendor/stdutil/current/src/stdutil.c 2005-07-15 14:26:58 UTC (rev 241)
@@ -0,0 +1,1035 @@
+/* Copyright (c) 2000-2005, The Johns Hopkins University
+ * All rights reserved.
+ *
+ * The contents of this file are subject to a license (the ``License'')
+ * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * You may not use this file except in compliance with the License. The
+ * specific language governing the rights and limitations of the License
+ * can be found in the file ``STDUTIL_LICENSE'' found in this
+ * distribution.
+ *
+ * Software distributed under the License is distributed on an AS IS
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ *
+ * The Original Software is:
+ * The Stdutil Library
+ *
+ * Contributors:
+ * Creator - John Lane Schultz ([email protected])
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include <stdutil/stderror.h>
+#include <stdutil/stdtime.h>
+#include <stdutil/stdutil.h>
+
+/************************************************************************************************
+ * stdstrcpy: Like C's strcpy, but returns strlen(dst) instead.
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdstrcpy(char *dst, const char *src)
+{
+ char *bdst = dst;
+
+ for (; *src != '\0'; ++src, ++dst) {
+ *dst = *src;
+ }
+
+ *dst = '\0';
+
+ return (stdsize) (dst - bdst);
+}
+
+/************************************************************************************************
+ * stdstrcpy_n: Like stdstrcpy, but only copies the first min('n',
+ * strlen('src')) bytes of 'src' and then adds a NUL termination
+ * (i.e. - dst must have room for n + 1 bytes).
+ ***********************************************************************************************/
+
+STDINLINE stdsize stdstrcpy_n(char *dst, const char *src, stdsize n)
+{
+ const char *esrc = src + n;
+ char * bdst = dst;
+
+ for (; src != esrc && *src != '\0'; ++src, ++dst) {
+ *dst = *src;
+ }
+
+ *dst = '\0';
+
+ return (stdsize) (dst - bdst);
+}
+
+/************************************************************************************************
+ * stdstrdup: Return a malloc'ed copy of 'dupme.'
+ ***********************************************************************************************/
+
+STDINLINE char *stdstrdup(const char *dupme, stdsize *len_ptr)
+{
+ stdsize len = strlen(dupme);
+ char * ret = malloc(len + 1);
+
+ if (len_ptr != NULL) {
+ *len_ptr = len;
+ }
+
+ return (char*) (ret != NULL ? memcpy(ret, dupme, len + 1) : NULL);
+}
+
+/************************************************************************************************
+ * stdstrdup_n: Like stdstrdup, but only copies up through the first
+ * min('n', strlen('src')) bytes of 'src' and then adds a NUL
+ * termination.
+ ***********************************************************************************************/
+
+STDINLINE char *stdstrdup_n(const char *src, stdsize *len_ptr, size_t n)
+{
+ const char *bsrc = src;
+ const char *esrc = src + n;
+ stdsize len;
+ char * ret;
+
+ for (; src != esrc && *src != '\0'; ++src); /* see if strlen(src) < n */
+
+ len = (stdsize) (src - bsrc); /* min(n, strlen(str)) */
+ ret = (char*) malloc(len + 1);
+
+ if (len_ptr != NULL) {
+ *len_ptr = len;
+ }
+
+ if (ret != NULL) { /* copy on successful allocation */
+ memcpy(ret, src, len);
+ ret[len] = '\0';
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdmemdup: Allocates a new block of memory 'n' bytes long and
+ * copies the first 'n' bytes of 'src' to the new block.
+ ***********************************************************************************************/
+
+STDINLINE void *stdmemdup(const void *src, size_t n)
+{
+ void * ret = malloc(n);
+
+ if (ret != NULL) {
+ memcpy(ret, src, n);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdhcode_oaat: Bob Jenkin's One-at-a-Time hash code function.
+ * Computes a 32 bit integer based on all 'buf_len' bytes of 'buf.'
+ * Every input bit can affect every bit of the result with about 50%
+ * probability per output bit -- has no funnels.
+ ***********************************************************************************************/
+
+STDINLINE stduint32 stdhcode_oaat(const void * buf, stdsize buf_len)
+{
+ const char * kit = (const char*) buf;
+ const char * kend = (const char*) buf + buf_len;
+ stduint32 ret = (stduint32) buf_len;
+
+ for (; kit != kend; ++kit) {
+ ret += *kit;
+ ret += (ret << 10);
+ ret ^= (ret >> 6);
+ }
+
+ ret += (ret << 3);
+ ret ^= (ret >> 11);
+ ret += (ret << 15);
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdhcode_oaat_start: Begin computing a One-at-a-Time hash that will
+ * span several buffers. Preferably, but not required, tot_len would
+ * equal the total length of the buffers to be hcoded. For least
+ * collisions, if the total length is unknown but non-zero,
+ * consistently use the same arbitrary non-zero constant (e.g. -1).
+ ***********************************************************************************************/
+
+STDINLINE void stdhcode_oaat_start(stduint32 *hsh, stdsize tot_len)
+{
+ *hsh = (stduint32) tot_len;
+}
+
+/************************************************************************************************
+ * stdhcode_oaat_churn: Mix the 'buf_len' bytes of 'buf' into 'hsh'
+ * using One-at-a-Time's mixer.
+ ***********************************************************************************************/
+
+STDINLINE void stdhcode_oaat_churn(stduint32 *hsh, const void * buf, stdsize buf_len)
+{
+ const char * kit = (const char *) buf;
+ const char * kend = (const char *) buf + buf_len;
+ stduint32 ret = *hsh;
+
+ for (; kit != kend; ++kit) {
+ ret += *kit;
+ ret += (ret << 10);
+ ret ^= (ret >> 6);
+ }
+
+ *hsh = ret;
+}
+
+/************************************************************************************************
+ * stdhcode_oaat_stop: Compute the final result for a multi-buffer
+ * One-at-a-Time hash code.
+ ***********************************************************************************************/
+
+STDINLINE void stdhcode_oaat_stop(stduint32 * hsh)
+{
+ stduint32 ret = *hsh;
+
+ ret += (ret << 3);
+ ret ^= (ret >> 11);
+ ret += (ret << 15);
+
+ *hsh = ret;
+}
+
+/************************************************************************************************
+ * stdhcode_sfh: Paul Hsieh's Super Fast Hash hash code function.
+ * Computes a 32 bit integer based on all 'buf_len' bytes of 'buf.'
+ * Every input bit can affect every bit of the result with about 50%
+ * probability per output bit -- has no funnels. Paul Hsieh alleges
+ * superior speed and distribution compared to One-at-a-Time.
+ ***********************************************************************************************/
+
+#if ((defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) || defined(_MSC_VER) || \
+ defined (__BORLANDC__) || defined (__TURBOC__))
+# define stdhcode_sfh_get16bits(d) (*((const stduint16*) (d)))
+#else
+# define stdhcode_sfh_get16bits(d) ( (stduint16) (*((const stduint8 *)(d) + 1) << 8) + *((const stduint8 *)(d)) )
+#endif
+
+STDINLINE stduint32 stdhcode_sfh(const void * buf, stdsize buf_len)
+{
+ const stduint8 * kit = (const stduint8*) buf;
+ const stduint8 * kend = (const stduint8*) buf + (buf_len & ~0x3);
+ stduint32 ret = (stduint32) buf_len;
+ stduint32 tmp;
+
+ /* main mixing loop */
+
+ while (kit != kend) {
+ ret += stdhcode_sfh_get16bits(kit);
+ tmp = (stdhcode_sfh_get16bits(kit + 2) << 11) ^ ret;
+ ret = (ret << 16) ^ tmp;
+ kit += 4;
+ ret += ret >> 11;
+ }
+
+ /* handle remainder not handled by loop */
+
+ switch (buf_len & 0x3) {
+ case 3:
+ ret += stdhcode_sfh_get16bits(kit);
+ ret ^= ret << 16;
+ ret ^= kit[2] << 18;
+ ret += ret >> 11;
+ break;
+
+ case 2:
+ ret += stdhcode_sfh_get16bits(kit);
+ ret ^= ret << 11;
+ ret += ret >> 17;
+ break;
+
+ case 1:
+ ret += *kit;
+ ret ^= ret << 10;
+ ret += ret >> 1;
+ break;
+ }
+
+ /* force avalanche of final 127 bits */
+
+ ret ^= ret << 3;
+ ret += ret >> 5;
+ ret ^= ret << 2;
+ ret += ret >> 15;
+ ret ^= ret << 10;
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdhcode_sfh_start: Begin computing a SuperFastHash hash that will
+ * span several buffers. Preferably, but not required, tot_len would
+ * equal the total length of the buffers to be hash coded. For least
+ * collisions, if the total length is unknown but non-zero,
+ * consistently use an arbitrary constant instead of zero (e.g. -1).
+ ***********************************************************************************************/
+
+STDINLINE void stdhcode_sfh_start(stduint32 *hsh, stdsize tot_len)
+{
+ *hsh = tot_len;
+}
+
+/************************************************************************************************
+ * stdhcode_sfh_churn: Mix the 'buf_len' bytes of 'buf' into 'hsh'
+ * using SuperFastHash's mixer.
+ ***********************************************************************************************/
+
+STDINLINE void stdhcode_sfh_churn(stduint32 *hsh, const void * buf, stdsize buf_len)
+{
+ const stduint8 * kit = (const stduint8*) buf;
+ const stduint8 * kend = (const stduint8*) buf + (buf_len & ~3);
+ stduint32 ret = *hsh;
+ stduint32 tmp;
+
+ /* main mixing loop */
+
+ while (kit != kend) {
+ ret += stdhcode_sfh_get16bits(kit);
+ tmp = (stdhcode_sfh_get16bits(kit + 2) << 11) ^ ret;
+ ret = (ret << 16) ^ tmp;
+ kit += 4;
+ ret += ret >> 11;
+ }
+
+ /* handle remainder not handled by loop */
+
+ switch (buf_len & 3) {
+ case 3:
+ ret += stdhcode_sfh_get16bits(kit);
+ ret ^= ret << 16;
+ ret ^= kit[2] << 18;
+ ret += ret >> 11;
+ break;
+
+ case 2:
+ ret += stdhcode_sfh_get16bits(kit);
+ ret ^= ret << 11;
+ ret += ret >> 17;
+ break;
+
+ case 1:
+ ret += *kit;
+ ret ^= ret << 10;
+ ret += ret >> 1;
+ break;
+ }
+
+ *hsh = ret;
+}
+
+/************************************************************************************************
+ * stdhcode_sfh_stop: Compute the final result of a multi-buffer
+ * SuperFastHash hash code.
+ ***********************************************************************************************/
+
+STDINLINE void stdhcode_sfh_stop(stduint32 *hsh)
+{
+ stduint32 ret = *hsh;
+
+ /* force avalanche of final 127 bits */
+
+ ret ^= ret << 3;
+ ret += ret >> 5;
+ ret ^= ret << 2;
+ ret += ret >> 15;
+ ret ^= ret << 10;
+
+ *hsh = ret;
+}
+
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#define RAND48_SEED_0 0x330e
+#define RAND48_SEED_1 0xabcd
+#define RAND48_SEED_2 0x1234
+#define RAND48_MULT_0 0xe66d
+#define RAND48_MULT_1 0xdeec
+#define RAND48_MULT_2 0x0005
+#define RAND48_ADD 0x000b
+
+/************************************************************************************************
+ * stdrand32: Returns a pseudo-random 32b integer using a linear
+ * congruential algorithm working on integers 48 bits in size (i.e. -
+ * 'x'). The function mixes the contents of 'x' while calculating the
+ * integer to return. I believe it has a period of 2^47.
+ ***********************************************************************************************/
+
+STDINLINE stduint32 stdrand32(stduint16 x[3])
+{
+ stduint16 temp[2];
+ stduint32 acc;
+
+ acc = (stduint32) RAND48_MULT_0 * x[0] + RAND48_ADD;
+ temp[0] = (stduint16) acc;
+
+ acc >>= 16;
+ acc += (stduint32) RAND48_MULT_0 * x[1] + (stduint32) RAND48_MULT_1 * x[0];
+ temp[1] = (stduint16) acc;
+
+ acc >>= 16;
+ acc += ((stduint32) RAND48_MULT_0 * x[2] + (stduint32) RAND48_MULT_1 * x[1] +
+ (stduint32) RAND48_MULT_2 * x[0]);
+
+ x[0] = temp[0];
+ x[1] = temp[1];
+ x[2] = (stduint16) acc;
+
+ return ((stduint32) x[2] << 16) | x[1];
+}
+
+/************************************************************************************************
+ * stdrand32_seed: Seeds the contents of 'x' based on 'seed' and the
+ * current system time.
+ ***********************************************************************************************/
+
+STDINLINE void stdrand32_seed(stduint16 x[3], stduint32 seed)
+{
+ stdtime64 t;
+
+ stdtime64_now(&t); /* get time since epoch in nanoseconds */
+ t >>= 10; /* truncate to approximately milliseconds, which most clocks can do */
+
+ stdrand32_dseed(x, ((stduint32) t ^ seed) * (seed | 0x1));
+}
+
+/************************************************************************************************
+ * stdrand32_dseed: Seeds the contents of 'x' based solely and
+ * deterministically (i.e. - repeatable) on 'seed.'
+ ***********************************************************************************************/
+
+STDINLINE void stdrand32_dseed(stduint16 x[3], stduint32 seed)
+{
+ x[2] = (stduint16) ((seed >> 16) ^ RAND48_SEED_0);
+ x[1] = (stduint16) ((seed & 0xFFFF) ^ RAND48_SEED_1);
+ x[0] = x[1] ^ x[2] ^ RAND48_SEED_2;
+}
+
+/************************************************************************************************
+ * stdrand64: Returns a pseudo-random 64b integers using a linear
+ * congruential algorithm working on integers 48 bits in size (i.e. -
+ * 'x'). The function mixes the contents of 'x' while calculating the
+ * integer to return. I believe it has a period of 2^47.
+ ***********************************************************************************************/
+
+STDINLINE stduint64 stdrand64(stduint32 x[3])
+{
+ return ((stduint64) stdrand32((stduint16*) x) << 32) | stdrand32((stduint16*) x + 3);
+}
+
+/************************************************************************************************
+ * stdrand64_seed: Seeds the contents of 'x' based on 'seed' and the
+ * current system time.
+ ***********************************************************************************************/
+
+STDINLINE void stdrand64_seed(stduint32 x[3], stduint64 seed)
+{
+ stdtime64 t;
+
+ stdtime64_now(&t); /* get time in nanoseconds since epoch */
+
+ stdrand64_dseed(x, ((stduint64) t ^ seed) * (seed | 0x1));
+}
+
+/************************************************************************************************
+ * stdrand64_dseed: Seeds the contents of 'x' based solely and
+ * deterministically (i.e. - repeatable) on 'seed.'
+ ***********************************************************************************************/
+
+STDINLINE void stdrand64_dseed(stduint32 x[3], stduint64 seed)
+{
+ stdrand32_dseed((stduint16*) x, (stduint32) (seed >> 32));
+ stdrand32_dseed((stduint16*) x + 3, (stduint32) seed);
+}
+
+/************************************************************************************************
+ * For the following endian flipping code, I have defined in
+ * stdutil/stdutil_p.h a mapping from network byte order to host byte
+ * order and the reverse mapping for several size integers.
+ *
+ * For example, in a 64b integer on little endian architectures, the
+ * most significant byte is the highest byte in memory (7), while on a
+ * big endian architecture it is the lowest byte in memory (0). We
+ * represent this information in stdutil/stdutil_p.h as, on the
+ * respective architectures,
+ *
+ * (#define STDENDIAN64_NET0_FROM_HOST 7, #define STDENDIAN64_HOST7_FROM_NET 0)
+ *
+ * and
+ *
+ * (#define STDENDIAN64_NET0_FROM_HOST 0, #define STDENDIAN64_HOST0_FROM_NET 0)
+ *
+ * If you need to correct these numbers by hand (e.g. - cross
+ * compiling for a different endian architecture so configure won't
+ * work correctly), then just make sure you get both mappings correct.
+ ***********************************************************************************************/
+
+/************************************************************************************************
+ * stdhton16: Rearranges the two bytes at which 'io' points from host
+ * to network byte ordering.
+ ***********************************************************************************************/
+
+STDINLINE void stdhton16(void *io)
+{
+#if (STDENDIAN16_SWAP == 1)
+ stduint8 * ptr = (stduint8*) io;
+ stduint8 t;
+
+ STDSWAP(ptr[0], ptr[1], t);
+#endif
+}
+
+/************************************************************************************************
+ * stdhton32: Rearranges the four bytes at which 'io' points from host
+ * to network byte ordering.
+ ***********************************************************************************************/
+
+STDINLINE void stdhton32(void *io)
+{
+#if (STDENDIAN32_NET0_FROM_HOST != 0 || STDENDIAN32_NET1_FROM_HOST != 1 || STDENDIAN32_NET2_FROM_HOST != 2 || STDENDIAN32_NET3_FROM_HOST != 3)
+ stduint8 * ptr = (stduint8*) io;
+ stduint8 buf[4];
+
+
+# if (STDENDIAN32_NET0_FROM_HOST != 0)
+ buf[0] = ptr[0];
+ ptr[0] = ptr[STDENDIAN32_NET0_FROM_HOST];
+# endif
+
+
+# if (STDENDIAN32_NET1_FROM_HOST != 1)
+# if (STDENDIAN32_NET0_FROM_HOST != 1)
+ buf[1] = ptr[1];
+# endif
+
+# if (STDENDIAN32_NET1_FROM_HOST > 1)
+ ptr[1] = ptr[STDENDIAN32_NET1_FROM_HOST];
+# else
+ ptr[1] = buf[STDENDIAN32_NET1_FROM_HOST];
+# endif
+# endif
+
+
+# if (STDENDIAN32_NET2_FROM_HOST != 2)
+# if (STDENDIAN32_NET0_FROM_HOST != 2 && STDENDIAN32_NET1_FROM_HOST != 2)
+ buf[2] = ptr[2]; /* ptr[2] was not previously consumed, so we need to save it in buf[2] */
+# endif
+
+# if (STDENDIAN32_NET2_FROM_HOST > 2)
+ ptr[2] = ptr[STDENDIAN32_NET2_FROM_HOST]; /* STDENDIAN32_NET2_FROM_HOST > 2 -> we haven't yet consumed/saved ptr[STDENDIAN32_NET2_FROM_HOST] */
+# else
+ ptr[2] = buf[STDENDIAN32_NET2_FROM_HOST]; /* STDENDIAN32_NET2_FROM_HOST < 2 -> we have consumed+saved ptr[STDENDIAN32_NET2_FROM_HOST] in buf */
+# endif
+# endif
+
+
+# if (STDENDIAN32_NET3_FROM_HOST != 3)
+ ptr[3] = buf[STDENDIAN32_NET3_FROM_HOST]; /* we have previously saved ptr[STDENDIAN32_NET3_FROM_HOST] in buf */
+# endif
+
+
+#endif
+}
+
+/************************************************************************************************
+ * stdhton64: Rearranges the eight bytes at which 'io' points from
+ * host to network byte order.
+ ***********************************************************************************************/
+
+STDINLINE void stdhton64(void *io)
+{
+#if (STDENDIAN64_NET0_FROM_HOST != 0 || STDENDIAN64_NET1_FROM_HOST != 1 || STDENDIAN64_NET2_FROM_HOST != 2 || STDENDIAN64_NET3_FROM_HOST != 3 || \
+ STDENDIAN64_NET4_FROM_HOST != 4 || STDENDIAN64_NET5_FROM_HOST != 5 || STDENDIAN64_NET6_FROM_HOST != 6 || STDENDIAN64_NET7_FROM_HOST != 7)
+ stduint8 * ptr = (stduint8*) io;
+ stduint8 buf[8];
+
+
+# if (STDENDIAN64_NET0_FROM_HOST != 0)
+ buf[0] = ptr[0];
+ ptr[0] = ptr[STDENDIAN64_NET0_FROM_HOST];
+# endif
+
+
+# if (STDENDIAN64_NET1_FROM_HOST != 1)
+# if (STDENDIAN64_NET0_FROM_HOST != 1)
+ buf[1] = ptr[1];
+# endif
+
+# if (STDENDIAN64_NET1_FROM_HOST > 1)
+ ptr[1] = ptr[STDENDIAN64_NET1_FROM_HOST];
+# else
+ ptr[1] = buf[STDENDIAN64_NET1_FROM_HOST];
+# endif
+# endif
+
+
+# if (STDENDIAN64_NET2_FROM_HOST != 2)
+# if (STDENDIAN64_NET0_FROM_HOST != 2 && STDENDIAN64_NET1_FROM_HOST != 2)
+ buf[2] = ptr[2];
+# endif
+
+# if (STDENDIAN64_NET2_FROM_HOST > 2)
+ ptr[2] = ptr[STDENDIAN64_NET2_FROM_HOST];
+# else
+ ptr[2] = buf[STDENDIAN64_NET2_FROM_HOST];
+# endif
+# endif
+
+
+# if (STDENDIAN64_NET3_FROM_HOST != 3)
+# if (STDENDIAN64_NET0_FROM_HOST != 3 && STDENDIAN64_NET1_FROM_HOST != 3 && STDENDIAN64_NET2_FROM_HOST != 3)
+ buf[3] = ptr[3];
+# endif
+
+# if (STDENDIAN64_NET3_FROM_HOST > 3)
+ ptr[3] = ptr[STDENDIAN64_NET3_FROM_HOST];
+# else
+ ptr[3] = buf[STDENDIAN64_NET3_FROM_HOST];
+# endif
+# endif
+
+
+# if (STDENDIAN64_NET4_FROM_HOST != 4)
+# if (STDENDIAN64_NET0_FROM_HOST != 4 && STDENDIAN64_NET1_FROM_HOST != 4 && STDENDIAN64_NET2_FROM_HOST != 4 && STDENDIAN64_NET3_FROM_HOST != 4)
+ buf[4] = ptr[4];
+# endif
+
+# if (STDENDIAN64_NET4_FROM_HOST > 4)
+ ptr[4] = ptr[STDENDIAN64_NET4_FROM_HOST];
+# else
+ ptr[4] = buf[STDENDIAN64_NET4_FROM_HOST];
+# endif
+# endif
+
+
+# if (STDENDIAN64_NET5_FROM_HOST != 5)
+# if (STDENDIAN64_NET0_FROM_HOST != 5 && STDENDIAN64_NET1_FROM_HOST != 5 && STDENDIAN64_NET2_FROM_HOST != 5 && \
+ STDENDIAN64_NET3_FROM_HOST != 5 && STDENDIAN64_NET4_FROM_HOST != 5)
+ buf[5] = ptr[5];
+# endif
+
+# if (STDENDIAN64_NET5_FROM_HOST > 5)
+ ptr[5] = ptr[STDENDIAN64_NET5_FROM_HOST];
+# else
+ ptr[5] = buf[STDENDIAN64_NET5_FROM_HOST];
+# endif
+# endif
+
+
+# if (STDENDIAN64_NET6_FROM_HOST != 6)
+# if (STDENDIAN64_NET0_FROM_HOST != 6 && STDENDIAN64_NET1_FROM_HOST != 6 && STDENDIAN64_NET2_FROM_HOST != 6 && \
+ STDENDIAN64_NET3_FROM_HOST != 6 && STDENDIAN64_NET4_FROM_HOST != 6 && STDENDIAN64_NET5_FROM_HOST != 6)
+ buf[6] = ptr[6]; /* ptr[6] was not previously consumed, so we need to save it in buf[6] */
+# endif
+
+# if (STDENDIAN64_NET6_FROM_HOST > 6)
+ ptr[6] = ptr[STDENDIAN64_NET6_FROM_HOST]; /* STDENDIAN64_NET6_FROM_HOST > 6 -> we haven't yet consumed/saved ptr[STDENDIAN64_NET6_FROM_HOST] */
+# else
+ ptr[6] = buf[STDENDIAN64_NET6_FROM_HOST]; /* STDENDIAN64_NET6_FROM_HOST < 6 -> we have consumed+saved ptr[STDENDIAN64_NET6_FROM_HOST] in buf */
+# endif
+# endif
+
+
+# if (STDENDIAN64_NET7_FROM_HOST != 7)
+ ptr[7] = buf[STDENDIAN64_NET7_FROM_HOST]; /* we have previously saved ptr[STDENDIAN64_NET7_FROM_HOST] in buf */
+# endif
+
+
+#endif
+}
+
+/************************************************************************************************
+ * stdhton_n: Rearranges the 'n' bytes at which 'io' points from host
+ * into network byte ordering. If n is one of (1, 2, 4, 8), then the fcn
+ * succeeds, returning zero. Otherwise it fails with no side effects,
+ * returning STDEINVAL.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdhton_n(void *io, size_t n)
+{
+ switch (n) {
+ case 1:
+ break;
+
+ case 2:
+ stdhton16(io);
+ break;
+
+ case 4:
+ stdhton32(io);
+ break;
+
+ case 8:
+ stdhton64(io);
+ break;
+
+ default:
+ return STDEINVAL;
+ }
+
+ return STDESUCCESS;
+}
+
+/************************************************************************************************
+ * stdntoh16: Rearranges the two bytes at which 'io' points from
+ * network to host byte ordering.
+ ***********************************************************************************************/
+
+STDINLINE void stdntoh16(void *io)
+{
+#if (STDENDIAN16_SWAP == 1)
+ stduint8 * ptr = (stduint8*) io;
+ stduint8 t;
+
+ STDSWAP(ptr[0], ptr[1], t);
+#endif
+}
+
+/************************************************************************************************
+ * stdntoh32: Rearranges the four bytes at which 'io' points from
+ * network to host byte ordering.
+ ***********************************************************************************************/
+
+STDINLINE void stdntoh32(void *io)
+{
+#if (STDENDIAN32_HOST0_FROM_NET != 0 || STDENDIAN32_HOST1_FROM_NET != 1 || STDENDIAN32_HOST2_FROM_NET != 2 || STDENDIAN32_HOST3_FROM_NET != 3)
+ stduint8 * ptr = (stduint8*) io;
+ stduint8 buf[4];
+
+
+# if (STDENDIAN32_HOST0_FROM_NET != 0)
+ buf[0] = ptr[0];
+ ptr[0] = ptr[STDENDIAN32_HOST0_FROM_NET];
+# endif
+
+
+# if (STDENDIAN32_HOST1_FROM_NET != 1)
+# if (STDENDIAN32_HOST0_FROM_NET != 1)
+ buf[1] = ptr[1];
+# endif
+
+# if (STDENDIAN32_HOST1_FROM_NET > 1)
+ ptr[1] = ptr[STDENDIAN32_HOST1_FROM_NET];
+# else
+ ptr[1] = buf[STDENDIAN32_HOST1_FROM_NET];
+# endif
+# endif
+
+
+# if (STDENDIAN32_HOST2_FROM_NET != 2)
+# if (STDENDIAN32_HOST0_FROM_NET != 2 && STDENDIAN32_HOST1_FROM_NET != 2)
+ buf[2] = ptr[2]; /* ptr[2] was not previously consumed, so we need to save it in buf[2] */
+# endif
+
+# if (STDENDIAN32_HOST2_FROM_NET > 2)
+ ptr[2] = ptr[STDENDIAN32_HOST2_FROM_NET]; /* STDENDIAN32_HOST2_FROM_NET > 2 -> we haven't yet consumed/saved ptr[STDENDIAN32_HOST2_FROM_NET] */
+# else
+ ptr[2] = buf[STDENDIAN32_HOST2_FROM_NET]; /* STDENDIAN32_HOST2_FROM_NET < 2 -> we have consumed+saved ptr[STDENDIAN32_HOST2_FROM_NET] in buf */
+# endif
+# endif
+
+
+# if (STDENDIAN32_HOST3_FROM_NET != 3)
+ ptr[3] = buf[STDENDIAN32_HOST3_FROM_NET]; /* we have previously saved ptr[STDENDIAN32_HOST3_FROM_NET] in buf */
+# endif
+
+
+#endif
+}
+
+/************************************************************************************************
+ * stdntoh64: Rearranges the eight bytes at which 'io' points from
+ * network to host byte ordering.
+ ***********************************************************************************************/
+
+STDINLINE void stdntoh64(void *io)
+{
+#if (STDENDIAN64_HOST0_FROM_NET != 0 || STDENDIAN64_HOST1_FROM_NET != 1 || STDENDIAN64_HOST2_FROM_NET != 2 || STDENDIAN64_HOST3_FROM_NET != 3 || \
+ STDENDIAN64_HOST4_FROM_NET != 4 || STDENDIAN64_HOST5_FROM_NET != 5 || STDENDIAN64_HOST6_FROM_NET != 6 || STDENDIAN64_HOST7_FROM_NET != 7)
+ stduint8 * ptr = (stduint8*) io;
+ stduint8 buf[8];
+
+
+# if (STDENDIAN64_HOST0_FROM_NET != 0)
+ buf[0] = ptr[0];
+ ptr[0] = ptr[STDENDIAN64_HOST0_FROM_NET];
+# endif
+
+
+# if (STDENDIAN64_HOST1_FROM_NET != 1)
+# if (STDENDIAN64_HOST0_FROM_NET != 1)
+ buf[1] = ptr[1];
+# endif
+
+# if (STDENDIAN64_HOST1_FROM_NET > 1)
+ ptr[1] = ptr[STDENDIAN64_HOST1_FROM_NET];
+# else
+ ptr[1] = buf[STDENDIAN64_HOST1_FROM_NET];
+# endif
+# endif
+
+
+# if (STDENDIAN64_HOST2_FROM_NET != 2)
+# if (STDENDIAN64_HOST0_FROM_NET != 2 && STDENDIAN64_HOST1_FROM_NET != 2)
+ buf[2] = ptr[2];
+# endif
+
+# if (STDENDIAN64_HOST2_FROM_NET > 2)
+ ptr[2] = ptr[STDENDIAN64_HOST2_FROM_NET];
+# else
+ ptr[2] = buf[STDENDIAN64_HOST2_FROM_NET];
+# endif
+# endif
+
+
+# if (STDENDIAN64_HOST3_FROM_NET != 3)
+# if (STDENDIAN64_HOST0_FROM_NET != 3 && STDENDIAN64_HOST1_FROM_NET != 3 && STDENDIAN64_HOST2_FROM_NET != 3)
+ buf[3] = ptr[3];
+# endif
+
+# if (STDENDIAN64_HOST3_FROM_NET > 3)
+ ptr[3] = ptr[STDENDIAN64_HOST3_FROM_NET];
+# else
+ ptr[3] = buf[STDENDIAN64_HOST3_FROM_NET];
+# endif
+# endif
+
+
+# if (STDENDIAN64_HOST4_FROM_NET != 4)
+# if (STDENDIAN64_HOST0_FROM_NET != 4 && STDENDIAN64_HOST1_FROM_NET != 4 && STDENDIAN64_HOST2_FROM_NET != 4 && STDENDIAN64_HOST3_FROM_NET != 4)
+ buf[4] = ptr[4];
+# endif
+
+# if (STDENDIAN64_HOST4_FROM_NET > 4)
+ ptr[4] = ptr[STDENDIAN64_HOST4_FROM_NET];
+# else
+ ptr[4] = buf[STDENDIAN64_HOST4_FROM_NET];
+# endif
+# endif
+
+
+# if (STDENDIAN64_HOST5_FROM_NET != 5)
+# if (STDENDIAN64_HOST0_FROM_NET != 5 && STDENDIAN64_HOST1_FROM_NET != 5 && STDENDIAN64_HOST2_FROM_NET != 5 && \
+ STDENDIAN64_HOST3_FROM_NET != 5 && STDENDIAN64_HOST4_FROM_NET != 5)
+ buf[5] = ptr[5];
+# endif
+
+# if (STDENDIAN64_HOST5_FROM_NET > 5)
+ ptr[5] = ptr[STDENDIAN64_HOST5_FROM_NET];
+# else
+ ptr[5] = buf[STDENDIAN64_HOST5_FROM_NET];
+# endif
+# endif
+
+
+# if (STDENDIAN64_HOST6_FROM_NET != 6)
+# if (STDENDIAN64_HOST0_FROM_NET != 6 && STDENDIAN64_HOST1_FROM_NET != 6 && STDENDIAN64_HOST2_FROM_NET != 6 && \
+ STDENDIAN64_HOST3_FROM_NET != 6 && STDENDIAN64_HOST4_FROM_NET != 6 && STDENDIAN64_HOST5_FROM_NET != 6)
+ buf[6] = ptr[6]; /* ptr[6] was not previously consumed, so we need to save it in buf[6] */
+# endif
+
+# if (STDENDIAN64_HOST6_FROM_NET > 6)
+ ptr[6] = ptr[STDENDIAN64_HOST6_FROM_NET]; /* STDENDIAN64_HOST6_FROM_NET > 6 -> we haven't yet consumed/saved ptr[STDENDIAN64_HOST6_FROM_NET] */
+# else
+ ptr[6] = buf[STDENDIAN64_HOST6_FROM_NET]; /* STDENDIAN64_HOST6_FROM_NET < 6 -> we have consumed+saved ptr[STDENDIAN64_HOST6_FROM_NET] in buf */
+# endif
+# endif
+
+
+# if (STDENDIAN64_HOST7_FROM_NET != 7)
+ ptr[7] = buf[STDENDIAN64_HOST7_FROM_NET]; /* we have previously saved ptr[STDENDIAN64_HOST7_FROM_NET] in buf */
+# endif
+
+
+#endif
+}
+
+/************************************************************************************************
+ * stdntoh_n: Rearranges the 'n' bytes at which 'io' points from
+ * network to host byte ordering. If n is one of (1, 2, 4, 8), then the
+ * fcn succeeds, returning zero. Otherwise it fails with no side
+ * effects, returning STDEINVAL.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdntoh_n(void *io, size_t n)
+{
+ switch (n) {
+ case 1:
+ break;
+
+ case 2:
+ stdntoh16(io);
+ break;
+
+ case 4:
+ stdntoh32(io);
+ break;
+
+ case 8:
+ stdntoh64(io);
+ break;
+
+ default:
+ return STDEINVAL;
+ }
+
+ return 0;
+}
+
+/************************************************************************************************
+ * stdflip16: Reverses the order of the two bytes at which 'io' points.
+ ***********************************************************************************************/
+
+STDINLINE void stdflip16(void *io)
+{
+ stduint8 * ptr = (stduint8*) io;
+ stduint8 t;
+
+ STDSWAP(ptr[0], ptr[1], t);
+}
+
+/************************************************************************************************
+ * stdflip32: Reverses the order of the four bytes at which 'io' points.
+ ***********************************************************************************************/
+
+STDINLINE void stdflip32(void *io)
+{
+ stduint8 * ptr = (stduint8*) io;
+ stduint8 t;
+
+ STDSWAP(ptr[0], ptr[3], t);
+ STDSWAP(ptr[1], ptr[2], t);
+}
+
+/************************************************************************************************
+ * stdflip64: Reverses the order of the eight bytes at which 'io'
+ * points.
+ ***********************************************************************************************/
+
+STDINLINE void stdflip64(void *io)
+{
+ stduint8 * ptr = (stduint8*) io;
+ stduint8 t;
+
+ STDSWAP(ptr[0], ptr[7], t);
+ STDSWAP(ptr[1], ptr[6], t);
+ STDSWAP(ptr[2], ptr[5], t);
+ STDSWAP(ptr[3], ptr[4], t);
+}
+
+/************************************************************************************************
+ * stdflip_n: Reverses the order of the 'n' bytes at which 'io'
+ * points.
+ ***********************************************************************************************/
+
+STDINLINE void stdflip_n(void *io, size_t n)
+{
+ stduint8 * ptr1 = (stduint8*) io;
+ stduint8 * ptr2 = (stduint8*) io + n;
+ stduint8 * pend = (stduint8*) io + (n >> 1);
+ stduint8 t;
+
+ for (--ptr2; ptr1 != pend; ++ptr1, --ptr2) {
+ STDSWAP(*ptr1, *ptr2, t);
+ }
+}
+
+/************************************************************************************************
+ * stdlg_down: Returns the log base 2 of 'x' rounded down to the
+ * closest integer (i.e. - floor(lg(x))). Returns (stduint32) -1 if
+ * 'x' 0.
+ ***********************************************************************************************/
+
+STDINLINE stduint32 stdlg_down(stduint64 x)
+{
+ stduint32 shift;
+
+ if (x == 0) {
+ return (stduint32) -1;
+ }
+
+ for (shift = 0; x != 0x1; x >>= 1, ++shift);
+
+ return shift;
+}
+
+/************************************************************************************************
+ * stdlg_up: Returns the log base 2 of 'x' rounded up to the closest
+ * integer (i.e. - ceil(lg(x))). Returns (stduint32) -1 if 'x' is 0.
+ ***********************************************************************************************/
+
+STDINLINE stduint32 stdlg_up(stduint64 x)
+{
+ switch (x) {
+ default:
+ return stdlg_down(x - 1) + 1;
+
+ case 1:
+ return 0;
+
+ case 0:
+ return (stduint32) -1;
+ }
+}
+
+/************************************************************************************************
+ * stdpow2_down: Returns the greatest power of 2 less than or equal to
+ * 'x' (i.e. - 2^floor(lg(x))). Returns 0 if 'x' is 0.
+ ***********************************************************************************************/
+
+STDINLINE stduint64 stdpow2_down(stduint64 x)
+{
+ return (x != 0 ? ((stduint64) 0x1 << stdlg_down(x)) : 0);
+}
+
+/************************************************************************************************
+ * stdpow2_up: Returns the least power of 2 greater than or equal to
+ * 'x' (i.e. - 2^ceil(lg(x))). Returns 0 if 'x' is 0. Returns 0 on
+ * overflow.
+ ***********************************************************************************************/
+
+STDINLINE stduint64 stdpow2_up(stduint64 x)
+{
+ return (x != 0 ? ((stduint64) 0x1 << stdlg_up(x)) : 0);
+}
+
+/************************************************************************************************
+ * stdpow2_cap: This fcn returns a power of 2 that is between 3/2 and
+ * 3 times of 'x'. Returns 0 if 'x' is zero. Returns 0 on overflow.
+ * This fcn is good for calculating the size of a table that has to be
+ * a power of 2 for a random size request.
+ ***********************************************************************************************/
+
+STDINLINE stduint64 stdpow2_cap(stduint64 x)
+{
+ stduint64 up_pow2 = stdpow2_up(x); /* up_pow2 in range [x, 2x) */
+
+ if (up_pow2 < x + (x >> 1)) { /* if (up_pow2 < 1.5x) */
+ up_pow2 <<= 1; /* double -> up_pow2 in range [2x, 3x) */
+ } /* else up_pow2 in range [1.5x, 2x) */
+
+ return up_pow2; /* up_pow2 in range [1.5x, 3x) */
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.