blob: df8e8fc1b3ac6d4d5887ee990c52e3965aad747b [file] [log] [blame]
Nicolas Capensc07dc4b2018-08-06 14:20:45 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include "Debug.hpp"
16
Ben Claytoneb50d252019-04-15 13:50:01 -040017#include <string>
Nicolas Capensc07dc4b2018-08-06 14:20:45 -040018#include <stdarg.h>
19
Nicolas Capens157ba262019-12-10 17:49:14 -050020namespace rr {
Ben Claytoneb50d252019-04-15 13:50:01 -040021
22void tracev(const char *format, va_list args)
Nicolas Capensc07dc4b2018-08-06 14:20:45 -040023{
Ben Claytoneb50d252019-04-15 13:50:01 -040024#ifndef RR_DISABLE_TRACE
Nicolas Capensc07dc4b2018-08-06 14:20:45 -040025 if(false)
26 {
Ben Claytoneb50d252019-04-15 13:50:01 -040027 FILE *file = fopen(TRACE_OUTPUT_FILE, "a");
Nicolas Capensc07dc4b2018-08-06 14:20:45 -040028
29 if(file)
30 {
Ben Claytoneb50d252019-04-15 13:50:01 -040031 vfprintf(file, format, args);
Nicolas Capensc07dc4b2018-08-06 14:20:45 -040032 fclose(file);
33 }
34 }
Ben Claytoneb50d252019-04-15 13:50:01 -040035#endif
Nicolas Capensc07dc4b2018-08-06 14:20:45 -040036}
Ben Claytoneb50d252019-04-15 13:50:01 -040037
38void trace(const char *format, ...)
39{
40 va_list vararg;
41 va_start(vararg, format);
42 tracev(format, vararg);
43 va_end(vararg);
44}
45
46void warn(const char *format, ...)
47{
48 va_list vararg;
49 va_start(vararg, format);
50 tracev(format, vararg);
51 va_end(vararg);
52
53 va_start(vararg, format);
54 vfprintf(stderr, format, vararg);
55 va_end(vararg);
56}
57
58void abort(const char *format, ...)
59{
60 va_list vararg;
61
62 va_start(vararg, format);
63 tracev(format, vararg);
64 va_end(vararg);
65
66 va_start(vararg, format);
67 vfprintf(stderr, format, vararg);
68 va_end(vararg);
69
70 ::abort();
71}
72
Nicolas Capens157ba262019-12-10 17:49:14 -050073} // namespace rr