[Rd] dyn.load

From: Tom McCallum <tom.mccallum_at_levelelimited.com>
Date: Tue 21 Nov 2006 - 17:30:56 GMT

Hi everyone,

Now I know there is information on this in the help files - which I have read. I am very close to implementing this but can't quite get how to remove this final hurdle.

I have a DLL called "X.DLL" which I have no original code for, just the DLL.
I have created a wrapper C file for the calls in X.DLL, and have successfully (I think) created a wrapper DLL for X called, lets say, WRAPX.DLL. On performing:

> dyn.load("WRAPX.dll")

in the Rgui terminal, I then received this warning:

Warning message:
DLL attempted to change FPU control word from 8001f to 9001f

Getting rid of this error was part of the reason for writing WRAPX.DLL, as X.DLL seems to play about with this register.

So having another look at the manual entry, I then used the function Rwin_fpset() (in gnuwin32/extra.c) to reset the FPU control register when I leave all the functions in WRAPX.DLL. But the problem persists. In the Delphi example in the manual, which I have put at the end of this message, ( and I have never programmed in Delphi before so I am guessing ) there is the opportunity on loading the dynamic library to set this register, but I am wondering where in the C file I can put this command so that when dyn.load is called it is not upset by X.DLL changing this register. I think I need the following passage of play to occur:         

USER		: > dyn.load("WRAPX.DLL");
R   		: Calls WRAPX.DLL

WRAPX.DLL : WRAPX.DLL initialises X.DLL which interferes with FPU register
WRAPX.DLL	: Calls Rwin_fpset() to reset FPU register
R		: R tests FPU register and is happy
USER		: Sees "Success library is loaded!" or something to that effect :)

Any ideas on how to achieve this?

Many thanks


====DELPHI CODE===== procedure Rwin_fpset; cdecl; external 'R.dll';

function Get8087CW:word;

     fstcw result


   Rwin_fpset(); <============== these lines I think is called on loading of the DLL to reset the register

   Set8087CW(Get8087CW); <========


Dr. Thomas McCallum
Systems Architect,
Level E Limited
ETTC, The King's Buildings
Mayfield Road,
Edinburgh EH9 3JL, UK
Work  +44 (0) 131 472 4813
Fax:  +44 (0) 131 472 4719
Email: tom@levelelimited.com

Level E is a limited company incorporated in Scotland. The c...{{dropped}}

R-devel@r-project.org mailing list
Received on Wed Nov 22 12:00:30 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 22 Nov 2006 - 21:30:48 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.