Move libspl_assertf into .c file
Variadic functions cannot be inlined. libspl_assertf ends up being duplicated in every file that uses it. Fix this by moving the function into a new assert.c. Also move the definition of aok into the new file instead of zone.c. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu> Closes #10538
This commit is contained in:
parent
2054f35e56
commit
b6437ea41c
@ -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)
|
||||
|
46
lib/libspl/assert.c
Normal file
46
lib/libspl/assert.c
Normal file
@ -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 <assert.h>
|
||||
|
||||
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();
|
||||
}
|
@ -33,37 +33,18 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#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
|
||||
|
@ -27,8 +27,6 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
int aok = 0;
|
||||
|
||||
zoneid_t
|
||||
getzoneid()
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -40,8 +40,6 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/stdtypes.h>
|
||||
|
||||
int aok = 0;
|
||||
|
||||
/*
|
||||
* Test messages from:
|
||||
* http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf
|
||||
|
Loading…
Reference in New Issue
Block a user