-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathcleancall.h
More file actions
51 lines (37 loc) · 1.43 KB
/
cleancall.h
File metadata and controls
51 lines (37 loc) · 1.43 KB
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
#ifndef CLEANCALL_H
#define CLEANCALL_H
#include <Rversion.h>
#include <Rinternals.h>
#include <R_ext/Rdynload.h>
#ifdef __cplusplus
extern "C" {
#endif
// --------------------------------------------------------------------
// Internals
// --------------------------------------------------------------------
typedef union {void* p; DL_FUNC fn;} fn_ptr;
#if (defined(R_VERSION) && R_VERSION < R_Version(3, 4, 0))
SEXP R_MakeExternalPtrFn(DL_FUNC p, SEXP tag, SEXP prot);
DL_FUNC R_ExternalPtrAddrFn(SEXP s);
#endif
// --------------------------------------------------------------------
// API for packages that embed cleancall
// --------------------------------------------------------------------
// The R API does not have a setter for external function pointers
SEXP cleancall_MakeExternalPtrFn(DL_FUNC p, SEXP tag, SEXP prot);
void cleancall_SetExternalPtrAddrFn(SEXP s, DL_FUNC p);
#define CLEANCALL_METHOD_RECORD \
{"cleancall_call", (DL_FUNC) &cleancall_call, 2}
SEXP cleancall_call(SEXP args, SEXP env);
void cleancall_init(void);
// --------------------------------------------------------------------
// Public API
// --------------------------------------------------------------------
#define R_CLEANCALL_SUPPORT 1
SEXP r_with_cleanup_context(SEXP (*fn)(void* data), void* data);
void r_call_on_exit(void (*fn)(void* data), void* data);
void r_call_on_early_exit(void (*fn)(void* data), void* data);
#ifdef __cplusplus
}
#endif
#endif