From f082eb37296278c3062400a157e98d43ad30a8a7 Mon Sep 17 00:00:00 2001 From: Pasha Stetsenko Date: Mon, 6 Nov 2017 10:33:09 -0800 Subject: [PATCH 1/2] Remove RVersion.h as a dependency --- src/data.table.h | 19 ++++++++++--------- src/dogroups.c | 2 -- src/quickselect.c | 2 -- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/data.table.h b/src/data.table.h index c4dbbef5f0..7c206a9c38 100644 --- a/src/data.table.h +++ b/src/data.table.h @@ -1,7 +1,6 @@ #include #define USE_RINTERNALS #include -#include #ifdef _OPENMP #include #else // so it still compiles on machines with compilers void of openmp support @@ -12,10 +11,12 @@ // raise(SIGINT); #include // for uint64_t rather than unsigned long long +#define RVersion(major, minor, micro) ((major<<16) + (minor<<8) + (micro)) + // Fixes R-Forge #5150, and #1641 -// a simple check for R version to decide if the type should be R_len_t or +// a simple check for R version to decide if the type should be R_len_t or // R_xlen_t long vector support was added in R 3.0.0 -#if defined(R_VERSION) && R_VERSION >= R_Version(3, 0, 0) +#if defined(R_VERSION) && R_VERSION >= RVersion(3, 0, 0) typedef R_xlen_t RLEN; #else typedef R_len_t RLEN; @@ -58,7 +59,7 @@ SEXP sym_BY; SEXP sym_starts, char_starts; SEXP sym_maxgrpn; Rboolean INHERITS(SEXP x, SEXP char_); -long long DtoLL(double x); +long long DtoLL(double x); double LLtoD(long long x); double NA_INT64_D; long long NA_INT64_LL; @@ -113,14 +114,14 @@ SEXP alloccol(SEXP dt, R_len_t n, Rboolean verbose); void memrecycle(SEXP target, SEXP where, int r, int len, SEXP source); SEXP shallowwrapper(SEXP dt, SEXP cols); -SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, - SEXP xjiscols, SEXP grporder, SEXP order, SEXP starts, - SEXP lens, SEXP jexp, SEXP env, SEXP lhs, SEXP newnames, +SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, + SEXP xjiscols, SEXP grporder, SEXP order, SEXP starts, + SEXP lens, SEXP jexp, SEXP env, SEXP lhs, SEXP newnames, SEXP on, SEXP verbose); // bmerge.c -SEXP bmerge(SEXP iArg, SEXP xArg, SEXP icolsArg, SEXP xcolsArg, SEXP isorted, - SEXP xoArg, SEXP rollarg, SEXP rollendsArg, SEXP nomatchArg, +SEXP bmerge(SEXP iArg, SEXP xArg, SEXP icolsArg, SEXP xcolsArg, SEXP isorted, + SEXP xoArg, SEXP rollarg, SEXP rollendsArg, SEXP nomatchArg, SEXP multArg, SEXP opArg, SEXP nqgrpArg, SEXP nqmaxgrpArg); SEXP ENC2UTF8(SEXP s); diff --git a/src/dogroups.c b/src/dogroups.c index 0b9c586571..659e08ece6 100644 --- a/src/dogroups.c +++ b/src/dogroups.c @@ -1,7 +1,5 @@ #include "data.table.h" #include -//#include -#include #include #include diff --git a/src/quickselect.c b/src/quickselect.c index ea79e79192..37500eb157 100644 --- a/src/quickselect.c +++ b/src/quickselect.c @@ -1,7 +1,5 @@ #include "data.table.h" #include -//#include -#include #include #include From 560060bd5b1dcb8a4c3d4b379f57b4d76bc16de7 Mon Sep 17 00:00:00 2001 From: Matt Dowle Date: Mon, 6 Nov 2017 13:04:49 -0800 Subject: [PATCH 2/2] Since data.table now depends on 3.0.0, RVersion macro can be removed completely. --- src/assign.c | 3 +-- src/data.table.h | 17 ++++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/assign.c b/src/assign.c index 9f9b8412d4..831cbbb92d 100644 --- a/src/assign.c +++ b/src/assign.c @@ -1,7 +1,6 @@ #include "data.table.h" #include #include -#include static SEXP *saveds=NULL; static R_len_t *savedtl=NULL, nalloc=0, nsaved=0; @@ -657,7 +656,7 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values, SEXP v } s = ATTRIB(index); // reset to first element indexNo = 0; - while(s != R_NilValue) { + while(s != R_NilValue) { a = TAG(s); indexLength = xlength(CAR(s)); tc1 = c1 = CHAR(PRINTNAME(a)); // the index name; e.g. "__col1__col2" diff --git a/src/data.table.h b/src/data.table.h index 7c206a9c38..56e1ea5b79 100644 --- a/src/data.table.h +++ b/src/data.table.h @@ -11,16 +11,12 @@ // raise(SIGINT); #include // for uint64_t rather than unsigned long long -#define RVersion(major, minor, micro) ((major<<16) + (minor<<8) + (micro)) - -// Fixes R-Forge #5150, and #1641 -// a simple check for R version to decide if the type should be R_len_t or -// R_xlen_t long vector support was added in R 3.0.0 -#if defined(R_VERSION) && R_VERSION >= RVersion(3, 0, 0) - typedef R_xlen_t RLEN; -#else - typedef R_len_t RLEN; -#endif +// data.table depends on R>=3.0.0 when R_xlen_t was introduced +// Before R 3.0.0, RLEN used to be switched to R_len_t as R_xlen_t wasn't available. +// We could now replace all RLEN with R_xlen_t directly. Or keep RLEN for the shorter +// name so as not to have to check closely one letter difference R_xlen_t/R_len_t. We +// might also undefine R_len_t to ensure not to use it. +typedef R_xlen_t RLEN; #define IS_UTF8(x) (LEVELS(x) & 8) #define IS_ASCII(x) (LEVELS(x) & 64) @@ -139,4 +135,3 @@ double wallclock(); int getDTthreads(); void avoid_openmp_hang_within_fork(); -