| 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 | namespace WTF { |
| 48 | |
| 49 | void* fastMalloc(size_t size) |
| 50 | { |
| 51 | return malloc(size: size); |
| 52 | } |
| 53 | |
| 54 | void* fastRealloc(void* ptr, size_t size) |
| 55 | { |
| 56 | return realloc(ptr: ptr, size: size); |
| 57 | } |
| 58 | |
| 59 | void fastFree(void* ptr) |
| 60 | { |
| 61 | free(ptr: ptr); |
| 62 | } |
| 63 | |
| 64 | uint32_t cryptographicallyRandomNumber() |
| 65 | { |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | static FilePrintStream* s_dataFile = nullptr; |
| 70 | |
| 71 | void setDataFile(FilePrintStream *ps) |
| 72 | { |
| 73 | delete s_dataFile; |
| 74 | s_dataFile = ps; |
| 75 | } |
| 76 | |
| 77 | void setDataFile(FILE* f) |
| 78 | { |
| 79 | delete s_dataFile; |
| 80 | s_dataFile = new FilePrintStream(f, FilePrintStream::Borrow); |
| 81 | } |
| 82 | |
| 83 | FilePrintStream& dataFile() |
| 84 | { |
| 85 | if (!s_dataFile) |
| 86 | s_dataFile = new FilePrintStream(stderr, FilePrintStream::Borrow); |
| 87 | return *s_dataFile; |
| 88 | } |
| 89 | |
| 90 | void dataLogFV(const char* format, va_list args) |
| 91 | { |
| 92 | char buffer[1024]; |
| 93 | qvsnprintf(str: buffer, n: sizeof(buffer), fmt: format, ap: args); |
| 94 | qDebug().nospace().noquote() << buffer; |
| 95 | } |
| 96 | |
| 97 | void dataLogF(const char* format, ...) |
| 98 | { |
| 99 | char buffer[1024]; |
| 100 | va_list args; |
| 101 | va_start(args, format); |
| 102 | qvsnprintf(str: buffer, n: sizeof(buffer), fmt: format, ap: args); |
| 103 | va_end(args); |
| 104 | qDebug().nospace().noquote() << buffer; |
| 105 | } |
| 106 | |
| 107 | void dataLogFString(const char* str) |
| 108 | { |
| 109 | qDebug().nospace().noquote() << str; |
| 110 | } |
| 111 | |
| 112 | } |
| 113 | |
| 114 | extern "C" { |
| 115 | // When adding a new stub here do not forget to add |
| 116 | // DEFINES += StubFunctionName=qmlStubFunctionName |
| 117 | // for example: |
| 118 | // DEFINES += WTFReportAssertionFailureWithMessage=qmlWTFReportAssertionFailureWithMessage |
| 119 | // to prevent "duplicate symbol" error during static library linking. See bugs QTBUG-35041 and QTBUG-63050 |
| 120 | |
| 121 | void WTFReportAssertionFailure(const char* file, int line, const char* function, const char*assertion) |
| 122 | { |
| 123 | fprintf(stderr, format: "WTF failing assertion in %s, line %d, function %s: %s\n" , file, line, function, assertion); |
| 124 | } |
| 125 | |
| 126 | void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...) |
| 127 | { |
| 128 | // TODO: show the message, or remove this function completely. (The latter would probably be best.) |
| 129 | Q_UNUSED(format); |
| 130 | fprintf(stderr, format: "WTF failing assertion in %s, line %d, function %s: %s\n" , file, line, function, assertion); |
| 131 | } |
| 132 | |
| 133 | void WTFReportBacktrace() |
| 134 | { |
| 135 | } |
| 136 | |
| 137 | void WTFInvokeCrashHook() |
| 138 | { |
| 139 | } |
| 140 | |
| 141 | } |
| 142 | |
| 143 | |
| 144 | #if ENABLE(ASSEMBLER) && CPU(X86) && !OS(MAC_OS_X) |
| 145 | #include <MacroAssemblerX86Common.h> |
| 146 | |
| 147 | JSC::MacroAssemblerX86Common::SSE2CheckState JSC::MacroAssemblerX86Common::s_sse2CheckState = JSC::MacroAssemblerX86Common::NotCheckedSSE2; |
| 148 | #endif |
| 149 | |
| 150 | |