1 /*
   2  * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef _Included_Trace
  27 #define _Included_Trace
  28 
  29 #include <jni.h>
  30 #include "debug_trace.h"
  31 
  32 #ifdef __cplusplus
  33 extern "C" {
  34 #endif /* __cplusplus */
  35 
  36 /**
  37  * J2dTrace
  38  * Trace utility used throughout Java 2D code.  Uses a "level"
  39  * parameter that allows user to specify how much detail
  40  * they want traced at runtime.  Tracing is only enabled
  41  * in debug mode, to avoid overhead running release build.
  42  */
  43 
  44 #define J2D_TRACE_INVALID       -1
  45 #define J2D_TRACE_OFF           0
  46 #define J2D_TRACE_ERROR         1
  47 #define J2D_TRACE_WARNING       2
  48 #define J2D_TRACE_INFO          3
  49 #define J2D_TRACE_VERBOSE       4
  50 #define J2D_TRACE_VERBOSE2      5
  51 #define J2D_TRACE_MAX           (J2D_TRACE_VERBOSE2+1)
  52 
  53 JNIEXPORT void JNICALL
  54 J2dTraceImpl(int level, jboolean cr, const char *string, ...);
  55 JNIEXPORT void JNICALL
  56 J2dTraceInit();
  57 
  58 #ifndef DEBUG
  59 #define J2dTrace(level, string)
  60 #define J2dTrace1(level, string, arg1)
  61 #define J2dTrace2(level, string, arg1, arg2)
  62 #define J2dTrace3(level, string, arg1, arg2, arg3)
  63 #define J2dTrace4(level, string, arg1, arg2, arg3, arg4)
  64 #define J2dTrace5(level, string, arg1, arg2, arg3, arg4, arg5)
  65 #define J2dTrace6(level, string, arg1, arg2, arg3, arg4, arg5, arg6)
  66 #define J2dTrace7(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
  67 #define J2dTrace8(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  68 #define J2dTraceLn(level, string)
  69 #define J2dTraceLn1(level, string, arg1)
  70 #define J2dTraceLn2(level, string, arg1, arg2)
  71 #define J2dTraceLn3(level, string, arg1, arg2, arg3)
  72 #define J2dTraceLn4(level, string, arg1, arg2, arg3, arg4)
  73 #define J2dTraceLn5(level, string, arg1, arg2, arg3, arg4, arg5)
  74 #define J2dTraceLn6(level, string, arg1, arg2, arg3, arg4, arg5, arg6)
  75 #define J2dTraceLn7(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
  76 #define J2dTraceLn8(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  77 #else /* DEBUG */
  78 #define J2dTrace(level, string) { \
  79             J2dTraceImpl(level, JNI_FALSE, string); \
  80         }
  81 #define J2dTrace1(level, string, arg1) { \
  82             J2dTraceImpl(level, JNI_FALSE, string, arg1); \
  83         }
  84 #define J2dTrace2(level, string, arg1, arg2) { \
  85             J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2); \
  86         }
  87 #define J2dTrace3(level, string, arg1, arg2, arg3) { \
  88             J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3); \
  89         }
  90 #define J2dTrace4(level, string, arg1, arg2, arg3, arg4) { \
  91             J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3, arg4); \
  92         }
  93 #define J2dTrace5(level, string, arg1, arg2, arg3, arg4, arg5) { \
  94             J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3, arg4, arg5); \
  95         }
  96 #define J2dTrace6(level, string, arg1, arg2, arg3, arg4, arg5, arg6) { \
  97             J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3, arg4, arg5, arg6); \
  98         }
  99 #define J2dTrace7(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7) { \
 100             J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
 101         }
 102 #define J2dTrace8(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) { \
 103             J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \
 104         }
 105 #define J2dTraceLn(level, string) { \
 106             J2dTraceImpl(level, JNI_TRUE, string); \
 107         }
 108 #define J2dTraceLn1(level, string, arg1) { \
 109             J2dTraceImpl(level, JNI_TRUE, string, arg1); \
 110         }
 111 #define J2dTraceLn2(level, string, arg1, arg2) { \
 112             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2); \
 113         }
 114 #define J2dTraceLn3(level, string, arg1, arg2, arg3) { \
 115             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3); \
 116         }
 117 #define J2dTraceLn4(level, string, arg1, arg2, arg3, arg4) { \
 118             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4); \
 119         }
 120 #define J2dTraceLn5(level, string, arg1, arg2, arg3, arg4, arg5) { \
 121             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5); \
 122         }
 123 #define J2dTraceLn6(level, string, arg1, arg2, arg3, arg4, arg5, arg6) { \
 124             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5, arg6); \
 125         }
 126 #define J2dTraceLn7(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7) { \
 127             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
 128         }
 129 #define J2dTraceLn8(level, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) { \
 130             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \
 131         }
 132 #endif /* DEBUG */
 133 
 134 
 135 /**
 136  * NOTE: Use the following RlsTrace calls very carefully; they are compiled
 137  * into the code and should thus not be put in any performance-sensitive
 138  * areas.
 139  */
 140 
 141 #define J2dRlsTrace(level, string) { \
 142             J2dTraceImpl(level, JNI_FALSE, string); \
 143         }
 144 #define J2dRlsTrace1(level, string, arg1) { \
 145             J2dTraceImpl(level, JNI_FALSE, string, arg1); \
 146         }
 147 #define J2dRlsTrace2(level, string, arg1, arg2) { \
 148             J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2); \
 149         }
 150 #define J2dRlsTrace3(level, string, arg1, arg2, arg3) { \
 151             J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3); \
 152         }
 153 #define J2dRlsTrace4(level, string, arg1, arg2, arg3, arg4) { \
 154             J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3, arg4); \
 155         }
 156 #define J2dRlsTrace5(level, string, arg1, arg2, arg3, arg4, arg5) { \
 157             J2dTraceImpl(level, JNI_FALSE, string, arg1, arg2, arg3, arg4, arg5); \
 158         }
 159 #define J2dRlsTraceLn(level, string) { \
 160             J2dTraceImpl(level, JNI_TRUE, string); \
 161         }
 162 #define J2dRlsTraceLn1(level, string, arg1) { \
 163             J2dTraceImpl(level, JNI_TRUE, string, arg1); \
 164         }
 165 #define J2dRlsTraceLn2(level, string, arg1, arg2) { \
 166             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2); \
 167         }
 168 #define J2dRlsTraceLn3(level, string, arg1, arg2, arg3) { \
 169             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3); \
 170         }
 171 #define J2dRlsTraceLn4(level, string, arg1, arg2, arg3, arg4) { \
 172             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4); \
 173         }
 174 #define J2dRlsTraceLn5(level, string, arg1, arg2, arg3, arg4, arg5) { \
 175             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5); \
 176         }
 177 
 178 #ifdef __cplusplus
 179 };
 180 #endif /* __cplusplus */
 181 
 182 #endif /* _Included_Trace */