Marcin 'Qrczak' Kowalczyk qrczak at
Wed Jan 3 06:09:19 EST 2001

Wed, 3 Jan 2001 21:12:54 +1100, Fergus Henderson <fjh at> pisze:

> Well, if they are left, then at very least they should be
> very clearly documented as being non-portable.

They should, they aren't. Perl internally relies on the fact that
memsetting all bits to 0 produces null pointers (at least in one
place). Libraries use identifiers from the namespace reserved
to the C implementation. Libraries use Posix functions, Single
Unix Spec. functions, BSD functions, Linux functions etc. without
documenting what interfaces they require.

> > Yes: me, for the readline library.
> Could you be more specific?

typedef struct {...} KEYMAP_ENTRY;
typedef KEYMAP_ENTRY *Keymap;
typedef int Function();

int rl_generic_bind (int type, char *keyseq, char *data, Keymap map)

If type == ISFUNC:
    data should be a value of type Function *, cast to char *.
    It will be applied to two int values.
If type == ISMACR:
    data should be a string.
If type == ISKMAP:
    data should be a value of type Keymap, cast to char *.

Function *rl_function_of_keyseq (char *keyseq, Keymap map, int *type)

Returns data as set by rl_generic_bind, cast to Function * this time,
and sets type appropriately.

> Why was the cast needed?

Because the library is designed and written in a horrible way.

> > Another example is dlopen.
> I think you mean dlsym().


 __("<  Marcin Kowalczyk * qrczak at
  ^^                      SYGNATURA ZASTÊPCZA

More information about the FFI mailing list