aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust.h
blob: 135a1799d32d2a935c0533c9f7bef1e1beba2b9f (plain) (blame)
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
#ifndef RUST_H
#define RUST_H

/*
 * Include this file after you've defined the ISO C9x stdint
 * types (size_t, uint8_t, uintptr_t, etc.)
 */

#ifdef __i386__
// 'cdecl' ABI only means anything on i386
#ifdef __WIN32__
#define CDECL __cdecl
#else
#define CDECL __attribute__((cdecl))
#endif
#else
#define CDECL
#endif

struct rust_srv {
    size_t live_allocs;

    virtual void log(char const *);
    virtual void fatal(char const *, char const *, size_t);
    virtual void *malloc(size_t);
    virtual void *realloc(void *, size_t);
    virtual void free(void *);
    virtual rust_srv *clone();

    rust_srv();
    virtual ~rust_srv();
};

inline void *operator new(size_t size, rust_srv *srv)
{
    return srv->malloc(size);
}

/*
 * Local Variables:
 * fill-column: 78;
 * indent-tabs-mode: nil
 * c-basic-offset: 4
 * buffer-file-coding-system: utf-8-unix
 * compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
 * End:
 */

#endif /* RUST_H */