Commit initial

This commit is contained in:
Matthieu Dubuget
2019-04-13 13:47:57 +02:00
commit ea1e853d0b
7 changed files with 146 additions and 0 deletions

4
tst_stub/dune Executable file
View File

@ -0,0 +1,4 @@
(library
(name tst_stub)
(c_names mytst_stub)
(library_flags :standard -linkall))

3
tst_stub/mytst.h Executable file
View File

@ -0,0 +1,3 @@
void tst_init();
int tst_init_ok();
/* int tst_sum(int a, int b); */

87
tst_stub/mytst_stub.c Executable file
View File

@ -0,0 +1,87 @@
#ifdef WIN32
#include <windows.h>
#endif
#include <assert.h>
#include <caml/mlvalues.h>
#include <caml/alloc.h>
#include <caml/memory.h>
#include <caml/callback.h>
#include "mytst.h"
#ifdef WIN32
#define TST_DLL_EXPORT __declspec(dllexport)
#else
#define TST_DLL_EXPORT
#endif
value dummy(value u){
CAMLparam1(u);
CAMLreturn(Val_unit);
}
static int tst_init_done = 0;
TST_DLL_EXPORT void
tst_init (void)
{
char_os *vide[1];
vide[0] = NULL;
if (!tst_init_done)
{
caml_startup_exn (vide);
tst_init_done = 1;
}
}
TST_DLL_EXPORT int tst_init_ok (void)
{
return tst_init_done;
}
/* TST_DLL_EXPORT int tst_sum(int a, int b){ */
/* CAMLparam0 (); */
/* static value *cbk = NULL; */
/* if (cbk == NULL) */
/* cbk = caml_named_value("additionner"); */
/* assert(cbk); */
/* CAMLlocal1(res); */
/* res = caml_callback2(*cbk, Val_int(a), Val_int(b)); */
/* CAMLreturnT(int, Int_val(res)); */
/* } */
#ifdef WIN32
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpReserved ) // reserved
{
// Perform actions based on the reason for calling.
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
// Initialize once for each new process.
// Return FALSE to fail DLL load.
/* ms_miniscan_init(); */
break;
case DLL_THREAD_ATTACH:
// Do thread-specific initialization.
break;
case DLL_THREAD_DETACH:
// Do thread-specific cleanup.
break;
case DLL_PROCESS_DETACH:
// Perform any necessary cleanup.
break;
}
return TRUE;
}
#endif