1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtQml module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | #include <config.h> |
40 | #include <stdlib.h> |
41 | #include <stdio.h> |
42 | #include <stdarg.h> |
43 | #include <qdebug.h> |
44 | #include <qbytearray.h> // qvsnprintf |
45 | #include <FilePrintStream.h> |
46 | |
47 | #if ENABLE(ASSEMBLER) && CPU(X86) && !OS(MAC_OS_X) |
48 | #include <MacroAssemblerX86Common.h> |
49 | #endif |
50 | |
51 | namespace WTF { |
52 | |
53 | void* fastMalloc(size_t size) |
54 | { |
55 | return malloc(size: size); |
56 | } |
57 | |
58 | void* fastRealloc(void* ptr, size_t size) |
59 | { |
60 | return realloc(ptr: ptr, size: size); |
61 | } |
62 | |
63 | void fastFree(void* ptr) |
64 | { |
65 | free(ptr: ptr); |
66 | } |
67 | |
68 | uint32_t cryptographicallyRandomNumber() |
69 | { |
70 | return 0; |
71 | } |
72 | |
73 | static FilePrintStream* s_dataFile = nullptr; |
74 | |
75 | void setDataFile(FilePrintStream *ps) |
76 | { |
77 | delete s_dataFile; |
78 | s_dataFile = ps; |
79 | } |
80 | |
81 | void setDataFile(FILE* f) |
82 | { |
83 | delete s_dataFile; |
84 | s_dataFile = new FilePrintStream(f, FilePrintStream::Borrow); |
85 | } |
86 | |
87 | FilePrintStream& dataFile() |
88 | { |
89 | if (!s_dataFile) |
90 | s_dataFile = new FilePrintStream(stderr, FilePrintStream::Borrow); |
91 | return *s_dataFile; |
92 | } |
93 | |
94 | void dataLogFV(const char* format, va_list args) |
95 | { |
96 | char buffer[1024]; |
97 | qvsnprintf(str: buffer, n: sizeof(buffer), fmt: format, ap: args); |
98 | qDebug().nospace().noquote() << buffer; |
99 | } |
100 | |
101 | void dataLogF(const char* format, ...) |
102 | { |
103 | char buffer[1024]; |
104 | va_list args; |
105 | va_start(args, format); |
106 | qvsnprintf(str: buffer, n: sizeof(buffer), fmt: format, ap: args); |
107 | va_end(args); |
108 | qDebug().nospace().noquote() << buffer; |
109 | } |
110 | |
111 | void dataLogFString(const char* str) |
112 | { |
113 | qDebug().nospace().noquote() << str; |
114 | } |
115 | |
116 | } |
117 | |
118 | extern "C" { |
119 | // When adding a new stub here do not forget to add |
120 | // DEFINES += StubFunctionName=qmlStubFunctionName |
121 | // for example: |
122 | // DEFINES += WTFReportAssertionFailureWithMessage=qmlWTFReportAssertionFailureWithMessage |
123 | // to prevent "duplicate symbol" error during static library linking. See bugs QTBUG-35041 and QTBUG-63050 |
124 | |
125 | void WTFReportAssertionFailure(const char* file, int line, const char* function, const char*assertion) |
126 | { |
127 | fprintf(stderr, format: "WTF failing assertion in %s, line %d, function %s: %s\n" , file, line, function, assertion); |
128 | } |
129 | |
130 | void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...) |
131 | { |
132 | // TODO: show the message, or remove this function completely. (The latter would probably be best.) |
133 | Q_UNUSED(format); |
134 | fprintf(stderr, format: "WTF failing assertion in %s, line %d, function %s: %s\n" , file, line, function, assertion); |
135 | } |
136 | |
137 | void WTFReportBacktrace() |
138 | { |
139 | } |
140 | |
141 | void WTFInvokeCrashHook() |
142 | { |
143 | } |
144 | |
145 | } |
146 | |
147 | |
148 | #if ENABLE(ASSEMBLER) && CPU(X86) && !OS(MAC_OS_X) |
149 | JSC::MacroAssemblerX86Common::SSE2CheckState JSC::MacroAssemblerX86Common::s_sse2CheckState = JSC::MacroAssemblerX86Common::NotCheckedSSE2; |
150 | #endif |
151 | |
152 | |