88 lines
1.7 KiB
C
88 lines
1.7 KiB
C
|
#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
|