Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/runtime/c-libs/dl/dlsym.c
ViewVC logotype

View of /sml/trunk/src/runtime/c-libs/dl/dlsym.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1573 - (download) (as text) (annotate)
Mon Aug 2 19:44:48 2004 UTC (15 years, 10 months ago) by mblume
File size: 969 byte(s)
added support for nlffi under win32
/* dlsym.c
 *
 * COPYRIGHT (c) 2000 by Lucent Technologies, Bell Laboratories
 */

#ifdef OPSYS_WIN32
# include <windows.h>
extern void dlerror_set (const char *fmt, const char *s);
#else
# include "ml-unixdep.h"
# include <dlfcn.h>
#endif
#include "ml-base.h"
#include "ml-values.h"
#include "ml-objects.h"
#include "ml-c.h"
#include "cfun-proto-list.h"

/* _ml_P_Dynload_dlsym : Word32.word * string -> Word32.word
 *
 * Extract symbol from dynamically loaded library.
 */
ml_val_t _ml_U_Dynload_dlsym (ml_state_t *msp, ml_val_t arg)
{
  ml_val_t ml_handle = REC_SEL (arg, 0);
  char *symname = STR_MLtoC (REC_SEL (arg, 1));
  void *handle = (void *) (WORD_MLtoC (ml_handle));
  void *addr;
  ml_val_t res;

#ifdef OPSYS_WIN32
  addr = GetProcAddress (handle, symname);
  if (addr == NULL && symname != NULL)
    dlerror_set ("Symbol `%s' not found", symname);
#else
  addr = dlsym (handle, symname);
#endif
  
  WORD_ALLOC (msp, res, (Word_t) addr);
  return res;
}

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0