Source/JavaScriptCore/ChangeLog

 12019-02-06 Ross Kirsling <ross.kirsling@sony.com>
 2
 3 [WTF] Add environment variable helpers
 4 https://bugs.webkit.org/show_bug.cgi?id=192405
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * inspector/remote/glib/RemoteInspectorGlib.cpp:
 9 (Inspector::RemoteInspector::RemoteInspector):
 10 (Inspector::RemoteInspector::start):
 11 * jsc.cpp:
 12 (startTimeoutThreadIfNeeded):
 13 * runtime/Options.cpp:
 14 (JSC::overrideOptionWithHeuristic):
 15 (JSC::Options::overrideAliasedOptionWithHeuristic):
 16 (JSC::Options::initialize):
 17 * runtime/VM.cpp:
 18 (JSC::enableAssembler):
 19 (JSC::VM::VM):
 20 * tools/CodeProfiling.cpp:
 21 (JSC::CodeProfiling::notifyAllocator):
 22
1232019-02-06 Yusuke Suzuki <ysuzuki@apple.com>
224
325 [JSC] Unify indirectEvalExecutableSpace and directEvalExecutableSpace

Source/WTF/ChangeLog

 12019-02-06 Ross Kirsling <ross.kirsling@sony.com>
 2
 3 [WTF] Add environment variable helpers
 4 https://bugs.webkit.org/show_bug.cgi?id=192405
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * WTF.xcodeproj/project.pbxproj:
 9 * wtf/CMakeLists.txt:
 10 * wtf/Environment.h: Added.
 11 * wtf/PlatformGTK.cmake:
 12 * wtf/PlatformJSCOnly.cmake:
 13 * wtf/PlatformMac.cmake:
 14 * wtf/PlatformPlayStation.cmake:
 15 * wtf/PlatformWPE.cmake:
 16 * wtf/PlatformWin.cmake:
 17 * wtf/generic/EnvironmentGeneric.cpp: Added.
 18 * wtf/glib/EnvironmentGlib.cpp: Added.
 19
 20 * wtf/DataLog.cpp:
 21 (WTF::initializeLogFileOnce):
 22 * wtf/NumberOfCores.cpp:
 23 (WTF::numberOfProcessorCores):
 24 * wtf/posix/FileSystemPOSIX.cpp:
 25 (WTF::FileSystemImpl::openTemporaryFile):
 26
1272019-02-05 Keith Rollin <krollin@apple.com>
228
329 Enable the automatic checking and regenerations of .xcfilelists during builds

Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp

3232#include "RemoteConnectionToTarget.h"
3333#include "RemoteInspectionTarget.h"
3434#include <gio/gio.h>
 35#include <wtf/Environment.h>
3536#include <wtf/NeverDestroyed.h>
3637#include <wtf/RunLoop.h>
3738#include <wtf/glib/GUniquePtr.h>

@@RemoteInspector& RemoteInspector::singleton()
5152
5253RemoteInspector::RemoteInspector()
5354{
54  if (g_getenv("WEBKIT_INSPECTOR_SERVER"))
 55 if (!!Environment::get("WEBKIT_INSPECTOR_SERVER"))
5556 start();
5657}
5758

@@void RemoteInspector::start()
6566 m_enabled = true;
6667 m_cancellable = adoptGRef(g_cancellable_new());
6768
68  GUniquePtr<char> inspectorAddress(g_strdup(g_getenv("WEBKIT_INSPECTOR_SERVER")));
 69 auto inspectorServerString = Environment::get("WEBKIT_INSPECTOR_SERVER").utf8().data();
 70 GUniquePtr<char> inspectorAddress(g_strdup(inspectorServerString));
6971 char* portPtr = g_strrstr(inspectorAddress.get(), ":");
7072 ASSERT(portPtr);
7173 *portPtr = '\0';

@@void RemoteInspector::start()
7981 if (GRefPtr<GDBusConnection> connection = adoptGRef(g_dbus_connection_new_for_address_finish(result, &error.outPtr())))
8082 inspector->setupConnection(WTFMove(connection));
8183 else if (!g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED))
82  WTFLogAlways("RemoteInspector failed to connect to inspector server at: %s: %s", g_getenv("WEBKIT_INSPECTOR_SERVER"), error->message);
 84 WTFLogAlways("RemoteInspector failed to connect to inspector server at: %s: %s", inspectorServerString, error->message);
8385 }, this);
8486}
8587

Source/JavaScriptCore/jsc.cpp

8383#include <type_traits>
8484#include <wtf/Box.h>
8585#include <wtf/CommaPrinter.h>
 86#include <wtf/Environment.h>
8687#include <wtf/MainThread.h>
8788#include <wtf/MemoryPressureHandler.h>
8889#include <wtf/MonotonicTime.h>

@@static double s_timeoutMultiplier = 1.0;
22502251
22512252static void startTimeoutThreadIfNeeded()
22522253{
2253  if (char* timeoutString = getenv("JSCTEST_timeout")) {
2254  if (sscanf(timeoutString, "%lf", &s_desiredTimeout) != 1) {
 2254 auto timeoutString = Environment::get("JSCTEST_timeout");
 2255 if (!!timeoutString) {
 2256 bool ok;
 2257 s_desiredTimeout = timeoutString.toDouble(&ok);
 2258 if (!ok) {
22552259 dataLog("WARNING: timeout string is malformed, got ", timeoutString,
22562260 " but expected a number. Not using a timeout.\n");
22572261 } else {

Source/JavaScriptCore/runtime/Options.cpp

3939#include <wtf/ASCIICType.h>
4040#include <wtf/Compiler.h>
4141#include <wtf/DataLog.h>
 42#include <wtf/Environment.h>
4243#include <wtf/NumberOfCores.h>
4344#include <wtf/PointerPreparations.h>
4445#include <wtf/StdLibExtras.h>

@@bool overrideOptionWithHeuristic(T& variable, Options::ID id, const char* name,
176177 bool available = (availability == Options::Availability::Normal)
177178 || Options::isAvailable(id, availability);
178179
179  const char* stringValue = getenv(name);
 180 auto stringValue = Environment::get(name).utf8().data();
180181 if (!stringValue)
181182 return false;
182183

@@bool overrideOptionWithHeuristic(T& variable, Options::ID id, const char* name,
189190
190191bool Options::overrideAliasedOptionWithHeuristic(const char* name)
191192{
192  const char* stringValue = getenv(name);
 193 auto stringValue = Environment::get(name).utf8().data();
193194 if (!stringValue)
194195 return false;
195196

@@void Options::initialize()
597598
598599#if ASAN_ENABLED && OS(LINUX) && ENABLE(WEBASSEMBLY_FAST_MEMORY)
599600 if (Options::useWebAssemblyFastMemory()) {
600  const char* asanOptions = getenv("ASAN_OPTIONS");
601  bool okToUseWebAssemblyFastMemory = asanOptions
602  && (strstr(asanOptions, "allow_user_segv_handler=1") || strstr(asanOptions, "handle_segv=0"));
 601 auto asanOptions = Environment::get("ASAN_OPTIONS");
 602 bool okToUseWebAssemblyFastMemory = asanOptions.contains("allow_user_segv_handler=1") || asanOptions.contains("handle_segv=0");
603603 if (!okToUseWebAssemblyFastMemory) {
604604 dataLogLn("WARNING: ASAN interferes with JSC signal handlers; useWebAssemblyFastMemory will be disabled.");
605605 Options::useWebAssemblyFastMemory() = false;

Source/JavaScriptCore/runtime/VM.cpp

149149#include "WeakGCMapInlines.h"
150150#include "WebAssemblyFunction.h"
151151#include "WebAssemblyWrapperFunction.h"
 152#include <wtf/Environment.h>
152153#include <wtf/ProcessID.h>
153154#include <wtf/ReadWriteLock.h>
154155#include <wtf/SimpleStats.h>

@@static bool enableAssembler(ExecutableAllocator& executableAllocator)
197198 return false;
198199 }
199200
200  char* canUseJITString = getenv("JavaScriptCoreUseJIT");
201  return !canUseJITString || atoi(canUseJITString);
 201 auto canUseJITString = Environment::get("JavaScriptCoreUseJIT");
 202 return !canUseJITString || canUseJITString.toInt();
202203}
203204#endif // ENABLE(!ASSEMBLER)
204205

@@VM::VM(VMType vmType, HeapType heapType)
428429 m_perBytecodeProfiler = std::make_unique<Profiler::Database>(*this);
429430
430431 StringPrintStream pathOut;
431  const char* profilerPath = getenv("JSC_PROFILER_PATH");
 432 auto profilerPath = Environment::get("JSC_PROFILER_PATH").utf8().data();
432433 if (profilerPath)
433434 pathOut.print(profilerPath, "/");
434435 pathOut.print("JSCProfile-", getCurrentProcessID(), "-", m_perBytecodeProfiler->databaseID(), ".json");

Source/JavaScriptCore/tools/CodeProfiling.cpp

2828
2929#include "CodeProfile.h"
3030#include "MachineContext.h"
 31#include <wtf/Environment.h>
3132#include <wtf/MetaAllocator.h>
3233
3334#if HAVE(SIGNAL_H)

@@void CodeProfiling::sample(void* pc, void** framePointer)
8586void CodeProfiling::notifyAllocator(WTF::MetaAllocator* allocator)
8687{
8788 // Check for JSC_CODE_PROFILING.
88  const char* codeProfilingMode = getenv("JSC_CODE_PROFILING");
89  if (!codeProfilingMode)
 89 auto codeProfilingModeString = Environment::get("JSC_CODE_PROFILING");
 90 if (!codeProfilingModeString)
9091 return;
9192
9293 // Check for a valid mode, currently "1", "2", or "3".
93  if (!codeProfilingMode[0] || codeProfilingMode[1])
 94 bool ok;
 95 auto codeProfilingMode = codeProfilingModeString.toUInt(&ok);
 96 if (!ok)
9497 return;
95  switch (*codeProfilingMode) {
96  case '1':
 98 switch (codeProfilingMode) {
 99 case 1:
97100 s_mode = Enabled;
98101 break;
99  case '2':
 102 case 2:
100103 s_mode = Verbose;
101104 break;
102  case '3':
 105 case 3:
103106 s_mode = VeryVerbose;
104107 break;
105108 default:

Source/WTF/WTF.xcodeproj/project.pbxproj

9595 A331D95F21F249F6009F02AA /* FileSystemCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A331D95E21F249F6009F02AA /* FileSystemCocoa.mm */; };
9696 A331D96121F24A0A009F02AA /* FileSystemMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A331D96021F24A0A009F02AA /* FileSystemMac.mm */; };
9797 A331D96721F24ABD009F02AA /* FileSystemPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D96621F24ABD009F02AA /* FileSystemPOSIX.cpp */; };
 98 A36FC643220BBCE9005E3C37 /* EnvironmentGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A36FC642220BBCE9005E3C37 /* EnvironmentGeneric.cpp */; };
9899 A3B725EC987446AD93F1A440 /* RandomDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C8F597CA2A57417FBAB92FD6 /* RandomDevice.cpp */; };
99100 A3E4DD931F3A803400DED0B4 /* TextStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3E4DD911F3A803400DED0B4 /* TextStream.cpp */; };
100101 A3EE5C3A21FFAC5F00FABD61 /* OSAllocatorPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3EE5C3921FFAC5E00FABD61 /* OSAllocatorPOSIX.cpp */; };

448449 A331D96021F24A0A009F02AA /* FileSystemMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileSystemMac.mm; sourceTree = "<group>"; };
449450 A331D96621F24ABD009F02AA /* FileSystemPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystemPOSIX.cpp; sourceTree = "<group>"; };
450451 A36E16F7216FF828008DD87E /* WTFSemaphore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFSemaphore.h; sourceTree = "<group>"; };
 452 A36FC640220BBC9F005E3C37 /* Environment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Environment.h; sourceTree = "<group>"; };
 453 A36FC642220BBCE9005E3C37 /* EnvironmentGeneric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnvironmentGeneric.cpp; sourceTree = "<group>"; };
451454 A3AB6E6A1F3E1AD6009C14B1 /* ValueToString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueToString.h; sourceTree = "<group>"; };
452455 A3D273B921F2EE9100866971 /* MetadataSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetadataSPI.h; sourceTree = "<group>"; };
453456 A3E4DD911F3A803400DED0B4 /* TextStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextStream.cpp; sourceTree = "<group>"; };

807810 path = posix;
808811 sourceTree = "<group>";
809812 };
 813 A36FC641220BBCB7005E3C37 /* generic */ = {
 814 isa = PBXGroup;
 815 children = (
 816 A36FC642220BBCE9005E3C37 /* EnvironmentGeneric.cpp */,
 817 );
 818 path = generic;
 819 sourceTree = "<group>";
 820 };
810821 A3D273B821F2EE7B00866971 /* mac */ = {
811822 isa = PBXGroup;
812823 children = (

845856 E4A0AD3B1A96251900536DF6 /* cocoa */,
846857 37C7CC281EA40A54007BD956 /* darwin */,
847858 A8A47281151A825A004123FF /* dtoa */,
 859 A36FC641220BBCB7005E3C37 /* generic */,
848860 1FA47C87152502DA00568D1B /* ios */,
849861 A8A472C4151A825A004123FF /* mac */,
850862 E43A46851E228B5700276B05 /* persistence */,

929941 FE05FAE61FDB214300093230 /* DumbPtrTraits.h */,
930942 AD653DA82006B6C200D820D7 /* DumbValueTraits.h */,
931943 1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */,
 944 A36FC640220BBC9F005E3C37 /* Environment.h */,
932945 AD7C434A1DD2A4A70026888B /* Expected.h */,
933946 A8A4729F151A825A004123FF /* ExportMacros.h */,
934947 0F7C5FB51D885CF20044F5E2 /* FastBitVector.cpp */,

10261039 A8A472CE151A825B004123FF /* MetaAllocator.h */,
10271040 A8A472CF151A825B004123FF /* MetaAllocatorHandle.h */,
10281041 FE7497ED209163060003565B /* MetaAllocatorPtr.h */,
1029  5FAD3AE121B9636600BEE178 /* URLHelpers.cpp */,
1030  5FAD3AE021B9636600BEE178 /* URLHelpers.h */,
10311042 0F66B2821DC97BAB004A1D3F /* MonotonicTime.cpp */,
10321043 0F66B2831DC97BAB004A1D3F /* MonotonicTime.h */,
10331044 FE8225301B2A1E5B00BA68FD /* NakedPtr.h */,

11751186 5CC0EE7121629F1800A1A842 /* URL.h */,
11761187 5C1F0597216439940039302C /* URLHash.h */,
11771188 5CC0EE772162A01000A1A842 /* URLHash.h */,
 1189 5FAD3AE121B9636600BEE178 /* URLHelpers.cpp */,
 1190 5FAD3AE021B9636600BEE178 /* URLHelpers.h */,
11781191 5CC0EE7321629F1900A1A842 /* URLParser.cpp */,
11791192 5CC0EE7221629F1900A1A842 /* URLParser.h */,
11801193 7AFEC6B01EB22B5900DADE36 /* UUID.cpp */,

15201533 A8A473B0151A825B004123FF /* double-conversion.cc in Sources */,
15211534 A8A473BA151A825B004123FF /* dtoa.cpp in Sources */,
15221535 143DDE9620C8BC37007F76FA /* Entitlements.mm in Sources */,
 1536 A36FC643220BBCE9005E3C37 /* EnvironmentGeneric.cpp in Sources */,
15231537 50DE35F5215BB01500B979C7 /* ExternalStringImpl.cpp in Sources */,
15241538 A8A473B3151A825B004123FF /* fast-dtoa.cc in Sources */,
15251539 0F7C5FB61D885CF20044F5E2 /* FastBitVector.cpp in Sources */,

15571571 5CC0EE8A2162BC2200A1A842 /* NSURLExtras.mm in Sources */,
15581572 A8A473F4151A825B004123FF /* NumberOfCores.cpp in Sources */,
15591573 8348BA0E21FBC0D500FD3054 /* ObjectIdentifier.cpp in Sources */,
1560  5FAD3AE221B9636600BEE178 /* URLHelpers.cpp in Sources */,
15611574 A3EE5C3A21FFAC5F00FABD61 /* OSAllocatorPOSIX.cpp in Sources */,
15621575 A8A473F9151A825B004123FF /* OSRandomSource.cpp in Sources */,
15631576 A8A47402151A825B004123FF /* PageBlock.cpp in Sources */,

16141627 5CC0EE7621629F1900A1A842 /* URL.cpp in Sources */,
16151628 5C1F0595216437B30039302C /* URLCF.cpp in Sources */,
16161629 5CC0EE892162BC2200A1A842 /* URLCocoa.mm in Sources */,
 1630 5FAD3AE221B9636600BEE178 /* URLHelpers.cpp in Sources */,
16171631 5CC0EE7521629F1900A1A842 /* URLParser.cpp in Sources */,
16181632 1C181C8F1D307AB800F5FA16 /* UTextProvider.cpp in Sources */,
16191633 1C181C911D307AB800F5FA16 /* UTextProviderLatin1.cpp in Sources */,

Source/WTF/wtf/CMakeLists.txt

@@set(WTF_PUBLIC_HEADERS
5555 DumbPtrTraits.h
5656 DumbValueTraits.h
5757 EnumTraits.h
 58 Environment.h
5859 Expected.h
5960 ExportMacros.h
6061 FastBitVector.h

Source/WTF/wtf/DataLog.cpp

2626#include "config.h"
2727#include <wtf/DataLog.h>
2828
 29#include <mutex>
2930#include <stdarg.h>
3031#include <string.h>
 32#include <thread>
 33#include <wtf/Environment.h>
3134#include <wtf/FilePrintStream.h>
3235#include <wtf/LockedPrintStream.h>
3336#include <wtf/ProcessID.h>
3437#include <wtf/Threading.h>
35 #include <mutex>
36 #include <thread>
3738
3839#if OS(UNIX) || OS(DARWIN)
3940#include <unistd.h>

@@static void initializeLogFileOnce()
9394#elif defined(DATA_LOG_FILENAME)
9495 filename = DATA_LOG_FILENAME;
9596#else
96  filename = getenv("WTF_DATA_LOG_FILENAME");
 97 filename = Environment::get("WTF_DATA_LOG_FILENAME").utf8().data();
9798#endif
9899 char actualFilename[maxPathLength + 1];
99100

Source/WTF/wtf/Environment.h

 1/*
 2 * Copyright (C) 2019 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 23 */
 24
 25#pragma once
 26
 27#include <wtf/text/WTFString.h>
 28
 29namespace WTF {
 30namespace EnvironmentImpl {
 31
 32WTF_EXPORT_PRIVATE String get(const String&);
 33WTF_EXPORT_PRIVATE void set(const String& variable, const String& value);
 34WTF_EXPORT_PRIVATE void add(const String& variable, const String& value); // does nothing if variable exists
 35WTF_EXPORT_PRIVATE void remove(const String&);
 36
 37} // namespace EnvironmentImpl
 38} // namespace WTF
 39
 40namespace Environment = WTF::EnvironmentImpl;

Source/WTF/wtf/NumberOfCores.cpp

2727#include <wtf/NumberOfCores.h>
2828
2929#include <cstdio>
 30#include <wtf/Environment.h>
3031
3132#if OS(DARWIN)
3233#include <sys/param.h>

@@int numberOfProcessorCores()
5051 if (s_numberOfCores > 0)
5152 return s_numberOfCores;
5253
53  if (const char* coresEnv = getenv("WTF_numberOfProcessorCores")) {
54  unsigned numberOfCores;
55  if (sscanf(coresEnv, "%u", &numberOfCores) == 1) {
 54 auto coresEnv = Environment::get("WTF_numberOfProcessorCores");
 55 if (!!coresEnv) {
 56 bool ok;
 57 auto numberOfCores = coresEnv.toUInt(&ok);
 58 if (ok) {
5659 s_numberOfCores = numberOfCores;
5760 return s_numberOfCores;
58  } else
59  fprintf(stderr, "WARNING: failed to parse WTF_numberOfProcessorCores=%s\n", coresEnv);
 61 }
 62
 63 fprintf(stderr, "WARNING: failed to parse WTF_numberOfProcessorCores=%s\n", coresEnv.utf8().data());
6064 }
6165
6266#if OS(DARWIN)

Source/WTF/wtf/PlatformGTK.cmake

@@list(APPEND WTF_SOURCES
2222 generic/MainThreadGeneric.cpp
2323 generic/WorkQueueGeneric.cpp
2424
 25 glib/EnvironmentGlib.cpp
2526 glib/FileSystemGlib.cpp
2627 glib/GLibUtilities.cpp
2728 glib/GRefPtr.cpp

Source/WTF/wtf/PlatformJSCOnly.cmake

@@endif ()
9797
9898if (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib")
9999 list(APPEND WTF_SOURCES
 100 glib/EnvironmentGlib.cpp
100101 glib/GRefPtr.cpp
101102 glib/RunLoopGLib.cpp
102103 )

@@if (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib")
110111 )
111112else ()
112113 list(APPEND WTF_SOURCES
 114 generic/EnvironmentGeneric.cpp
113115 generic/RunLoopGeneric.cpp
114116 )
115117endif ()

Source/WTF/wtf/PlatformMac.cmake

@@list(APPEND WTF_SOURCES
6060 cocoa/URLCocoa.mm
6161 cocoa/WorkQueueCocoa.cpp
6262
 63 generic/EnvironmentGeneric.cpp
 64
6365 mac/DeprecatedSymbolsUsedBySafari.mm
6466 mac/FileSystemMac.mm
6567 mac/SchedulePairMac.mm

Source/WTF/wtf/PlatformPlayStation.cmake

11list(APPEND WTF_SOURCES
 2 generic/EnvironmentGeneric.cpp
23 generic/MainThreadGeneric.cpp
34 generic/MemoryFootprintGeneric.cpp
45 generic/MemoryPressureHandlerGeneric.cpp

Source/WTF/wtf/PlatformWPE.cmake

@@list(APPEND WTF_SOURCES
1616 generic/MainThreadGeneric.cpp
1717 generic/WorkQueueGeneric.cpp
1818
 19 glib/EnvironmentGlib.cpp
1920 glib/FileSystemGlib.cpp
2021 glib/GLibUtilities.cpp
2122 glib/GRefPtr.cpp

Source/WTF/wtf/PlatformWin.cmake

@@list(APPEND WTF_PUBLIC_HEADERS
88)
99
1010list(APPEND WTF_SOURCES
 11 generic/EnvironmentGeneric.cpp
 12
1113 text/win/TextBreakIteratorInternalICUWin.cpp
1214
1315 win/CPUTimeWin.cpp

Source/WTF/wtf/generic/EnvironmentGeneric.cpp

 1/*
 2 * Copyright (C) 2019 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 23 */
 24
 25#include "config.h"
 26#include <wtf/Environment.h>
 27
 28#include <stdlib.h>
 29
 30namespace WTF {
 31namespace EnvironmentImpl {
 32
 33String get(const String& variable)
 34{
 35 return getenv(variable.utf8().data());
 36}
 37
 38void set(const String& variable, const String& value)
 39{
 40 setenv(variable.utf8().data(), value.utf8().data(), 1);
 41}
 42
 43void add(const String& variable, const String& value)
 44{
 45 setenv(variable.utf8().data(), value.utf8().data(), 0);
 46}
 47
 48void remove(const String& variable)
 49{
 50 unsetenv(variable.utf8().data());
 51}
 52
 53} // namespace EnvironmentImpl
 54} // namespace WTF

Source/WTF/wtf/glib/EnvironmentGlib.cpp

 1/*
 2 * Copyright (C) 2019 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 23 */
 24
 25#include "config.h"
 26#include <wtf/Environment.h>
 27
 28#include <glib.h>
 29
 30namespace WTF {
 31namespace EnvironmentImpl {
 32
 33String get(const String& variable)
 34{
 35 return g_getenv(variable.utf8().data());
 36}
 37
 38void set(const String& variable, const String& value)
 39{
 40 g_setenv(variable.utf8().data(), value.utf8().data(), 1);
 41}
 42
 43void add(const String& variable, const String& value)
 44{
 45 g_setenv(variable.utf8().data(), value.utf8().data(), 0);
 46}
 47
 48void remove(const String& variable)
 49{
 50 g_unsetenv(variable.utf8().data());
 51}
 52
 53} // namespace EnvironmentImpl
 54} // namespace WTF

Source/WTF/wtf/posix/FileSystemPOSIX.cpp

4040#include <sys/types.h>
4141#include <unistd.h>
4242#include <wtf/EnumTraits.h>
 43#include <wtf/Environment.h>
4344#include <wtf/FileMetadata.h>
4445#include <wtf/text/CString.h>
4546#include <wtf/text/StringBuilder.h>

@@bool getVolumeFreeSpace(const String& path, uint64_t& freeSpace)
424425String openTemporaryFile(const String& prefix, PlatformFileHandle& handle)
425426{
426427 char buffer[PATH_MAX];
427  const char* tmpDir = getenv("TMPDIR");
 428 auto tmpDir = Environment::get("TMPDIR").utf8().data();
428429
429430 if (!tmpDir)
430431 tmpDir = "/tmp";