-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathinit.cpp
More file actions
52 lines (42 loc) · 971 Bytes
/
init.cpp
File metadata and controls
52 lines (42 loc) · 971 Bytes
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
#include <R.h>
#include <Rinternals.h>
#include <stdlib.h> // for NULL
#include <R_ext/Rdynload.h>
#ifndef _WIN32
# include <sys/types.h>
# include <unistd.h>
#endif
namespace RcppParallel {
#ifndef _WIN32
static pid_t s_loadPid = 0;
bool isForkedChild()
{
return getpid() != s_loadPid;
}
#else
bool isForkedChild()
{
return false;
}
#endif
} // namespace RcppParallel
/* .Call calls */
extern "C" SEXP defaultNumThreads();
extern "C" SEXP isForkedChild()
{
int forked = RcppParallel::isForkedChild() ? TRUE : FALSE;
return Rf_ScalarLogical(forked);
}
static const R_CallMethodDef CallEntries[] = {
{"defaultNumThreads", (DL_FUNC) &defaultNumThreads, 0},
{"isForkedChild", (DL_FUNC) &isForkedChild, 0},
{NULL, NULL, 0}
};
extern "C" void R_init_RcppParallel(DllInfo *dll)
{
#ifndef _WIN32
RcppParallel::s_loadPid = getpid();
#endif
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}