Merge pull request #4493 from schveiguy/fixcycles2

Fix cycles in Phobos
This commit is contained in:
David Nadlinger 2016-07-06 00:06:11 +01:00 committed by GitHub
commit c33f3862b7
8 changed files with 54 additions and 49 deletions

View file

@ -212,7 +212,7 @@ EXTRA_MODULES_INTERNAL := $(addprefix \
std/internal/digest/, sha_SSSE3 ) $(addprefix \
std/internal/math/, biguintcore biguintnoasm biguintx86 \
gammafunction errorfunction) $(addprefix std/internal/, \
cstring processinit unicode_tables scopebuffer\
cstring phobosinit unicode_tables scopebuffer\
unicode_comp unicode_decomp unicode_grapheme unicode_norm) \
$(addprefix std/internal/test/, dummyrange) \
$(addprefix std/experimental/ndslice/, internal) \

View file

@ -2635,10 +2635,11 @@ abstract class EncodingScheme
*/
class EncodingSchemeASCII : EncodingScheme
{
/* // moved to std.internal.phobosinit
shared static this()
{
EncodingScheme.register("std.encoding.EncodingSchemeASCII");
}
}*/
const
{
@ -2720,10 +2721,11 @@ class EncodingSchemeASCII : EncodingScheme
*/
class EncodingSchemeLatin1 : EncodingScheme
{
/* // moved to std.internal.phobosinit
shared static this()
{
EncodingScheme.register("std.encoding.EncodingSchemeLatin1");
}
}*/
const
{
@ -2799,10 +2801,11 @@ class EncodingSchemeLatin1 : EncodingScheme
*/
class EncodingSchemeLatin2 : EncodingScheme
{
/* // moved to std.internal.phobosinit
shared static this()
{
EncodingScheme.register("std.encoding.EncodingSchemeLatin2");
}
}*/
const
{
@ -2870,10 +2873,11 @@ class EncodingSchemeLatin2 : EncodingScheme
*/
class EncodingSchemeWindows1250 : EncodingScheme
{
/* // moved to std.internal.phobosinit
shared static this()
{
EncodingScheme.register("std.encoding.EncodingSchemeWindows1250");
}
}*/
const
{
@ -2937,10 +2941,11 @@ class EncodingSchemeWindows1250 : EncodingScheme
*/
class EncodingSchemeWindows1252 : EncodingScheme
{
/* // moved to std.internal.phobosinit
shared static this()
{
EncodingScheme.register("std.encoding.EncodingSchemeWindows1252");
}
}*/
const
{
@ -3004,10 +3009,11 @@ class EncodingSchemeWindows1252 : EncodingScheme
*/
class EncodingSchemeUtf8 : EncodingScheme
{
/* // moved to std.internal.phobosinit
shared static this()
{
EncodingScheme.register("std.encoding.EncodingSchemeUtf8");
}
}*/
const
{
@ -3072,10 +3078,11 @@ class EncodingSchemeUtf8 : EncodingScheme
*/
class EncodingSchemeUtf16Native : EncodingScheme
{
/* // moved to std.internal.phobosinit
shared static this()
{
EncodingScheme.register("std.encoding.EncodingSchemeUtf16Native");
}
}*/
const
{
@ -3167,10 +3174,11 @@ class EncodingSchemeUtf16Native : EncodingScheme
*/
class EncodingSchemeUtf32Native : EncodingScheme
{
/* // moved to std.internal.phobosinit
shared static this()
{
EncodingScheme.register("std.encoding.EncodingSchemeUtf32Native");
}
}*/
const
{

View file

@ -596,21 +596,6 @@ version(Posix) struct SbrkRegion(uint minAlign = platformAlignment)
private static shared pthread_mutex_t sbrkMutex = PTHREAD_MUTEX_INITIALIZER;
import std.typecons : Ternary;
// workaround for https://issues.dlang.org/show_bug.cgi?id=14617
version(OSX)
{
shared static this()
{
pthread_mutex_init(cast(pthread_mutex_t*) &sbrkMutex, null) == 0
|| assert(0);
}
shared static ~this()
{
pthread_mutex_destroy(cast(pthread_mutex_t*) &sbrkMutex) == 0
|| assert(0);
}
}
static assert(minAlign.isGoodStaticAlignment);
static assert(size_t.sizeof == (void*).sizeof);
private shared void* _brkInitial, _brkCurrent;

35
std/internal/phobosinit.d Normal file
View file

@ -0,0 +1,35 @@
// Written in the D programming language.
/++
The purpose of this module is to perform static construction away from the
normal modules to eliminate cyclic construction errors.
Copyright: Copyright 2011 - 2016
License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: Jonathan M Davis, Kato Shoichi, Steven Schveighoffer
Source: $(PHOBOSSRC std/internal/_phobosinit.d)
+/
module std.internal.phobosinit;
version(OSX)
{
extern(C) void std_process_shared_static_this();
shared static this()
{
std_process_shared_static_this();
}
}
shared static this()
{
import std.encoding;
EncodingScheme.register("std.encoding.EncodingSchemeASCII");
EncodingScheme.register("std.encoding.EncodingSchemeLatin1");
EncodingScheme.register("std.encoding.EncodingSchemeLatin2");
EncodingScheme.register("std.encoding.EncodingSchemeWindows1250");
EncodingScheme.register("std.encoding.EncodingSchemeWindows1252");
EncodingScheme.register("std.encoding.EncodingSchemeUtf8");
EncodingScheme.register("std.encoding.EncodingSchemeUtf16Native");
EncodingScheme.register("std.encoding.EncodingSchemeUtf32Native");
}

View file

@ -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();
}
}

View file

@ -100,7 +100,6 @@ version (Windows)
import std.range.primitives;
import std.stdio;
import std.internal.processinit;
import std.internal.cstring;

View file

@ -270,7 +270,7 @@ SRC_STD_C_FREEBSD= \
SRC_STD_INTERNAL= \
std\internal\cstring.d \
std\internal\processinit.d \
std\internal\phobosinit.d \
std\internal\unicode_tables.d \
std\internal\unicode_comp.d \
std\internal\unicode_decomp.d \

View file

@ -292,7 +292,7 @@ SRC_STD_C_FREEBSD= \
SRC_STD_INTERNAL= \
std\internal\cstring.d \
std\internal\processinit.d \
std\internal\phobosinit.d \
std\internal\unicode_tables.d \
std\internal\unicode_comp.d \
std\internal\unicode_decomp.d \