Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate shared this from std/process.d #5466

Merged
merged 3 commits into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ EXTRA_MODULES_INTERNAL := $(addprefix std/, \
cstring digest/sha_SSSE3 \
$(addprefix math/, biguintcore biguintnoasm biguintx86 \
errorfunction gammafunction ) \
processinit scopebuffer test/dummyrange \
scopebuffer test/dummyrange \
$(addprefix unicode_, comp decomp grapheme norm tables) \
) \
)
Expand Down
22 changes: 0 additions & 22 deletions std/internal/processinit.d

This file was deleted.

69 changes: 36 additions & 33 deletions std/process.d
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ version (Windows)
}

import std.internal.cstring;
import std.internal.processinit;
import std.range.primitives;
import std.stdio;

Expand All @@ -112,45 +111,47 @@ version (Win32) version (CRuntime_DigitalMars) version = DMC_RUNTIME;
// Some of the following should be moved to druntime.
private
{

// Microsoft Visual C Runtime (MSVCRT) declarations.
version (Windows)
{
version (DMC_RUNTIME) { } else
// Microsoft Visual C Runtime (MSVCRT) declarations.
version (Windows)
{
import core.stdc.stdint;
enum
version (DMC_RUNTIME) { } else
{
STDIN_FILENO = 0,
STDOUT_FILENO = 1,
STDERR_FILENO = 2,
import core.stdc.stdint;
enum
{
STDIN_FILENO = 0,
STDOUT_FILENO = 1,
STDERR_FILENO = 2,
}
}
}
}

// POSIX API declarations.
version (Posix)
{
version (OSX)
{
extern(C) char*** _NSGetEnviron() nothrow;
private __gshared const(char**)* environPtr;
extern(C) void std_process_shared_static_this() { environPtr = _NSGetEnviron(); }
const(char**) environ() @property @trusted nothrow { return *environPtr; }
}
else
// POSIX API declarations.
version (Posix)
{
// Made available by the C runtime:
extern(C) extern __gshared const char** environ;
}
version (OSX)
{
extern(C) char*** _NSGetEnviron() nothrow;
const(char**) getEnvironPtr() @trusted
{
return *_NSGetEnviron;
}
}
else
{
// Made available by the C runtime:
extern(C) extern __gshared const char** environ;
const(char**) getEnvironPtr() @trusted
{
return environ;
}
}

@system unittest
{
new Thread({assert(environ !is null);}).start();
@system unittest
{
new Thread({assert(getEnvironPtr !is null);}).start();
}
}
}


} // private


Expand Down Expand Up @@ -703,6 +704,7 @@ private const(char*)* createEnv(const string[string] childEnv,
{
// Determine the number of strings in the parent's environment.
int parentEnvLength = 0;
auto environ = getEnvironPtr;
if (mergeWithParentEnv)
{
if (childEnv.length == 0) return environ;
Expand Down Expand Up @@ -737,6 +739,7 @@ version (Posix) @system unittest
auto e2 = createEnv(null, true);
assert(e2 != null);
int i = 0;
auto environ = getEnvironPtr;
for (; environ[i] != null; ++i)
{
assert(e2[i] != null);
Expand Down Expand Up @@ -3333,6 +3336,7 @@ static:
string[string] aa;
version (Posix)
{
auto environ = getEnvironPtr;
for (int i=0; environ[i] != null; ++i)
{
import std.string : indexOf;
Expand Down Expand Up @@ -3902,4 +3906,3 @@ else version (Posix)
}
else
static assert(0, "os not supported");

1 change: 0 additions & 1 deletion win32.mak
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ SRC_STD_C_FREEBSD= \

SRC_STD_INTERNAL= \
std\internal\cstring.d \
std\internal\processinit.d \
std\internal\unicode_tables.d \
std\internal\unicode_comp.d \
std\internal\unicode_decomp.d \
Expand Down
1 change: 0 additions & 1 deletion win64.mak
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ SRC_STD_C_FREEBSD= \

SRC_STD_INTERNAL= \
std\internal\cstring.d \
std\internal\processinit.d \
std\internal\unicode_tables.d \
std\internal\unicode_comp.d \
std\internal\unicode_decomp.d \
Expand Down