From a1d774c27fd6b07ef043eb3602d3c6a431745323 Mon Sep 17 00:00:00 2001 From: avg Date: Fri, 23 Aug 2013 14:18:24 +0000 Subject: [PATCH] MFC r253996,253997: opensolaris code: translate INVARIANTS to DEBUG and ZFS_DEBUG Please note that support for compiling ZFS into a kernel is not in this branch as of now. Also, not all modules from head are in this branch. git-svn-id: svn://svn.freebsd.org/base/stable/8@254705 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- .../compat/opensolaris/sys/debug_compat.h | 37 +++++++++++++++++++ sys/cddl/compat/opensolaris/sys/mutex.h | 2 +- sys/cddl/compat/opensolaris/sys/rwlock.h | 2 +- sys/cddl/dev/dtrace/dtrace_load.c | 2 + sys/cddl/dev/dtrace/dtrace_unload.c | 2 + sys/conf/options | 1 + sys/modules/cyclic/Makefile | 4 +- sys/modules/dtrace/dtmalloc/Makefile | 2 + sys/modules/dtrace/dtnfsclient/Makefile | 2 + sys/modules/dtrace/dtrace/Makefile | 5 ++- sys/modules/dtrace/dtrace_test/Makefile | 2 + sys/modules/dtrace/dtraceall/Makefile | 2 + sys/modules/dtrace/fasttrap/Makefile | 5 ++- sys/modules/dtrace/fbt/Makefile | 2 + sys/modules/dtrace/lockstat/Makefile | 2 + sys/modules/dtrace/profile/Makefile | 2 + sys/modules/dtrace/prototype/Makefile | 2 + sys/modules/dtrace/sdt/Makefile | 2 + sys/modules/dtrace/systrace/Makefile | 2 + .../dtrace/systrace_freebsd32/Makefile | 2 + sys/modules/dtrace/systrace_linux32/Makefile | 2 + sys/modules/opensolaris/Makefile | 2 + sys/modules/zfs/Makefile | 2 + 23 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 sys/cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/cddl/compat/opensolaris/sys/debug_compat.h b/sys/cddl/compat/opensolaris/sys/debug_compat.h new file mode 100644 index 000000000..72756a912 --- /dev/null +++ b/sys/cddl/compat/opensolaris/sys/debug_compat.h @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2013 Andriy Gapon + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +/* + * This is a special file that SHOULD NOT be included using #include directive. + */ + +#if defined(INVARIANTS) +#ifndef DEBUG +#define DEBUG +#endif +#endif diff --git a/sys/cddl/compat/opensolaris/sys/mutex.h b/sys/cddl/compat/opensolaris/sys/mutex.h index eff4166aa..b1982e724 100644 --- a/sys/cddl/compat/opensolaris/sys/mutex.h +++ b/sys/cddl/compat/opensolaris/sys/mutex.h @@ -46,7 +46,7 @@ typedef enum { typedef struct sx kmutex_t; -#ifndef DEBUG +#ifndef OPENSOLARIS_WITNESS #define MUTEX_FLAGS (SX_DUPOK | SX_NOWITNESS) #else #define MUTEX_FLAGS (SX_DUPOK) diff --git a/sys/cddl/compat/opensolaris/sys/rwlock.h b/sys/cddl/compat/opensolaris/sys/rwlock.h index 996a42635..372413697 100644 --- a/sys/cddl/compat/opensolaris/sys/rwlock.h +++ b/sys/cddl/compat/opensolaris/sys/rwlock.h @@ -47,7 +47,7 @@ typedef enum { typedef struct sx krwlock_t; -#ifndef DEBUG +#ifndef OPENSOLARIS_WITNESS #define RW_FLAGS (SX_DUPOK | SX_NOWITNESS) #else #define RW_FLAGS (SX_DUPOK) diff --git a/sys/cddl/dev/dtrace/dtrace_load.c b/sys/cddl/dev/dtrace/dtrace_load.c index 59267259c..a47813c3e 100644 --- a/sys/cddl/dev/dtrace/dtrace_load.c +++ b/sys/cddl/dev/dtrace/dtrace_load.c @@ -73,7 +73,9 @@ dtrace_load(void *dummy) mutex_init(&dtrace_lock,"dtrace probe state", MUTEX_DEFAULT, NULL); mutex_init(&dtrace_provider_lock,"dtrace provider state", MUTEX_DEFAULT, NULL); mutex_init(&dtrace_meta_lock,"dtrace meta-provider state", MUTEX_DEFAULT, NULL); +#ifdef DEBUG mutex_init(&dtrace_errlock,"dtrace error lock", MUTEX_DEFAULT, NULL); +#endif mutex_enter(&dtrace_provider_lock); mutex_enter(&dtrace_lock); diff --git a/sys/cddl/dev/dtrace/dtrace_unload.c b/sys/cddl/dev/dtrace/dtrace_unload.c index 247cbb183..91d20bd71 100644 --- a/sys/cddl/dev/dtrace/dtrace_unload.c +++ b/sys/cddl/dev/dtrace/dtrace_unload.c @@ -121,7 +121,9 @@ dtrace_unload() mutex_destroy(&dtrace_meta_lock); mutex_destroy(&dtrace_provider_lock); mutex_destroy(&dtrace_lock); +#ifdef DEBUG mutex_destroy(&dtrace_errlock); +#endif /* XXX Hack */ mutex_destroy(&mod_lock); diff --git a/sys/conf/options b/sys/conf/options index b78bef214..f32f9de73 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -671,6 +671,7 @@ KTR_VERBOSE opt_ktr.h WITNESS opt_global.h WITNESS_KDB opt_witness.h WITNESS_SKIPSPIN opt_witness.h +OPENSOLARIS_WITNESS opt_global.h # options for ACPI support ACPI_DEBUG opt_acpi.h diff --git a/sys/modules/cyclic/Makefile b/sys/modules/cyclic/Makefile index 371dac680..9bac7445d 100644 --- a/sys/modules/cyclic/Makefile +++ b/sys/modules/cyclic/Makefile @@ -12,8 +12,8 @@ CFLAGS+= -I${.CURDIR}/../../cddl/compat/opensolaris \ -I${.CURDIR}/../.. \ -I${.CURDIR}/../../cddl/dev/cyclic/${MACHINE_ARCH:S/amd64/i386/} -CFLAGS+= -DDEBUG=1 - IGNORE_PRAGMA= 1 .include + +CFLAGS+= -include ${.CURDIR}/../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/dtmalloc/Makefile b/sys/modules/dtrace/dtmalloc/Makefile index efb260763..3034b4664 100644 --- a/sys/modules/dtrace/dtmalloc/Makefile +++ b/sys/modules/dtrace/dtmalloc/Makefile @@ -11,3 +11,5 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ -I${.CURDIR}/../../.. .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/dtnfsclient/Makefile b/sys/modules/dtrace/dtnfsclient/Makefile index 5e26bba65..b19cc3f17 100644 --- a/sys/modules/dtrace/dtnfsclient/Makefile +++ b/sys/modules/dtrace/dtnfsclient/Makefile @@ -11,3 +11,5 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ -I${.CURDIR}/../../.. .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/dtrace/Makefile b/sys/modules/dtrace/dtrace/Makefile index 18c317c41..603a144cf 100644 --- a/sys/modules/dtrace/dtrace/Makefile +++ b/sys/modules/dtrace/dtrace/Makefile @@ -36,7 +36,7 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ -I${.CURDIR}/../../../cddl/contrib/opensolaris/uts/common \ -I${.CURDIR}/../../.. -DDIS_MEM -CFLAGS+= -DSMP -DDEBUG +CFLAGS+= -DSMP EXPORT_SYMS= dtrace_register \ dtrace_unregister \ @@ -46,6 +46,9 @@ dtrace_asm.o: assym.s .include +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h + CWARNFLAGS+= -Wno-parentheses CWARNFLAGS+= -Wno-uninitialized CWARNFLAGS+= -Wno-cast-qual +CWARNFLAGS+= -Wno-unused diff --git a/sys/modules/dtrace/dtrace_test/Makefile b/sys/modules/dtrace/dtrace_test/Makefile index bc096f3a7..206dd89af 100644 --- a/sys/modules/dtrace/dtrace_test/Makefile +++ b/sys/modules/dtrace/dtrace_test/Makefile @@ -12,3 +12,5 @@ CFLAGS+= -I${.CURDIR}/../../.. CFLAGS+= -D_KERNEL .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/dtraceall/Makefile b/sys/modules/dtrace/dtraceall/Makefile index cfb158da2..6cef5254f 100644 --- a/sys/modules/dtrace/dtraceall/Makefile +++ b/sys/modules/dtrace/dtraceall/Makefile @@ -15,3 +15,5 @@ opt_compat.h: .endif .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/fasttrap/Makefile b/sys/modules/dtrace/fasttrap/Makefile index 40aabd7bd..85ad07864 100644 --- a/sys/modules/dtrace/fasttrap/Makefile +++ b/sys/modules/dtrace/fasttrap/Makefile @@ -15,6 +15,9 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/uts/intel .PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/uts/intel/dtrace .endif -CFLAGS+= -DSMP -DDEBUG +CFLAGS+= -DSMP .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h +CWARNFLAGS+= -Wno-unused diff --git a/sys/modules/dtrace/fbt/Makefile b/sys/modules/dtrace/fbt/Makefile index 9b69b224a..65779f0bb 100644 --- a/sys/modules/dtrace/fbt/Makefile +++ b/sys/modules/dtrace/fbt/Makefile @@ -11,3 +11,5 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ -I${.CURDIR}/../../.. .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/lockstat/Makefile b/sys/modules/dtrace/lockstat/Makefile index d00a0ec37..c87a65ab8 100644 --- a/sys/modules/dtrace/lockstat/Makefile +++ b/sys/modules/dtrace/lockstat/Makefile @@ -12,3 +12,5 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ -I${.CURDIR}/../../.. .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/profile/Makefile b/sys/modules/dtrace/profile/Makefile index 22cd10d6c..daa5d2ca6 100644 --- a/sys/modules/dtrace/profile/Makefile +++ b/sys/modules/dtrace/profile/Makefile @@ -11,3 +11,5 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ -I${.CURDIR}/../../.. .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/prototype/Makefile b/sys/modules/dtrace/prototype/Makefile index 49cc0a89b..cad750a20 100644 --- a/sys/modules/dtrace/prototype/Makefile +++ b/sys/modules/dtrace/prototype/Makefile @@ -11,3 +11,5 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ -I${.CURDIR}/../../.. .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/sdt/Makefile b/sys/modules/dtrace/sdt/Makefile index d531d789b..96605e111 100644 --- a/sys/modules/dtrace/sdt/Makefile +++ b/sys/modules/dtrace/sdt/Makefile @@ -11,3 +11,5 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ -I${.CURDIR}/../../.. .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/systrace/Makefile b/sys/modules/dtrace/systrace/Makefile index d85a36570..f495d550c 100644 --- a/sys/modules/dtrace/systrace/Makefile +++ b/sys/modules/dtrace/systrace/Makefile @@ -11,3 +11,5 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ -I${.CURDIR}/../../.. .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/systrace_freebsd32/Makefile b/sys/modules/dtrace/systrace_freebsd32/Makefile index 284d99f54..ec72d0bd8 100644 --- a/sys/modules/dtrace/systrace_freebsd32/Makefile +++ b/sys/modules/dtrace/systrace_freebsd32/Makefile @@ -11,3 +11,5 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ -I${.CURDIR}/../../.. -DFREEBSD32_SYSTRACE .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/dtrace/systrace_linux32/Makefile b/sys/modules/dtrace/systrace_linux32/Makefile index c950aacd3..a2bfc8123 100644 --- a/sys/modules/dtrace/systrace_linux32/Makefile +++ b/sys/modules/dtrace/systrace_linux32/Makefile @@ -16,3 +16,5 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ -I${.CURDIR}/../../.. -DLINUX_SYSTRACE .include + +CFLAGS+= -include ${.CURDIR}/../../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/opensolaris/Makefile b/sys/modules/opensolaris/Makefile index 29adb1812..9250f863d 100644 --- a/sys/modules/opensolaris/Makefile +++ b/sys/modules/opensolaris/Makefile @@ -24,3 +24,5 @@ CFLAGS+= -I${.CURDIR}/../../cddl/compat/opensolaris \ IGNORE_PRAGMA= 1 .include + +CFLAGS+= -include ${.CURDIR}/../../cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/zfs/Makefile b/sys/modules/zfs/Makefile index d7482cc07..9ad8ba5ed 100644 --- a/sys/modules/zfs/Makefile +++ b/sys/modules/zfs/Makefile @@ -89,6 +89,8 @@ CFLAGS+=-DBUILDING_ZFS .include +CFLAGS+= -include ${.CURDIR}/../../cddl/compat/opensolaris/sys/debug_compat.h + CWARNFLAGS+=-Wno-unknown-pragmas CWARNFLAGS+=-Wno-missing-prototypes CWARNFLAGS+=-Wno-undef -- 2.45.0