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

SCM Repository

[smlnj] Annotation of /sml/branches/SMLNJ/src/runtime/c-libs/ml-c.h
ViewVC logotype

Annotation of /sml/branches/SMLNJ/src/runtime/c-libs/ml-c.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (view) (download) (as text)
Original Path: sml/trunk/src/runtime/c-libs/ml-c.h

1 : monnier 2 /* ml-c.h
2 :     *
3 :     * COPYRIGHT (c) 1993 by AT&T Bell Laboratories.
4 :     *
5 :     * Header file for C functions that are callable from ML. This defines
6 :     * a number of macros for checking return results and for raising the SysErr
7 :     * exception:
8 :     *
9 :     * RAISE_SYSERR(msp, sts) Raise the SysErr exception using the
10 :     * appropriate system error message (on
11 :     * some systems, sts may be an error code).
12 :     *
13 :     * RAISE_ERROR(msp, msg) Raise the SysErr exception using the
14 :     * given message (with NONE for the system
15 :     * error part).
16 :     *
17 :     * CHK_RETURN_VAL(msp, sts, val) Check sts for an error (< 0); if okay,
18 :     * then return val. Otherwise raise
19 :     * SysErr with the appropriate system
20 :     * error message.
21 :     *
22 :     * CHK_RETURN(msp, sts) Check sts for an error (< 0); if okay,
23 :     * then return it as the result (after
24 :     * converting to an ML int).
25 :     *
26 :     * CHK_RETURN_UNIT(msp, sts) Check sts for an error (< 0); if okay,
27 :     * then return unit.
28 :     */
29 :    
30 :     #ifndef _ML_C_
31 :     #define _ML_C_
32 :    
33 :     #ifndef _ML_OSDEP_
34 :     #include "ml-osdep.h"
35 :     #endif
36 :    
37 :    
38 :     #ifdef SYSCALL_RET_ERR
39 :     ml_val_t RaiseSysError (ml_state_t *msp, int err, const char *alt_msg);
40 :     #define RAISE_SYSERR(msp, sts) RaiseSysError((msp), (sts), NIL(char *))
41 :     #define RAISE_ERROR(msp, msg) RaiseSysError((msp), 0, (msg))
42 :    
43 :     #else
44 :     ml_val_t RaiseSysError (ml_state_t *msp, const char *alt_msg);
45 :     #define RAISE_SYSERR(msp, sts) RaiseSysError((msp), NIL(char *))
46 :     #define RAISE_ERROR(msp, msg) RaiseSysError((msp), (msg))
47 :    
48 :     #endif
49 :    
50 :     /* return a value to the calling ML code, but raise an exception if an error
51 :     * occured.
52 :     */
53 :     #define CHK_RETURN_VAL(msp,sts,val) { \
54 :     if ((sts) < 0) \
55 :     return RAISE_SYSERR(msp, sts); \
56 :     else \
57 :     return (val); \
58 :     }
59 :    
60 :     /* return sts to the calling ML code, but raise an exception if an error occured */
61 :     #define CHK_RETURN(msp,sts) { \
62 :     int __sts = (sts); \
63 :     CHK_RETURN_VAL((msp), __sts, INT_CtoML(__sts)) \
64 :     }
65 :    
66 :     /* return unit to the calling ML code, but raise an exception if an error occured */
67 :     #define CHK_RETURN_UNIT(msp,sts) \
68 :     CHK_RETURN_VAL(msp, sts, ML_unit)
69 :    
70 :     #endif /* !_ML_C_ */

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