summaryrefslogtreecommitdiffstats
path: root/lib/libstand
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1998-11-01 09:31:08 +0000
committermsmith <msmith@FreeBSD.org>1998-11-01 09:31:08 +0000
commitf00eb1aa6445c9df1cc7392df8ea57731e3af4e4 (patch)
tree87b4256697ab30b183dea932bef45f48f2b2b4f4 /lib/libstand
parent6889817a6e70076fbe448f63f4d41cc27da7731b (diff)
downloadFreeBSD-src-f00eb1aa6445c9df1cc7392df8ea57731e3af4e4.zip
FreeBSD-src-f00eb1aa6445c9df1cc7392df8ea57731e3af4e4.tar.gz
Add:
assert() setjmp()/longjmp() vsprintf()
Diffstat (limited to 'lib/libstand')
-rw-r--r--lib/libstand/Makefile13
-rw-r--r--lib/libstand/assert.c37
-rw-r--r--lib/libstand/libstand.316
-rw-r--r--lib/libstand/printf.c14
-rw-r--r--lib/libstand/stand.h3
5 files changed, 73 insertions, 10 deletions
diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile
index 84e031d..9228e40 100644
--- a/lib/libstand/Makefile
+++ b/lib/libstand/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.5 1998/10/04 08:10:29 msmith Exp $
+# $Id: Makefile,v 1.6 1998/10/06 19:23:57 msmith Exp $
#
# Originally from $NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $
#
@@ -20,9 +20,9 @@ CFLAGS+= -mno-fp-regs
.endif
# standalone components and stuff we have modified locally
-SRCS+= __main.c bcd.c bswap.c environment.c getopt.c gets.c globals.c \
- pager.c printf.c strdup.c strerror.c strtol.c random.c sbrk.c \
- twiddle.c zalloc.c zalloc_malloc.c
+SRCS+= __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
+ globals.c pager.c printf.c strdup.c strerror.c strtol.c random.c \
+ sbrk.c twiddle.c zalloc.c zalloc_malloc.c
# private (pruned) versions of libc string functions
SRCS+= strcasecmp.c
@@ -90,6 +90,11 @@ __reml.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4
.PATH: ${.CURDIR}/../libc/net
SRCS+= inet_ntoa.c inet_addr.c
+# setjmp/longjmp
+.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/gen
+CFLAGS+=-I${.CURDIR}/../libc/${MACHINE_ARCH}
+SRCS+= setjmp.S
+
# decompression functionality from libz
.PATH: ${.CURDIR}/../libz
CFLAGS+=-DHAVE_MEMCPY
diff --git a/lib/libstand/assert.c b/lib/libstand/assert.c
new file mode 100644
index 0000000..1ca15f8
--- /dev/null
+++ b/lib/libstand/assert.c
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 1998 Michael Smith.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $Id$
+ */
+
+#include <stand.h>
+#include <assert.h>
+
+void
+__assert(const char *file, int line, const char *expression)
+{
+ printf("assertion \"%s\" failed: file \"%s\", line %d\n", expression, file, line);
+ exit();
+}
diff --git a/lib/libstand/libstand.3 b/lib/libstand/libstand.3
index 4d4b287..ae04323 100644
--- a/lib/libstand/libstand.3
+++ b/lib/libstand/libstand.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id$
+.\" $Id: libstand.3,v 1.1.1.1 1998/08/20 08:19:55 msmith Exp $
.\"
.Dd June 22, 1998
.Dt LIBSTAND 3
@@ -124,6 +124,15 @@ may be used to prevent a variable being unset.
.Pp
Returns error messages for the subset of errno values supported by
.Nm No .
+.It Fn "assert" "expression"
+.Pp
+Requires
+.Fd #include <assert.h>
+.It Fn "int setjmp" "jmp_buf env"
+.It Fn "void longjmp" "jmp_buf env" "int val"
+.Pp
+Require
+.Fd #include <setjmp.h>
.El
.Sh CHARACTER I/O
.Bl -hang -width 10n
@@ -155,6 +164,7 @@ if successful, or -1 if a read error occurs.
.It Fn "int printf" "const char *fmt" "..."
.It Fn "void vprintf" "const char *fmt" "va_list ap"
.It Fn "int sprintf" "char *buf" "const char *fmt" "..."
+.It Fn "void vsprintf" "char *buf" "const char *fmt" "va_list ap"
.Pp
The *printf functions implement a subset of the standard
.Fn printf
@@ -448,6 +458,10 @@ and
.Nm libkern
from
.Fx 3.0 .
+.It
+.Nm zalloc
+from
+.An Matthew Dillon Aq dillon@backplane.com
.El
.Pp
The reorganisation and port to
diff --git a/lib/libstand/printf.c b/lib/libstand/printf.c
index 8c7b384..5135e10 100644
--- a/lib/libstand/printf.c
+++ b/lib/libstand/printf.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
- * $Id: subr_prf.c,v 1.46 1998/05/28 09:30:20 phk Exp $
+ * $Id: printf.c,v 1.1.1.1 1998/08/20 08:19:55 msmith Exp $
*/
/*
@@ -74,9 +74,6 @@ vprintf(const char *fmt, va_list ap)
kvprintf(fmt, putchar, NULL, 10, ap);
}
-/*
- * Scaled down version of sprintf(3).
- */
int
sprintf(char *buf, const char *cfmt, ...)
{
@@ -90,6 +87,15 @@ sprintf(char *buf, const char *cfmt, ...)
return retval;
}
+void
+vsprintf(char *buf, const char *cfmt, va_list ap)
+{
+ int retval;
+
+ retval = kvprintf(cfmt, NULL, (void *)buf, 10, ap);
+ buf[retval] = '\0';
+}
+
/*
* Put a number (base <= 16) in a buffer in reverse order; return an
* optional length and a pointer to the NULL terminated (preceded?)
diff --git a/lib/libstand/stand.h b/lib/libstand/stand.h
index 3a05490..490c5a6 100644
--- a/lib/libstand/stand.h
+++ b/lib/libstand/stand.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: stand.h,v 1.8 1998/10/19 09:08:40 dfr Exp $
+ * $Id: stand.h,v 1.9 1998/10/31 02:48:29 msmith Exp $
* From $NetBSD: stand.h,v 1.22 1997/06/26 19:17:40 drochner Exp $
*/
@@ -194,6 +194,7 @@ extern int dkcksum(struct disklabel *);
extern int printf(const char *fmt, ...);
extern void vprintf(const char *fmt, _BSD_VA_LIST_);
extern int sprintf(char *buf, const char *cfmt, ...);
+extern void vsprintf(char *buf, const char *cfmt, _BSD_VA_LIST_);
extern void twiddle(void);
OpenPOWER on IntegriCloud