File: run_time.h

package info (click to toggle)
polyml 5.7.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 40,616 kB
  • sloc: cpp: 44,142; ansic: 26,963; sh: 22,002; asm: 13,486; makefile: 602; exp: 525; python: 253; awk: 91
file content (102 lines) | stat: -rw-r--r-- 4,054 bytes parent folder | download | duplicates (3)
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
91
92
93
94
95
96
97
98
99
100
101
102
/*
    Title:  run_time.h

    Copyright (c) 2000-9
        Cambridge University Technical Services Limited
    Further development Copyright David C.J. Matthews 2016-17

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License version 2.1 as published by the Free Software Foundation.
    
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
    
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/

#ifndef _RUNTIME_H_DEFINED
#define _RUNTIME_H_DEFINED 1

#include "globals.h" // PolyWord, PolyObject etc
#include "noreturn.h"

class SaveVecEntry;
typedef SaveVecEntry *Handle;
class TaskData;

// Exceptions thrown by C++ code.  Indicates that the caller should not return normally.
// They now result in ML exceptions.

class IOException {
public:
    IOException() { }
};

// This exception is used in the exporter and sharedata code.  It is
// converted into an ML exception at the outer level.
class MemoryException {
public:
    MemoryException() {}
};

// A request to kill the thread raises this exception.
// This allows IO operations to handle this and unwind.
class KillException {
public:
    KillException() {}
};

/* storage allocation functions */
extern PolyObject *alloc(TaskData *taskData, POLYUNSIGNED words, unsigned flags = 0);
extern Handle alloc_and_save(TaskData *taskData, POLYUNSIGNED words, unsigned flags = 0);

extern Handle makeList(TaskData *taskData, int count, char *p, int size, void *arg,
                       Handle (mkEntry)(TaskData *, void*, char*));

// Exceptions without an argument e.g. Size and Overflow
NORETURNFN(extern void raiseException0WithLocation(TaskData *taskData, int id, const char *file, int line));
#define raise_exception0(taskData, id) raiseException0WithLocation(taskData, id, __FILE__, __LINE__)

// Exceptions with a string argument e.g. Foreign
NORETURNFN(extern void raiseExceptionStringWithLocation(TaskData *taskData, int id, const char *str, const char *file, int line));
#define raise_exception_string(taskData, id, str) raiseExceptionStringWithLocation(taskData, id, str, __FILE__, __LINE__)

// Fail exception
NORETURNFN(extern void raiseExceptionFailWithLocation(TaskData *taskData, const char *str, const char *file, int line));
#define raise_fail(taskData, errmsg) raiseExceptionFailWithLocation(taskData, errmsg, __FILE__, __LINE__)

// Syscall exception.  The errmsg argument is ignored and replaced with the standard string unless err is zero.
NORETURNFN(extern void raiseSycallWithLocation(TaskData *taskData, const char *errmsg, int err, const char *file, int line));
#define raise_syscall(taskData, errMsg, err) raiseSycallWithLocation(taskData, errMsg, err, __FILE__, __LINE__)

// Construct an exception packet for future use
poly_exn *makeExceptionPacket(TaskData *taskData, int id);

// Check to see that there is space in the stack.  May GC and may raise a C++ exception.
extern void CheckAndGrowStack(TaskData *mdTaskData, POLYUNSIGNED minSize);

extern Handle errorMsg(TaskData *taskData, int err);

// Create fixed precision values.
extern Handle Make_fixed_precision(TaskData *taskData, long);
extern Handle Make_fixed_precision(TaskData *taskData, unsigned long);

extern Handle Make_fixed_precision(TaskData *taskData, int);
extern Handle Make_fixed_precision(TaskData *taskData, unsigned);

#ifdef HAVE_LONG_LONG
extern Handle Make_fixed_precision(TaskData *taskData, long long);
extern Handle Make_fixed_precision(TaskData *taskData, unsigned long long);
#endif

extern Handle Make_sysword(TaskData *taskData, uintptr_t p);

extern struct _entrypts runTimeEPT[];

#endif /* _RUNTIME_H_DEFINED */