Re: C structs and STk FFI (and Copyright problems ...)

From: Erick Gallesio <>
Date: Fri, 25 Dec 1998 12:20:08 +0100 (CET)

David Tillman writes:
> I have been playing with the FFI and it is very nice.
> However; I am not sure how to specify a struct as a parameter.
> For instance if the external function requires a struct
> of the form:
> typedef struct {
> int id;
> int serial;
> } unit;
> This is nothing more than a struct of two integers, or
> perhaps a pointer to a struct of two integers.

I've no implemented structures, because alignment problem make all the
stuff very complicated. For now, if you want to do such a call you
have two possibilities in such a case:
        - use pointers in the C lib (just say that the object is a
void *). The problem is that if you don't have the source of the
library, you need to write a wrapper which transform a pointer to the
structure. In this case, this is probably more efficient to make
an ad-hoc interface and avoid the FFI extra cost.
        - since here the structure is a simple one, if you have a
function such as "int f(unit x)", you can declare it in scheme as it
is was a "int f(int id, int serial)"; The problem is that it
de-structure your object, which is probably not suitable and it depend
of the way structures are ordered, which is very machine specific.


As you can see none of both solution is very pleasant and there are
really too hacky. I know at least two tools which are far better than
the code that I have written for FFI. Unluckily, this tools are GPL
and I had not uses them in STk to avoid to be caught by the GPL virus.

BTW, I have decided to delete the clause about commercial applications
in the STk copyright. As I have already said here (and in a lot of
private mails), this clause was just for "counting" commercial
applications and I always given permission to use STk in commercial
products to people which have asked for. However, I know that (at
least three times) some people have thought to use STk for some
product and have choose another tool before starting development,
because they were "afraid" to be too committed in it and that I will
decline them the right to use it as they want after that :-<

Copyright problems are, for me, too mush boring and I thought that a
perfect solution would be to deliver STk with a BSD like license (in fact
the STk license was a BSD one plus the extra option for commercial

In the last months, I've said to all the people which ask me about STk
copyright, that I intended to make it BSD-like. I was astonished that
most of the people found that a BSD solution would be fine but that a
GPL one would be OK too. I don't like too much the GPL, because of the
way it contaminate software (please no flame war about that in the
mailing list :-) but I must admit that making STk GPL would make my
life easier, since most of the code written today is GPL'ed. To take
the subject of the original message (structures in the FFI), that
means that we could have a better solution for nearly free (I've spent
several days for writing the code I have for the current FFI, most of
it trying to figure how the parameters were passed on the different
architectures, whereas this code already exists (and is better than
mine) GPL'ed). Another example, the API of the bignum numbers library
I have used has changed in its 2.0 version. I cannot use last version
without adapting the free version that I provide too with the
distribution to allow commercial applications. Other extensions which
come in mind: using the emacs unexec to make STk disk images, using
zlib library to allow reading and writing of compressed files,
including the code of Thomas Buerger about GDBM, which was sent here
several day ago (I must admit that I have not looked at this code
since it was GPL'ed and I cannot use it with the current copyright

As I said before, I'm not very found of the GPL (or LGPL) but it seems
to me that it will be more and more difficult to develop code without
reinventing the wheel with other licenses policies...

However, I feel that it will give problem to people which intend to
embed the interpreter in a commercial application (Guile has a special
license for this purpose, even if it also embed pure GPL code which if
I understand well the GPL make it BTW GPL ;-)

I suppose that member of the list have an opinion for this point and
I hope that you can give me some light for the future version of STk.
Please try to avoid flame war, since I know that this kind of subject
can bring rapidly to a religious war.

                -- Erick
Received on Fri Dec 25 1998 - 12:19:26 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST