/* $NetBSD: debug.h,v 1.11 2010/08/09 23:07:20 uwe Exp $ */ /*- * Copyright (c) 1999-2002 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by UCHIYAMA Yasushi. * * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. */ /* * debug version exports all symbols. */ #ifdef DEBUG #define STATIC #else #define STATIC static #endif /* * printf control * sample: * #ifdef FOO_DEBUG * #define DPRINTF_ENABLE * #define DPRINTF_DEBUG foo_debug * #define DPRINTF_LEVEL 2 * #endif */ #ifdef USE_HPC_DPRINTF #ifdef DPRINTF_ENABLE #ifndef DPRINTF_DEBUG #error "specify unique debug variable" #endif #ifndef DPRINTF_LEVEL #define DPRINTF_LEVEL 1 #endif int DPRINTF_DEBUG = DPRINTF_LEVEL; #endif /* DPRINTF_ENABLE */ #ifdef __DPRINTF_EXT /* * printf with function name prepended */ #define PRINTF(fmt, args...) do { \ printf("%s: " fmt, __func__ , ##args); \ } while (/* CONSTCOND */0) #ifdef DPRINTF_ENABLE #define DPRINTF(fmt, args...) do { \ if (DPRINTF_DEBUG) \ PRINTF(fmt, ##args); \ } while (/* CONSTCOND */0) #define _DPRINTF(fmt, args...) do { \ if (DPRINTF_DEBUG) \ printf(fmt, ##args); \ } while (/* CONSTCOND */0) #define DPRINTFN(n, fmt, args...) do { \ if (DPRINTF_DEBUG > (n)) \ PRINTF(fmt, ##args); \ } while (/* CONSTCOND */0) #define _DPRINTFN(n, fmt, args...) do { \ if (DPRINTF_DEBUG > (n)) \ printf(fmt, ##args); \ } while (/* CONSTCOND */0) #else /* !DPRINTF_ENABLE */ #define DPRINTF(args...) do {} while (/* CONSTCOND */ 0) #define _DPRINTF(args...) do {} while (/* CONSTCOND */ 0) #define DPRINTFN(n, args...) do {} while (/* CONSTCOND */ 0) #define _DPRINTFN(n, args...) do {} while (/* CONSTCOND */ 0) #endif /* !DPRINTF_ENABLE */ #else /* !__DPRINTF_EXT */ /* * normal debug printf */ #ifdef DPRINTF_ENABLE #define DPRINTF(arg) do { \ if (DPRINTF_DEBUG) \ printf arg; \ } while (/* CONSTCOND */0) #define DPRINTFN(n, arg) do { \ if (DPRINTF_DEBUG > (n)) \ printf arg; \ } while (/* CONSTCOND */0) #else /* !DPRINTF_ENABLE */ #define DPRINTF(arg) do {} while (/* CONSTCOND */ 0) #define DPRINTFN(n, arg) do {} while (/* CONSTCOND */ 0) #endif /* !DPRINTF_ENABLE */ #endif /* !__DPRINT_EXT */ #endif /* USE_HPC_DPRINTF */ /* * debug print utility */ #define DBG_BIT_PRINT_COUNT (1 << 0) #define DBG_BIT_PRINT_QUIET (1 << 1) void __dbg_bit_print(uint32_t, int, int, int, const char *, int); #define dbg_bit_print(a) do { \ __dbg_bit_print((a), sizeof(typeof(a)), 0, 0, NULL, \ DBG_BIT_PRINT_COUNT); \ } while (/* CONSTCOND */0) #define dbg_bit_print_msg(a, m) do { \ __dbg_bit_print((a), sizeof(typeof(a)), 0, 0, (m), \ DBG_BIT_PRINT_COUNT); \ } while (/* CONSTCOND */0) #define dbg_bit_display(a) do { \ __dbg_bit_print((a), sizeof(typeof(a)), 0, 0, NULL, \ DBG_BIT_PRINT_QUIET); \ } while (/* CONSTCOND */0) void dbg_bitmask_print(uint32_t, uint32_t, const char *); void dbg_draw_line(int); void dbg_banner_title(const char *, size_t); void dbg_banner_line(void); #define dbg_banner_function() do { \ dbg_banner_title(__func__, sizeof(__func__) - 1); \ } while (/* CONSTCOND */ 0) /* HPC_DEBUG_LCD */ #define RGB565_BLACK 0x0000 #define RGB565_RED 0xf800 #define RGB565_GREEN 0x07e0 #define RGB565_YELLOW 0xffe0 #define RGB565_BLUE 0x001f #define RGB565_MAGENTA 0xf81f #define RGB565_CYAN 0x07ff #define RGB565_WHITE 0xffff void dbg_lcd_test(void); it/usr.bin/pr?id=e1b4957e7f9d58132f831b334bbcaeba941c9575'>Fix -Wcast-qual issueslukem 2009-03-11Use semantic markupjoerg 2008-07-21Remove the \n and tabs from the __COPYRIGHT() strings.lukem 2007-10-14Convert to using raise_default_signal(3).lukem 2007-04-29fix typosmsaitoh 2006-05-24Coverity CID 3212: Don't return, goto out in all cases so that cleanupchristos 2006-05-01Coverity CID 2989: Use the error path to return.christos 2006-04-02Coverity CID 1660: Plug memory leaks.christos 2005-12-28PR/32402: Jeffrey Bedard: pr filter dumps core with -s option specified,christos 2003-10-13Move Keith Muller's code from a 4-clause to a 3-clause licence by removingagc 2003-08-07Move UCB-licensed code from 4-clause to 3-clause licence.agc 2003-02-25.Nm does not need a dummy argument ("") before punctuation orwiz 2002-02-26Correct spelling of "delimiter", and remove from ignored-errors lists.wiz 2002-02-08Generate <>& symbolically. I'm avoiding .../dist/... directories for now.ross 2001-12-08Punctuation nits, drop superfluous .Pps.wiz 2001-12-01Whitespace cleanup.wiz 2001-07-22seperate -> separatewiz 2000-10-22Don't be silly and try to read an strftime() format string from the LC_TIMEkleink 2000-07-13For the -i option, don't convert a single space before a tab stop to asimonb 1999-11-19Typos (from OpenBSD)kristerw 1999-03-22More and more .Os cleanups. .Os is defined in the tmac.doc-common file,garbled 1999-03-07Clean up SYNOPSIS formatting.mycroft 1998-12-19char -> unsigned charchristos 1998-04-02Need <time.h> for localtime() and strftime() prototypes.kleink 1997-10-19WARNSify, fix .Nm usage, deprecate registerlukem 1997-06-26Fix formatting directives; from SAITOH Masanobu <msaitoh@spa.is.uec.ac.jp>kleink 1997-01-09RCS ID policetls 1997-01-09Import from 4.4BSD-Lite2tls