Re: extern(C) in druntime

2014-11-14 Thread Martin Nowak via Digitalmars-d
On 11/10/2014 03:48 PM, Steven Schveighoffer wrote: Opinion from those in the know: When extern(C) is used in druntime, my understanding is that the reason is twofold: 1. Because the compiler requires certain symbols for hooks. 2. To get around some requirements that druntime knows better,

Re: extern(C) in druntime

2014-11-11 Thread Dicebot via Digitalmars-d
On Monday, 10 November 2014 at 23:22:00 UTC, Sean Kelly wrote: On Monday, 10 November 2014 at 23:08:55 UTC, Logan Capaldo wrote: So just to be clear, there are _some_ legitimate uses of extern (C) in druntime, yes? rt_init/rt_term, rt_loadLibrary, thread_init(? think this one can

Re: extern(C) in druntime

2014-11-11 Thread Steven Schveighoffer via Digitalmars-d
On 11/11/14 11:01 AM, Dicebot wrote: On Monday, 10 November 2014 at 23:22:00 UTC, Sean Kelly wrote: On Monday, 10 November 2014 at 23:08:55 UTC, Logan Capaldo wrote: So just to be clear, there are _some_ legitimate uses of extern (C) in druntime, yes? rt_init/rt_term, rt_loadLibrary

extern(C) in druntime

2014-11-10 Thread Steven Schveighoffer via Digitalmars-d
to limit those functions to only things that C supports. Would it make sense to change to use pragma(mangle)? or is there some other reason why we use extern(C) in druntime? I'm asking the old veterans who may know some of the history, i.e. Walter, Sean, etc. If we go this route, we can put more

Re: extern(C) in druntime

2014-11-10 Thread Sean Kelly via Digitalmars-d
allows us not to put this code in the import tree when distributing druntime. In short, extern (C) is often used because you can't forward declare extern (D) functions. It doesn't mean anything about the language used by the function.

Re: extern(C) in druntime

2014-11-10 Thread Dicebot via Digitalmars-d
??? $ cat a.d module a; pragma(mangle, foo) extern(D) void foo() { import std.stdio; writeln(in extern foo); } $ cat b.d module b; pragma(mangle, foo) extern void foo(); void main() { foo(); } $ ./a in extern foo

Re: extern(C) in druntime

2014-11-10 Thread Dicebot via Digitalmars-d
This was an answer to you can't forward declare extern (D) functions

Re: extern(C) in druntime

2014-11-10 Thread Steven Schveighoffer via Digitalmars-d
On 11/10/14 10:40 AM, Dicebot wrote: This was an answer to you can't forward declare extern (D) functions I think Sean's point is that is another historical reason why we used extern(C), back when pragma(mangle) didn't exist. -Steve

Re: extern(C) in druntime

2014-11-10 Thread Sean Kelly via Digitalmars-d
On Monday, 10 November 2014 at 15:52:56 UTC, Steven Schveighoffer wrote: On 11/10/14 10:40 AM, Dicebot wrote: This was an answer to you can't forward declare extern (D) functions I think Sean's point is that is another historical reason why we used extern(C), back when pragma(mangle) didn't

Re: extern(C) in druntime

2014-11-10 Thread Dicebot via Digitalmars-d
?id=8887 (with possibly making any differences compile-time error initially for soft transition) Right now question is, however, are there any legitimate uses of `extern(C)` in druntime or those all can be replaced with `pragma(mangle, XXX) extern(D)`?

Re: extern(C) in druntime

2014-11-10 Thread Sean Kelly via Digitalmars-d
On Monday, 10 November 2014 at 16:59:47 UTC, Dicebot wrote: Right now question is, however, are there any legitimate uses of `extern(C)` in druntime or those all can be replaced with `pragma(mangle, XXX) extern(D)`? I don't think there's any reason to use extern (C) in druntime any more.

Re: extern(C) in druntime

2014-11-10 Thread Dicebot via Digitalmars-d
On Monday, 10 November 2014 at 17:48:04 UTC, Sean Kelly wrote: On Monday, 10 November 2014 at 16:59:47 UTC, Dicebot wrote: Right now question is, however, are there any legitimate uses of `extern(C)` in druntime or those all can be replaced with `pragma(mangle, XXX) extern(D)`? I don't

Re: extern(C) in druntime

2014-11-10 Thread Logan Capaldo via Digitalmars-d
On Monday, 10 November 2014 at 19:44:05 UTC, Dicebot wrote: On Monday, 10 November 2014 at 17:48:04 UTC, Sean Kelly wrote: On Monday, 10 November 2014 at 16:59:47 UTC, Dicebot wrote: Right now question is, however, are there any legitimate uses of `extern(C)` in druntime or those all can

Re: extern(C) in druntime

2014-11-10 Thread Steven Schveighoffer via Digitalmars-d
of `extern(C)` in druntime or those all can be replaced with `pragma(mangle, XXX) extern(D)`? I don't think there's any reason to use extern (C) in druntime any more. I guess that nails it, will make a PR What about things that are meant to be called from C? E.g. `rt_init`/`rt_term`? Those should

Re: extern(C) in druntime

2014-11-10 Thread Logan Capaldo via Digitalmars-d
wrote: Right now question is, however, are there any legitimate uses of `extern(C)` in druntime or those all can be replaced with `pragma(mangle, XXX) extern(D)`? [snip] What about things that are meant to be called from C? E.g. `rt_init`/`rt_term`? Those should remain extern(C). Of course

Re: extern(C) in druntime

2014-11-10 Thread Sean Kelly via Digitalmars-d
On Monday, 10 November 2014 at 23:08:55 UTC, Logan Capaldo wrote: So just to be clear, there are _some_ legitimate uses of extern (C) in druntime, yes? rt_init/rt_term, rt_loadLibrary, thread_init(? think this one can be bootstrapped from D code), ...? Yes. There are a few functions meant

Re: Global extern(C) in druntime header files?

2013-06-06 Thread Gary Willoughby
You are passing a function pointer to a C library, where it will be expected that the function uses the C calling convention. So you have to declare the function as extern(C), otherwise DMD will not compile it as such. That can cause segfaults. Right ok thanks.

Global extern(C) in druntime header files?

2013-06-05 Thread Gary Willoughby
I've been doing some coding and noticed something strange with core.sys.posix.signal. In the following snippet you will see that i have to decorate the handleTermination function with extern(C) to satisfy the type requirements of the bsd_signal function. import core.sys.posix.signal; import

Re: Global extern(C) in druntime header files?

2013-06-05 Thread Jesse Phillips
Not going to look into the file, but I'm pretty sure bsd_signal is function for an external C library right? If that is the case, it must use C calling convention, so yes this is correct.

Re: Global extern(C) in druntime header files?

2013-06-05 Thread Gary Willoughby
On Wednesday, 5 June 2013 at 18:54:45 UTC, Jesse Phillips wrote: Not going to look into the file, but I'm pretty sure bsd_signal is function for an external C library right? If that is the case, it must use C calling convention, so yes this is correct. Ah sorry i wasn't clear. The question

Re: Global extern(C) in druntime header files?

2013-06-05 Thread Mike Parker
On Wednesday, 5 June 2013 at 20:40:59 UTC, Gary Willoughby wrote: On Wednesday, 5 June 2013 at 18:54:45 UTC, Jesse Phillips wrote: Not going to look into the file, but I'm pretty sure bsd_signal is function for an external C library right? If that is the case, it must use C calling