druntime investigation troubles

Steven Schveighoffer schveiguy at yahoo.com
Wed May 23 12:58:51 PDT 2012


On Wed, 23 May 2012 15:46:16 -0400, Jacob Carlborg <doob at me.com> wrote:

> On 2012-05-23 19:32, Denis Shelomovskij wrote:
>
>> What call have you found in "_d_criticalenter"?
>>
>> By the way, `_STI_critical_init` is called before C main (uncomment
>> printf's and check), so it is definitely called not by druntime.
>>
>
> "_STI_critical_init" is called here:
>
> *  
> https://github.com/D-Programming-Language/druntime/blob/master/src/rt/critical_.d#L149
>
> *  
> https://github.com/D-Programming-Language/druntime/blob/master/src/rt/critical.c#L124
>
> *  
> https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L364
>
> Found another one:
>
> *  
> https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L255
>
> I assume, and hope, that only one of these are actually called. That's  
> why I said all this is a big mess.
>
> The last one is only called if the runtime is manually initialized, i.e.  
> via C using the "rt_init" function. Which is stupid, "rt_init" should be  
> called from the C main function as well. There's unnecessary code  
> duplication here.
>

+1

dmain2 has that "magic runtime" feel where you look at it and are so  
confused that you are afraid to touch anything :P

-Steve


More information about the Digitalmars-d-learn mailing list