Revise remaining 32{omf,mscoff} usages

This commit is contained in:
Martin Kinkelin 2024-05-25 16:23:38 +02:00
parent d715bdc972
commit 920678a820
24 changed files with 33 additions and 682 deletions

View file

@ -6,20 +6,8 @@ version=7.51 Build 020
[Environment] [Environment]
DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import" DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import"
; optlink only reads from the Environment section so we need this redundancy
; from the Environment32omf section (bugzilla 11302)
LIB="%@P%\..\lib"
[Environment32] [Environment32]
LIB=%@P%\..\lib32mscoff LIB=%@P%\..\lib32mscoff
[Environment32omf]
LIB="%@P%\..\lib"
LINKCMD=%@P%\optlink.exe
[Environment64] [Environment64]
LIB=%@P%\..\lib64 LIB=%@P%\..\lib64
; -----------------------------------------------------------------------------
[Environment32mscoff]
LIB=%@P%\..\lib32mscoff

View file

@ -1,8 +0,0 @@
LIBRARY dserver
EXETYPE NT
SUBSYSTEM WINDOWS
EXPORTS
DllGetClassObject = _DllGetClassObject@12
DllCanUnloadNow = _DllCanUnloadNow@0
DllRegisterServer = _DllRegisterServer@0
DllUnregisterServer = _DllUnregisterServer@0

View file

@ -3,7 +3,7 @@ DMD=..\..\windows\bin\dmd
DFLAGS=-m$(MODEL) DFLAGS=-m$(MODEL)
EXAMPLES = hello d2html dhry pi sieve wc wc2 \ EXAMPLES = hello d2html dhry pi sieve wc wc2 \
winsamp dserver$(MODEL) mydll$(MODEL) htmlget listener winsamp dserver mydll htmlget listener
all: $(EXAMPLES) all: $(EXAMPLES)
echo done echo done
@ -50,22 +50,12 @@ winsamp:
# COM client/server example # COM client/server example
# dclient will fail unless run with administrator rights # dclient will fail unless run with administrator rights
dserver32: dserver:
$(DMD) dserver.d chello.d $(DFLAGS) dserver.def advapi32.lib ole32.lib user32.lib
$(DMD) dclient $(DFLAGS) ole32.lib uuid.lib
.\dclient.exe
dserver64 dserver32mscoff:
$(DMD) dserver.d chello.d $(DFLAGS) -L/DLL dserver64.def advapi32.lib ole32.lib user32.lib $(DMD) dserver.d chello.d $(DFLAGS) -L/DLL dserver64.def advapi32.lib ole32.lib user32.lib
$(DMD) dclient $(DFLAGS) ole32.lib uuid.lib $(DMD) dclient $(DFLAGS) ole32.lib uuid.lib
.\dclient.exe .\dclient.exe
mydll32: mydll:
$(DMD) $(DFLAGS) -ofmydll.dll -L/IMPLIB mydll\mydll.d mydll\dll.d mydll\mydll.def
$(DMD) $(DFLAGS) -ofdlltest.exe mydll\test.d mydll\mydll.di mydll.lib
.\dlltest.exe
mydll64 mydll32mscoff:
$(DMD) $(DFLAGS) -ofmydll.dll mydll\mydll.d mydll\dll.d -L/DLL $(DMD) $(DFLAGS) -ofmydll.dll mydll\mydll.d mydll\dll.d -L/DLL
$(DMD) $(DFLAGS) -ofdlltest.exe mydll\test.d mydll\mydll.di mydll.lib $(DMD) $(DFLAGS) -ofdlltest.exe mydll\test.d mydll\mydll.di mydll.lib
.\dlltest.exe .\dlltest.exe

View file

@ -299,9 +299,6 @@ DFLAGS=%DFLAGS% -L/OPT:NOICF
[Environment64] [Environment64]
DFLAGS=%DFLAGS% -L/OPT:NOICF DFLAGS=%DFLAGS% -L/OPT:NOICF
[Environment32mscoff]
DFLAGS=%DFLAGS% -L/OPT:NOICF
`; `;
} }
else else

View file

@ -389,15 +389,7 @@ private void obj_start(ref OutBuffer objbuf, const(char)* srcfile)
version (Windows) version (Windows)
{ {
import dmd.backend.mscoffobj; import dmd.backend.mscoffobj;
import dmd.backend.cgobj; objmod = MsCoffObj_init(&objbuf, srcfile, null);
// Produce Ms COFF files by default, OMF for -m32omf
assert(objbuf.length() == 0);
switch (target.objectFormat())
{
case Target.ObjectFormat.coff: objmod = MsCoffObj_init(&objbuf, srcfile, null); break;
default: assert(0);
}
} }
else else
{ {

View file

@ -812,7 +812,6 @@ bool parseCommandlineAndConfig(size_t argc, const(char)** argv, ref Param params
bool isX86_64 = arch[0] == '6'; bool isX86_64 = arch[0] == '6';
version(Windows) // delete LIB entry in [Environment] (necessary for optlink) to allow inheriting environment for MS-COFF version(Windows) // delete LIB entry in [Environment] (necessary for optlink) to allow inheriting environment for MS-COFF
if (arch != "32omf")
environment.update("LIB", 3).value = null; environment.update("LIB", 3).value = null;
// read from DFLAGS in [Environment{arch}] section // read from DFLAGS in [Environment{arch}] section

View file

@ -191,7 +191,7 @@ void main(string[] args)
Test parameters can be restricted to certain targets by adding a brace-enclosed Test parameters can be restricted to certain targets by adding a brace-enclosed
condition after the name, i.e. `REQUIRED_ARGS(<condition>): ...`. The `<condition>` condition after the name, i.e. `REQUIRED_ARGS(<condition>): ...`. The `<condition>`
consists of the target operating system followed by an optional model suffix, consists of the target operating system followed by an optional model suffix,
e.g. `linux`, `win32mscoff`, `freebsd64`. e.g. `linux`, `win32`, `freebsd64`.
Valid platforms: Valid platforms:
- win - win
@ -203,8 +203,6 @@ Valid platforms:
Valid models: Valid models:
- 32 - 32
- 32mscoff (windows only)
- 32omf (windows only)
- 64 - 64
Note that test parameters *MUST* be followed by a colon (intermediate whitespace is allowed). Note that test parameters *MUST* be followed by a colon (intermediate whitespace is allowed).
@ -430,7 +428,7 @@ depend on the current platform and target:
Supported conditions: Supported conditions:
- OS: posix, windows, ... - OS: posix, windows, ...
- Model: 64, 32mscoff, 32omf and 32 (also matches 32mscoff + 32omf) - Model: 64, 32
$r:<regex>$ any text matching <regex> (using $ inside of <regex> is not $r:<regex>$ any text matching <regex> (using $ inside of <regex> is not
supported, use multiple regexes instead) supported, use multiple regexes instead)

View file

@ -1,8 +1,5 @@
// REQUIRED_ARGS: -identifiers-importc=UAX31 // REQUIRED_ARGS: -identifiers-importc=UAX31
// sppn doesn't support anything newer than c99
// DISABLED: win32omf
// verify that the UAX31 identifier set is applied. // verify that the UAX31 identifier set is applied.
int \u00F8ide\u00F9nt; int \u00F8ide\u00F9nt;

View file

@ -1,8 +1,5 @@
// REQUIRED_ARGS: -identifiers-importc=all // REQUIRED_ARGS: -identifiers-importc=all
// sppn doesn't support anything newer than c99
// DISABLED: win32omf
// verify that the All identifier set is applied. // verify that the All identifier set is applied.
int \u00F8ide\u00F9nt; int \u00F8ide\u00F9nt;

View file

@ -1,8 +1,5 @@
// REQUIRED_ARGS: -identifiers-importc=c11 // REQUIRED_ARGS: -identifiers-importc=c11
// sppn doesn't support anything newer than c99
// DISABLED: win32omf
// verify that the C11 identifier set is applied. // verify that the C11 identifier set is applied.
int \u00A8ide\u00AFnt; int \u00A8ide\u00AFnt;

View file

@ -49,13 +49,6 @@ void testConfigurations()
"-conf=" ~ configPath "-conf=" ~ configPath
]; ];
version (Windows) if (MODEL == "32omf")
{
// 32-OMF tries to use `optlink.exe` located next to `sc.ini`
// and also doesn't like the LIB setup, so skip it for now
extraFlags = [""];
}
foreach (const target; targets) foreach (const target; targets)
{ {
foreach (const flags; extraFlags) foreach (const flags; extraFlags)

View file

@ -2,9 +2,6 @@ import dshell;
int main() int main()
{ {
version (Windows) if (Vars.MODEL == "32omf") // Avoid optlink
return DISABLED;
version (DigitalMars) version (DigitalMars)
{ {
// Disable DM Dlls for now, need to redesign it // Disable DM Dlls for now, need to redesign it

View file

@ -25,18 +25,9 @@ int main()
version (Windows) version (Windows)
{ {
Vars.set(`DLL_LIB`, `$OUTPUT_BASE${SEP}mydll.lib`); Vars.set(`DLL_LIB`, `$OUTPUT_BASE${SEP}mydll.lib`);
if (Vars.MODEL == "32omf") // CXX should be cl
{ dllCmd ~= [`/LD`, `/nologo`, `/Fe` ~ Vars.DLL];
// CXX should be dmc for win32omf. mainExtra = `$DLL_LIB`;
dllCmd ~= [`-mn`, `-L/implib:` ~ Vars.DLL_LIB, `-WD`, `-o` ~ Vars.DLL, `kernel32.lib`, `user32.lib`];
mainExtra = `$DLL_LIB`;
}
else
{
// CXX should be cl for win32mscoff.
dllCmd ~= [`/LD`, `/nologo`, `/Fe` ~ Vars.DLL];
mainExtra = `$DLL_LIB`;
}
} }
else version(OSX) else version(OSX)
{ {

View file

@ -2,15 +2,6 @@ import dshell;
int main() int main()
{ {
version (DigitalMars)
{
if (OS == "windows" && MODEL == "32omf")
{
writeln("Skipping test when using Optlink.");
return DISABLED;
}
}
Vars.set("lib", "$OUTPUT_BASE/dir with spaces/b$LIBEXT"); Vars.set("lib", "$OUTPUT_BASE/dir with spaces/b$LIBEXT");
run("$DMD -m$MODEL -of$lib -lib $EXTRA_FILES/linker_flag_with_spaces_b.d"); run("$DMD -m$MODEL -of$lib -lib $EXTRA_FILES/linker_flag_with_spaces_b.d");

View file

@ -307,12 +307,9 @@ void ensureToolsExists(const string[string] env, const TestTool[] tools ...)
} }
else else
{ {
string model = env["MODEL"];
if (model == "32omf") model = "32";
buildCommand = [ buildCommand = [
hostDMD, hostDMD,
"-m"~model, "-m"~env["MODEL"],
"-of"~targetBin, "-of"~targetBin,
sourceFile sourceFile
] ~ getPicFlags(env) ~ tool.extraArgs; ] ~ getPicFlags(env) ~ tool.extraArgs;

View file

@ -1,206 +0,0 @@
/* test bitfields for Digital Mars C
* Note that this test is for win32 only
*
* REQUIRED_ARGS:
* DISABLED: win32mscoff win64 linux freebsd osx
* RUN_OUTPUT:
---
DM | MS | P32 | P64
T0 = 1 1 || 1 1 | 1 1 | 1 1 | 1 1
T1 = 2 2 || 2 2 | 2 2 | 2 2 | 2 2
T2 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4
T3 = 16 8 || 16 8 | 16 8 | 8 4 | 8 8
T4 = 16 8 || 16 8 | 16 8 | 12 4 | 16 8
T5 = 16 8 || 16 8 | 16 8 | 8 4 | 8 8
S1 = 8 8 || 8 8 | 8 8 | 4 4 | 8 8
S2 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4
S3 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4
S4 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4
S5 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4
S6 = 2 2 || 2 2 | 2 2 | 2 2 | 2 2
S7 = 16 8 || 16 8 | 16 8 | 4 4 | 8 8
S8 = 4 2 || 4 2 | 4 2 | 2 2 | 2 2
S8A = 4 2 || 4 2 | 4 2 | 2 2 | 2 2
S8B = 6 2 || 6 2 | 6 2 | 2 2 | 2 2
S8C = 8 4 || 8 4 | 8 4 | 4 4 | 4 4
S9 = 4 2 || 4 2 | 4 2 | 4 2 | 4 2
S10 = 0 0 || 0 0 | * * | 0 1 | 0 1
S11 = 0 0 || 0 0 | 4 1 | 0 1 | 0 1
S12 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4
S13 = 8 4 || 8 4 | 8 4 | 8 4 | 8 4
S14 = 8 4 || 8 4 | 8 4 | 8 4 | 8 4
S15 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4
S16 = 0 0 || 0 0 | 4 4 | 4 1 | 4 1
S17 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4
S18 = 2 1 || 2 1 | 2 1 | 5 1 | 9 1
A0 = 16 8 || 16 8 | 16 8 | 12 4 | 16 8
A1 = 12 4 || 12 4 | 12 4 | 12 4 | 12 4
A2 = 12 4 || 12 4 | 12 4 | 12 4 | 12 4
A3 = 16 4 || 16 4 | 16 4 | 16 4 | 16 4
A4 = 12 4 || 12 4 | 12 4 | 8 4 | 8 4
A5 = 2 1 || 2 1 | 2 1 | 2 1 | 2 1
A6 = 4 2 || 4 2 | 4 2 | 2 2 | 2 2
A7 = 16 4 || 16 4 | 16 4 | 12 4 | 16 8
A8 = 12 4 || 12 4 | 12 4 | 8 4 | 8 8
A9 = 32 8 || 32 8 | 32 8 | 16 4 | 16 8
A10 = 4 2 || 4 2 | 4 2 | 2 2 | 2 2
A11 = 16 4 || 16 4 | 16 4 | 12 4 | 12 4
S9 = x30200
S14 = x300000201
S15 = x201
S18 = 1 should be 4
A0 = x1
---
*/
int printf(const char *fmt, ...);
void exit(int);
void assert(int n, int b)
{
if (!b)
{
printf("assert fail %d\n", n);
exit(1);
}
}
int is64bit() { return sizeof(long) == 8; } // otherwise assume 32 bit
/*************************************************************/
struct T0 { char x:1; }; //
struct T1 { short x:1; }; //
struct T2 { int x:1; }; //
struct T3 { char a,b,c,d; long long x:1; }; //
struct T4 { char a,b,c,d,e,f,g,h; long long x:1; }; //
struct T5 { char a,b,c,d,e,f,g; long long x:1; }; //
struct S1 { long long int f:1; }; //
struct S2 { int x:1; int y:1; }; //
struct S3 { short c; int x:1; unsigned y:1; }; //
struct S4 { int x:1; short y:1; }; //
struct S5 { short x:1; int y:1; }; //
struct S6 { short x:1; short y:1; }; //
struct S7 { short x:1; int y:1; long long z:1; }; //
struct S8 { char a; char b:1; short c:2; }; //
struct S8A { char b:1; short c:2; }; //
struct S8B { char a; short b:1; char c:2; }; //
struct S8C { char a; int b:1; }; //
struct S9 { char a; char b:2; short c:9; }; //
struct S10 { }; //
struct S11 { int :0; }; //
struct S12 { int :0; int x; }; //
struct S13 { unsigned x:12; unsigned x1:1; unsigned x2:1; unsigned x3:1; unsigned x4:1; int w; }; //
struct S14 { char a; char b:4; int c:30; }; //
struct S15 { char a; char b:2; int c:9; }; //
struct S16 { int :32; }; //
struct S17 { int a:32; }; //
struct S18 { char a; long long :0; char b; }; //
struct A0 { int a; long long b:34, c:4; }; //
struct A1 { int a; unsigned b:11; int c; }; //
struct A2 { int a; unsigned b:11, c:5, d:16; //
int e; };
struct A3 { int a; unsigned b:11, c:5, :0, d:16; //
int e; };
struct A4 { int a:8; short b:7; //
unsigned int c:29; };
struct A5 { char a:7, b:2; }; //
struct A6 { char a:7; short b:2; }; //
struct A7 { short a:8; long b:16; int c; //
char d:7; };
struct A8 { short a:8; long b:16; int :0; //
char c:7; };
struct A9 { unsigned short a:8; long b:16; //
unsigned long c:29; long long d:9;
unsigned long e:2, f:31; };
struct A10 { unsigned short a:8; char b; }; //
struct A11 { char a; int b:5, c:11, :0, d:8; //
struct { int ee:8; } e; };
int main()
{
/* MS produces identical results for 32 and 64 bit compiles,
* DM is 32 bit only
*/
printf(" DM | MS | P32 | P64\n");
printf("T0 = %2d %d || 1 1 | 1 1 | 1 1 | 1 1\n", (int)sizeof(struct T0), (int)_Alignof(struct T0));
printf("T1 = %2d %d || 2 2 | 2 2 | 2 2 | 2 2\n", (int)sizeof(struct T1), (int)_Alignof(struct T1));
printf("T2 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", (int)sizeof(struct T2), (int)_Alignof(struct T2));
printf("T3 = %2d %d || 16 8 | 16 8 | 8 4 | 8 8\n", (int)sizeof(struct T3), (int)_Alignof(struct T3));
printf("T4 = %2d %d || 16 8 | 16 8 | 12 4 | 16 8\n", (int)sizeof(struct T4), (int)_Alignof(struct T4));
printf("T5 = %2d %d || 16 8 | 16 8 | 8 4 | 8 8\n", (int)sizeof(struct T5), (int)_Alignof(struct T5));
printf("S1 = %2d %d || 8 8 | 8 8 | 4 4 | 8 8\n", (int)sizeof(struct S1), (int)_Alignof(struct S1));
printf("S2 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", (int)sizeof(struct S2), (int)_Alignof(struct S2));
printf("S3 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", (int)sizeof(struct S3), (int)_Alignof(struct S3));
printf("S4 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", (int)sizeof(struct S4), (int)_Alignof(struct S4));
printf("S5 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", (int)sizeof(struct S5), (int)_Alignof(struct S5));
printf("S6 = %2d %d || 2 2 | 2 2 | 2 2 | 2 2\n", (int)sizeof(struct S6), (int)_Alignof(struct S6));
printf("S7 = %2d %d || 16 8 | 16 8 | 4 4 | 8 8\n", (int)sizeof(struct S7), (int)_Alignof(struct S7));
printf("S8 = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", (int)sizeof(struct S8), (int)_Alignof(struct S8));
printf("S8A = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", (int)sizeof(struct S8A), (int)_Alignof(struct S8A));
printf("S8B = %2d %d || 6 2 | 6 2 | 2 2 | 2 2\n", (int)sizeof(struct S8B), (int)_Alignof(struct S8B));
printf("S8C = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", (int)sizeof(struct S8C), (int)_Alignof(struct S8C));
printf("S9 = %2d %d || 4 2 | 4 2 | 4 2 | 4 2\n", (int)sizeof(struct S9), (int)_Alignof(struct S9));
printf("S10 = %2d %d || 0 0 | * * | 0 1 | 0 1\n", (int)sizeof(struct S10), (int)_Alignof(struct S10)); // MS doesn't compile
printf("S11 = %2d %d || 0 0 | 4 1 | 0 1 | 0 1\n", (int)sizeof(struct S11), (int)_Alignof(struct S11));
printf("S12 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", (int)sizeof(struct S12), (int)_Alignof(struct S12));
printf("S13 = %2d %d || 8 4 | 8 4 | 8 4 | 8 4\n", (int)sizeof(struct S13), (int)_Alignof(struct S13));
printf("S14 = %2d %d || 8 4 | 8 4 | 8 4 | 8 4\n", (int)sizeof(struct S14), (int)_Alignof(struct S14));
printf("S15 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", (int)sizeof(struct S15), (int)_Alignof(struct S15));
printf("S16 = %2d %d || 0 0 | 4 4 | 4 1 | 4 1\n", (int)sizeof(struct S16), (int)_Alignof(struct S16));
printf("S17 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", (int)sizeof(struct S17), (int)_Alignof(struct S17));
printf("S18 = %2d %d || 2 1 | 2 1 | 5 1 | 9 1\n", (int)sizeof(struct S18), (int)_Alignof(struct S18));
printf("A0 = %2d %d || 16 8 | 16 8 | 12 4 | 16 8\n", (int)sizeof(struct A0), (int)_Alignof(struct A0));
printf("A1 = %2d %d || 12 4 | 12 4 | 12 4 | 12 4\n", (int)sizeof(struct A1), (int)_Alignof(struct A1));
printf("A2 = %2d %d || 12 4 | 12 4 | 12 4 | 12 4\n", (int)sizeof(struct A2), (int)_Alignof(struct A2));
printf("A3 = %2d %d || 16 4 | 16 4 | 16 4 | 16 4\n", (int)sizeof(struct A3), (int)_Alignof(struct A3));
printf("A4 = %2d %d || 12 4 | 12 4 | 8 4 | 8 4\n", (int)sizeof(struct A4), (int)_Alignof(struct A4));
printf("A5 = %2d %d || 2 1 | 2 1 | 2 1 | 2 1\n", (int)sizeof(struct A5), (int)_Alignof(struct A5));
printf("A6 = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", (int)sizeof(struct A6), (int)_Alignof(struct A6));
printf("A7 = %2d %d || 16 4 | 16 4 | 12 4 | 16 8\n", (int)sizeof(struct A7), (int)_Alignof(struct A7));
printf("A8 = %2d %d || 12 4 | 12 4 | 8 4 | 8 8\n", (int)sizeof(struct A8), (int)_Alignof(struct A8));
printf("A9 = %2d %d || 32 8 | 32 8 | 16 4 | 16 8\n", (int)sizeof(struct A9), (int)_Alignof(struct A9));
printf("A10 = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", (int)sizeof(struct A10), (int)_Alignof(struct A10));
printf("A11 = %2d %d || 16 4 | 16 4 | 12 4 | 12 4\n", (int)sizeof(struct A11), (int)_Alignof(struct A11));
{
struct S9 s;
unsigned x;
*(unsigned *)&s = 0;
s.b = 2; s.c = 3;
x = *(unsigned *)&s;
printf("S9 = x%x\n", x);
}
{
struct S14 s = { 1, 2, 3 };
unsigned long long v;
*(long long *)&s = 0;
s.a = 1;
s.b = 2;
s.c = 3;
v = *(unsigned long long *)&s;
printf("S14 = x%llx\n", v);
}
{
struct S15 s = { 1,2,3 };
unsigned x;
*(unsigned *)&s = 0;
s.a = 1; s.b = 2; s.c = 3;
x = *(unsigned *)&s;
printf("S15 = x%x\n", x);
}
{
struct S18 s;
printf("S18 = %d should be %d\n", (int)(&s.b - &s.a), is64bit() ? 8 : 4);
}
{
struct A0 s;
long long x;
*(long long *)&s = 0;
s.a = 1; s.b = 15;
x = *(long long *)&s;
printf("A0 = x%llx\n", x);
}
return 0;
}

View file

@ -1,196 +0,0 @@
/* test bitfields for Digital Mars
* Note that this test is for win32 only
*
* REQUIRED_ARGS: -preview=bitfields
* DISABLED: win32mscoff win64 linux freebsd osx
* RUN_OUTPUT:
---
DM | MS | P32 | P64
T0 = 1 1 || 1 1 | 1 1 | 1 1 | 1 1
T1 = 2 2 || 2 2 | 2 2 | 2 2 | 2 2
T2 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4
T3 = 16 8 || 16 8 | 16 8 | 8 4 | 8 8
T4 = 16 8 || 16 8 | 16 8 | 12 4 | 16 8
T5 = 16 8 || 16 8 | 16 8 | 8 4 | 8 8
S1 = 8 8 || 8 8 | 8 8 | 4 4 | 8 8
S2 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4
S3 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4
S4 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4
S5 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4
S6 = 2 2 || 2 2 | 2 2 | 2 2 | 2 2
S7 = 16 8 || 16 8 | 16 8 | 4 4 | 8 8
S8 = 4 2 || 4 2 | 4 2 | 2 2 | 2 2
S8A = 4 2 || 4 2 | 4 2 | 2 2 | 2 2
S8B = 6 2 || 6 2 | 6 2 | 2 2 | 2 2
S8C = 8 4 || 8 4 | 8 4 | 4 4 | 4 4
S9 = 4 2 || 4 2 | 4 2 | 4 2 | 4 2
S10 = 1 1 || 0 0 | * * | 0 1 | 0 1
S11 = 1 1 || 0 0 | 4 1 | 0 1 | 0 1
S12 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4
S13 = 8 4 || 8 4 | 8 4 | 8 4 | 8 4
S14 = 8 4 || 8 4 | 8 4 | 8 4 | 8 4
S15 = 8 4 || 8 4 | 8 4 | 4 4 | 4 4
S16 = 1 1 || 0 0 | 4 4 | 4 1 | 4 1
S17 = 4 4 || 4 4 | 4 4 | 4 4 | 4 4
S18 = 2 1 || 2 1 | 2 1 | 5 1 | 9 1
A0 = 16 8 || 16 8 | 16 8 | 12 4 | 16 8
A1 = 12 4 || 12 4 | 12 4 | 12 4 | 12 4
A2 = 12 4 || 12 4 | 12 4 | 12 4 | 12 4
A3 = 16 4 || 16 4 | 16 4 | 16 4 | 16 4
A4 = 12 4 || 12 4 | 12 4 | 8 4 | 8 4
A5 = 2 1 || 2 1 | 2 1 | 2 1 | 2 1
A6 = 4 2 || 4 2 | 4 2 | 2 2 | 2 2
A7 = 16 4 || 16 4 | 16 4 | 12 4 | 16 8
A8 = 12 4 || 12 4 | 12 4 | 8 4 | 8 8
A9 = 32 8 || 32 8 | 32 8 | 16 4 | 16 8
A10 = 4 2 || 4 2 | 4 2 | 2 2 | 2 2
A11 = 16 4 || 16 4 | 16 4 | 12 4 | 12 4
S9 = x30200
S14 = x300000201
S15 = x201
S18 = 1 should be 4
A0 = x1
---
*/
import core.stdc.stdio;
int is64bit() { return size_t.sizeof == 8; } // otherwise assume 32 bit
/*************************************************************/
struct T0 { ubyte x:1; }; //
struct T1 { short x:1; }; //
struct T2 { int x:1; }; //
struct T3 { ubyte a,b,c,d; long x:1; }; //
struct T4 { ubyte a,b,c,d,e,f,g,h; long x:1; }; //
struct T5 { ubyte a,b,c,d,e,f,g; long x:1; }; //
struct S1 { long f:1; }; //
struct S2 { int x:1; int y:1; }; //
struct S3 { short c; int x:1; uint y:1; }; //
struct S4 { int x:1; short y:1; }; //
struct S5 { short x:1; int y:1; }; //
struct S6 { short x:1; short y:1; }; //
struct S7 { short x:1; int y:1; long z:1; }; //
struct S8 { ubyte a; ubyte b:1; short c:2; }; //
struct S8A { ubyte b:1; short c:2; }; //
struct S8B { ubyte a; short b:1; ubyte c:2; }; //
struct S8C { ubyte a; int b:1; }; //
struct S9 { ubyte a; ubyte b:2; short c:9; }; //
struct S10 { }; // sizeof differs from C treatment
struct S11 { int :0; }; // sizeof differs from C treatment
struct S12 { int :0; int x; }; //
struct S13 { uint x:12; uint x1:1; uint x2:1; uint x3:1; uint x4:1; int w; }; //
struct S14 { ubyte a; ubyte b:4; int c:30; }; //
struct S15 { ubyte a; ubyte b:2; int c:9; }; //
struct S16 { int :32; }; // sizeof differs from C treatment
struct S17 { int a:32; }; //
struct S18 { ubyte a; long :0; ubyte b; }; //
struct A0 { int a; long b:34, c:4; }; //
struct A1 { int a; uint b:11; int c; }; //
struct A2 { int a; uint b:11, c:5, d:16; //
int e; };
struct A3 { int a; uint b:11, c:5, :0, d:16; //
int e; };
struct A4 { int a:8; short b:7; //
uint c:29; };
struct A5 { ubyte a:7, b:2; }; //
struct A6 { ubyte a:7; short b:2; }; //
struct A7 { short a:8; int b:16; int c; //
ubyte d:7; };
struct A8 { short a:8; int b:16; int :0; //
ubyte c:7; };
struct A9 { ushort a:8; int b:16; //
uint c:29; long d:9;
uint e:2, f:31; };
struct A10 { ushort a:8; ubyte b; }; //
struct A11 { ubyte a; int b:5, c:11, :0, d:8; //
struct { int ee:8; } };
int main()
{
/* MS produces identical results for 32 and 64 bit compiles,
* DM is 32 bit only
*/
printf(" DM | MS | P32 | P64\n");
printf("T0 = %2d %d || 1 1 | 1 1 | 1 1 | 1 1\n", cast(int)T0.sizeof, cast(int)T0.alignof);
printf("T1 = %2d %d || 2 2 | 2 2 | 2 2 | 2 2\n", cast(int)T1.sizeof, cast(int)T1.alignof);
printf("T2 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", cast(int)T2.sizeof, cast(int)T2.alignof);
printf("T3 = %2d %d || 16 8 | 16 8 | 8 4 | 8 8\n", cast(int)T3.sizeof, cast(int)T3.alignof);
printf("T4 = %2d %d || 16 8 | 16 8 | 12 4 | 16 8\n", cast(int)T4.sizeof, cast(int)T4.alignof);
printf("T5 = %2d %d || 16 8 | 16 8 | 8 4 | 8 8\n", cast(int)T5.sizeof, cast(int)T5.alignof);
printf("S1 = %2d %d || 8 8 | 8 8 | 4 4 | 8 8\n", cast(int)S1.sizeof, cast(int)S1.alignof);
printf("S2 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", cast(int)S2.sizeof, cast(int)S2.alignof);
printf("S3 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", cast(int)S3.sizeof, cast(int)S3.alignof);
printf("S4 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", cast(int)S4.sizeof, cast(int)S4.alignof);
printf("S5 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", cast(int)S5.sizeof, cast(int)S5.alignof);
printf("S6 = %2d %d || 2 2 | 2 2 | 2 2 | 2 2\n", cast(int)S6.sizeof, cast(int)S6.alignof);
printf("S7 = %2d %d || 16 8 | 16 8 | 4 4 | 8 8\n", cast(int)S7.sizeof, cast(int)S7.alignof);
printf("S8 = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", cast(int)S8.sizeof, cast(int)S8.alignof);
printf("S8A = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", cast(int)S8A.sizeof, cast(int)S8A.alignof);
printf("S8B = %2d %d || 6 2 | 6 2 | 2 2 | 2 2\n", cast(int)S8B.sizeof, cast(int)S8B.alignof);
printf("S8C = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", cast(int)S8C.sizeof, cast(int)S8C.alignof);
printf("S9 = %2d %d || 4 2 | 4 2 | 4 2 | 4 2\n", cast(int)S9.sizeof, cast(int)S9.alignof);
printf("S10 = %2d %d || 0 0 | * * | 0 1 | 0 1\n", cast(int)S10.sizeof, cast(int)S10.alignof); // MS doesn't compile
printf("S11 = %2d %d || 0 0 | 4 1 | 0 1 | 0 1\n", cast(int)S11.sizeof, cast(int)S11.alignof);
printf("S12 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", cast(int)S12.sizeof, cast(int)S12.alignof);
printf("S13 = %2d %d || 8 4 | 8 4 | 8 4 | 8 4\n", cast(int)S13.sizeof, cast(int)S13.alignof);
printf("S14 = %2d %d || 8 4 | 8 4 | 8 4 | 8 4\n", cast(int)S14.sizeof, cast(int)S14.alignof);
printf("S15 = %2d %d || 8 4 | 8 4 | 4 4 | 4 4\n", cast(int)S15.sizeof, cast(int)S15.alignof);
printf("S16 = %2d %d || 0 0 | 4 4 | 4 1 | 4 1\n", cast(int)S16.sizeof, cast(int)S16.alignof);
printf("S17 = %2d %d || 4 4 | 4 4 | 4 4 | 4 4\n", cast(int)S17.sizeof, cast(int)S17.alignof);
printf("S18 = %2d %d || 2 1 | 2 1 | 5 1 | 9 1\n", cast(int)S18.sizeof, cast(int)S18.alignof);
printf("A0 = %2d %d || 16 8 | 16 8 | 12 4 | 16 8\n", cast(int)A0.sizeof, cast(int)A0.alignof);
printf("A1 = %2d %d || 12 4 | 12 4 | 12 4 | 12 4\n", cast(int)A1.sizeof, cast(int)A1.alignof);
printf("A2 = %2d %d || 12 4 | 12 4 | 12 4 | 12 4\n", cast(int)A2.sizeof, cast(int)A2.alignof);
printf("A3 = %2d %d || 16 4 | 16 4 | 16 4 | 16 4\n", cast(int)A3.sizeof, cast(int)A3.alignof);
printf("A4 = %2d %d || 12 4 | 12 4 | 8 4 | 8 4\n", cast(int)A4.sizeof, cast(int)A4.alignof);
printf("A5 = %2d %d || 2 1 | 2 1 | 2 1 | 2 1\n", cast(int)A5.sizeof, cast(int)A5.alignof);
printf("A6 = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", cast(int)A6.sizeof, cast(int)A6.alignof);
printf("A7 = %2d %d || 16 4 | 16 4 | 12 4 | 16 8\n", cast(int)A7.sizeof, cast(int)A7.alignof);
printf("A8 = %2d %d || 12 4 | 12 4 | 8 4 | 8 8\n", cast(int)A8.sizeof, cast(int)A8.alignof);
printf("A9 = %2d %d || 32 8 | 32 8 | 16 4 | 16 8\n", cast(int)A9.sizeof, cast(int)A9.alignof);
printf("A10 = %2d %d || 4 2 | 4 2 | 2 2 | 2 2\n", cast(int)A10.sizeof, cast(int)A10.alignof);
printf("A11 = %2d %d || 16 4 | 16 4 | 12 4 | 12 4\n", cast(int)A11.sizeof, cast(int)A11.alignof);
{
S9 s;
uint x;
*cast(uint *)&s = 0;
s.b = 2; s.c = 3;
x = *cast(uint *)&s;
printf("S9 = x%x\n", x);
}
{
S14 s = { 1, 2, 3 };
ulong v;
*cast(long *)&s = 0;
s.a = 1;
s.b = 2;
s.c = 3;
v = *cast(ulong *)&s;
printf("S14 = x%llx\n", v);
}
{
S15 s = { 1,2,3 };
uint x;
*cast(uint *)&s = 0;
s.a = 1; s.b = 2; s.c = 3;
x = *cast(uint *)&s;
printf("S15 = x%x\n", x);
}
{
S18 s;
printf("S18 = %d should be %d\n", cast(int)(&s.b - &s.a), is64bit() ? 8 : 4);
}
{
A0 s;
long x;
*cast(long *)&s = 0;
s.a = 1; s.b = 15;
x = *cast(long *)&s;
printf("A0 = x%llx\n", x);
}
return 0;
}

View file

@ -5,10 +5,10 @@ PERMUTE_ARGS:
ARG_SETS: -version=Single ARG_SETS: -version=Single
ARG_SETS: -version=Double ARG_SETS: -version=Double
ARG_SETS(win32mscoff windows64): -version=Extended ../src/dmd/root/longdouble.d ARG_SETS(windows): -version=Extended ../src/dmd/root/longdouble.d
ARG_SETS(win32mscoff windows64): -version=ExtendedSoft ../src/dmd/root/longdouble.d ARG_SETS(windows): -version=ExtendedSoft ../src/dmd/root/longdouble.d
ARG_SETS(linux osx win32): -version=Extended ARG_SETS(linux osx): -version=Extended
*/ */
module test.runnable.paranoia; module test.runnable.paranoia;

View file

@ -1,4 +1,4 @@
// DISABLED: win32mscoff win64 freebsd // DISABLED: win freebsd
// https://issues.dlang.org/show_bug.cgi?id=23886 // https://issues.dlang.org/show_bug.cgi?id=23886

View file

@ -8,9 +8,6 @@
// N.B MSVC doesn't have a C++11 switch, but it defaults to the latest fully-supported standard // N.B MSVC doesn't have a C++11 switch, but it defaults to the latest fully-supported standard
// Broken for unknown reasons since the OMF => MsCOFF switch
// DISABLED: win32omf
import core.stdc.stdio; import core.stdc.stdio;
import core.stdc.stdarg; import core.stdc.stdarg;
import core.stdc.config; import core.stdc.config;

View file

@ -175,15 +175,6 @@ immutable(EnvData) processEnvironment()
envData.ccompiler = environment.get("CC"); envData.ccompiler = environment.get("CC");
envData.cxxcompiler = environment.get("CXX"); envData.cxxcompiler = environment.get("CXX");
envData.model = envGetRequired("MODEL"); envData.model = envGetRequired("MODEL");
if (envData.os == "windows" && envData.model == "32")
{
// FIXME: we need to translate the default 32-bit model (COFF) on Windows to legacy `32mscoff`.
// Reason: OMF-specific tests are currently specified like this:
// DISABLED: win32mscoff win64 …
// and `DISABLED: win32` would disable it for `win32omf` too.
// So we'd need something like an `ENABLED: win32omf` parameter to restrict tests to specific platforms.
envData.model = "32mscoff";
}
envData.required_args = environment.get("REQUIRED_ARGS"); envData.required_args = environment.get("REQUIRED_ARGS");
envData.dobjc = environment.get("D_OBJC") == "1"; envData.dobjc = environment.get("D_OBJC") == "1";
envData.coverage_build = environment.get("DMD_TEST_COVERAGE") == "1"; envData.coverage_build = environment.get("DMD_TEST_COVERAGE") == "1";
@ -196,35 +187,17 @@ immutable(EnvData) processEnvironment()
if (envData.ccompiler.empty) if (envData.ccompiler.empty)
{ {
if (envData.os != "windows") if (envData.os == "windows")
envData.ccompiler = "cc";
else if (envData.model == "32omf")
envData.ccompiler = "dmc";
else if (envData.model == "64")
envData.ccompiler = "cl";
else if (envData.model == "32mscoff")
envData.ccompiler = "cl"; envData.ccompiler = "cl";
else else
{ envData.ccompiler = "cc";
writeln("Can't determine C compiler (CC). Unknown $OS$MODEL combination: ", envData.os, envData.model);
throw new SilentQuit();
}
} }
if (envData.cxxcompiler.empty) if (envData.cxxcompiler.empty)
{ {
if (envData.os != "windows") if (envData.os == "windows")
envData.cxxcompiler = "c++";
else if (envData.model == "32omf")
envData.cxxcompiler = "dmc";
else if (envData.model == "64")
envData.cxxcompiler = "cl";
else if (envData.model == "32mscoff")
envData.cxxcompiler = "cl"; envData.cxxcompiler = "cl";
else else
{ envData.cxxcompiler = "c++";
writeln("Can't determine C++ compiler (CXX). Unknown $OS$MODEL combination: ", envData.os, envData.model);
throw new SilentQuit();
}
} }
version (Windows) {} else version (Windows) {} else
@ -547,9 +520,7 @@ private bool consumeNextToken(ref string file, const string token, ref const Env
file = file.stripLeft!(ch => ch == ' '); // Don't read line breaks file = file.stripLeft!(ch => ch == ' '); // Don't read line breaks
// Check if the current environment matches an entry in oss, which can either // Check if the current environment matches an entry in oss, which can either
// be an OS (e.g. "linux") or a combination of OS + MODEL (e.g. "windows32omf"). // be an OS (e.g. "linux") or a combination of OS + MODEL (e.g. "windows32").
// The latter is important on windows because m32omf might require other
// parameters than m32mscoff/m64.
if (!oss.canFind!(o => o.skipOver(envData.os) && (o.empty || o == envData.model))) if (!oss.canFind!(o => o.skipOver(envData.os) && (o.empty || o == envData.model)))
continue; // Parameter was skipped continue; // Parameter was skipped
} }
@ -646,9 +617,8 @@ string getDisabledReason(string[] disabledPlatforms, const ref EnvData envData)
unittest unittest
{ {
immutable EnvData win32omf = { os: "windows", model: "32omf" }; immutable EnvData win32 = { os: "windows", model: "32" };
immutable EnvData win32mscoff = { os: "windows", model: "32mscoff" }; immutable EnvData win64 = { os: "windows", model: "64" };
immutable EnvData win64 = { os: "windows", model: "64" };
assert(getDisabledReason(null, win64) is null); assert(getDisabledReason(null, win64) is null);
@ -658,11 +628,8 @@ unittest
assert(getDisabledReason([ "linux", "win64" ], win64) == "on win64"); assert(getDisabledReason([ "linux", "win64" ], win64) == "on win64");
assert(getDisabledReason([ "linux", "win32" ], win64) is null); assert(getDisabledReason([ "linux", "win32" ], win64) is null);
assert(getDisabledReason([ "win32mscoff" ], win32mscoff) == "on win32mscoff"); assert(getDisabledReason([ "win32" ], win32) == "on win32");
assert(getDisabledReason([ "win32mscoff" ], win32omf) is null); assert(getDisabledReason([ "win32" ], win64) is null);
assert(getDisabledReason([ "win32" ], win32mscoff) == "on win32");
assert(getDisabledReason([ "win32" ], win32omf) == "on win32");
} }
/** /**
* Reads the test configuration from the source code (using `findTestParameter` and * Reads the test configuration from the source code (using `findTestParameter` and
@ -1126,11 +1093,7 @@ bool collectExtraSources (in string input_dir, in string output_dir, in string[]
auto curObj = output_dir ~ envData.sep ~ cur ~ envData.obj; auto curObj = output_dir ~ envData.sep ~ cur ~ envData.obj;
bool is_cpp_file = cur.extension() == ".cpp"; bool is_cpp_file = cur.extension() == ".cpp";
string command = quoteSpaces(is_cpp_file ? cxxcompiler : ccompiler); string command = quoteSpaces(is_cpp_file ? cxxcompiler : ccompiler);
if (envData.model == "32omf") // dmc.exe if (envData.os == "windows") // cl.exe
{
command ~= " -c "~curSrc~" -o"~curObj;
}
else if (envData.os == "windows") // cl.exe
{ {
command ~= ` /c /nologo `~curSrc~` /Fo`~curObj; command ~= ` /c /nologo `~curSrc~` /Fo`~curObj;
} }
@ -1413,8 +1376,8 @@ bool compareOutput(string output, string refoutput, const ref EnvData envData)
toSkip = chunk; toSkip = chunk;
break; break;
} }
// Match against OS or model (accepts "32mscoff" as "32") // Match against OS or model
else if (searchResult[0].splitter('+').all!(c => c.among(envData.os, envData.model, envData.model[0 .. min(2, $)]))) else if (searchResult[0].splitter('+').all!(c => c.among(envData.os, envData.model)))
{ {
toSkip = searchResult[2]; toSkip = searchResult[2];
break; break;
@ -1487,7 +1450,7 @@ unittest
const emptyFmt = "On <$?:windows=abc|$> use <$?:posix=$>!"; const emptyFmt = "On <$?:windows=abc|$> use <$?:posix=$>!";
assert(compareOutput("On <> use <>!", emptyFmt, ed)); assert(compareOutput("On <> use <>!", emptyFmt, ed));
ed.model = "32mscoff"; ed.model = "32";
assert(compareOutput("size_t is uint!", "size_t is $?:32=uint|64=ulong$!", ed)); assert(compareOutput("size_t is uint!", "size_t is $?:32=uint|64=ulong$!", ed));
assert(compareOutput("no", "$?:posix+64=yes|no$", ed)); assert(compareOutput("no", "$?:posix+64=yes|no$", ed));
@ -1872,11 +1835,10 @@ int tryMain(string[] args)
{ {
toCleanup ~= test_app_dmd; toCleanup ~= test_app_dmd;
version(Windows) version(Windows)
if (envData.model != "32omf") {
{ toCleanup ~= test_app_dmd_base ~ to!string(permuteIndex) ~ ".ilk";
toCleanup ~= test_app_dmd_base ~ to!string(permuteIndex) ~ ".ilk"; toCleanup ~= test_app_dmd_base ~ to!string(permuteIndex) ~ ".pdb";
toCleanup ~= test_app_dmd_base ~ to!string(permuteIndex) ~ ".pdb"; }
}
if (testArgs.gdbScript is null) if (testArgs.gdbScript is null)
{ {

View file

@ -375,10 +375,7 @@ $(abspath ../generated/$(OS)/$(BUILD)/$(MODEL)/dmd$(DOTEXE)): ../generated/$(OS)
################### C/ASM Targets ############################ ################### C/ASM Targets ############################
OBJS:=$(ROOT)/errno_c$(DOTOBJ) OBJS:=$(ROOT)/errno_c$(DOTOBJ)
ifeq (32omf,$(MODEL)) ifneq (windows,$(OS))
# minit.asm is only used for -m32omf on Windows; there's a pre-built minit.obj
OBJS+=src/rt/minit$(DOTOBJ)
else ifneq (windows,$(OS))
OBJS+=$(ROOT)/threadasm$(DOTOBJ) $(ROOT)/valgrind$(DOTOBJ) OBJS+=$(ROOT)/threadasm$(DOTOBJ) $(ROOT)/valgrind$(DOTOBJ)
endif endif
@ -434,12 +431,7 @@ endif
.PHONY : unittest .PHONY : unittest
ifeq (1,$(BUILD_WAS_SPECIFIED)) ifeq (1,$(BUILD_WAS_SPECIFIED))
ifeq (32omf,$(MODEL))
unittest :
@echo "Skipping druntime unittests because they cannot be linked on Win32 + OMF due to OPTLINK issues."
else
unittest : $(UT_MODULES) $(addsuffix /.run,$(ADDITIONAL_TESTS)) unittest : $(UT_MODULES) $(addsuffix /.run,$(ADDITIONAL_TESTS))
endif
else else
unittest : unittest-debug unittest-release unittest : unittest-debug unittest-release
unittest-%: target unittest-%: target
@ -519,7 +511,7 @@ benchmark-compile-only: $(ROOT)/benchmark$(DOTEXE) $(DMD)
MANIFEST = $(shell git ls-tree --name-only -r HEAD) MANIFEST = $(shell git ls-tree --name-only -r HEAD)
CWS_MAKEFILES = $(filter mak/% %.mak %/Makefile,$(MANIFEST)) CWS_MAKEFILES = $(filter mak/% %.mak %/Makefile,$(MANIFEST))
NOT_MAKEFILES = $(filter-out $(CWS_MAKEFILES) src/rt/minit.obj test/%.exp,$(MANIFEST)) NOT_MAKEFILES = $(filter-out $(CWS_MAKEFILES) test/%.exp,$(MANIFEST))
GREP = grep GREP = grep
checkwhitespace: checkwhitespace:

View file

@ -1,114 +0,0 @@
;_ minit.asm
; Module initialization support.
;
; Copyright: Copyright Digital Mars 2000 - 2010.
; License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
; Authors: Walter Bright
;
; Copyright Digital Mars 2000 - 2010.
; Distributed under the Boost Software License, Version 1.0.
; (See accompanying file LICENSE or copy at
; http://www.boost.org/LICENSE_1_0.txt)
;
; With VC installed, build with:
; ml /omf minit.asm
.model FLAT
ifdef _WIN32
DATAGRP EQU FLAT
else
DATAGRP EQU DGROUP
endif
; Provide a default resolution for weak extern records, no way in C
; to define an omf symbol with a specific value
public __nullext
__nullext equ 0
extrn __moduleinfo_array:near
; This bit of assembler is needed because, from C or D, one cannot
; specify the names of data segments. Why does this matter?
; All the ModuleInfo pointers are placed into a segment named 'FM'.
; The order in which they are placed in 'FM' is arbitrarily up to the linker.
; In order to walk all the pointers, we need to be able to find the
; beginning and the end of the 'FM' segment.
; This is done by bracketing the 'FM' segment with two other, empty,
; segments named 'FMB' and 'FME'. Since this module is the only one that
; ever refers to 'FMB' and 'FME', we get to control the order in which
; these segments appear relative to 'FM' by using a GROUP statement.
; So, we have in memory:
; FMB empty segment
; FM contains all the pointers
; FME empty segment
; and finding the limits of FM is as easy as taking the address of FMB
; and the address of FME.
; These segments bracket FM, which contains the list of ModuleInfo pointers
FMB segment dword use32 public 'DATA'
FMB ends
FM segment dword use32 public 'DATA'
FM ends
FME segment dword use32 public 'DATA'
FME ends
; This leaves room in the _fatexit() list for _moduleDtor()
XOB segment dword use32 public 'BSS'
XOB ends
XO segment dword use32 public 'BSS'
dd ?
XO ends
XOE segment dword use32 public 'BSS'
XOE ends
DGROUP group FMB,FM,FME
; These segments bracket DP, which contains the _DATA pointer references
public __DPbegin, __DPend
DPB segment dword use32 public 'CODE'
__DPbegin:
DPB ends
DP segment dword use32 public 'CODE'
DP ends
DPE segment dword use32 public 'CODE'
__DPend:
DPE ends
CGROUP group DPB,DP,DPE
; These segments bracket TP, which contains the TLS pointer references
public __TPbegin, __TPend
TPB segment dword use32 public 'CODE'
__TPbegin:
TPB ends
TP segment dword use32 public 'CODE'
TP ends
TPE segment dword use32 public 'CODE'
__TPend:
TPE ends
CGROUP group TPB,TP,TPE
_TEXT segment para use32 public 'CODE'
assume CS:_TEXT
; extern (C) void _minit();
; Converts array of ModuleInfo pointers to a D dynamic array of them,
; so they can be accessed via D.
; Result is written to:
; extern (C) ModuleInfo[] _moduleinfo_array;
public __minit
__minit:
mov EDX,offset DATAGRP:FMB
mov EAX,offset DATAGRP:FME
mov dword ptr __moduleinfo_array+4,EDX
sub EAX,EDX ; size in bytes of FM segment
shr EAX,2 ; convert to array length
mov dword ptr __moduleinfo_array,EAX
ret
_TEXT ends
end

Binary file not shown.