1c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/*
2c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*******************************************************************************
3c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*
4c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   Copyright (C) 2003-2004, International Business Machines
5c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   Corporation and others.  All Rights Reserved.
6c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*
7c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*******************************************************************************
8c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   file name:  utracimp.h
9c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   encoding:   US-ASCII
10c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   tab size:   8 (not used)
11c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   indentation:4
12c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*
13c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   created on: 2003aug06
14c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   created by: Markus W. Scherer
15c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*
16c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   Internal header for ICU tracing/logging.
17c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*
18c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*
19c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   Various notes:
20c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   - using a trace level variable to only call trace functions
21c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*     when the level is sufficient
22c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   - using the same variable for tracing on/off to never make a function
23c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*     call when off
24c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   - the function number is put into a local variable by the entry macro
25c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*     and used implicitly to avoid copy&paste/typing mistakes by the developer
26c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   - the application must call utrace_setFunctions() and pass in
27c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*     implementations for the trace functions
28c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   - ICU trace macros call ICU functions that route through the function
29c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*     pointers if they have been set;
30c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*     this avoids an indirection at the call site
31c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*     (which would cost more code for another check and for the indirection)
32c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*
33c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   ### TODO Issues:
34c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   - Verify that va_list is portable among compilers for the same platform.
35c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*     va_list should be portable because printf() would fail otherwise!
36c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*   - Should enum values like UTraceLevel be passed into int32_t-type arguments,
37c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*     or should enum types be used?
38c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott*/
39c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
40c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#ifndef __UTRACIMP_H__
41c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define __UTRACIMP_H__
42c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
43c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#include "unicode/utrace.h"
44c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#include <stdarg.h>
45c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
46c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick ScottU_CDECL_BEGIN
47c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
48c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
49c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * \var utrace_level
50c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace level variable. Negative for "off".
51c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Use only via UTRACE_ macros.
52c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
53c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
54c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#ifdef UTRACE_IMPL
55c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick ScottU_EXPORT int32_t
56c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#else
57c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick ScottU_CFUNC U_COMMON_API int32_t
58c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#endif
59c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottutrace_level;
60c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
61c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
62c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
63c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *   Traced Function Exit return types.
64c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *   Flags indicating the number and types of varargs included in a call
65c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *   to a UTraceExit function.
66c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *   Bits 0-3:  The function return type.  First variable param.
67c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *   Bit    4:  Flag for presence of U_ErrorCode status param.
68c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *   @internal
69c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
70c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scotttypedef enum UTraceExitVal {
71c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    /** The traced function returns no value  @internal */
72c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    UTRACE_EXITV_NONE   = 0,
73c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    /** The traced function returns an int32_t, or compatible, type.  @internal */
74c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    UTRACE_EXITV_I32    = 1,
75c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    /** The traced function returns a pointer  @internal */
76c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    UTRACE_EXITV_PTR    = 2,
77c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    /** The traced function returns a UBool  @internal */
78c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    UTRACE_EXITV_BOOL   = 3,
79c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    /** Mask to extract the return type values from a UTraceExitVal  @internal */
80c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    UTRACE_EXITV_MASK   = 0xf,
81c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    /** Bit indicating that the traced function includes a UErrorCode parameter  @internal */
82c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    UTRACE_EXITV_STATUS = 0x10
83c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott} UTraceExitVal;
84c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
85c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
86c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace function for the entry point of a function.
87c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Do not use directly, use UTRACE_ENTRY instead.
88c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @param fnNumber The UTraceFunctionNumber for the current function.
89c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
90c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
91c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick ScottU_CAPI void U_EXPORT2
92c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottutrace_entry(int32_t fnNumber);
93c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
94c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
95c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace function for each exit point of a function.
96c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Do not use directly, use UTRACE_EXIT* instead.
97c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @param fnNumber The UTraceFunctionNumber for the current function.
98c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @param returnType The type of the value returned by the function.
99c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @param errorCode The UErrorCode value at function exit. See UTRACE_EXIT.
100c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
101c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
102c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick ScottU_CAPI void U_EXPORT2
103c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottutrace_exit(int32_t fnNumber, int32_t returnType, ...);
104c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
105c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
106c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
107c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace function used inside functions that have a UTRACE_ENTRY() statement.
108c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Do not use directly, use UTRACE_DATAX() macros instead.
109c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *
110c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @param utraceFnNumber The number of the current function, from the local
111c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *        variable of the same name.
112c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @param level The trace level for this message.
113c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @param fmt The trace format string.
114c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *
115c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
116c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
117c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick ScottU_CAPI void U_EXPORT2
118c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottutrace_data(int32_t utraceFnNumber, int32_t level, const char *fmt, ...);
119c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
120c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick ScottU_CDECL_END
121c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
122c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#if U_ENABLE_TRACING
123c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
124c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
125c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Boolean expression to see if ICU tracing is turned on
126c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * to at least the specified level.
127c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
128c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
129c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_LEVEL(level) (utrace_level>=(level))
130c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
131c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
132c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  *  Flag bit in utraceFnNumber, the local variable added to each function
133c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  *  with tracing code to contains the function number.
134c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  *
135c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  *  Set the flag if the function's entry is traced, which will cause the
136c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  *  function's exit to also be traced.  utraceFnNumber is uncoditionally
137c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  *  set at entry, whether or not the entry is traced, so that it will
138c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  *  always be available for error trace output.
139c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  *  @internal
140c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  */
141c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_TRACED_ENTRY 0x80000000
142c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
143c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
144c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement for the entry point of a function.
145c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Stores the function number in a local variable.
146c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * In C code, must be placed immediately after the last variable declaration.
147c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Must be matched with UTRACE_EXIT() at all function exit points.
148c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *
149c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Tracing should start with UTRACE_ENTRY after checking for
150c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * U_FAILURE at function entry, so that if a function returns immediately
151c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * because of a pre-existing error condition, it does not show up in the trace,
152c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * consistent with ICU's error handling model.
153c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *
154c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @param fnNumber The UTraceFunctionNumber for the current function.
155c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
156c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
157c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_ENTRY(fnNumber) \
158c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    int32_t utraceFnNumber=(fnNumber); \
159c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(utrace_level>=UTRACE_INFO) { \
160c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_entry(fnNumber); \
161c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utraceFnNumber |= UTRACE_TRACED_ENTRY; \
162c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
163c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
164c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
165c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
166c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement for the entry point of open and close functions.
167c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Produces trace output at a less verbose setting than plain UTRACE_ENTRY
168c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Stores the function number in a local variable.
169c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * In C code, must be placed immediately after the last variable declaration.
170c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Must be matched with UTRACE_EXIT() at all function exit points.
171c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *
172c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @param fnNumber The UTraceFunctionNumber for the current function.
173c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
174c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
175c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_ENTRY_OC(fnNumber) \
176c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    int32_t utraceFnNumber=(fnNumber); \
177c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(utrace_level>=UTRACE_OPEN_CLOSE) { \
178c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_entry(fnNumber); \
179c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utraceFnNumber |= UTRACE_TRACED_ENTRY; \
180c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
181c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
182c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
183c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement for each exit point of a function that has a UTRACE_ENTRY()
184c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * statement.
185c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *
186c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @param errorCode The function's ICU UErrorCode value at function exit,
187c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *                  or U_ZERO_ERROR if the function does not use a UErrorCode.
188c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *                  0==U_ZERO_ERROR indicates success,
189c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *                  positive values an error (see u_errorName()),
190c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *                  negative values an informational status.
191c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *
192c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
193c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
194c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_EXIT() \
195c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \
196c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, UTRACE_EXITV_NONE); \
197c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }}
198c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
199c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
200c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement for each exit point of a function that has a UTRACE_ENTRY()
201c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * statement, and that returns a value.
202c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *
203c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @param val       The function's return value, int32_t or comatible type.
204c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott *
205c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
206c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
207c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_EXIT_VALUE(val) \
208c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \
209c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, UTRACE_EXITV_I32, val); \
210c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }}
211c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
212c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_EXIT_STATUS(status) \
213c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \
214c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, UTRACE_EXITV_STATUS, status); \
215c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }}
216c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
217c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_EXIT_VALUE_STATUS(val, status) \
218c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \
219c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (UTRACE_EXITV_I32 | UTRACE_EXITV_STATUS), val, status); \
220c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }}
221c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
222c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_EXIT_PTR_STATUS(ptr, status) \
223c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \
224c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (UTRACE_EXITV_PTR | UTRACE_EXITV_STATUS), ptr, status); \
225c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }}
226c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
227c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
228c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement used inside functions that have a UTRACE_ENTRY() statement.
229c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Takes no data arguments.
230c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * The number of arguments for this macro must match the number of inserts
231c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * in the format string. Vector inserts count as two arguments.
232c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Calls utrace_data() if the level is high enough.
233c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
234c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
235c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA0(level, fmt) \
236c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(UTRACE_LEVEL(level)) { \
237c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt)); \
238c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
239c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
240c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
241c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement used inside functions that have a UTRACE_ENTRY() statement.
242c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Takes one data argument.
243c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * The number of arguments for this macro must match the number of inserts
244c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * in the format string. Vector inserts count as two arguments.
245c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Calls utrace_data() if the level is high enough.
246c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
247c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
248c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA1(level, fmt, a) \
249c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(UTRACE_LEVEL(level)) { \
250c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY , (level), (fmt), (a)); \
251c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
252c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
253c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
254c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement used inside functions that have a UTRACE_ENTRY() statement.
255c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Takes two data arguments.
256c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * The number of arguments for this macro must match the number of inserts
257c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * in the format string. Vector inserts count as two arguments.
258c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Calls utrace_data() if the level is high enough.
259c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
260c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
261c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA2(level, fmt, a, b) \
262c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(UTRACE_LEVEL(level)) { \
263c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY , (level), (fmt), (a), (b)); \
264c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
265c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
266c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
267c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement used inside functions that have a UTRACE_ENTRY() statement.
268c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Takes three data arguments.
269c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * The number of arguments for this macro must match the number of inserts
270c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * in the format string. Vector inserts count as two arguments.
271c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Calls utrace_data() if the level is high enough.
272c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
273c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
274c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA3(level, fmt, a, b, c) \
275c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(UTRACE_LEVEL(level)) { \
276c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c)); \
277c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
278c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
279c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
280c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement used inside functions that have a UTRACE_ENTRY() statement.
281c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Takes four data arguments.
282c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * The number of arguments for this macro must match the number of inserts
283c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * in the format string. Vector inserts count as two arguments.
284c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Calls utrace_data() if the level is high enough.
285c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
286c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
287c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA4(level, fmt, a, b, c, d) \
288c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(UTRACE_LEVEL(level)) { \
289c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d)); \
290c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
291c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
292c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
293c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement used inside functions that have a UTRACE_ENTRY() statement.
294c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Takes five data arguments.
295c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * The number of arguments for this macro must match the number of inserts
296c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * in the format string. Vector inserts count as two arguments.
297c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Calls utrace_data() if the level is high enough.
298c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
299c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
300c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA5(level, fmt, a, b, c, d, e) \
301c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(UTRACE_LEVEL(level)) { \
302c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e)); \
303c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
304c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
305c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
306c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement used inside functions that have a UTRACE_ENTRY() statement.
307c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Takes six data arguments.
308c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * The number of arguments for this macro must match the number of inserts
309c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * in the format string. Vector inserts count as two arguments.
310c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Calls utrace_data() if the level is high enough.
311c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
312c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
313c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA6(level, fmt, a, b, c, d, e, f) \
314c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(UTRACE_LEVEL(level)) { \
315c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f)); \
316c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
317c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
318c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
319c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement used inside functions that have a UTRACE_ENTRY() statement.
320c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Takes seven data arguments.
321c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * The number of arguments for this macro must match the number of inserts
322c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * in the format string. Vector inserts count as two arguments.
323c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Calls utrace_data() if the level is high enough.
324c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
325c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
326c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA7(level, fmt, a, b, c, d, e, f, g) \
327c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(UTRACE_LEVEL(level)) { \
328c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f), (g)); \
329c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
330c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
331c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
332c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement used inside functions that have a UTRACE_ENTRY() statement.
333c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Takes eight data arguments.
334c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * The number of arguments for this macro must match the number of inserts
335c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * in the format string. Vector inserts count as two arguments.
336c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Calls utrace_data() if the level is high enough.
337c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
338c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
339c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA8(level, fmt, a, b, c, d, e, f, g, h) \
340c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(UTRACE_LEVEL(level)) { \
341c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f), (g), (h)); \
342c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
343c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
344c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/**
345c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Trace statement used inside functions that have a UTRACE_ENTRY() statement.
346c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Takes nine data arguments.
347c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * The number of arguments for this macro must match the number of inserts
348c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * in the format string. Vector inserts count as two arguments.
349c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * Calls utrace_data() if the level is high enough.
350c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * @internal
351c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
352c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA9(level, fmt, a, b, c, d, e, f, g, h, i) \
353c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if(UTRACE_LEVEL(level)) { \
354c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott        utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f), (g), (h), (i)); \
355c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
356c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
357c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#else
358c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
359c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott/*
360c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott * When tracing is disabled, the following macros become empty
361c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott */
362c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
363c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_LEVEL(level) 0
364c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_ENTRY(fnNumber)
365c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_ENTRY_OC(fnNumber)
366c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_EXIT()
367c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_EXIT_VALUE(val)
368c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_EXIT_STATUS(status)
369c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_EXIT_VALUE_STATUS(val, status)
370c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_EXIT_PTR_STATUS(ptr, status)
371c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA0(level, fmt)
372c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA1(level, fmt, a)
373c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA2(level, fmt, a, b)
374c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA3(level, fmt, a, b, c)
375c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA4(level, fmt, a, b, c, d)
376c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA5(level, fmt, a, b, c, d, e)
377c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA6(level, fmt, a, b, c, d, e, f)
378c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA7(level, fmt, a, b, c, d, e, f, g)
379c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA8(level, fmt, a, b, c, d, e, f, g, h)
380c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define UTRACE_DATA9(level, fmt, a, b, c, d, e, f, g, h, i)
381c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
382c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#endif
383c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
384c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#endif
385