1
1
// ==============================================================================
2
- // Copyright (c) 2016-2021 Advanced Micro Devices, Inc. All rights reserved.
2
+ // Copyright (c) 2016-2023 Advanced Micro Devices, Inc. All rights reserved.
3
3
// / @author AMD Developer Tools Team
4
4
// / @file
5
5
// / @brief Logging utility.
53
53
#define TRACE_PRIVATE_FUNCTION_WITH_ARGS (func, ...) // /< Macro used for tracing private function with parameters.
54
54
#endif // trace functions.
55
55
56
+ #ifdef __GNUC__
57
+ #define GPA_ATTRIBUTE_PRINTF (fmt, args ) __attribute__((format(printf, fmt, args)))
58
+ #else
59
+ #define GPA_ATTRIBUTE_PRINTF (fmg, args )
60
+ #endif
61
+
56
62
// / @brief Internal GPA logger function.
57
63
// /
58
64
// / @param [in] log_type Logging type.
@@ -103,7 +109,7 @@ class GpaLogger : public TSingleton<GpaLogger>
103
109
}
104
110
}
105
111
106
- void Logf (GpaLoggingType type, const char * msg_fmt, ...) __attribute__((format(printf, 3 , 4 )) )
112
+ void Logf (GpaLoggingType type, const char * msg_fmt, ...) GPA_ATTRIBUTE_PRINTF( 3 , 4 )
107
113
{
108
114
va_list args;
109
115
va_start (args, msg_fmt);
@@ -114,7 +120,7 @@ class GpaLogger : public TSingleton<GpaLogger>
114
120
// / @brief Logs an error message.
115
121
// /
116
122
// / @param [in] msg_fmt The message to format and pass along.
117
- inline void LogError (const char * msg_fmt, ...) __attribute__((format(printf, 2 , 3 )) )
123
+ inline void LogError (const char * msg_fmt, ...) GPA_ATTRIBUTE_PRINTF( 2 , 3 )
118
124
{
119
125
va_list args;
120
126
va_start (args, msg_fmt);
@@ -125,7 +131,7 @@ class GpaLogger : public TSingleton<GpaLogger>
125
131
// / @brief Logs an informational message.
126
132
// /
127
133
// / @param [in] msg_fmt The message to format and pass along.
128
- inline void LogMessage (const char * msg_fmt, ...) __attribute__((format(printf, 2 , 3 )) )
134
+ inline void LogMessage (const char * msg_fmt, ...) GPA_ATTRIBUTE_PRINTF( 2 , 3 )
129
135
{
130
136
va_list args;
131
137
va_start (args, msg_fmt);
@@ -136,7 +142,7 @@ class GpaLogger : public TSingleton<GpaLogger>
136
142
// / @brief Logs a trace message.
137
143
// /
138
144
// / @param [in] msg_fmt The message to format and pass along.
139
- inline void LogTrace (const char * msg_fmt, ...) __attribute__((format(printf, 2 , 3 )) )
145
+ inline void LogTrace (const char * msg_fmt, ...) GPA_ATTRIBUTE_PRINTF( 2 , 3 )
140
146
{
141
147
va_list args;
142
148
va_start (args, msg_fmt);
@@ -147,7 +153,7 @@ class GpaLogger : public TSingleton<GpaLogger>
147
153
// / @brief Logs a formatted message in internal builds; does nothing in release.
148
154
// /
149
155
// / @param [in] msg_fmt The message to format and pass along.
150
- void LogDebugMessage (const char * msg_fmt, ...) __attribute__((format(printf, 2 , 3 )) )
156
+ void LogDebugMessage (const char * msg_fmt, ...) GPA_ATTRIBUTE_PRINTF( 2 , 3 )
151
157
{
152
158
va_list args;
153
159
va_start (args, msg_fmt);
@@ -158,7 +164,7 @@ class GpaLogger : public TSingleton<GpaLogger>
158
164
// / @brief Logs a formatted error message in debug builds; does nothing in release.
159
165
// /
160
166
// / @param [in] msg_fmt The message to format and pass along.
161
- void LogDebugError (const char * msg_fmt, ...) __attribute__((format(printf, 2 , 3 )) )
167
+ void LogDebugError (const char * msg_fmt, ...) GPA_ATTRIBUTE_PRINTF( 2 , 3 )
162
168
{
163
169
va_list args;
164
170
va_start (args, msg_fmt);
@@ -169,7 +175,7 @@ class GpaLogger : public TSingleton<GpaLogger>
169
175
// / @brief Logs a formatted error message in debug builds; does nothing in release.
170
176
// /
171
177
// / @param [in] msg_fmt The message to format and pass along.
172
- void LogDebugTrace (const char * msg_fmt, ...) __attribute__((format(printf, 2 , 3 )) )
178
+ void LogDebugTrace (const char * msg_fmt, ...) GPA_ATTRIBUTE_PRINTF( 2 , 3 )
173
179
{
174
180
va_list args;
175
181
va_start (args, msg_fmt);
@@ -180,7 +186,7 @@ class GpaLogger : public TSingleton<GpaLogger>
180
186
// / @brief Logs a formatted message in internal builds; does nothing in public builds.
181
187
// /
182
188
// / @param [in] msg_fmt The message to format and pass along.
183
- void LogDebugCounterDefs (const char * msg_fmt, ...) __attribute__((format(printf, 2 , 3 )) )
189
+ void LogDebugCounterDefs (const char * msg_fmt, ...) GPA_ATTRIBUTE_PRINTF( 2 , 3 )
184
190
{
185
191
va_list args;
186
192
va_start (args, msg_fmt);
0 commit comments