"The memory is unaliased." refers to the memory as seen by the callee of cd. Any changes made by callee won't be written back to the original memory. That's why the value of names remained unchanged after cd call. Unless you had taken the address of name and passed the address to cd.
The release note also mentioned & but use it only if you know what you are doing. Mon, 19 Nov 2018, Ben Gorte написал(а): > Dear Henry, Bill, Linda, > > Thanks for your responses, I am getting the point/ers. > > Perhaps in > https://code.jsoftware.com/wiki/Guides/DLLs/Calling_DLLs#J807_Incompatibilities > , the phrase: "The DLL can read or write this memory." is a bit confusing, > although it also says "The memory is unaliased." That means "copied if > required", and I thought it wouldn't be... > > Anyway, all is well again, > > Thanks, > Ben > > > > > > On Mon, Nov 19, 2018 at 1:15 AM Henry Rich <[email protected]> wrote: > > > What Bill is saying is that starting in 807, cd makes an copy of any > > argument to cd that might be shared by another noun. So, the value of > > 'res' is put into a temporary block and passed to the DLL. The > > temporary block is put into the boxed result of cd. You need to look in > > that boxed result, not in the name res, which has not been modified. > > > > This change was made in 807 because that release has a much more > > aggressive policy of sharing nouns and parts of nouns without making > > separate copies; for example > > > > ({. name) > > > > actually gives you a pointer to the first item of name, without > > recopying it, and > > > > (i. 3) > > > > is liable to give you a pointer to unchangeable internal data. With all > > these pointers flying around we can no longer trust the user to know > > when it is safe to pass a pointer into a DLL that might modify the data. > > > > Henry Rich > > > > On 11/18/2018 7:55 AM, bill lam wrote: > > > j807 must get from result of cd, like this > > > 0 3{ (sqrdll, 'sqr i i *i *i') cd (#y);y;res > > > > > > On Sun, Nov 18, 2018, 2:22 PM Ben Gorte <[email protected] wrote: > > > > > >> Dear All, > > >> > > >> Long ago I made quite a lot of c-functions that I am calling from J > > using > > >> the cd mechanism (load 'dll') in linux. > > >> > > >> They stopped working in j64-807. I see in the release notes that indeed > > >> something has changed, but I cannot quite relate that to my case (but > > maybe > > >> I should - I'm not sure I entirely understand the story). > > >> > > >> In the simplest form it looks like this: > > >> First the c-code, sqr.c : > > >> int sqr (int n, int a[], int b[]) > > >> { > > >> int i, sumsqr=0; > > >> for (i=0; i<n; i++) > > >> sumsqr += b[i] = a[i] * a[i]; > > >> return sumsqr; > > >> } > > >> > > >> which I compile with > > >> gcc -O3 -shared -fPIC -o sql.so -Wl,--no-as-needed sqr.c > > >> (omitting -O3 does not make a difference). > > >> > > >> In J I go like: > > >> > > >> load 'dll' > > >> > > >> sqrdll =: jpath '~user/ext/sqr.so ' > > >> > > >> > > >> sqr =: 3 : 0 > > >> > > >> res =. (#y)#4 NB. make sure it's integer > > >> > > >> ret =. (sqrdll, 'sqr > i i *i *i') cd (#y);y;res > > >> > > >> ret, res > > >> > > >> ) > > >> > > >> > > >> Up until j806 I would get: > > >> > > >> sqr i.10 > > >> > > >> 285 0 1 4 9 16 25 36 49 64 81 > > >> > > >> > > >> But in j807: > > >> > > >> sqr i.10 > > >> > > >> 285 4 4 4 4 4 4 4 4 4 4 > > >> > > >> > > >> > > >> So my DLL 'reads' an array alright, but seems to be not 'writing' it. > > >> > > >> > > >> For completeness: > > >> JVERSION > > >> Engine: j807/j64/linux > > >> Release: commercial/2018-10-04T15:00:41 > > >> Library: 8.07.20 > > >> Qt IDE: 1.7.7/5.5.1 > > >> Platform: Linux 64 > > >> Installer: J807 install > > >> InstallPath: /home/ben/j64-807 > > >> Contact: www.jsoftware.com > > >> > > >> Perhaps I'm overlooking something trivial; any help is highly > > appreciated! > > >> > > >> Ben > > >> ---------------------------------------------------------------------- > > >> For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > > > --- > > This email has been checked for viruses by AVG. > > https://www.avg.com > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm -- regards, ==================================================== GPG key 1024D/4434BAB3 2008-08-24 gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
