diff --git a/lib/libspl/Makefile.am b/lib/libspl/Makefile.am index b3d9ee79c3..ad34c3588c 100644 --- a/lib/libspl/Makefile.am +++ b/lib/libspl/Makefile.am @@ -17,7 +17,10 @@ AM_CFLAGS += $(LIBTIRPC_CFLAGS) AM_CCASFLAGS = \ $(CFLAGS) -noinst_LTLIBRARIES = libspl.la +noinst_LTLIBRARIES = libspl_assert.la libspl.la + +libspl_assert_la_SOURCES = \ + assert.c USER_C = \ list.c \ @@ -49,4 +52,7 @@ libspl_la_SOURCES = \ $(USER_C) \ $(TARGET_CPU_ATOMIC_SOURCE) -libspl_la_LIBADD = -lrt $(LIBTIRPC_LIBS) +libspl_la_LIBADD = \ + libspl_assert.la + +libspl_la_LIBADD += -lrt $(LIBTIRPC_LIBS) diff --git a/lib/libspl/assert.c b/lib/libspl/assert.c new file mode 100644 index 0000000000..94290ae13e --- /dev/null +++ b/lib/libspl/assert.c @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#include + +int aok = 0; + +/* printf version of libspl_assert */ +void +libspl_assertf(const char *file, const char *func, int line, + const char *format, ...) +{ + va_list args; + + va_start(args, format); + vfprintf(stderr, format, args); + fprintf(stderr, "\n"); + fprintf(stderr, "ASSERT at %s:%d:%s()", file, line, func); + va_end(args); + if (aok) { + return; + } + abort(); +} diff --git a/lib/libspl/include/assert.h b/lib/libspl/include/assert.h index 6f80f13348..0503ce4921 100644 --- a/lib/libspl/include/assert.h +++ b/lib/libspl/include/assert.h @@ -33,37 +33,18 @@ #include #include -#ifndef _KERNEL +/* Set to non-zero to avoid abort()ing on an assertion failure */ extern int aok; -#endif + +/* printf version of libspl_assert */ +extern void libspl_assertf(const char *file, const char *func, int line, + const char *format, ...); static inline int libspl_assert(const char *buf, const char *file, const char *func, int line) { - fprintf(stderr, "%s\n", buf); - fprintf(stderr, "ASSERT at %s:%d:%s()", file, line, func); - if (aok) { - return (0); - } - abort(); -} - -/* printf version of libspl_assert */ -static inline void -libspl_assertf(const char *file, const char *func, int line, - const char *format, ...) -{ - va_list args; - - va_start(args, format); - vfprintf(stderr, format, args); - fprintf(stderr, "\n"); - fprintf(stderr, "ASSERT at %s:%d:%s()", file, line, func); - va_end(args); - if (aok) { - return; - } - abort(); + libspl_assertf(file, func, line, "%s", buf); + return (0); } #ifdef verify diff --git a/lib/libspl/zone.c b/lib/libspl/zone.c index 4a0e600ca3..5ca93b224d 100644 --- a/lib/libspl/zone.c +++ b/lib/libspl/zone.c @@ -27,8 +27,6 @@ #include #include -int aok = 0; - zoneid_t getzoneid() { diff --git a/tests/zfs-tests/tests/functional/checksum/Makefile.am b/tests/zfs-tests/tests/functional/checksum/Makefile.am index a8eb41331f..7cd15324e2 100644 --- a/tests/zfs-tests/tests/functional/checksum/Makefile.am +++ b/tests/zfs-tests/tests/functional/checksum/Makefile.am @@ -1,7 +1,9 @@ include $(top_srcdir)/config/Rules.am AM_CPPFLAGS += -I$(top_srcdir)/include -LDADD = $(top_builddir)/lib/libicp/libicp.la +LDADD = \ + $(top_builddir)/lib/libicp/libicp.la \ + $(top_builddir)/lib/libspl/libspl_assert.la AUTOMAKE_OPTIONS = subdir-objects diff --git a/tests/zfs-tests/tests/functional/checksum/edonr_test.c b/tests/zfs-tests/tests/functional/checksum/edonr_test.c index 3c676c91f8..a88756091e 100644 --- a/tests/zfs-tests/tests/functional/checksum/edonr_test.c +++ b/tests/zfs-tests/tests/functional/checksum/edonr_test.c @@ -40,8 +40,6 @@ #include #include -int aok = 0; - /* * Test messages from: * http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf