struct function only with libffi compiled in?

Q&A's, tips, howto's

struct function only with libffi compiled in?

Postby TedWalther » Tue Apr 21, 2015 5:09 pm

Lutz, I did some tests last week, and it appears (could be wrong) that struct is only supported when libffi support is compiled in. Is this true? If so, would it be hard to enable struct even without libffi support?

Also, is libffi a Unix only thing, or is there Windows support as well?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.
TedWalther
 
Posts: 605
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC

Re: struct function only with libffi compiled in?

Postby Lutz » Wed Apr 22, 2015 6:24 am

All the main newLISP distributions: OSX, Windows and UBUTU Linux support the extended import API based on libffi and the struct function. If libffi support is present, the signon message contains the word libffi. In code you also could use the expression (primitive? struct) which only evaluates to true on libffi enabled versions.

But you can handle structures as well with the simple import API present in all versions and compiled flavors of newLISP. See the subchapter "Importing data structures" of the CodePatterns document here:

http://www.newlisp.org/downloads/CodePa ... tml#toc-23

The simple function import API relies on a strict implementation of C-calling conventions with all function parameters passed on the stack and in fixed width memory words, either 32-bit words on 32-bit versions of newLISP and 64-bit words on 64-bit versions of newLISP. When using the simple API, the programmer must have knowledge about the bit size of the different C-types and how ther are alligned and padded with dummy bytes on 32/64 bit borders when occuring next to each other in a structure. Using the pack and unpack functions present in all versions of newLISP, this can be handled by the programmer.
Lutz
 
Posts: 5276
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: struct function only with libffi compiled in?

Postby TedWalther » Wed Apr 22, 2015 4:23 pm

Thank you for the explanation Lutz.

I find struct a very convenient function, but I see what you are saying about pack/unpack being sufficient. Would it be hard to enable struct without libffi, or is that a libffi function itself?

Alternately, could you add that to the documentation for struct, that it is only present when libffi is compiled in?

The reason I have a newLisp without libffi is I haven't had time to upgrade my OpenBSD box. After some gentle reminders over the past two years, the latest release (or two) of OpenBSD have a new enough libffi that it should work with newLisp, but the older version I have has the wrong release of libffi. Thanks to Jasper and friends for updating the libffi in OpenBSD.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.
TedWalther
 
Posts: 605
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests

cron