On May 23, 2012, at 7:49 AM, Jacob Carlborg wrote: > On 2012-05-23 13:31, Steven Schveighoffer wrote: >> On Wed, 23 May 2012 02:21:14 -0400, Jacob Carlborg <d...@me.com> wrote: >> >>> On 2012-05-22 23:01, Steven Schveighoffer wrote: >>> >>>> It looks like code that is not called on Windows. Which doesn't make >>>> sense. It would seem that you must initialize a critical section in >>>> order to use it. >>>> >>>> I can't find any reference to STI_monitor in dmd, dmc, or druntime >>>> source code, except those calls that are done for Posix only. This isn't >>>> some closed-source mystery, I think it is just unused code. >>>> >>>> Sean, does this make sense? Are we using uninitialized critical >>>> sections? >>>> >>>> -Steve >>> >>> I found a call now, it's in "_d_criticalenter", both in critical.c and >>> critical_.d. >>> >> >> OK, so does this mean monitor is only used on Posix, and critical is >> used only on windows? This seems a little weird. Especially since we are >> still compiling monitor.c. >> >> -Steve > > No, there's a "_d_criticalenter" for Posix in critical(_).d/c which calls > "_STI_critical_init". It seems there's a duplicate call for > "_STI_critical_init" on Posix, in dmain2.d and in critical(_).d/c. > > Also this actually looks like a big mess: > > * critical_.d and critical.c contains the same code. critical_.d is used in > the posix makefile. critical.c _and_ critical_.d is used in the win32 makefile > > * "_STI_critical_init" is implemented on both Posix and Windows, but it's > only called on Posix > > * "_STI_critical_init" is called on multiple places on Posix. In dmain2.d and > in "_d_criticalenter".
If I remember correctly, Brad Roberts tried porting the old C critical section code to D a while back and something didn't work right. Both versions of the code still exist, and at some point the D code needs to be sorted and the C code should be thrown away. I suppose I should make this my top priority, when I find the time.