blob: 7f0d2cddd9a65b3de63cd3e781fbdd32b13a089d [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
20namespace rr
21{
Ben Claytoneb50d252019-04-15 13:50:01 -040022
23void tracev(const char *format, va_list args)
Nicolas Capensc07dc4b2018-08-06 14:20:45 -040024{
Ben Claytoneb50d252019-04-15 13:50:01 -040025#ifndef RR_DISABLE_TRACE
Nicolas Capensc07dc4b2018-08-06 14:20:45 -040026 if(false)
27 {
Ben Claytoneb50d252019-04-15 13:50:01 -040028 FILE *file = fopen(TRACE_OUTPUT_FILE, "a");
Nicolas Capensc07dc4b2018-08-06 14:20:45 -040029
30 if(file)
31 {
Ben Claytoneb50d252019-04-15 13:50:01 -040032 vfprintf(file, format, args);
Nicolas Capensc07dc4b2018-08-06 14:20:45 -040033 fclose(file);
34 }
35 }
Ben Claytoneb50d252019-04-15 13:50:01 -040036#endif
Nicolas Capensc07dc4b2018-08-06 14:20:45 -040037}
Ben Claytoneb50d252019-04-15 13:50:01 -040038
39void trace(const char *format, ...)
40{
41 va_list vararg;
42 va_start(vararg, format);
43 tracev(format, vararg);
44 va_end(vararg);
45}
46
47void warn(const char *format, ...)
48{
49 va_list vararg;
50 va_start(vararg, format);
51 tracev(format, vararg);
52 va_end(vararg);
53
54 va_start(vararg, format);
55 vfprintf(stderr, format, vararg);
56 va_end(vararg);
57}
58
59void abort(const char *format, ...)
60{
61 va_list vararg;
62
63 va_start(vararg, format);
64 tracev(format, vararg);
65 va_end(vararg);
66
67 va_start(vararg, format);
68 vfprintf(stderr, format, vararg);
69 va_end(vararg);
70
71 ::abort();
72}
73
74} // namespace rr