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/c-libraries.c
ViewVC logotype

View of /sml/trunk/src/runtime/c-libs/c-libraries.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 569 - (download) (as text) (annotate)
Tue Mar 7 04:01:07 2000 UTC (19 years, 4 months ago) by blume
File size: 2490 byte(s)
- size info in BOOTLIST
     * no fixed upper limits for number of bootfiles or length of
       bootfile names in runtime
     * falling back to old behavior if no BOOTLIST size info found
- allocation size heuristics in .run-sml
     * tries to read cache size from /proc/cpuinfo (this is important for
        small-cache Celeron systems!)
- install.sh robustified
- CM manual updates
- paranoid mode
     * no more CMB.deliver() (i.e., all done by CMB.make())
     * can re-use existing sml.boot.* files
     * init.cmi now treated as library
     * library stamps for consistency checks
- sml.boot.<arch>-<os>/PIDMAP file
     * This file is read by the CM startup code.  This is used to minimize
       the amount of dynamic state that needs to be stowed away for the
       purpose of sharing between interactive system and user code.
- CM.Anchor.anchor instead of CM.Anchor.{set,cancel}
     * Upon request by Elsa.  Anchors now controlled by get-set-pair
       like most other CM state variables.
- Compiler.CMSA eliminated
     * No longer supported by CM anyway.
- fixed bugs in pickler that kept biting Stefan
     * past refs to past refs (was caused by the possibility that
       ad-hoc sharing is more discriminating than hash-cons sharing)
     * integer overflow on LargeInt.minInt
- ml-{lex,yacc} build scripts now use new mechanism
  for building standalone programs
- fixed several gcc -Wall warnings that were caused by missing header
  files, missing initializations, etc., in runtime (not all warnings
  eliminated, though)
/* c-libraries.c
 *
 * COPYRIGHT (c) 1994 AT&T Bell Laboratories.
 *
 * This is the home of the CLibrary table, C library initialization code,
 * and C function lookup code.  It is part of the run-time proper (not part
 * of libcfuns.a).
 */

#include <stdio.h>

#ifdef OPSYS_UNIX
#  include "ml-unixdep.h"	/* for the HAS_POSIX_LIBRARIES option flag */
#endif
#include "ml-base.h"
#include "ml-values.h"
#include "c-library.h"
#include "c-globals-tbl.h"

#define C_LIBRARY(lib)  extern c_library_t lib;
#include "clib-list.h"
#undef C_LIBRARY

PVT c_library_t	*CLibs[] = {
#define C_LIBRARY(lib)	&lib,
#	include "clib-list.h"
#undef C_LIBRARY
	NIL(c_library_t *)
    };

/* InitCFunList:
 * Initialize the list of C functions callable from ML.
 */
void InitCFunList ()
{
    int             i, j, libNameLen;
    char	    *nameBuf;

    for (i = 0;  CLibs[i] != NIL(c_library_t *);  i++) {
	c_library_t	*clib = CLibs[i];
	cfunc_binding_t	*cfuns = CLibs[i]->cfuns;

	if (clib->initFn != NIL(clib_init_fn_t)) {
	  /* call the libraries initialization function */
	    (*(clib->initFn)) (0, 0/** argc, argv **/);
	}

      /* register the C functions in the C symbol table */
	libNameLen = strlen(clib->libName) + 2; /* incl "." and "\0" */
	for (j = 0;  cfuns[j].name != NIL(char *);  j++) {
	    nameBuf = NEW_VEC(char, strlen(cfuns[j].name) + libNameLen);
	    sprintf (nameBuf, "%s.%s", clib->libName, cfuns[j].name);
#ifdef INDIRECT_CFUNC
	    RecordCSymbol (nameBuf, PTR_CtoML(&(cfuns[j])));
#else
	    RecordCSymbol (nameBuf, PTR_CtoML(cfuns[j].cfunc));
#endif
	}
    }

} /* end of InitCFunList */

/* BindCFun:
 *
 * Search the C function table for the given function; return ML_unit, if
 * not found.
 * NOTE: eventually, we will raise an exception when the function isn't found.
 */
ml_val_t BindCFun (char *moduleName, char *funName)
{
    int		i, j;

/* SayDebug("BIND: %s.%s\n", moduleName, funName); */
    for (i = 0;  CLibs[i] != NIL(c_library_t *);  i++) {
	if (strcmp(CLibs[i]->libName, moduleName) == 0) {
	    cfunc_binding_t	*cfuns = CLibs[i]->cfuns;
	    for (j = 0;  cfuns[j].name != NIL(char *);  j++) {
		if (strcmp(cfuns[j].name, funName) == 0)
#ifdef INDIRECT_CFUNC
		    return PTR_CtoML(&(cfuns[j]));
#else
		    return PTR_CtoML(cfuns[j].cfunc);
#endif
	    }
	  /* here, we didn't find the library so we return ML_unit */
	    return ML_unit;
	}
    }

  /* here, we didn't find the library so we return ML_unit */
    return ML_unit;

} /* end of BindCFun */


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