[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] using c libs in apl?

From: Elias Mårtenson
Subject: Re: [Bug-apl] using c libs in apl?
Date: Fri, 10 Feb 2017 14:04:18 +0800

On 10 February 2017 at 13:30, Xiao-Yong Jin <address@hidden> wrote:
I believe passing/returning struct is actually compiler dependent (man gcc and /struct-return).

In C++ it's compiler-dependent, I think. The C ABI however is stable in this respect, at least on Linux.
What you are talking about implementation dependent type and alignment is a real problem.
Actually without fully preprocessing the headerfiles, we can never be sure about system/architecture dependent types.

In <sys/time.h>, we have
           struct timeval {
               time_t      tv_sec;     /* seconds */
               suseconds_t tv_usec;    /* microseconds */
the size of time_t and suseconds_t are architecture dependent.  The only reliable way that I
know of is,
      gcc -x c -include stdio.h -include sys/time.h -o /tmp/tt - <<<'int main()
      {printf("%d %d %d\n",sizeof(struct timeval),sizeof(time_t),sizeof(suseconds_t));}' && /tmp/tt && rm /tmp/tt

And this is exactly how the CFFI Groveller works. As you say, it's the only way to reliably get this information and the groveller achieves this automatically behind the scenes.

This would, of course, be possible in GNU APL too, but just as the groveller is a tool built on top of CFFI, the same should be the case for the GNU APL FFI. In other words, I think it makes sense to build it by assuming hardcoded offsets at first, and later, if someone feels up to it, that person can build a groveller on top of the GNU APL FFI.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]