1*26475619Schristos /* $NetBSD: debug.c,v 1.2 1999/03/01 16:40:07 christos Exp $ */ 241fe218bScgd 341fe218bScgd /* 441fe218bScgd * Copyright 1996 John D. Polstra. 541fe218bScgd * Copyright 1996 Matt Thomas <matt@3am-software.com> 641fe218bScgd * All rights reserved. 741fe218bScgd * 841fe218bScgd * Redistribution and use in source and binary forms, with or without 941fe218bScgd * modification, are permitted provided that the following conditions 1041fe218bScgd * are met: 1141fe218bScgd * 1. Redistributions of source code must retain the above copyright 1241fe218bScgd * notice, this list of conditions and the following disclaimer. 1341fe218bScgd * 2. Redistributions in binary form must reproduce the above copyright 1441fe218bScgd * notice, this list of conditions and the following disclaimer in the 1541fe218bScgd * documentation and/or other materials provided with the distribution. 1641fe218bScgd * 3. All advertising materials mentioning features or use of this software 1741fe218bScgd * must display the following acknowledgement: 1841fe218bScgd * This product includes software developed by John Polstra. 1941fe218bScgd * 4. The name of the author may not be used to endorse or promote products 2041fe218bScgd * derived from this software without specific prior written permission. 2141fe218bScgd * 2241fe218bScgd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2341fe218bScgd * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2441fe218bScgd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2541fe218bScgd * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2641fe218bScgd * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2741fe218bScgd * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2841fe218bScgd * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2941fe218bScgd * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3041fe218bScgd * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3141fe218bScgd * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3241fe218bScgd */ 3341fe218bScgd 3441fe218bScgd /* 3541fe218bScgd * Support for printing debugging messages. 3641fe218bScgd */ 3741fe218bScgd 38*26475619Schristos #include <sys/cdefs.h> 39*26475619Schristos #ifdef __STDC__ 4041fe218bScgd #include <stdarg.h> 41*26475619Schristos #else 42*26475619Schristos #include <varargs.h> 43*26475619Schristos #endif 4441fe218bScgd 4541fe218bScgd #include "debug.h" 4641fe218bScgd #include "rtldenv.h" 4741fe218bScgd 4841fe218bScgd #ifdef DEBUG 4941fe218bScgd int debug = 0; 5041fe218bScgd 5141fe218bScgd void 52*26475619Schristos #ifdef __STDC__ 5341fe218bScgd debug_printf(const char *format, ...) 54*26475619Schristos #else 55*26475619Schristos debug_printf(va_alist) 56*26475619Schristos va_dcl 57*26475619Schristos #endif 5841fe218bScgd { 5941fe218bScgd if(debug) { 6041fe218bScgd va_list ap; 61*26475619Schristos #ifdef __STDC__ 6241fe218bScgd va_start(ap, format); 63*26475619Schristos #else 64*26475619Schristos const char *format; 65*26475619Schristos 66*26475619Schristos va_start(ap); 67*26475619Schristos format = va_arg(ap, const char *); 68*26475619Schristos #endif 6941fe218bScgd 7041fe218bScgd xvprintf(format, ap); 7141fe218bScgd 7241fe218bScgd va_end(ap); 7341fe218bScgd xprintf("\n"); 7441fe218bScgd } 7541fe218bScgd } 7641fe218bScgd #endif 77