*BSD News Article 8438


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!agate!dog.ee.lbl.gov!horse.ee.lbl.gov!torek
From: torek@horse.ee.lbl.gov (Chris Torek)
Newsgroups: comp.unix.bsd
Subject: Re: [386bsd] gcc-2.3.1 and XFree86-1.1 compile
Date: 2 Dec 1992 02:53:50 GMT
Organization: Lawrence Berkeley Laboratory, Berkeley CA
Lines: 144
Message-ID: <27738@dog.ee.lbl.gov>
References: <veit.723126991@du9ds3> <1992Dec1.153305.15456@runx.oz.au>
NNTP-Posting-Host: 128.3.112.15

In article <1992Dec1.153305.15456@runx.oz.au>
bde@runx.oz.au (Bruce Evans) writes:
>... Unfortunately the 386BSD <assert.h> is not ANSI conformant
>(assert() is statement but it is supposed to be an expression).

Here is what I used to replace the previous BSD assert.  This is (or
should be) what is on the 4.4BSD-alpha tape.  You will probably have
to add assert.c to the libc/gen/Makefile.inc file.
--
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  The new files
# will be owned by you and have default permissions.
#
# This archive contains:
#
#	assert.h [goes in /usr/src/include]
#	assert.c [goes in /usr/src/lib/libc/gen]
#
echo x - assert.h
sed 's/^X//' >assert.h << 'END-of-/usr/src/include/assert.h'
X/*-
X * Copyright (c) 1992 The Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X *
X *	@(#)assert.h	5.2 (Berkeley) 6/18/92
X */
X
X/*
X * Unlike other ANSI header files, <assert.h> may usefully be included
X * multiple times, with and without NDEBUG defined.
X */
X
X#undef assert
X
X#ifdef NDEBUG
X#define	assert(e)	((void)0)
X#define	_assert(e)	((void)0)
X#else
X#define	_assert(e)	assert(e)
X#ifdef __STDC__
X#define	assert(e)	((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
X#else	/* PCC */
X#define	assert(e)	((e) ? (void)0 : __assert(__FILE__, __LINE__, "e"))
X#endif
X#endif
X
X#include <sys/cdefs.h>
X
X__BEGIN_DECLS
Xvoid __assert __P((const char *, int, const char *));
X__END_DECLS
END-of-/usr/src/include/assert.h
echo x - assert.c
sed 's/^X//' >assert.c << 'END-of-assert.c'
X/*-
X * Copyright (c) 1992 The Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic char sccsid[] = "@(#)assert.c	5.1 (Berkeley) 4/23/92";
X#endif /* LIBC_SCCS and not lint */
X
X#include <sys/types.h>
X#include <assert.h>
X#include <stdio.h>
X#include <stdlib.h>
X
Xvoid
X__assert(file, line, failedexpr)
X	const char *file, *failedexpr;
X	int line;
X{
X	(void)fprintf(stderr,
X	    "assertion \"%s\" failed: file \"%s\", line %d\n",
X	    failedexpr, file, line);
X	abort();
X	/* NOTREACHED */
X}
END-of-assert.c
exit

-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov