mirror of
https://github.com/openRuyi-Project/gcc.git
synced 2026-09-06 05:51:43 +00:00
D front-end changes: - `delete' is no longer a keyword. - Initializing a field with itself has been deprecated. D runtime changes: - Add Windows BCrypt bindings under `core.sys.windows.bcrypt'. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream b7e3b3b617. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream b7e3b3b617. * libdruntime/Makefile.am (DRUNTIME_DSOURCES_WINDOWS): Add core/sys/windows/bcrypt.d. * libdruntime/Makefile.in: Regenerate. * libdruntime/gcc/sections/elf.d (sizeofTLS): Give function the same mangling as gcc.sections.sizeofTLS. * libdruntime/gcc/sections/package.d: Import core.internal.traits. (pinLoadedLibraries): Mangle as function from rt.sections_elf_shared. (unpinLoadedLibraries): Likewise. (inheritLoadedLibraries): Likewise. (cleanupLoadedLibraries): Likewise. (sizeOfTLS): Add forward declaration.
66 lines
1.6 KiB
D
66 lines
1.6 KiB
D
/**
|
|
*
|
|
* Copyright: Copyright Digital Mars 2011 - 2012.
|
|
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
|
* Authors: Martin Nowak
|
|
* Source: $(DRUNTIMESRC rt/tlsgc.d)
|
|
*/
|
|
|
|
/* Copyright Digital Mars 2011.
|
|
* Distributed under the Boost Software License, Version 1.0.
|
|
* (See accompanying file LICENSE or copy at
|
|
* http://www.boost.org/LICENSE_1_0.txt)
|
|
*/
|
|
module rt.tlsgc;
|
|
|
|
import core.exception : onOutOfMemoryError;
|
|
import core.stdc.stdlib : free, malloc;
|
|
static import rt.sections;
|
|
|
|
/**
|
|
* Per thread record to store thread associated data for garbage collection.
|
|
*/
|
|
struct Data
|
|
{
|
|
typeof(rt.sections.initTLSRanges()) tlsRanges;
|
|
}
|
|
|
|
/**
|
|
* Initialization hook, called FROM each thread. No assumptions about
|
|
* module initialization state should be made.
|
|
*/
|
|
void* init() nothrow @nogc
|
|
{
|
|
auto data = cast(Data*).malloc(Data.sizeof);
|
|
if ( data is null ) onOutOfMemoryError();
|
|
*data = Data.init;
|
|
|
|
// do module specific initialization
|
|
data.tlsRanges = rt.sections.initTLSRanges();
|
|
return data;
|
|
}
|
|
|
|
/**
|
|
* Finalization hook, called FOR each thread. No assumptions about
|
|
* module initialization state should be made.
|
|
*/
|
|
void destroy(void* data) nothrow @nogc
|
|
{
|
|
// do module specific finalization
|
|
rt.sections.finiTLSRanges((cast(Data*)data).tlsRanges);
|
|
|
|
.free(data);
|
|
}
|
|
|
|
alias void delegate(void* pstart, void* pend) nothrow ScanDg;
|
|
|
|
/**
|
|
* GC scan hook, called FOR each thread. Can be used to scan
|
|
* additional thread local memory.
|
|
*/
|
|
void scan(void* data, scope ScanDg dg) nothrow
|
|
{
|
|
// do module specific marking
|
|
rt.sections.scanTLSRanges((cast(Data*)data).tlsRanges, dg);
|
|
}
|