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 8 - (view) (download) (as text)

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 : monnier 8 ml_val_t RaiseSysError (ml_state_t *msp, int err, const char *alt_msg, const char *at);
40 :     #define RAISE_SYSERR(msp, sts) \
41 :     RaiseSysError((msp), (sts), NIL(char *), "<" __FILE__ ">")
42 :     #define RAISE_ERROR(msp, msg) \
43 :     RaiseSysError((msp), 0, (msg), "<" __FILE__ ">")
44 : monnier 2
45 :     #else
46 : monnier 8 ml_val_t RaiseSysError (ml_state_t *msp, const char *alt_msg, const char *at);
47 :     #define RAISE_SYSERR(msp, sts) \
48 :     RaiseSysError((msp), NIL(char *), "<" __FILE__ ">")
49 :     #define RAISE_ERROR(msp, msg) \
50 :     RaiseSysError((msp), (msg), "<" __FILE__ ">")
51 : monnier 2
52 :     #endif
53 :    
54 :     /* return a value to the calling ML code, but raise an exception if an error
55 :     * occured.
56 :     */
57 :     #define CHK_RETURN_VAL(msp,sts,val) { \
58 :     if ((sts) < 0) \
59 :     return RAISE_SYSERR(msp, sts); \
60 :     else \
61 :     return (val); \
62 :     }
63 :    
64 :     /* return sts to the calling ML code, but raise an exception if an error occured */
65 :     #define CHK_RETURN(msp,sts) { \
66 :     int __sts = (sts); \
67 :     CHK_RETURN_VAL((msp), __sts, INT_CtoML(__sts)) \
68 :     }
69 :    
70 :     /* return unit to the calling ML code, but raise an exception if an error occured */
71 :     #define CHK_RETURN_UNIT(msp,sts) \
72 :     CHK_RETURN_VAL(msp, sts, ML_unit)
73 :    
74 :     #endif /* !_ML_C_ */

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