File: c-library.h

package info (click to toggle)
smlnj-runtime 110.44-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,968 kB
  • ctags: 5,368
  • sloc: ansic: 24,674; asm: 4,195; makefile: 1,353; sh: 91
file content (45 lines) | stat: -rw-r--r-- 1,248 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* c-library.h
 *
 * COPYRIGHT (c) 1994 AT&T Bell Laboratories.
 */

#ifndef _C_LIBRARY_
#define _C_LIBRARY_

/* a pointer to a library initialization function; it is passed the
 * list of command-line arguments.
 */
typedef void (*clib_init_fn_t) (int, char **);

/* a pointer to an ML callable C function */
typedef ml_val_t (*cfunc_t) (ml_state_t *, ml_val_t);

/* an element in the table of name/function pairs. */
typedef struct {
    const char	    *name;
    cfunc_t	    cfunc;
} cfunc_binding_t;

/* The representation of a library of ML callable C functions */
typedef struct {
    const char	    *libName;	/* the library name */
    const char	    *version;
    const char	    *date;
    clib_init_fn_t  initFn;	/* an optional initialization function */
    cfunc_binding_t *cfuns;	/* the list of C function bindings, which is */
				/* terminated by {0, 0}. */
} c_library_t;


/* A C function prototype declaration */
#define CFUNC_PROTO(NAME, FUNC, MLTYPE)	\
	extern ml_val_t FUNC (ml_state_t *msp, ml_val_t arg);

/* A C function binding */
#define CFUNC_BIND(NAME, FUNC, MLTYPE)	\
    { NAME, FUNC },

/* the terminator for a C function list */
#define CFUNC_NULL_BIND		{ NIL(const char *), NIL(cfunc_t) }

#endif /* !_C_LIBRARY_ */