1cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes/* $NetBSD: utils.h,v 1.6 2003/08/07 16:43:21 agc Exp $ */ 2cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes 3cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes/*- 4cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * Copyright (c) 1992, 1993, 1994 5cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * The Regents of the University of California. All rights reserved. 6cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 7cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * This code is derived from software contributed to Berkeley by 8cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * Henry Spencer. 9cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 10cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * Redistribution and use in source and binary forms, with or without 11cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * modification, are permitted provided that the following conditions 12cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * are met: 13cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 1. Redistributions of source code must retain the above copyright 14cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * notice, this list of conditions and the following disclaimer. 15cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 2. Redistributions in binary form must reproduce the above copyright 16cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * notice, this list of conditions and the following disclaimer in the 17cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * documentation and/or other materials provided with the distribution. 18cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 3. Neither the name of the University nor the names of its contributors 19cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * may be used to endorse or promote products derived from this software 20cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * without specific prior written permission. 21cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 22cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * SUCH DAMAGE. 33cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 34cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * @(#)utils.h 8.3 (Berkeley) 3/20/94 35cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes */ 36cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes 37cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes/*- 38cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * Copyright (c) 1992, 1993, 1994 Henry Spencer. 39cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 40cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * This code is derived from software contributed to Berkeley by 41cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * Henry Spencer. 42cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 43cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * Redistribution and use in source and binary forms, with or without 44cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * modification, are permitted provided that the following conditions 45cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * are met: 46cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 1. Redistributions of source code must retain the above copyright 47cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * notice, this list of conditions and the following disclaimer. 48cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 2. Redistributions in binary form must reproduce the above copyright 49cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * notice, this list of conditions and the following disclaimer in the 50cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * documentation and/or other materials provided with the distribution. 51cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 3. All advertising materials mentioning features or use of this software 52cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * must display the following acknowledgement: 53cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * This product includes software developed by the University of 54cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * California, Berkeley and its contributors. 55cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 4. Neither the name of the University nor the names of its contributors 56cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * may be used to endorse or promote products derived from this software 57cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * without specific prior written permission. 58cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 59cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 60cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 61cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 62cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 63cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 64cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 65cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 66cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 67cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 68cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 69cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * SUCH DAMAGE. 70cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 71cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * @(#)utils.h 8.3 (Berkeley) 3/20/94 72cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes */ 73cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes 74cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes/* utility definitions */ 75cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */ 76cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define INFINITY (DUPMAX + 1) 77cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define NC (CHAR_MAX - CHAR_MIN + 1) 78cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughestypedef unsigned char uch; 79cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes 80cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes/* switch off assertions (if not already off) if no REDEBUG */ 81cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#ifndef REDEBUG 82cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#ifndef NDEBUG 83cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define NDEBUG /* no assertions please */ 84cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#endif 85cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#endif 86cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#include <assert.h> 87cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes 88cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes/* for old systems with bcopy() but no memmove() */ 89cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#ifdef USEBCOPY 90cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define memmove(d, s, c) bcopy(s, d, c) 91cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#endif 92