mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
Eliminate shared this from std/process.d
This commit is contained in:
parent
30ff7ac56f
commit
2f16ae7cb7
5 changed files with 15 additions and 33 deletions
|
@ -224,7 +224,7 @@ EXTRA_MODULES_INTERNAL := $(addprefix std/, \
|
||||||
cstring digest/sha_SSSE3 \
|
cstring digest/sha_SSSE3 \
|
||||||
$(addprefix math/, biguintcore biguintnoasm biguintx86 \
|
$(addprefix math/, biguintcore biguintnoasm biguintx86 \
|
||||||
errorfunction gammafunction ) \
|
errorfunction gammafunction ) \
|
||||||
processinit scopebuffer test/dummyrange \
|
scopebuffer test/dummyrange \
|
||||||
$(addprefix unicode_, comp decomp grapheme norm tables) \
|
$(addprefix unicode_, comp decomp grapheme norm tables) \
|
||||||
) \
|
) \
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
// Written in the D programming language.
|
|
||||||
|
|
||||||
/++
|
|
||||||
The only purpose of this module is to do the static construction for
|
|
||||||
std.process in order to eliminate cyclic construction errors.
|
|
||||||
|
|
||||||
Copyright: Copyright 2011 -
|
|
||||||
License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
|
||||||
Authors: Jonathan M Davis and Kato Shoichi
|
|
||||||
Source: $(PHOBOSSRC std/internal/_processinit.d)
|
|
||||||
+/
|
|
||||||
module std.internal.processinit;
|
|
||||||
|
|
||||||
version(OSX)
|
|
||||||
{
|
|
||||||
extern(C) void std_process_shared_static_this();
|
|
||||||
|
|
||||||
shared static this()
|
|
||||||
{
|
|
||||||
std_process_shared_static_this();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -99,7 +99,6 @@ version (Windows)
|
||||||
}
|
}
|
||||||
|
|
||||||
import std.internal.cstring;
|
import std.internal.cstring;
|
||||||
import std.internal.processinit;
|
|
||||||
import std.range.primitives;
|
import std.range.primitives;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
|
|
||||||
|
@ -133,20 +132,25 @@ version (Posix)
|
||||||
{
|
{
|
||||||
version (OSX)
|
version (OSX)
|
||||||
{
|
{
|
||||||
extern(C) char*** _NSGetEnviron() nothrow;
|
private extern(C) char*** _NSGetEnviron() nothrow;
|
||||||
private __gshared const(char**)* environPtr;
|
private const(char**) getEnvironPtr() @property @trusted
|
||||||
extern(C) void std_process_shared_static_this() { environPtr = _NSGetEnviron(); }
|
{
|
||||||
const(char**) environ() @property @trusted nothrow { return *environPtr; }
|
return *_NSGetEnviron;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Made available by the C runtime:
|
// Made available by the C runtime:
|
||||||
extern(C) extern __gshared const char** environ;
|
private extern(C) extern __gshared const char** environ;
|
||||||
|
private const(char**) getEnvironPtr() @property @trusted
|
||||||
|
{
|
||||||
|
return environ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@system unittest
|
@system unittest
|
||||||
{
|
{
|
||||||
new Thread({assert(environ !is null);}).start();
|
new Thread({assert(getEnvironPtr !is null);}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,6 +707,7 @@ private const(char*)* createEnv(const string[string] childEnv,
|
||||||
{
|
{
|
||||||
// Determine the number of strings in the parent's environment.
|
// Determine the number of strings in the parent's environment.
|
||||||
int parentEnvLength = 0;
|
int parentEnvLength = 0;
|
||||||
|
auto environ = getEnvironPtr;
|
||||||
if (mergeWithParentEnv)
|
if (mergeWithParentEnv)
|
||||||
{
|
{
|
||||||
if (childEnv.length == 0) return environ;
|
if (childEnv.length == 0) return environ;
|
||||||
|
@ -737,6 +742,7 @@ version (Posix) @system unittest
|
||||||
auto e2 = createEnv(null, true);
|
auto e2 = createEnv(null, true);
|
||||||
assert(e2 != null);
|
assert(e2 != null);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
auto environ = getEnvironPtr;
|
||||||
for (; environ[i] != null; ++i)
|
for (; environ[i] != null; ++i)
|
||||||
{
|
{
|
||||||
assert(e2[i] != null);
|
assert(e2[i] != null);
|
||||||
|
@ -3333,6 +3339,7 @@ static:
|
||||||
string[string] aa;
|
string[string] aa;
|
||||||
version (Posix)
|
version (Posix)
|
||||||
{
|
{
|
||||||
|
auto environ = getEnvironPtr;
|
||||||
for (int i=0; environ[i] != null; ++i)
|
for (int i=0; environ[i] != null; ++i)
|
||||||
{
|
{
|
||||||
import std.string : indexOf;
|
import std.string : indexOf;
|
||||||
|
@ -3902,4 +3909,3 @@ else version (Posix)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
static assert(0, "os not supported");
|
static assert(0, "os not supported");
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,6 @@ SRC_STD_C_FREEBSD= \
|
||||||
|
|
||||||
SRC_STD_INTERNAL= \
|
SRC_STD_INTERNAL= \
|
||||||
std\internal\cstring.d \
|
std\internal\cstring.d \
|
||||||
std\internal\processinit.d \
|
|
||||||
std\internal\unicode_tables.d \
|
std\internal\unicode_tables.d \
|
||||||
std\internal\unicode_comp.d \
|
std\internal\unicode_comp.d \
|
||||||
std\internal\unicode_decomp.d \
|
std\internal\unicode_decomp.d \
|
||||||
|
|
|
@ -295,7 +295,6 @@ SRC_STD_C_FREEBSD= \
|
||||||
|
|
||||||
SRC_STD_INTERNAL= \
|
SRC_STD_INTERNAL= \
|
||||||
std\internal\cstring.d \
|
std\internal\cstring.d \
|
||||||
std\internal\processinit.d \
|
|
||||||
std\internal\unicode_tables.d \
|
std\internal\unicode_tables.d \
|
||||||
std\internal\unicode_comp.d \
|
std\internal\unicode_comp.d \
|
||||||
std\internal\unicode_decomp.d \
|
std\internal\unicode_decomp.d \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue