File: mangling_definitions.d

package info (click to toggle)
ldc 1%3A1.30.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 59,248 kB
  • sloc: cpp: 61,598; ansic: 14,545; sh: 1,014; makefile: 972; asm: 510; objc: 135; exp: 48; python: 12
file content (51 lines) | stat: -rw-r--r-- 1,588 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module definitions;

// variables:

extern(C) __gshared int cGlobal = 1;
static assert(cGlobal.mangleof == "cGlobal");

extern(C++, cpp_vars) __gshared int cppGlobal = 2;
version(CRuntime_Microsoft)
    static assert(cppGlobal.mangleof == "?cppGlobal@cpp_vars@@3HA");
else
    static assert(cppGlobal.mangleof == "_ZN8cpp_vars9cppGlobalE");

__gshared int dGlobal = 3;
static assert(dGlobal.mangleof == "_D11definitions7dGlobali");

// functions:

extern(C) int cFunc(double a) { return cGlobal; }
static assert(cFunc.mangleof == "cFunc");

extern(C++, cpp_funcs) int cppFunc(double a) { return cppGlobal; }
version(CRuntime_Microsoft)
    static assert(cppFunc.mangleof == "?cppFunc@cpp_funcs@@YAHN@Z");
else
    static assert(cppFunc.mangleof == "_ZN9cpp_funcs7cppFuncEd");

int dFunc(double a) { return dGlobal; }
static assert(dFunc.mangleof == "_D11definitions5dFuncFdZi");

// naked functions:

version(D_InlineAsm_X86)
    version = AsmX86;
else version(D_InlineAsm_X86_64)
    version = AsmX86;

version(AsmX86)
{
    extern(C) int naked_cFunc(double a) { asm { naked; ret; } }
    static assert(naked_cFunc.mangleof == "naked_cFunc");

    extern(C++, cpp_naked_funcs) int naked_cppFunc(double a) { asm { naked; ret; } }
    version(CRuntime_Microsoft)
        static assert(naked_cppFunc.mangleof == "?naked_cppFunc@cpp_naked_funcs@@YAHN@Z");
    else
        static assert(naked_cppFunc.mangleof == "_ZN15cpp_naked_funcs13naked_cppFuncEd");

    int naked_dFunc(double a) { asm { naked; ret; } }
    static assert(naked_dFunc.mangleof == "_D11definitions11naked_dFuncFdZi");
}