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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/* ----------------------------------------------------------------------------
* $Id: RtsAPI.h,v 1.9 2000/01/13 12:40:15 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
* API for invoking Haskell functions via the RTS
*
* --------------------------------------------------------------------------*/
#ifndef RTSAPI_H
#define RTSAPI_H
/*
* Running the scheduler
*/
typedef enum {
NoStatus, /* not finished yet */
Success,
Killed, /* another thread killed us */
Interrupted, /* stopped in response to a call to interruptStgRts */
Deadlock /* no threads to run, but main thread hasn't finished */
} SchedulerStatus;
typedef StgClosure *HaskellObj;
/* ----------------------------------------------------------------------------
Starting up and shutting down the Haskell RTS.
------------------------------------------------------------------------- */
extern void startupHaskell ( int argc, char *argv[] );
extern void shutdownHaskell ( void );
extern void shutdownHaskellAndExit ( int exitCode );
/* ----------------------------------------------------------------------------
Building Haskell objects from C datatypes.
------------------------------------------------------------------------- */
HaskellObj rts_mkChar ( char c );
HaskellObj rts_mkInt ( int i );
HaskellObj rts_mkInt8 ( int i );
HaskellObj rts_mkInt16 ( int i );
HaskellObj rts_mkInt32 ( int i );
HaskellObj rts_mkInt64 ( long long i );
HaskellObj rts_mkWord ( unsigned int w );
HaskellObj rts_mkWord8 ( unsigned int w );
HaskellObj rts_mkWord16 ( unsigned int w );
HaskellObj rts_mkWord32 ( unsigned int w );
HaskellObj rts_mkWord64 ( unsigned long long w );
HaskellObj rts_mkFloat ( float f );
HaskellObj rts_mkDouble ( double f );
HaskellObj rts_mkStablePtr ( StgStablePtr s );
HaskellObj rts_mkAddr ( void *a );
HaskellObj rts_mkBool ( int b );
HaskellObj rts_mkString ( char *s );
HaskellObj rts_apply ( HaskellObj, HaskellObj );
/* ----------------------------------------------------------------------------
Deconstructing Haskell objects
------------------------------------------------------------------------- */
char rts_getChar ( HaskellObj );
int rts_getInt ( HaskellObj );
int rts_getInt32 ( HaskellObj );
unsigned int rts_getWord ( HaskellObj );
unsigned int rts_getWord32 ( HaskellObj );
float rts_getFloat ( HaskellObj );
double rts_getDouble ( HaskellObj );
StgStablePtr rts_getStablePtr ( HaskellObj );
void * rts_getAddr ( HaskellObj );
int rts_getBool ( HaskellObj );
/* ----------------------------------------------------------------------------
Evaluating Haskell expressions
The versions ending in '_' allow you to specify an initial stack size.
------------------------------------------------------------------------- */
SchedulerStatus
rts_eval ( HaskellObj p, /*out*/HaskellObj *ret );
SchedulerStatus
rts_eval_ ( HaskellObj p, unsigned int stack_size, /*out*/HaskellObj *ret );
SchedulerStatus
rts_evalIO ( HaskellObj p, /*out*/HaskellObj *ret );
SchedulerStatus
rts_evalLazyIO ( HaskellObj p, unsigned int stack_size, /*out*/HaskellObj *ret );
void
rts_checkSchedStatus ( char* site, SchedulerStatus rc);
#endif /* RTSAPI_H */
|