From: Fabrice Le Fessant <fabrice.le_fessant@inria.fr>
To: Chris Hecker <checker@d6.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] dynamically loading C functions
Date: Thu, 8 Mar 2001 09:22:51 +0100 (CET) [thread overview]
Message-ID: <15015.16731.108064.51473@cremant.inria.fr> (raw)
In-Reply-To: <4.3.2.7.2.20010306094319.00e2b8e0@shell16.ba.best.com>
I've written a Dlopen module for x86 and alpha available at
http://pauillac.inria.fr/~lefessan/src/dlopen.tar.gz
It allows this kind of thing:
cremant:~/devel/dlopen% ./top
Objective Caml version 3.00+9 (2000-07-08)
# open Dlopen;;
# let dll = dlopen "./test.so" [RTLD_NOW];;
val dll : Dlopen.dll = <abstr>
# let add_int = dlsym dll "add_int" "%d:%d%d";;
val add_int : int -> int -> int = <fun>
# let print_string = dlsym dll "print_string" "%d:%s";;
val print_string : string -> int = <fun>
# let add_double = dlsym dll "add_double" "%f:%f%f";;
val add_double : float -> float -> float = <fun>
# add_double (1.0) (2.0);;
x: 1.000000 y: 2.000000
- : float = 3.000000
# print_string "bonjour";;
bonjour
- : int = 10
# add_int 1 2;;
x: 1 y: 2
- : int = 3
#
where test.c is:
#include <stdio.h>
#include <stdlib.h>
int add_int(int x, int y)
{ printf("x: %d y: %d\n",x,y); return x+y; }
int print_string(char *s)
{ printf("%s\n", s); return 10;}
double add_double(double x, double y)
{ printf("x: %f y: %f\n",x,y); return x+y;}
- Fabrice
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
next prev parent reply other threads:[~2001-03-08 8:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-05 20:28 Chris Hecker
2001-03-05 21:24 ` Marcin 'Qrczak' Kowalczyk
2001-03-06 0:10 ` Chris Hecker
2001-03-06 0:55 ` Chris Hecker
2001-03-06 16:48 ` Marcin 'Qrczak' Kowalczyk
2001-03-06 18:02 ` Chris Hecker
2001-03-08 8:22 ` Fabrice Le Fessant [this message]
2001-03-08 9:34 ` Chris Hecker
2001-03-09 10:54 ` Fabrice Le Fessant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15015.16731.108064.51473@cremant.inria.fr \
--to=fabrice.le_fessant@inria.fr \
--cc=caml-list@inria.fr \
--cc=checker@d6.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).