digitalmars.D - core.runtime: loadLibrary and unloadLibrary?
- Rob T (7/7) Jan 09 2013 http://dlang.org/phobos/core_runtime.html#.Runtime.loadLibrary
- Jonathan M Davis (8/14) Jan 09 2013 I don't know what the state of those functions is, but the GC can't hand...
- evilrat (5/25) Jan 10 2013 what's wrong with them? already used it on windows and mac, no
- Jonathan M Davis (7/10) Jan 10 2013 C shared libraries are fine. It's D shared libraries that are the proble...
- evilrat (3/5) Jan 10 2013 tweaks like this http://dlang.org/dll.html#Dcode ?
- Jonathan M Davis (5/12) Jan 10 2013 I don't know any of the details, but that page does seem to discuss at l...
- evilrat (4/19) Jan 10 2013 well anyway thanks for info, this would definitely save some time
- Jacob Carlborg (5/6) Jan 10 2013 Tweaks like this:
- Martin Nowak (3/16) Jan 10 2013 Multiple GC copies are result from an ODR violation. We need a shared
- David Nadlinger (6/9) Jan 10 2013 Could you quickly summarize the current state of your related
- Martin Nowak (2/3) Jan 10 2013 Please have a look at my other post in this thread.
- Jacob Carlborg (4/7) Jan 10 2013 I think we need to start tracking these issues in bugzilla.
- Walter Bright (2/7) Jan 10 2013 This was fixed in D1 long ago. DLLs would use the Executable's gc instan...
- F i L (4/16) Jan 10 2013 Wait.. this was a bit unclear, but it sounded like you just said
- evilrat (5/8) Jan 10 2013 look for the link in this topic to the d runtime source (dmain2.d
- evilrat (2/11) Jan 10 2013 oops, my bad, there is exception throwed.
- Jacob Carlborg (5/8) Jan 10 2013 I'm pretty sure that when he says "DLL" he means DLL on Windows. So the
- Walter Bright (3/9) Jan 11 2013 "DLL" is Windows
- Jacob Carlborg (5/7) Jan 11 2013 Some people have a tendency to mix the terms. I like to call it "dynamic...
- Jacob Carlborg (6/8) Jan 10 2013 Apparently you haven't tested at all on Mac since it's only implemented
- evilrat (5/13) Jan 10 2013 well like i said i don't used D shared libs yet.
- Sean Kelly (11/24) Jan 10 2013 I think the main issue is scanning static memory segments in the shared ...
- Jacob Carlborg (5/7) Jan 10 2013 For loading regular C shared libraries there is no problem, just a
- Jacob Carlborg (5/7) Jan 10 2013 For D shared libraries the problem is that I and Sean have said in other...
- Rob T (7/13) Jan 10 2013 Thanks for the replies.
- Jacob Carlborg (5/7) Jan 10 2013 Yes. But as I've said, these functions are only implemented for Windows....
- Rob T (11/17) Jan 10 2013 OK so these functions are not yet portable as stated in the
- H. S. Teoh (8/14) Jan 10 2013 [...]
- Rob T (5/19) Jan 10 2013 I was referring to the portable D wrapper for dlsym, it seems to
- evilrat (3/12) Jan 10 2013 a "portable" version with what we already know commented in
- Rob T (3/19) Jan 11 2013 Thanks for that! I'll make use of that for my C plugins.
- Jacob Carlborg (7/13) Jan 10 2013 Yes, please file a bug report. Either to fix the documentation or
- Jacob Carlborg (12/18) Jan 10 2013 The state is that they're only implement on Windows:
- Martin Nowak (11/23) Jan 10 2013 Right this is the same state on POSIX and of 2.061 all shared libraries
- Jacob Carlborg (6/17) Jan 10 2013 This code seems to only be fore ELF targets. This is not needed on Mac
- Walter Bright (2/6) Jan 10 2013 Windows or Linux?
- Rob T (3/12) Jan 10 2013 The more immediate need for me is definitely Linux.
- Phil Lavoie (5/12) Jan 11 2013 Speaking of which,
- evilrat (2/17) Jan 11 2013 it's not a desire, it's must have! O_o
- Phil Lavoie (2/22) Jan 11 2013 +1
- Sean Kelly (3/4) Jan 11 2013 whateverReturnedByLoadLib, string name )" function?
- H. S. Teoh (12/18) Jan 11 2013 Is it safe to use void* for representing _both_ variables and functions?
- Sean Kelly (8/26) Jan 11 2013 functions?
I want to load shared libraries during runtime as plug-in's, but the consensus seemed to indicate that DMD is not yet ready for this. I wonder if these functions provide any useful plug-in support or not? Thanks! --rt
Jan 09 2013
On Thursday, January 10, 2013 08:35:53 Rob T wrote:I want to load shared libraries during runtime as plug-in's, but the consensus seemed to indicate that DMD is not yet ready for this. I wonder if these functions provide any useful plug-in support or not?I don't know what the state of those functions is, but the GC can't handle shared libraries at this point. I believe that that's the main reason why shared libraries are a no-go at this point. And with a problem like that, it seems to me like a _really_ bad idea to try and use them. If I were you, I'd keep away from them until druntime was fixed to properly support them. That's certainly what I intend to do. - Jonathan M Davis
Jan 09 2013
On Thursday, 10 January 2013 at 07:52:19 UTC, Jonathan M Davis wrote:On Thursday, January 10, 2013 08:35:53 Rob T wrote:what's wrong with them? already used it on windows and mac, no problems so far, though not tested too deep, and not with D shared libs o_OI want to load shared libraries during runtime as plug-in's, but the consensus seemed to indicate that DMD is not yet ready for this. I wonder if these functions provide any useful plug-in support or not?I don't know what the state of those functions is, but the GC can't handle shared libraries at this point. I believe that that's the main reason why shared libraries are a no-go at this point. And with a problem like that, it seems to me like a _really_ bad idea to try and use them. If I were you, I'd keep away from them until druntime was fixed to properly support them. That's certainly what I intend to do. - Jonathan M Davis
Jan 10 2013
On Thursday, January 10, 2013 11:31:50 evilrat wrote:what's wrong with them? already used it on windows and mac, no problems so far, though not tested too deep, and not with D shared libs o_OC shared libraries are fine. It's D shared libraries that are the problem. I don't remember the details, but IIRC, among other things, you end up with multiple copies of the GC running. The runtime needs a variety of non-trivial tweaks to it order to fix those problems before shared D libraries become viable. - Jonathan M Davis
Jan 10 2013
On Thursday, 10 January 2013 at 10:43:14 UTC, Jonathan M Davis wrote:The runtime needs a variety of non-trivial tweaks to it order to fix those problems before shared D libraries become viable.tweaks like this http://dlang.org/dll.html#Dcode ?
Jan 10 2013
On Thursday, January 10, 2013 11:54:03 evilrat wrote:On Thursday, 10 January 2013 at 10:43:14 UTC, Jonathan M Davis wrote:I don't know any of the details, but that page does seem to discuss at least some of the issues. Other folks around here are far more familiar with what the exact situation is than I am. - Jonathan M DavisThe runtime needs a variety of non-trivial tweaks to it order to fix those problems before shared D libraries become viable.tweaks like this http://dlang.org/dll.html#Dcode ?
Jan 10 2013
On Thursday, 10 January 2013 at 11:00:55 UTC, Jonathan M Davis wrote:On Thursday, January 10, 2013 11:54:03 evilrat wrote:well anyway thanks for info, this would definitely save some time if i encounter some bugs while doing D shared libs.On Thursday, 10 January 2013 at 10:43:14 UTC, Jonathan M Davis wrote:I don't know any of the details, but that page does seem to discuss at least some of the issues. Other folks around here are far more familiar with what the exact situation is than I am. - Jonathan M DavisThe runtime needs a variety of non-trivial tweaks to it order to fix those problems before shared D libraries become viable.tweaks like this http://dlang.org/dll.html#Dcode ?
Jan 10 2013
On 2013-01-10 11:54, evilrat wrote:tweaks like this http://dlang.org/dll.html#Dcode ?Tweaks like this: https://github.com/dawgfoto/druntime/tree/SharedRuntime -- /Jacob Carlborg
Jan 10 2013
Am 10.01.2013 11:42, schrieb Jonathan M Davis:On Thursday, January 10, 2013 11:31:50 evilrat wrote:Multiple GC copies are result from an ODR violation. We need a shared phobos/druntime library to support other shared libraries.what's wrong with them? already used it on windows and mac, no problems so far, though not tested too deep, and not with D shared libs o_OC shared libraries are fine. It's D shared libraries that are the problem. I don't remember the details, but IIRC, among other things, you end up with multiple copies of the GC running. The runtime needs a variety of non-trivial tweaks to it order to fix those problems before shared D libraries become viable. - Jonathan M Davis
Jan 10 2013
On Thursday, 10 January 2013 at 23:57:10 UTC, Martin Nowak wrote:Multiple GC copies are result from an ODR violation. We need a shared phobos/druntime library to support other shared libraries.Could you quickly summarize the current state of your related work? I might be able to spend some time on the issue in a few weeks if nobody beats me to it, but I'd rather not re-discover all of the problems that might be blocking your approach myself. David
Jan 10 2013
Could you quickly summarize the current state of your related work?Please have a look at my other post in this thread. http://forum.dlang.org/post/50EF5875.1060009 dawg.eu
Jan 10 2013
On 2013-01-11 01:28, Martin Nowak wrote:I think we need to start tracking these issues in bugzilla. -- /Jacob CarlborgCould you quickly summarize the current state of your related work?Please have a look at my other post in this thread. http://forum.dlang.org/post/50EF5875.1060009 dawg.eu
Jan 10 2013
On 1/10/2013 2:42 AM, Jonathan M Davis wrote:C shared libraries are fine. It's D shared libraries that are the problem. I don't remember the details, but IIRC, among other things, you end up with multiple copies of the GC running. The runtime needs a variety of non-trivial tweaks to it order to fix those problems before shared D libraries become viable.This was fixed in D1 long ago. DLLs would use the Executable's gc instance.
Jan 10 2013
On Friday, 11 January 2013 at 02:20:27 UTC, Walter Bright wrote:On 1/10/2013 2:42 AM, Jonathan M Davis wrote:Wait.. this was a bit unclear, but it sounded like you just said D's DLL issues where fixed awhile ago.. Is D2 capable of correctly loading DLLs? What's the situation with Linux?C shared libraries are fine. It's D shared libraries that are the problem. I don't remember the details, but IIRC, among other things, you end up with multiple copies of the GC running. The runtime needs a variety of non-trivial tweaks to it order to fix those problems before shared D libraries become viable.This was fixed in D1 long ago. DLLs would use the Executable's gc instance.
Jan 10 2013
On Friday, 11 January 2013 at 06:26:56 UTC, F i L wrote:Wait.. this was a bit unclear, but it sounded like you just said D's DLL issues where fixed awhile ago.. Is D2 capable of correctly loading DLLs? What's the situation with Linux?look for the link in this topic to the d runtime source (dmain2.d file), there is static assert in Runtime.loadLibrary(...) for non windows, it shouldn't compile at all, but if i remember on OSX it compiled for me. no really, can't remember...
Jan 10 2013
On Friday, 11 January 2013 at 06:40:00 UTC, evilrat wrote:On Friday, 11 January 2013 at 06:26:56 UTC, F i L wrote:oops, my bad, there is exception throwed.Wait.. this was a bit unclear, but it sounded like you just said D's DLL issues where fixed awhile ago.. Is D2 capable of correctly loading DLLs? What's the situation with Linux?look for the link in this topic to the d runtime source (dmain2.d file), there is static assert in Runtime.loadLibrary(...) for non windows, it shouldn't compile at all, but if i remember on OSX it compiled for me. no really, can't remember...
Jan 10 2013
On 2013-01-11 07:26, F i L wrote:Wait.. this was a bit unclear, but it sounded like you just said D's DLL issues where fixed awhile ago.. Is D2 capable of correctly loading DLLs? What's the situation with Linux?I'm pretty sure that when he says "DLL" he means DLL on Windows. So the situation is that we cannot correctly use D shared libraries on Posix. -- /Jacob Carlborg
Jan 10 2013
On 1/10/2013 11:44 PM, Jacob Carlborg wrote:On 2013-01-11 07:26, F i L wrote:"DLL" is Windows "shared library" is Linux/OSX/FreeBSDWait.. this was a bit unclear, but it sounded like you just said D's DLL issues where fixed awhile ago.. Is D2 capable of correctly loading DLLs? What's the situation with Linux?I'm pretty sure that when he says "DLL" he means DLL on Windows. So the situation is that we cannot correctly use D shared libraries on Posix.
Jan 11 2013
On 2013-01-11 09:21, Walter Bright wrote:"DLL" is Windows "shared library" is Linux/OSX/FreeBSDSome people have a tendency to mix the terms. I like to call it "dynamic library" on all platforms. -- /Jacob Carlborg
Jan 11 2013
On 2013-01-10 11:31, evilrat wrote:what's wrong with them? already used it on windows and mac, no problems so far, though not tested too deep, and not with D shared libs o_OApparently you haven't tested at all on Mac since it's only implemented on Windows: https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L122 -- /Jacob Carlborg
Jan 10 2013
On Thursday, 10 January 2013 at 14:07:38 UTC, Jacob Carlborg wrote:On 2013-01-10 11:31, evilrat wrote:well like i said i don't used D shared libs yet. umm.. looks simple at glance, whats the catch then if it still not implemented at least on osx?what's wrong with them? already used it on windows and mac, no problems so far, though not tested too deep, and not with D shared libs o_OApparently you haven't tested at all on Mac since it's only implemented on Windows: https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L122
Jan 10 2013
I think the main issue is scanning static memory segments in the shared libr= ary during collections. Pretty sure this is sorted for Windows, but I think w= ork still needs to be done for other platforms. It's been a while since I'v= e looked at this code though. Other things may be needed as well. Either way= , if your D shared library is operating as if it were a C library then you s= hould be fine. The trick is getting all shared libraries to share a single D= runtime.=20 On Jan 10, 2013, at 6:43 AM, "evilrat" <evilrat666 gmail.com> wrote:On Thursday, 10 January 2013 at 14:07:38 UTC, Jacob Carlborg wrote:n Windows:On 2013-01-10 11:31, evilrat wrote: =20what's wrong with them? already used it on windows and mac, no problems so far, though not tested too deep, and not with D shared libs o_O=20 Apparently you haven't tested at all on Mac since it's only implemented o=in2.d#L122=20 https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dma==20 well like i said i don't used D shared libs yet. =20 umm.. looks simple at glance, whats the catch then if it still not impleme=nted at least on osx?
Jan 10 2013
On 2013-01-10 15:43, evilrat wrote:umm.. looks simple at glance, whats the catch then if it still not implemented at least on osx?For loading regular C shared libraries there is no problem, just a simple wrapper around dlopen. -- /Jacob Carlborg
Jan 10 2013
On 2013-01-10 19:34, Jacob Carlborg wrote:For loading regular C shared libraries there is no problem, just a simple wrapper around dlopen.For D shared libraries the problem is that I and Sean have said in other posts in this thread. -- /Jacob Carlborg
Jan 10 2013
On Thursday, 10 January 2013 at 18:34:52 UTC, Jacob Carlborg wrote:On 2013-01-10 19:34, Jacob Carlborg wrote:Thanks for the replies. So if I understand all this correctly, I can safely load C plugins and use them reliably, but I cannot yet use D plugins. Correct? --rtFor loading regular C shared libraries there is no problem, just a simple wrapper around dlopen.For D shared libraries the problem is that I and Sean have said in other posts in this thread.
Jan 10 2013
On 2013-01-10 21:21, Rob T wrote:So if I understand all this correctly, I can safely load C plugins and use them reliably, but I cannot yet use D plugins. Correct?Yes. But as I've said, these functions are only implemented for Windows. "dlopen" will work fine on Posix. -- /Jacob Carlborg
Jan 10 2013
On Thursday, 10 January 2013 at 20:48:00 UTC, Jacob Carlborg wrote:On 2013-01-10 21:21, Rob T wrote:OK so these functions are not yet portable as stated in the documentation, and currently only work for Windows (the docs should be updated to state this). I'm using Linux, so that means I have to use the usual dlopen, dlclose and dlsym? If so, this is at least a start, and I can safely load C shared libs as plugins. BTW, where's the portable version of dlsym? Was the omission an oversight, or left out for a reason? --rtSo if I understand all this correctly, I can safely load C plugins and use them reliably, but I cannot yet use D plugins. Correct?Yes. But as I've said, these functions are only implemented for Windows. "dlopen" will work fine on Posix.
Jan 10 2013
On Fri, Jan 11, 2013 at 12:54:40AM +0100, Rob T wrote: [...]I'm using Linux, so that means I have to use the usual dlopen, dlclose and dlsym? If so, this is at least a start, and I can safely load C shared libs as plugins. BTW, where's the portable version of dlsym? Was the omission an oversight, or left out for a reason?[...] Are you talking about the D wrappers for dlsym, or the fact that dlsym is non-portable? T -- WINDOWS = Will Install Needless Data On Whole System -- CompuMan
Jan 10 2013
On Friday, 11 January 2013 at 00:05:32 UTC, H. S. Teoh wrote:On Fri, Jan 11, 2013 at 12:54:40AM +0100, Rob T wrote: [...]I was referring to the portable D wrapper for dlsym, it seems to be missing by oversight, or was not implemented for some specific technical reason. --rtI'm using Linux, so that means I have to use the usual dlopen, dlclose and dlsym? If so, this is at least a start, and I can safely load C shared libs as plugins. BTW, where's the portable version of dlsym? Was the omission an oversight, or left out for a reason?[...] Are you talking about the D wrappers for dlsym, or the fact that dlsym is non-portable? T
Jan 10 2013
On Thursday, 10 January 2013 at 23:54:41 UTC, Rob T wrote:OK so these functions are not yet portable as stated in the documentation, and currently only work for Windows (the docs should be updated to state this). I'm using Linux, so that means I have to use the usual dlopen, dlclose and dlsym? If so, this is at least a start, and I can safely load C shared libs as plugins. BTW, where's the portable version of dlsym? Was the omission an oversight, or left out for a reason? --rta "portable" version with what we already know commented in http://pastebin.com/rz5xPy8W
Jan 10 2013
On Friday, 11 January 2013 at 02:13:51 UTC, evilrat wrote:On Thursday, 10 January 2013 at 23:54:41 UTC, Rob T wrote:Thanks for that! I'll make use of that for my C plugins. --rtOK so these functions are not yet portable as stated in the documentation, and currently only work for Windows (the docs should be updated to state this). I'm using Linux, so that means I have to use the usual dlopen, dlclose and dlsym? If so, this is at least a start, and I can safely load C shared libs as plugins. BTW, where's the portable version of dlsym? Was the omission an oversight, or left out for a reason? --rta "portable" version with what we already know commented in http://pastebin.com/rz5xPy8W
Jan 11 2013
On 2013-01-11 00:54, Rob T wrote:OK so these functions are not yet portable as stated in the documentation, and currently only work for Windows (the docs should be updated to state this).Yes, please file a bug report. Either to fix the documentation or implement the functions for Posix. The Posix functions can be implemented to only work for C shared libraries.I'm using Linux, so that means I have to use the usual dlopen, dlclose and dlsym? If so, this is at least a start, and I can safely load C shared libs as plugins.Yes. -- /Jacob Carlborg
Jan 10 2013
On 2013-01-10 08:51, Jonathan M Davis wrote:I don't know what the state of those functions is, but the GC can't handle shared libraries at this point. I believe that that's the main reason why shared libraries are a no-go at this point. And with a problem like that, it seems to me like a _really_ bad idea to try and use them. If I were you, I'd keep away from them until druntime was fixed to properly support them. That's certainly what I intend to do.The state is that they're only implement on Windows: https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L122 About D shared libraries, this is what's missing: The runtime need to collect the following from all loaded images (shared libraries and executables) and all that are loaded during program execution: * Exception handling tables * Ranges scanned by the GC * TLS data There are more issues than listed above that I can remember right now. -- /Jacob Carlborg
Jan 10 2013
About D shared libraries, this is what's missing: The runtime need to collect the following from all loaded images (shared libraries and executables) and all that are loaded during program execution: * Exception handling tables * Ranges scanned by the GC * TLS data There are more issues than listed above that I can remember right now.Right this is the same state on POSIX and of 2.061 all shared libraries produced by dmd try to call a weakly linked `_d_dso_registry` upon loading/unloading to pass EH and ModuleInfo tables. https://github.com/D-Programming-Language/dmd/pull/1043/files#L0R3112 The current state of: https://github.com/dawgfoto/druntime/tree/SharedRuntime https://github.com/dawgfoto/phobos/tree/SharedRuntime is here: http://forum.dlang.org/post/op.wcrffp2asqugbd localhost Some unsolved issues remain: http://forum.dlang.org/post/mailman.2052.1325532031.24802.digitalmars-d puremagic.com
Jan 10 2013
On 2013-01-11 01:10, Martin Nowak wrote:Right this is the same state on POSIX and of 2.061 all shared libraries produced by dmd try to call a weakly linked `_d_dso_registry` upon loading/unloading to pass EH and ModuleInfo tables. https://github.com/D-Programming-Language/dmd/pull/1043/files#L0R3112This code seems to only be fore ELF targets. This is not needed on Mac OS X, right? Bracketed sections are not needed on Mac OS X.The current state of: https://github.com/dawgfoto/druntime/tree/SharedRuntime https://github.com/dawgfoto/phobos/tree/SharedRuntime is here: http://forum.dlang.org/post/op.wcrffp2asqugbd localhost Some unsolved issues remain: http://forum.dlang.org/post/mailman.2052.1325532031.24802.digitalmars-d puremagic.comThanks for the update. This looks interesting. -- /Jacob Carlborg
Jan 10 2013
On 1/9/2013 11:35 PM, Rob T wrote:I want to load shared libraries during runtime as plug-in's, but the consensus seemed to indicate that DMD is not yet ready for this. I wonder if these functions provide any useful plug-in support or not?Windows or Linux?
Jan 10 2013
On Friday, 11 January 2013 at 02:19:32 UTC, Walter Bright wrote:On 1/9/2013 11:35 PM, Rob T wrote:The more immediate need for me is definitely Linux. --rtI want to load shared libraries during runtime as plug-in's, but the consensus seemed to indicate that DMD is not yet ready for this. I wonder if these functions provide any useful plug-in support or not?Windows or Linux?
Jan 10 2013
On Thursday, 10 January 2013 at 07:35:54 UTC, Rob T wrote:I want to load shared libraries during runtime as plug-in's, but the consensus seemed to indicate that DMD is not yet ready for this. I wonder if these functions provide any useful plug-in support or not? Thanks! --rtSpeaking of which, Anyone else finds themself desiring a "loadSymbol( void * whateverReturnedByLoadLib, string name )" function? Phil
Jan 11 2013
On Friday, 11 January 2013 at 15:34:33 UTC, Phil Lavoie wrote:On Thursday, 10 January 2013 at 07:35:54 UTC, Rob T wrote:it's not a desire, it's must have! O_oI want to load shared libraries during runtime as plug-in's, but the consensus seemed to indicate that DMD is not yet ready for this. I wonder if these functions provide any useful plug-in support or not? Thanks! --rtSpeaking of which, Anyone else finds themself desiring a "loadSymbol( void * whateverReturnedByLoadLib, string name )" function? Phil
Jan 11 2013
On Friday, 11 January 2013 at 15:36:29 UTC, evilrat wrote:On Friday, 11 January 2013 at 15:34:33 UTC, Phil Lavoie wrote:+1On Thursday, 10 January 2013 at 07:35:54 UTC, Rob T wrote:it's not a desire, it's must have! O_oI want to load shared libraries during runtime as plug-in's, but the consensus seemed to indicate that DMD is not yet ready for this. I wonder if these functions provide any useful plug-in support or not? Thanks! --rtSpeaking of which, Anyone else finds themself desiring a "loadSymbol( void * whateverReturnedByLoadLib, string name )" function? Phil
Jan 11 2013
On Jan 11, 2013, at 7:34 AM, Phil Lavoie <maidenphil hotmail.com> wrote:Anyone else finds themself desiring a "loadSymbol( void * =whateverReturnedByLoadLib, string name )" function? Please submit an enhancement request :-)=
Jan 11 2013
On Fri, Jan 11, 2013 at 11:26:33AM -0800, Sean Kelly wrote:On Jan 11, 2013, at 7:34 AM, Phil Lavoie <maidenphil hotmail.com> wrote:Is it safe to use void* for representing _both_ variables and functions? I know in C++ this was a problem in the standard, because a function pointer may not be the same size as a pointer to a variable, and therefore dlsym technically has undefined behaviour (though I doubt if any implementation actually doesn't work). What's the situation in D? What if the library exports delegates? Would it be dangerous to cast it to void*? Do we need separate functions for loading function symbols vs. data symbols? T -- Give me some fresh salted fish, please.Anyone else finds themself desiring a "loadSymbol( void * whateverReturnedByLoadLib, string name )" function?Please submit an enhancement request :-)
Jan 11 2013
On Jan 11, 2013, at 12:41 PM, H. S. Teoh <hsteoh quickfur.ath.cx> wrote:On Fri, Jan 11, 2013 at 11:26:33AM -0800, Sean Kelly wrote:wrote:On Jan 11, 2013, at 7:34 AM, Phil Lavoie <maidenphil hotmail.com> =functions?=20=20 Is it safe to use void* for representing _both_ variables and =Anyone else finds themself desiring a "loadSymbol( void * whateverReturnedByLoadLib, string name )" function?=20 Please submit an enhancement request :-)=20 I know in C++ this was a problem in the standard, because a function pointer may not be the same size as a pointer to a variable, and therefore dlsym technically has undefined behaviour (though I doubt if any implementation actually doesn't work). =20 What's the situation in D? What if the library exports delegates? =Wouldit be dangerous to cast it to void*? Do we need separate functions for loading function symbols vs. data symbols?I don't think a library can directly export a delegate, because that = implies a context pointer linked to instantiated data. void* is safe = provided that's what the underlying API uses. It may be a better idea = to change this to an opaque handle though.=
Jan 11 2013