1/* 2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22 23 24#import "FWTracepoints.h" 25 26// the controls 27 28#define FWLOGGING 0 29#define FWASSERTS 1 30 31/////////////////////////////////////////// 32 33#if FWLOGGING 34#define FWKLOG(x) IOLog x 35#else 36#define FWKLOG(x) do {} while (0) 37#endif 38 39#if FWLOCALLOGGING 40#define FWLOCALKLOG(x) IOLog x 41#else 42#define FWLOCALKLOG(x) do {} while (0) 43#endif 44 45#if FWASSERTS 46#define FWKLOGASSERT(a) { if(!(a)) { IOLog( "File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } } 47#else 48#define FWKLOGASSERT(a) do {} while (0) 49#endif 50 51#if FWASSERTS 52#define FWPANICASSERT(a) { if(!(a)) { panic( "File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } } 53#else 54#define FWPANICASSERT(a) do {} while (0) 55#endif 56 57#if FWASSERTS 58#define FWASSERTINGATE(a) { if(!((a)->inGate())) { IOLog( "File "__FILE__", line %d: warning - workloop lock is not held.\n", __LINE__); } } 59#else 60#define FWASSERTINGATE(a) do {} while (0) 61#endif 62 63#if FIRELOG > 0 64# define DoErrorLog( x... ) { FireLog( "ERROR: " x ) ; } 65# define DoDebugLog( x... ) { FireLog( x ) ; } 66#else 67# define DoErrorLog( x... ) { IOLog( "ERROR: " x ) ; } 68# define DoDebugLog( x... ) { IOLog( x ) ; } 69#endif 70 71#define ErrorLog(x...) DoErrorLog( x ) ; 72#define ErrorLogCond( x, y... ) { if (x) ErrorLog ( y ) ; } 73 74#if IOFIREWIREDEBUG > 0 75#if FIRELOG 76# import <IOKit/firewire/FireLog.h> 77#endif 78# define DebugLog(x...) DoDebugLog( x ) ; 79# define DebugLogCond( x, y... ) { if (x) DebugLog ( y ) ; } 80#else 81# define DebugLog(x...) do {} while (0) 82# define DebugLogCond( x, y... ) do {} while (0) 83#endif 84 85#define TIMEIT( doit, description ) \ 86{ \ 87 AbsoluteTime start, end; \ 88 IOFWGetAbsoluteTime( & start ); \ 89 { \ 90 doit ;\ 91 }\ 92 IOFWGetAbsoluteTime( & end ); \ 93 SUB_ABSOLUTETIME( & end, & start ) ;\ 94 UInt64 nanos ;\ 95 absolutetime_to_nanoseconds( end, & nanos ) ;\ 96 DebugLog("%s duration %llu us\n", "" description, nanos/1000) ;\ 97} 98 99#define InfoLog(x...) do {} while (0) 100 101 102