<br><br><div class="gmail_quote">On Sat, Sep 25, 2010 at 10:10 AM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
On 25 September 2010 19:30, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Sat, Sep 25, 2010 at 7:30 AM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On 25 September 2010 10:32, K. K. Subramaniam &lt;<a href="http://kksubbu.ml" target="_blank">kksubbu.ml</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt; On Saturday 25 Sep 2010 6:44:19 am Igor Stasenko wrote:<br>
&gt;&gt; &gt;&gt; But on Linux, mmap() is a part of GLIBC library.<br>
&gt;&gt; &gt;&gt; Any idea, what module name i could use to get a pointer to<br>
&gt;&gt; &gt;&gt; mmap/dlopen/dlsym using interpreterProxy functions?<br>
&gt;&gt; &gt; libc.so.6 (for sixth generation C library). see man page for libc<br>
&gt;&gt; &gt;<br>
&gt;&gt; how i can be sure that squeak vm always using this &#39; sixth generation<br>
&gt;&gt; C library&#39;,<br>
&gt;&gt; and i&#39;m not trying load a different version of it?<br>
&gt;&gt; Where the guarantees that all unix boxes using libc.so.6?<br>
&gt;<br>
&gt; Nothing.  And on Mac OS X it will likely be libSystem.B.dylib and on Solaris will be something else again etc.  You&#39;ll need to use the tool that displays the dynamic libraries against which the VM is linked.  e.g.<br>

&gt; ldd cogunix/bin/lib/squeak/3.9-7/squeak<br>
&gt;         linux-gate.so.1 =&gt;  (0x00765000)<br>
&gt;         libutil.so.1 =&gt; /lib/libutil.so.1 (0x06b55000)<br>
&gt;         libdl.so.2 =&gt; /lib/libdl.so.2 (0x00afd000)<br>
&gt;         libpthread.so.0 =&gt; /lib/libpthread.so.0 (0x00b04000)<br>
&gt;         libm.so.6 =&gt; /lib/libm.so.6 (0x00ad2000)<br>
&gt;         libnsl.so.1 =&gt; /lib/libnsl.so.1 (0x064b5000)<br>
&gt;         libc.so.6 =&gt; /lib/libc.so.6 (0x00b53000)<br>
&gt;         /lib/ld-linux.so.2 (0x00ab3000)<br>
&gt;<br>
&gt;  otool -L Cog/oscogvm/macbuild/Fast.app/Contents/MacOS/Croquet<br>
&gt; Cog/oscogvm/macbuild/Fast.app/Contents/MacOS/Croquet:<br>
&gt;         /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 476.19.0)<br>
&gt;         /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 136.0.0)<br>
&gt;         /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)<br>
&gt;         /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)<br>
&gt;         /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime (compatibility version 1.0.0, current version 1327.73.0)<br>
&gt;         /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)<br>
&gt;         /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1.0.0)<br>
&gt;         /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)<br>
&gt;         /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 677.26.0)<br>
&gt;         /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration (compatibility version 1.0.0, current version 212.2.0)<br>
&gt;         /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 949.54.0)<br>
&gt;         /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)<br>
&gt;         /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)<br>
&gt;         /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)<br>
&gt;         /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 32.0.0)<br>
&gt;         /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 34.0.0)<br>
&gt; It would be convenient if the VM could answer the basename of the C library against which it was linked, e.g. through a systemAttributeAt:, but I expect that would be implemented by using a manifest string constant in the VM.  Clearly this info belongs in the VM, not a table in the image.  But VM builders would still need to test it as it could easily get stale if its supplied from the build system.  We&#39;d need a test and e.g. one of my Alien tests is an invocation of qsort which is in the C library.<br>

<br>
</div></div>Exactly the same. I also using qsort to test callbacks.<br>
Obviously, its easy to run tool from command line to discover the<br>
library, and that was the reason why i can&#39;t google for solution,<br>
because all pages it finds, says: hey, just run this tool and you are<br>
done! Apparently not. I don&#39;t wanna tell user, who running<br>
squeak VM : hey pal, since you on linux, run this tool from command<br>
line and then copy the library name here and then you done. :)<br>
<br>
This is the case, when it is good to have a well-established standarts<br>
or conventions...<br>
<div class="im"><br>
&gt; Igor, for now I would hard code this in the image.  But we should add it to the VM soon.<br>
<br>
</div>Well, i just added prim which returns a dlsym() function pointer. But<br>
it would be good if interpreterProxy-&gt;ioLoadSymbolOfLengthFromModule()<br>
could accept a default module handle, which corresponds to process&#39;s<br>
global symbol space.<br></blockquote><div><br></div><div>On Unix systems using dlopen et al that&#39;s dlsym(RTLD_DEFAULT,symbolname).  I don&#39;t know what the equivalent, if any, there is on Windows.</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
&gt; But this raises an important issue.  I think the architecture of dynamic linking of both named primitives and FFI calls in Squeak is wrong.  The VM does all the work of binding names to functions, taking a function name, library/plugin pair and resolving it to an address, which means for example that one can&#39;t substitute a symbolic name such as TheCLibrary in an FFI call since this name will be interpreted literally by the VM (and will fail).<br>

&gt; If instead there were two primitives, openLibrary and lookupInLibrary (as there are in Alien) then the linking machinery could be moved up into the image where we could concretize symbolic names.  This would be done either explicitly, e.g.<br>

&gt;     myPluginPrimitive<br>
&gt;         &lt;primitive: &#39;myPluginPrimitive&#39; module: &#39;ThePlugin&#39; error: errorCode&gt;<br>
&gt;         errorCode == #unlinked ifTrue:<br>
&gt;             [^thisContext linkAndRetryExternalPluginInvocation]<br>
&gt;         ...<br>
&gt;     qsort: base elements: nel width: width comparator: compar<br>
&gt; &lt;apicall: void &#39;qsort&#39; (void* ulong ulong void*)<br>
&gt; module: &#39;WhateverTheCLibraryIsOnThisPlatform&#39;<br>
&gt; error: err&gt;<br>
&gt;         errorCode == #unlinked ifTrue:<br>
&gt;             [^thisContext linkAndRetryExternalPluginInvocation]<br>
&gt; ^self externalCallFailedWith: err<br>
&gt; or, as it is in VisualWorks, with a hidden callback (selector in the specialObjectsArray) that sends a message to the unlinked method whose arguments are the calls receiver and arguments.  Personally I think the explicit method is better since its more flexible.<br>

<br>
</div>Yes. And i trying to add this to NativeBoost, so you can choose own<br>
way how to search for module and symbol in it.<br>
But i thought that for bootstrapping NativeBoost itself, i could reuse<br>
vm functionality to access requred bits (dlsym/dlopen),<br>
and then i free to do anything else from that point.<br>
<div class="im"><br>
<br>
&gt; best<br>
&gt; Eliot<br>
&gt;&gt;<br>
&gt;&gt; &gt; Subbu<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Best regards,<br>
&gt;&gt; Igor Stasenko AKA sig.<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div>--<br>
<div><div></div><div class="h5">Best regards,<br>
Igor Stasenko AKA sig.<br>
</div></div></blockquote></div><br>