diff -Nru r-cran-dotcall64-0.9-04/debian/changelog r-cran-dotcall64-0.9-5.2/debian/changelog --- r-cran-dotcall64-0.9-04/debian/changelog 2017-11-09 21:17:55.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/debian/changelog 2018-01-30 17:32:18.000000000 +0000 @@ -1,3 +1,16 @@ +r-cran-dotcall64 (0.9-5.2-1) unstable; urgency=medium + + * Team upload. + * New upstream version 0.9-5.2 + * Drop patches applied upstream: + + buffer-overflow.patch + + hurd-path-max.patch + * Update long description. + * Bump to debhelper compat level 11. + * Bump Standards-Version to 4.1.3. + + -- Sébastien Villemot Tue, 30 Jan 2018 18:32:18 +0100 + r-cran-dotcall64 (0.9-04-2) unstable; urgency=medium * Team upload. diff -Nru r-cran-dotcall64-0.9-04/debian/compat r-cran-dotcall64-0.9-5.2/debian/compat --- r-cran-dotcall64-0.9-04/debian/compat 2017-11-09 21:01:16.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/debian/compat 2018-01-30 17:30:52.000000000 +0000 @@ -1 +1 @@ -10 +11 diff -Nru r-cran-dotcall64-0.9-04/debian/control r-cran-dotcall64-0.9-5.2/debian/control --- r-cran-dotcall64-0.9-04/debian/control 2017-11-09 21:05:00.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/debian/control 2018-01-30 17:31:11.000000000 +0000 @@ -3,10 +3,10 @@ Uploaders: Andreas Tille Section: gnu-r Priority: optional -Build-Depends: debhelper (>= 10), +Build-Depends: debhelper (>= 11), dh-r, r-base-dev -Standards-Version: 4.1.1 +Standards-Version: 4.1.3 Vcs-Browser: https://anonscm.debian.org/cgit/debian-science/packages/r-cran-dotcall64.git Vcs-Git: https://anonscm.debian.org/git/debian-science/packages/r-cran-dotcall64.git Homepage: https://cran.r-project.org/package=dotCall64 @@ -19,8 +19,8 @@ Recommends: ${R:Recommends} Suggests: ${R:Suggests} Description: Enhanced Foreign Function Interface Supporting Long Vectors - An alternative version of .C() and .Fortran() supporting long vectors - and 64-bit integer type arguments. The provided interface .C64() - features mechanisms the avoid unnecessary copies of read-only or write- - only arguments. This makes it a convenient and fast interface to C/C++ - and Fortran code. + Provides .C64(), which is an enhanced version of .C() and .Fortran() from the + foreign function interface. .C64() supports long vectors, arguments of type + 64-bit integer, and provides a mechanism to avoid unnecessary copies of + read-only and write-only arguments. This makes it a convenient and fast + interface to C/C++ and Fortran code. diff -Nru r-cran-dotcall64-0.9-04/debian/patches/buffer-overflow.patch r-cran-dotcall64-0.9-5.2/debian/patches/buffer-overflow.patch --- r-cran-dotcall64-0.9-04/debian/patches/buffer-overflow.patch 2017-11-09 21:14:51.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/debian/patches/buffer-overflow.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -Description: Fix a potential buffer overflow issue - symName is allocated a size of MaxSymbolBytes (1024), not PATH_MAX. -Author: Sébastien Villemot -Last-Update: 2017-11-09 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/src/dotCall64.c -+++ b/src/dotCall64.c -@@ -107,7 +107,7 @@ SEXP dC64(SEXP args_in) { - - // Copy the symbol Name: - p = translateChar(STRING_ELT(CAR(args_in), 0)); -- if(strlen(p) > PATH_MAX - 1) -+ if(strlen(p) > MaxSymbolBytes - 1) - error(_("argument '.NAME' is too long (dotCall64)")); - strcpy(symName, p); - diff -Nru r-cran-dotcall64-0.9-04/debian/patches/hurd-path-max.patch r-cran-dotcall64-0.9-5.2/debian/patches/hurd-path-max.patch --- r-cran-dotcall64-0.9-04/debian/patches/hurd-path-max.patch 2017-11-09 21:17:55.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/debian/patches/hurd-path-max.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -Description: Fix build failure on GNU/Hurd - PATH_MAX is not defined on GNU/Hurd, so give a decent default value. -Author: Sébastien Villemot -Bug-Debian: https://bugs.debian.org/875331 -Last-Update: 2017-11-09 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/src/dotCall64.c -+++ b/src/dotCall64.c -@@ -26,7 +26,10 @@ - // copied from dotcode.c:69 - #define MaxSymbolBytes 1024 - -- -+// Define PATH_MAX for GNU/Hurd -+#ifndef PATH_MAX -+#define PATH_MAX 4096 -+#endif - - /* Attributes like PACKAGE have to be prefixed in order to not get interpreted by .External(...) */ - #define SYMBOL_PREFIX "dotCall64" diff -Nru r-cran-dotcall64-0.9-04/debian/patches/series r-cran-dotcall64-0.9-5.2/debian/patches/series --- r-cran-dotcall64-0.9-04/debian/patches/series 2017-11-09 21:14:58.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/debian/patches/series 2018-01-30 17:29:54.000000000 +0000 @@ -1,2 +0,0 @@ -buffer-overflow.patch -hurd-path-max.patch diff -Nru r-cran-dotcall64-0.9-04/DESCRIPTION r-cran-dotcall64-0.9-5.2/DESCRIPTION --- r-cran-dotcall64-0.9-04/DESCRIPTION 2016-10-07 07:19:26.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/DESCRIPTION 2018-01-11 21:36:35.000000000 +0000 @@ -1,18 +1,19 @@ Package: dotCall64 Type: Package Title: Enhanced Foreign Function Interface Supporting Long Vectors -Version: 0.9-04 -Date: 2016-10-03 -Authors@R: c(person("Kaspar", "Moesinger", role = c("aut", "cre"), +Version: 0.9-5.2 +Date: 2018-01-11 +Authors@R: c(person("Kaspar", "Moesinger", role = c("aut"), email = "kaspar.moesinger@gmail.com"), - person("Florian", "Gerber", role = "ctb", + person("Florian", "Gerber", role = c("cre", "ctb"), email = "florian.gerber@math.uzh.ch"), person("Reinhard", "Furrer", role = "ctb", email = "reinhard.furrer@math.uzh.ch")) -Author: Kaspar Moesinger [aut, cre], Florian Gerber [ctb], Reinhard Furrer [ctb] -Maintainer: Kaspar Moesinger -Description: - An alternative version of .C() and .Fortran() supporting long vectors and 64-bit integer type arguments. The provided interface .C64() features mechanisms the avoid unnecessary copies of read-only or write-only arguments. This makes it a convenient and fast interface to C/C++ and Fortran code. +Description: Provides .C64(), which is an enhanced version of .C() + and .Fortran() from the foreign function interface. .C64() supports long + vectors, arguments of type 64-bit integer, and provides a mechanism to + avoid unnecessary copies of read-only and write-only arguments. This + makes it a convenient and fast interface to C/C++ and Fortran code. License: GPL (>= 2) URL: https://git.math.uzh.ch/reinhard.furrer/dotCall64 BugReports: https://git.math.uzh.ch/reinhard.furrer/dotCall64/issues @@ -20,7 +21,12 @@ Suggests: microbenchmark, OpenMPController, RColorBrewer, roxygen2, spam, testthat, Collate: 'vector_dc.R' 'dotCall64.R' 'zzz.R' +RoxygenNote: 6.0.1 NeedsCompilation: yes -Packaged: 2016-10-06 20:49:44 UTC; moe +Packaged: 2018-01-11 16:23:57 UTC; floger +Author: Kaspar Moesinger [aut], + Florian Gerber [cre, ctb], + Reinhard Furrer [ctb] +Maintainer: Florian Gerber Repository: CRAN -Date/Publication: 2016-10-07 09:19:26 +Date/Publication: 2018-01-11 21:36:35 UTC diff -Nru r-cran-dotcall64-0.9-04/inst/CITATION r-cran-dotcall64-0.9-5.2/inst/CITATION --- r-cran-dotcall64-0.9-04/inst/CITATION 2016-10-01 19:08:23.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/inst/CITATION 2018-01-08 13:13:44.000000000 +0000 @@ -1,40 +1,37 @@ -citHeader("To cite gapfill in publications use:") +citHeader("To cite dotCall64 in publications use:") citEntry(entry = "Article", - title = "{dotCall64}: An efficient interface to compiled {C/C++} and {F}ortran code supporting long vectors", + title = "Extending {R} packages to support 64-bit compiled code: An illustration with spam64 and {GIMMS} {NDVI3g} data", author = personList(as.person("Florian Gerber"), as.person("Kaspar Moesinger"), as.person("Reinhard Furrer")), - journal = "R journal", - year = "2016", - volume = "", + journal = "Computer & Geoscience", + year = "2017", + volume = "104", number = "", - pages = "", - url = "", - note = "submitted", - + pages = "109--119", + issn = "0098-3004", + doi = "10.1016/j.cageo.2016.11.015", textVersion = - paste("F. Gerber, K. Moesinger, R. Furrer (2016),", - "\"dotCall64: An efficient interface to compiled C/C++ and Fortran code supporting long vectors\",", - "submitted to the R Journal.") + paste("F. Gerber, K. Moesinger, R. Furrer (2017),", + "Extending R packages to support 64-bit compiled code: An illustration with spam64 and GIMMS NDVI3g data,", + "Computer & Geoscience 104, 109-119, https://doi.org/10.1016/j.cageo.2016.11.015.") ) - citEntry(entry = "Article", - title = "Extending {R} packages to support 64-bit compiled code: An illustration with spam64 and {GIMMS} {NDVI3g} data", + title = "{dotCall64}: An efficient interface to compiled {C/C++} and {F}ortran code supporting long vectors", author = personList(as.person("Florian Gerber"), as.person("Kaspar Moesinger"), as.person("Reinhard Furrer")), - journal = "Computer & Geoscience", - year = "2015", + journal = "arXiv", + year = "2017", volume = "", number = "", pages = "", - url = "", - note = "submitted", - + url = "https://arxiv.org/abs/1702.08188", + note = "", textVersion = - paste("F. Gerber, K. Moesinger, R. Furrer (2016),", - "\"Extending R packages to support 64-bit compiled code: An illustration with spam64 and GIMMS NDVI3g data\",", - "submitted to Computer & Geoscience.") + paste("F. Gerber, K. Moesinger, R. Furrer (2017),", + "dotCall64: An efficient interface to compiled C/C++ and Fortran code supporting long vectors,", + "https://arxiv.org/abs/1702.08188.") ) diff -Nru r-cran-dotcall64-0.9-04/inst/include/dotCall64.h r-cran-dotcall64-0.9-5.2/inst/include/dotCall64.h --- r-cran-dotcall64-0.9-04/inst/include/dotCall64.h 2016-10-02 07:17:33.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/inst/include/dotCall64.h 2018-01-08 13:13:44.000000000 +0000 @@ -4,19 +4,19 @@ #include #include -// Defines DL_FUNC. +// Definition of DL_FUNC. #include -// Defines INTSXP and REALSXP to be used in the args_type array. +// Definition of INTSXP and REALSXP. #include -// Defines int64_t on windows +// Definition of int64_t #include /* - * Because R does not define an int64 type, this pseudo type should be used to + * Because R does not define an int64 type, this pseudo type is used to * indicate an int64_t argument type: - * Currently, R only uses 4 bits for it's types. Therefore this value will not + * Currently, R only uses 4 bits for types. Therefore, this value will not * clash. */ #define INT64_TYPE 9999 @@ -28,9 +28,6 @@ #define INT64_STRING "int64" -/* - * TODO: Maybe, this should be defined as an enum? - */ #define INTENT_READ 0x1 #define INTENT_WRITE 0x2 #define INTENT_COPY 0x4 @@ -74,7 +71,7 @@ -// The maximum number of arguments that a function may have: +// The maximum number of arguments that a function can have. #define MAX_ARGS 65 #endif diff -Nru r-cran-dotcall64-0.9-04/man/dotCall64.Rd r-cran-dotcall64-0.9-5.2/man/dotCall64.Rd --- r-cran-dotcall64-0.9-04/man/dotCall64.Rd 2016-10-03 16:45:12.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/man/dotCall64.Rd 2018-01-11 16:10:21.000000000 +0000 @@ -1,24 +1,24 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dotCall64.R \name{dotCall64} -\alias{.C64} \alias{dotCall64} +\alias{.C64} \title{dotCall64 - Extended Foreign Function Interface} \usage{ .C64(.NAME, SIGNATURE, ..., INTENT = NULL, NAOK = FALSE, PACKAGE = "", VERBOSE = getOption("dotCall64.verbose")) } \arguments{ -\item{.NAME}{a character vector of length 1. Specifies the name of the compiled function to be called.} +\item{.NAME}{character vector of length 1. Name of the compiled function to be called.} -\item{SIGNATURE}{a character vector of the same length as the number of arguments of the compiled function. -Accepted strings are \code{"double"}, \code{"integer"}, \code{"int64"} describing the signature -of each argument of the compiled function.} +\item{SIGNATURE}{character vector of the same length as the number of arguments of the compiled function. +Accepted strings are \code{"double"}, \code{"integer"}, and \code{"int64"}. +They describe the signature of each argument of the compiled function.} \item{...}{arguments passed to the compiled function. One R object for each argument. Up to 65 arguments are supported.} -\item{INTENT}{a character vector of the same length as the number of arguments of the compiled code. -Accepted strings are \code{"rw"}, \code{"r"} or \code{"w"} indicating +\item{INTENT}{character vector of the same length as the number of arguments of the compiled function. +Accepted strings are \code{"rw"}, \code{"r"}, and \code{"w"}, which indicate whether the intent of the argument is "read and write", "read", or "write", respectively. If the INTENT of an argument is \code{"rw"}, the R object is copied and the compiled function receives a pointer to that copy. @@ -27,55 +27,54 @@ While this avoids copying and hence is more efficient in terms of speed and memory usage, it is absolutely necessary that the compiled function does not alter the object, since this corrupts the R object in the current R session. -When the intent is \code{"w"}, the corresponding input argument can be specified +When the INTENT is \code{"w"}, the corresponding input argument can be specified with the function \code{\link{vector_dc}} or its shortcuts \code{\link{integer_dc}} and \code{\link{numeric_dc}}. This avoids copying the passed R objects and hence is more efficient in terms of speed and memory usage. -By default, all arguments have intent \code{"rw"}.} +By default, all arguments have INTENT \code{"rw"}.} -\item{NAOK}{logical vector of length 1. If \code{FALSE} (default), the presence of \code{NA} or \code{NaN} or \code{Inf} +\item{NAOK}{logical vector of length 1. If \code{FALSE} (default), the presence of \code{NA}, \code{NaN}, and \code{Inf} in the R objects passed through \code{...} results in an error. -If \code{TRUE}, any \code{NA} or \code{NaN} or \code{Inf} values in the -arguments are passed on to the compiled function. -The used time to check arguments (if \code{FALSE}) maybe considerable for large vectors.} +If \code{TRUE}, \code{NA}, \code{NaN}, and \code{Inf} values are passed to the compiled function. +The used time to check arguments (if \code{FALSE}) is considerable for large vectors.} -\item{PACKAGE}{character vector of length 1. Specifies where to search for the function given in \code{.NAME}. +\item{PACKAGE}{character vector of length 1. Specifies where to search for the function given in \code{.NAME}. This is intended to add safety for packages, which can use this argument to ensure that no other package can override their external symbols, and also speeds up the search.} -\item{VERBOSE}{Numeric vector of length 1. If \code{0}, no warnings are printed. -If \code{1} warnings are printed (which may help to improve the performance of the call), -If \code{2} additional debug information is given as warnings. +\item{VERBOSE}{numeric vector of length 1. If \code{0}, no warnings are printed. +If \code{1}, warnings are printed, which help to improve the performance of the call. +If \code{2}, additional debug information is given as warnings. The default value can be changed via the \code{dotCall64.verbose} option, which is set to \code{0} by default.} } \value{ -A list similar to the \code{...} list of arguments passed in (including -any names given to the arguments), but reflecting any changes made -by the compiled C or Fortran code. +list of R objects similar to the list of arguments specified as \code{...} arguments. +The objects of the list reflect the changes made by the compiled C or Fortran function. } \description{ -\code{.C64} can be used to call compiled and loaded C functions and Fortran subroutines. -It works similar to \code{\link{.C}} and \code{\link{.Fortran}}, and +\code{.C64} can be used to call compiled and loaded C/C++ functions and Fortran subroutines. +\code{.C64} is similar to \code{\link{.C}} and \code{\link{.Fortran}}, but \enumerate{ - \item supports long vectors, i.e., vectors with more than \code{2^31-1} elements, + \item supports long vectors, i.e., vectors with more than \code{2^31-1} elements \item does the necessary castings to expose the R representation of "64-bit integers" (numeric vectors) -to 64-bit integers arguments of the compiled function; int64_t types in C and integer (kind = 8) in Fortran, - \item provides a mechanism the control the duplication of the R objects exposed to the compiled code, - \item checks if the provided R objects are of the expected type and coerces the R object if necessary. +to 64-bit integer arguments of the compiled function. The latter are int64_t in C code and integer (kind = 8) in Fortran code + \item provides a mechanism the control duplication of the R objects exposed to the compiled code + \item checks if the provided R objects are of the expected types and coerces them if necessary } Compared to \code{\link{.C}}, \code{.C64} has the additional arguments \code{SIGNATURE}, \code{INTENT} and \code{VERBOSE}. \code{SIGNATURE} specifies the types of the arguments of the compiled function. -\code{INTENT} indicates whether the compiled function "reads", "writes", or "read and writes" the R objects passed -to the compiled function. This is then used to duplicates R objects if (and only if) necessary. +\code{INTENT} indicates whether the compiled function "reads", "writes", +or "read and writes" to the R objects passed to the compiled function. +This information is then used to duplicate R objects if and only if necessary. } \examples{ ## Consider the following C function, which is included -## in the dotCall64 package: +## in the dotCall64 package: ## void get_c(double *input, int *index, double *output) { ## output[0] = input[index[0] - 1]; ## } ## -## We can use .C64() the call it from R: +## We can use .C64() to call get_c() from R: .C64("get_c", SIGNATURE = c("double", "integer", "double"), input = 1:10, index = 9, output = double(1))$output @@ -86,23 +85,23 @@ .C64("get_c", SIGNATURE = c("double", "integer", "double"), input = x_long, index = 9, output = double(1))$output -## Since 'index' is of type 'signed int' resulting in a 32-bit integer, -## it can only capture integers op to 2^31-1. To extend this, -## we define the C function as follows: -## #include // defines the int64_t type +## Since 'index' is of type 'signed int' (a 32-bit integer), +## it can only address the first 2^31-1 elements of 'input'. +## To also address elements beyond 2^31-1, we change the +## definition of the C function as follows: +## #include // for int64_t ## void get64_c(double *input, int64_t *index, double *output) { ## output[0] = input[index[0] - 1]; ## } -## We can use .C64() to call the function from R. +## Now, we can use .C64() to call get64_c() from R. .C64("get64_c", SIGNATURE = c("double", "int64", "double"), input = x_long, index = 2^31, output = double(1))$output +## Note that 2^31 is of type double and .C64() casts it into an +## int64_t type before calling the C function get64_c(). -## Note that .C64() takes 2^31 as double and casts it to int64_t -## before calling the C function get64_c(). - -## The performance of the previous call can be improved with -## additional options: +## The performance of the previous call can be improved by +## setting additional arguments: .C64("get64_c", SIGNATURE = c("double", "int64", "double"), x = x_long, i = 2^31, r = numeric_dc(1), INTENT = c("r", "r", "w"), NAOK = TRUE, PACKAGE = "dotCall64", VERBOSE = 0)$r @@ -118,16 +117,15 @@ ## The function is provided in dotCall64 and can be called with .C64("get64_f", SIGNATURE = c("double", "int64", "double"), input = x_long, index = 2^31, output = double(1))$output - } } \references{ -F. Gerber, K. Moesinger, and R. Furrer, -"dotCall64: An efficient interface to compiled C/C++ and Fortran code -supporting long vectors", submitted to the Rjournal, 2016. - -F. Gerber, K. Moesinger, and R. Furrer, -"Extending R packages to support 64-bit compiled code: An illustration -with spam64 and GIMMS NDVI 3g data", submitted to Computers & Geoscience, 2015. +F. Gerber, K. Moesinger, and R. Furrer (2017), +Extending R packages to support 64-bit compiled code: An illustration with spam64 and GIMMS NDVI3g data, +Computer & Geoscience 104, 109-119, +https://doi.org/10.1016/j.cageo.2016.11.015. + +F. Gerber, K. Moesinger, and R. Furrer (2017), +dotCall64: An efficient interface to compiled C/C++ and Fortran code supporting long vectors, +https://arxiv.org/abs/1702.08188. } - diff -Nru r-cran-dotcall64-0.9-04/man/vector_dc.Rd r-cran-dotcall64-0.9-5.2/man/vector_dc.Rd --- r-cran-dotcall64-0.9-04/man/vector_dc.Rd 2016-10-01 19:08:23.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/man/vector_dc.Rd 2018-01-11 15:54:50.000000000 +0000 @@ -1,9 +1,9 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/vector_dc.R \name{vector_dc} -\alias{integer_dc} -\alias{numeric_dc} \alias{vector_dc} +\alias{numeric_dc} +\alias{integer_dc} \title{Allocate vectors in .C64()} \usage{ vector_dc(mode = "logical", length = 0L) @@ -13,23 +13,21 @@ integer_dc(length = 0) } \arguments{ -\item{mode}{Character vector of length 1. Storage mode of the vector to allocate.} +\item{mode}{character vector of length 1. Storage mode of the vector.} -\item{length}{Numeric vector of length 1. Length of the vector to allocate.} +\item{length}{numeric vector of length 1. Length of the vector.} } \value{ -Object of class \code{vector_dc} and \code{list}. +object of class \code{vector_dc} and \code{list}. } \description{ -Helper functions to be used in calls to \code{\link{.C64}}. -The function \code{vector_dc} and its shortcuts \code{numeric_dc} and -\code{integer_dc} return a R object of class \code{c("vector_dc", "list")} -containing the necessary information (type and length) to allocate the -vector (initialized with 0) inside the call to \code{\link{.C64}}. +\code{vector_dc} and its shortcuts \code{numeric_dc} and +\code{integer_dc} are helper functions used in calls to \code{\link{.C64}}. +They return an R object of class \code{c("vector_dc", "list")}, +which contains information on the type and length of the vector to allocate. Using \code{vector_dc} together with \code{INTENT = "w"} argument of \code{\link{.C64}} leads to performance gains by avoiding unnecessary castings and copies. } \examples{ vector_dc("integer", 20) } - diff -Nru r-cran-dotcall64-0.9-04/MD5 r-cran-dotcall64-0.9-5.2/MD5 --- r-cran-dotcall64-0.9-04/MD5 2016-10-07 07:19:26.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/MD5 2018-01-11 21:36:35.000000000 +0000 @@ -1,16 +1,17 @@ -bb9658cd9b919b602b6dd780117de4e6 *DESCRIPTION -5ecae9e999f7d9a791dda6059ff99459 *NAMESPACE -d63df473072cc85e7ad20d472e48114f *NEWS.md -348f28da309d88d4df9cf7b7510c6c07 *R/dotCall64.R -a0f4b3a03d134e8516714968c6cdb5f8 *R/vector_dc.R +0754dee2fca84c8680471efb375f08fc *DESCRIPTION +1ba18d2efda06ab031f178ca7e736a01 *NAMESPACE +2c68f04593e39af2bef7f419be05e13c *NEWS.md +8b51f3d261ad6f14bce13b6967ad569f *R/dotCall64.R +9979be048884f10640063c09d1b00878 *R/vector_dc.R 6ce69e2ecaa6aafccc57181a7bc52836 *R/zzz.R -925c93f8b7afa048eafb1f2296f52a25 *inst/CITATION -065858e22b509b800788b11a16c24469 *inst/include/dotCall64.h -024bc9e50267a3e99b47ce54358cd22f *man/dotCall64.Rd -fa197f82b993deebe4441b037fc8c5bc *man/vector_dc.Rd +2eaf60d9a55612cb6fd2528002cf0213 *inst/CITATION +013a77abf97cc8a7237c37e5ff9af37a *inst/include/dotCall64.h +bc39e8bd582afbbb7ccf09d735417ed5 *man/dotCall64.Rd +d96db3736e853f2eadce547224a297c6 *man/vector_dc.Rd 356b809b916a94506bcdde171e6e4cfc *src/Makevars -542435e461765df5e414b5d94885f122 *src/dotCall64.c +8ea93cdb08279ce23b8209f4dfa0bf5c *src/dotCall64.c 20ff6f909591b7aed0035f7fd7c2e684 *src/dotCall64helpers.c +dad049af9ed37d954f4959b54a1cfe4e *src/init.c 4b772404f987db420fd647b31e159fb6 *src/testfunctions_c.c 1b0b68eab1e335c1aba9588886f4b480 *src/testfunctions_f.f 4b8524917a613bc864ba74a64b2e61a4 *tests/run-all.R diff -Nru r-cran-dotcall64-0.9-04/NAMESPACE r-cran-dotcall64-0.9-5.2/NAMESPACE --- r-cran-dotcall64-0.9-04/NAMESPACE 2016-10-01 19:08:23.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/NAMESPACE 2018-01-08 13:13:44.000000000 +0000 @@ -1,7 +1,7 @@ -# Generated by roxygen2 (4.1.1): do not edit by hand +# Generated by roxygen2: do not edit by hand export(.C64) export(integer_dc) export(numeric_dc) export(vector_dc) -useDynLib(dotCall64) +useDynLib(dotCall64, .registration = TRUE) diff -Nru r-cran-dotcall64-0.9-04/NEWS.md r-cran-dotcall64-0.9-5.2/NEWS.md --- r-cran-dotcall64-0.9-04/NEWS.md 2016-10-06 20:44:24.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/NEWS.md 2018-01-11 16:23:31.000000000 +0000 @@ -1,3 +1,20 @@ -# dotCall64 0.9-04 +# dotCall64 + +# 0.9-5.2 +commit c184c8a9e883ccc3b5afe3d5639d689724f71176 +Author: Florian Gerber +Date: Thu Jan 11 17:14:48 2018 +0100 +* improve documentation + + +# 0.9-5 +commit 1cfc4937b52fcad0ce6bf28b246cec289c15d07d +Author: Florian Gerber +Date: Tue Dec 5 21:37:52 2017 +0100 +* debian patch +* update references +* register native routines + +# 0.9-4 * CRAN release. \ No newline at end of file diff -Nru r-cran-dotcall64-0.9-04/R/dotCall64.R r-cran-dotcall64-0.9-5.2/R/dotCall64.R --- r-cran-dotcall64-0.9-04/R/dotCall64.R 2016-10-03 16:45:12.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/R/dotCall64.R 2018-01-11 16:09:25.000000000 +0000 @@ -1,26 +1,27 @@ #' dotCall64 - Extended Foreign Function Interface #' -#' \code{.C64} can be used to call compiled and loaded C functions and Fortran subroutines. -#' It works similar to \code{\link{.C}} and \code{\link{.Fortran}}, and +#' \code{.C64} can be used to call compiled and loaded C/C++ functions and Fortran subroutines. +#' \code{.C64} is similar to \code{\link{.C}} and \code{\link{.Fortran}}, but #' \enumerate{ -#' \item supports long vectors, i.e., vectors with more than \code{2^31-1} elements, +#' \item supports long vectors, i.e., vectors with more than \code{2^31-1} elements #' \item does the necessary castings to expose the R representation of "64-bit integers" (numeric vectors) -#' to 64-bit integers arguments of the compiled function; int64_t types in C and integer (kind = 8) in Fortran, -#' \item provides a mechanism the control the duplication of the R objects exposed to the compiled code, -#' \item checks if the provided R objects are of the expected type and coerces the R object if necessary. +#' to 64-bit integer arguments of the compiled function. The latter are int64_t in C code and integer (kind = 8) in Fortran code +#' \item provides a mechanism the control duplication of the R objects exposed to the compiled code +#' \item checks if the provided R objects are of the expected types and coerces them if necessary #' } #' Compared to \code{\link{.C}}, \code{.C64} has the additional arguments \code{SIGNATURE}, \code{INTENT} and \code{VERBOSE}. #' \code{SIGNATURE} specifies the types of the arguments of the compiled function. -#' \code{INTENT} indicates whether the compiled function "reads", "writes", or "read and writes" the R objects passed -#' to the compiled function. This is then used to duplicates R objects if (and only if) necessary. +#' \code{INTENT} indicates whether the compiled function "reads", "writes", +#' or "read and writes" to the R objects passed to the compiled function. +#' This information is then used to duplicate R objects if and only if necessary. #' -#' @param .NAME a character vector of length 1. Specifies the name of the compiled function to be called. -#' @param SIGNATURE a character vector of the same length as the number of arguments of the compiled function. -#' Accepted strings are \code{"double"}, \code{"integer"}, \code{"int64"} describing the signature -#' of each argument of the compiled function. +#' @param .NAME character vector of length 1. Name of the compiled function to be called. +#' @param SIGNATURE character vector of the same length as the number of arguments of the compiled function. +#' Accepted strings are \code{"double"}, \code{"integer"}, and \code{"int64"}. +#' They describe the signature of each argument of the compiled function. #' @param ... arguments passed to the compiled function. One R object for each argument. Up to 65 arguments are supported. -#' @param INTENT a character vector of the same length as the number of arguments of the compiled code. -#' Accepted strings are \code{"rw"}, \code{"r"} or \code{"w"} indicating +#' @param INTENT character vector of the same length as the number of arguments of the compiled function. +#' Accepted strings are \code{"rw"}, \code{"r"}, and \code{"w"}, which indicate #' whether the intent of the argument is "read and write", "read", or "write", respectively. #' If the INTENT of an argument is \code{"rw"}, the R object is copied and the #' compiled function receives a pointer to that copy. @@ -29,37 +30,36 @@ #' While this avoids copying and hence is more efficient in terms of speed and memory usage, #' it is absolutely necessary that the compiled function does not alter the object, #' since this corrupts the R object in the current R session. -#' When the intent is \code{"w"}, the corresponding input argument can be specified +#' When the INTENT is \code{"w"}, the corresponding input argument can be specified #' with the function \code{\link{vector_dc}} or its shortcuts \code{\link{integer_dc}} and \code{\link{numeric_dc}}. #' This avoids copying the passed R objects and hence is more efficient in terms of speed and memory usage. -#' By default, all arguments have intent \code{"rw"}. -#' @param NAOK logical vector of length 1. If \code{FALSE} (default), the presence of \code{NA} or \code{NaN} or \code{Inf} +#' By default, all arguments have INTENT \code{"rw"}. +#' @param NAOK logical vector of length 1. If \code{FALSE} (default), the presence of \code{NA}, \code{NaN}, and \code{Inf} #' in the R objects passed through \code{...} results in an error. -#' If \code{TRUE}, any \code{NA} or \code{NaN} or \code{Inf} values in the -#' arguments are passed on to the compiled function. -#' The used time to check arguments (if \code{FALSE}) maybe considerable for large vectors. +#' If \code{TRUE}, \code{NA}, \code{NaN}, and \code{Inf} values are passed to the compiled function. +#' The used time to check arguments (if \code{FALSE}) is considerable for large vectors. #' @param PACKAGE character vector of length 1. Specifies where to search for the function given in \code{.NAME}. #' This is intended to add safety for packages, #' which can use this argument to ensure that no other package can override their external symbols, #' and also speeds up the search. -#' @param VERBOSE Numeric vector of length 1. If \code{0}, no warnings are printed. -#' If \code{1} warnings are printed (which may help to improve the performance of the call), -#' If \code{2} additional debug information is given as warnings. +#' @param VERBOSE numeric vector of length 1. If \code{0}, no warnings are printed. +#' If \code{1}, warnings are printed, which help to improve the performance of the call. +#' If \code{2}, additional debug information is given as warnings. #' The default value can be changed via the \code{dotCall64.verbose} option, which is set to \code{0} by default. #' -#' @return A list similar to the \code{...} list of arguments passed in (including -#' any names given to the arguments), but reflecting any changes made -#' by the compiled C or Fortran code. +#' @return list of R objects similar to the list of arguments specified as \code{...} arguments. +#' The objects of the list reflect the changes made by the compiled C or Fortran function. #' #' @references -#' F. Gerber, K. Moesinger, and R. Furrer, -#' "dotCall64: An efficient interface to compiled C/C++ and Fortran code -#' supporting long vectors", submitted to the Rjournal, 2016. -#' -#' F. Gerber, K. Moesinger, and R. Furrer, -#' "Extending R packages to support 64-bit compiled code: An illustration -#' with spam64 and GIMMS NDVI 3g data", submitted to Computers & Geoscience, 2015. -#' +#' F. Gerber, K. Moesinger, and R. Furrer (2017), +#' Extending R packages to support 64-bit compiled code: An illustration with spam64 and GIMMS NDVI3g data, +#' Computer & Geoscience 104, 109-119, +#' https://doi.org/10.1016/j.cageo.2016.11.015. +#' +#' F. Gerber, K. Moesinger, and R. Furrer (2017), +#' dotCall64: An efficient interface to compiled C/C++ and Fortran code supporting long vectors, +#' https://arxiv.org/abs/1702.08188. +#' #' @examples #' ## Consider the following C function, which is included #' ## in the dotCall64 package: @@ -67,7 +67,7 @@ #' ## output[0] = input[index[0] - 1]; #' ## } #' ## -#' ## We can use .C64() the call it from R: +#' ## We can use .C64() to call get_c() from R: #' .C64("get_c", SIGNATURE = c("double", "integer", "double"), #' input = 1:10, index = 9, output = double(1))$output #' @@ -78,23 +78,23 @@ #' .C64("get_c", SIGNATURE = c("double", "integer", "double"), #' input = x_long, index = 9, output = double(1))$output #' -#' ## Since 'index' is of type 'signed int' resulting in a 32-bit integer, -#' ## it can only capture integers op to 2^31-1. To extend this, -#' ## we define the C function as follows: -#' ## #include // defines the int64_t type +#' ## Since 'index' is of type 'signed int' (a 32-bit integer), +#' ## it can only address the first 2^31-1 elements of 'input'. +#' ## To also address elements beyond 2^31-1, we change the +#' ## definition of the C function as follows: +#' ## #include // for int64_t #' ## void get64_c(double *input, int64_t *index, double *output) { #' ## output[0] = input[index[0] - 1]; #' ## } #' -#' ## We can use .C64() to call the function from R. +#' ## Now, we can use .C64() to call get64_c() from R. #' .C64("get64_c", SIGNATURE = c("double", "int64", "double"), #' input = x_long, index = 2^31, output = double(1))$output +#' ## Note that 2^31 is of type double and .C64() casts it into an +#' ## int64_t type before calling the C function get64_c(). #' -#' ## Note that .C64() takes 2^31 as double and casts it to int64_t -#' ## before calling the C function get64_c(). -#' -#' ## The performance of the previous call can be improved with -#' ## additional options: +#' ## The performance of the previous call can be improved by +#' ## setting additional arguments: #' .C64("get64_c", SIGNATURE = c("double", "int64", "double"), #' x = x_long, i = 2^31, r = numeric_dc(1), INTENT = c("r", "r", "w"), #' NAOK = TRUE, PACKAGE = "dotCall64", VERBOSE = 0)$r @@ -110,9 +110,8 @@ #' ## The function is provided in dotCall64 and can be called with #' .C64("get64_f", SIGNATURE = c("double", "int64", "double"), #' input = x_long, index = 2^31, output = double(1))$output -#' #' } -#' @useDynLib dotCall64 +#' @useDynLib dotCall64, .registration = TRUE #' @export #' @name dotCall64 .C64 <- function(.NAME, SIGNATURE, ..., INTENT = NULL, NAOK = FALSE, diff -Nru r-cran-dotcall64-0.9-04/R/vector_dc.R r-cran-dotcall64-0.9-5.2/R/vector_dc.R --- r-cran-dotcall64-0.9-04/R/vector_dc.R 2016-10-01 19:08:23.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/R/vector_dc.R 2018-01-11 15:54:50.000000000 +0000 @@ -1,16 +1,15 @@ #' Allocate vectors in .C64() #' -#' Helper functions to be used in calls to \code{\link{.C64}}. -#' The function \code{vector_dc} and its shortcuts \code{numeric_dc} and -#' \code{integer_dc} return a R object of class \code{c("vector_dc", "list")} -#' containing the necessary information (type and length) to allocate the -#' vector (initialized with 0) inside the call to \code{\link{.C64}}. +#' \code{vector_dc} and its shortcuts \code{numeric_dc} and +#' \code{integer_dc} are helper functions used in calls to \code{\link{.C64}}. +#' They return an R object of class \code{c("vector_dc", "list")}, +#' which contains information on the type and length of the vector to allocate. #' Using \code{vector_dc} together with \code{INTENT = "w"} argument of \code{\link{.C64}} #' leads to performance gains by avoiding unnecessary castings and copies. #' -#' @param mode Character vector of length 1. Storage mode of the vector to allocate. -#' @param length Numeric vector of length 1. Length of the vector to allocate. -#' @return Object of class \code{vector_dc} and \code{list}. +#' @param mode character vector of length 1. Storage mode of the vector. +#' @param length numeric vector of length 1. Length of the vector. +#' @return object of class \code{vector_dc} and \code{list}. #' @name vector_dc #' @rdname vector_dc #' @examples diff -Nru r-cran-dotcall64-0.9-04/src/dotCall64.c r-cran-dotcall64-0.9-5.2/src/dotCall64.c --- r-cran-dotcall64-0.9-04/src/dotCall64.c 2016-10-06 20:49:44.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/src/dotCall64.c 2018-01-11 16:23:57.000000000 +0000 @@ -1,7 +1,6 @@ #include "dotCall64.h" // MAYBE_SHARED is not available in R 3.0.1 -// TODO: find out when introduced #ifndef MAYBE_SHARED #define MAYBE_SHARED(x) (NAMED(x) > 1) #define NO_REFERENCES(x) (NAMED(x) == 0) @@ -26,6 +25,10 @@ // copied from dotcode.c:69 #define MaxSymbolBytes 1024 +/* Define PATH_MAX for GNU/Hurd */ +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif /* Attributes like PACKAGE have to be prefixed in order to not get interpreted by .External(...) */ @@ -61,8 +64,6 @@ switch(p[i]) { case('r'): x |= INTENT_READ; break; case('w'): x |= INTENT_WRITE; break; -// case('c'): x |= INTENT_COPY; break; // disabled -// case('s'): x |= INTENT_SPEED; break; default: error(_("unknown intent '%c'"), p[i]); } } @@ -90,7 +91,7 @@ SEXP args[MAX_ARGS]; SEXP args_names[MAX_ARGS]; - int n_protect = 0; // counts the number of times that PROTECT has been called. + int n_protect = 0; // counts how many times PROTECT has been called. // The first argument contains the value "dotCall64", as it is the first argument given to .External(...). args_in = CDR(args_in); @@ -104,10 +105,9 @@ } } - - // Copy the symbol Name: + // Copy the symbol name: p = translateChar(STRING_ELT(CAR(args_in), 0)); - if(strlen(p) > PATH_MAX - 1) + if(strlen(p) > MaxSymbolBytes - 1) error(_("argument '.NAME' is too long (dotCall64)")); strcpy(symName, p); @@ -116,7 +116,7 @@ // Get the effective arguments: argsfind(args_in, args, args_names, &nargs, packageName, &signature, &intent, &naok, &verbose); - // We don't need to PROTECT args and args_names, because they are protected by being a subobject of args_in. + // We do not need to PROTECT args and args_names, because they are protected by being a subobject of args_in. // Check the NAOK argument if(!naok || LENGTH(naok) != 1) @@ -145,7 +145,7 @@ } // We cannot check if the number of given arguments equals to the number of expected arguments because - // R_RegisteredNativeSymbol is declared private API. + // R_RegisteredNativeSymbol is declared as private API. // Any argument of class "vector_dc" must be expanded to the correct type @@ -164,7 +164,7 @@ } - // First we determine the current type of the vectors, as they represent the default type: + // First we determine the current types of the vectors, as they represent the default types: int args_type[MAX_ARGS]; int args_intent[MAX_ARGS]; SEXP sexpargs[MAX_ARGS]; @@ -207,7 +207,7 @@ } - // Determine if the arguments were named and keep the names if true. + // Determine if the arguments are named and keep the names if true. SEXP names = NULL; Rboolean havenames = FALSE; for(na = 0; na < nargs; na++) { @@ -225,11 +225,11 @@ } - // Finally, call the function + // Call the function. dotCall64(fun, nargs, sexpargs, args_type, args_intent, flag_naok, flag_verbose); - // First, protect every 'write' argument returned by dotCall64 + // Protect every 'write' argument returned by dotCall64. for (na = 0 ; na < nargs; na++) { if(!HAS_INTENT_WRITE(args_intent[na])) continue; @@ -241,7 +241,7 @@ PROTECT(answer = allocVector(VECSXP, nargs)); n_protect++; - // Add the argument names, if available: + // Add the argument names, if available. if (names) { setAttrib(answer, R_NamesSymbol, names); } @@ -264,7 +264,7 @@ void dotCall64(DL_FUNC fun, int nargs, SEXP *args, int *args_type, int *args_intent_in, int flag_naok, int flag_verbose) { int na; - // The do_ variables contain the instructions that will applied by the function 'prepareArguments(...)'. + // The do_ variables contain the instructions for the 'prepareArguments(...)' function. SEXPTYPE do_type[MAX_ARGS]; // int do_alloc[MAX_ARGS]; // int do_coerce[MAX_ARGS]; @@ -277,8 +277,8 @@ error(_("dotCall64 only supports up to 64 arguments (dotCall64)")); // When an object is given multiple times as an argument, we have to be careful. - // To exclude any side effects, we duplicate every object when it's INTENT is write. - // If the type is of int64, we duplicate it in every case. + // To exclude any side effects, we duplicate every object when its INTENT is write. + // If the type is int64, we duplicate it in every case. for(na = 0; na < nargs; na++) { args_intent[na] = args_intent_in[na]; } @@ -311,28 +311,28 @@ int maybe_shared = MAYBE_SHARED(s); // Unused - // First, determine the expected R type of the object + // Determine the expected R type of the object. if(args_type[na] == INT64_TYPE) { - // int64 is based on the double type + // int64 is based on the double type. do_type[na] = REALSXP; }else{ do_type[na] = args_type[na]; } - // Check if we should raise a warning, because we didn't get the expected type: + // Check if a warning should be raised in case the provided argument type dose not match the expected type. if(flag_verbose >= 1 && TYPEOF(s)!=do_type[na]) { warning(_("[dotCall64|wrong R object type] argument %d; expected type '%s'; got type '%s'; argument coerced"), na+1, type2char(do_type[na]), CHAR(type2str(TYPEOF(s)))); } - // Start with the flowchart: + // Start flowchart. if(HAS_INTENT_WRITE(args_intent[na]) && !HAS_INTENT_READ(args_intent[na])) { - // Right part of the flowchart + // Right part of the flowchart. // Intent = w if(TYPEOF(s) == do_type[na] && !maybe_referenced) { - // We can just pass the object as argument + // We can just pass the object as argument. }else{ - // We need a new object for the return value: + // We need a new object for the return value. if(flag_verbose >= 1 && maybe_referenced) { warning(_("[dotCall64|referenced 'w' argument] argument %d has 'INTENT' 'w' and is referenced.\nConsider using vector_dc() to avoid copying."), na+1); @@ -340,14 +340,14 @@ do_alloc[na] = 1; } - // Check if we have to cast back: + // Check if we have to cast back. if(args_type[na] == INT64_TYPE) { do_cast_back[na] = 1; } }else if(args_type[na] == INT64_TYPE) { - // Left part of the flowchart - // Argument of type int_64 with intents r, rw + // Left part of the flowchart. + // Argument of type int_64 with intents r, rw. if(TYPEOF(s) == INTSXP || TYPEOF(s) == REALSXP) { do_alloc[na] = 1; @@ -355,7 +355,7 @@ do_coerce[na] = 1; } - // As the argument is read, we have to cast from double->int64 + // As the argument is read, we have to cast from double->int64. do_cast_in[na] = 1; if(HAS_INTENT_WRITE(args_intent[na])) { @@ -364,12 +364,12 @@ }else{ // Center part of the flowchart - // argument of native type: + // Argument of native type. if(TYPEOF(s)!=do_type[na]) { - // Well, we got the wrong type: + // wrong type. do_coerce[na] = 1; }else if(HAS_INTENT_WRITE(args_intent[na])) { - // intent= rw + // intent= rw. do_duplicate[na] = 1; } } @@ -393,12 +393,12 @@ int *do_duplicate, int *do_cast_in, int *do_cast_back, int *flag_naok) { int na; - void **cargs[MAX_ARGS]; // pointers for the actual function - SEXP args_in[MAX_ARGS]; // Contains a copy of the arguments given + void **cargs[MAX_ARGS]; // pointers for the actual function. + SEXP args_in[MAX_ARGS]; // contains a copy of the given arguments. - int n_protect = 0; // contains the number of times that PROTECT has been called. + int n_protect = 0; // counts how many times PROTECT has been called. - // Copy the the argument: Used for efficient int64 casting. + // Copy the argument (for efficient int64 casting). for(na=0; na < nargs; na++) args_in[na] = args[na]; @@ -412,13 +412,13 @@ }else if(do_coerce[na]) { args[na] = PROTECT(coerceVector(s, do_type[na])); n_protect++; - args_in[na] = args[na]; // If we coerce, we pretend that we were given that object + args_in[na] = args[na]; // If coerce, pretend that this object was provided }else if(do_duplicate[na]) { args[na] = PROTECT(duplicate(s)); n_protect++; } - // we will now work on the new object: + // We will now work on the new object. s = args[na]; @@ -464,8 +464,8 @@ } - // We do coerce any argument of type int64 (from double -> int64_t). - // We cannot do this earlier. We might overwrite the memory of the object and so any call to 'error()' would + // Coerce arguments of type int64 (from double -> int64_t). + // We cannot do this earlier as the memory of the object might be overwritten, and hence, any call to 'error()' would // destroy the object. for(na = 0; na < nargs; na++) { SEXP s = args[na]; @@ -476,17 +476,17 @@ R_xlen_t i, len; len = XLENGTH(s); - // We will cast into this pointer: + // We will cast into this pointer. int64_t *iptr = (int64_t*) REAL(s); // All other types have been coerced to REALSXP. - // We handle INTSXP separately, as this can happen in spam. + // We handle INTSXP separately if(TYPEOF(args_in[na]) == REALSXP) { double *in_ptr = REAL(args_in[na]); #pragma omp parallel for default(none) shared(len, iptr, in_ptr) private(i) for(i=0; i < len; i++) { - // TODO: Check if value is too high -> raise warning + // #1 iptr[i] = (int64_t) in_ptr[i]; } }else if(TYPEOF(args_in[na]) == INTSXP) { @@ -494,21 +494,20 @@ #pragma omp parallel for default(none) shared(len, iptr, in_ptr) private(i) for(i=0; i < len; i++) { - // TODO: Check if value is too high -> raise warning + // #1 iptr[i] = (int64_t) in_ptr[i]; } }else{ - // We should never get here. - error(_("should not happen: internal error (do_cast_in) (dotCall64)")); + error(_("should not happen: internal error (do_cast_in) (dotCall64)")); } } } - // Finally, call the function + // Finally, call the function. dotCall64_callFunction(fun, nargs, (void**)cargs); - // The values of every argument of type int64 has to be cast back: + // Back cast the values of all arguments of type int64. for(na = 0; na < nargs; na++) { SEXP s = args[na]; @@ -521,10 +520,7 @@ #pragma omp parallel for default(none) shared(len, iptr, dptr) private(i) for(i=0; i < len; i++) { -// TODO: If value cannot be cast precisely -> raise warning -// if(iptr[i] > R_XLEN_T_MAX && ((int64_t)((double)iptr[i])) - iptr[i] != 0 ) -// warning(_("Element %d of argument %d cannot be cast from int64_t to double precisely (difference %d)."), -// i+1, na+1, ((int64_t)((double)iptr[i])) - iptr[i]); +// #2 dptr[i] = (double) iptr[i]; } } @@ -552,7 +548,7 @@ VerboseSymbol = install("VERBOSE"); } - // Initialize it to an empty string + // Initialize to an empty string strcpy(packageName, ""); *signature = NULL; *intent = NULL; @@ -645,8 +641,6 @@ if(strcmp(str, INT64_STRING) == 0) { return INT64_TYPE; - - // just for convenience: }else if(strcmp(str, "int") == 0) { return INTSXP; }else if(strcmp(str, "int32") == 0) { diff -Nru r-cran-dotcall64-0.9-04/src/init.c r-cran-dotcall64-0.9-5.2/src/init.c --- r-cran-dotcall64-0.9-04/src/init.c 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-dotcall64-0.9-5.2/src/init.c 2018-01-11 16:23:57.000000000 +0000 @@ -0,0 +1,56 @@ +#include +#include // for NULL +#include + +/* to get all functions: + + nm -g lib/dotCall64/libs/dotCall64.so | grep " T " + +*/ + +// C +extern void BENCHMARK ( void *); +extern void dC64 ( void *); +extern void get64_c ( void *, void *, void *); +extern void get_c ( void *, void *, void *); +extern void TEST_prod_double ( void *, void *); +extern void TEST_prod_int ( void *, void *); +extern void TEST_prod_int64 ( void *, void *); +extern void TEST_times2_double ( void *, void *); +extern void TEST_times2_int ( void *, void *); +extern void TEST_times2_int64 ( void *, void *); + +// Fortran +extern void F77_NAME(get_f) ( void *, void *, void *); +extern void F77_NAME(get64_f) ( void *, void *, void *); + + + +static const R_CallMethodDef CEntries[] = { + {"BENCHMARK", (DL_FUNC)&BENCHMARK, 1}, + {"dC64", (DL_FUNC)&dC64, 1}, + {"get64_c", (DL_FUNC)&get64_c, 3}, + {"get_c", (DL_FUNC)&get_c, 3}, + {"TEST_prod_double", (DL_FUNC)&TEST_prod_double, 2}, + {"TEST_prod_int", (DL_FUNC)&TEST_prod_int, 2}, + {"TEST_prod_int64", (DL_FUNC)&TEST_prod_int64, 2}, + {"TEST_times2_double", (DL_FUNC)&TEST_times2_double, 2}, + {"TEST_prod_int", (DL_FUNC)&TEST_prod_int, 2}, + {"TEST_prod_int64", (DL_FUNC)&TEST_prod_int64, 2}, + {NULL, NULL, 0} +}; + + +static const R_FortranMethodDef FortranEntries[] = { + {"get_f", (DL_FUNC)&F77_NAME(get_f ), 3}, + {"get64_f", (DL_FUNC)&F77_NAME(get64_f), 3}, + {NULL, NULL, 0} +}; + +void R_init_spam(DllInfo *dll) +{ + R_registerRoutines(dll, NULL, NULL, FortranEntries, NULL); + R_registerRoutines(dll, NULL, CEntries, NULL, NULL); + R_useDynamicSymbols(dll, FALSE); +} +