-
Notifications
You must be signed in to change notification settings - Fork 978
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40d4fc5
commit 85f1c7e
Showing
1 changed file
with
4 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
|
||
# Ensure no calls to omp_set_num_threads() [to avoid affecting other packages and base R] | ||
# Only comments referring to it should be in openmp-utils.c | ||
omp_set_num_threads_linter = function(c_file) { | ||
processed_lines = system2("gcc", c("-fpreprocessed", "-E", "-xc", "-"), stdin=c_file, stdout=TRUE, stderr=FALSE) | ||
# strip comments, we only care if the function appears in actual code. | ||
processed_lines = system2("gcc", c("-fpreprocessed", "-E", "-xc", "-", c_file), stdout=TRUE, stderr=FALSE) | ||
idx = grep("omp_set_num_threads", processed_lines, fixed = TRUE) | ||
if (!length(idx)) return() | ||
stop(sprintf( | ||
"In %s, found 'omp_set_num_threads() usage, which could affect other packages and base R:\n%s", | ||
"In %s, found omp_set_num_threads() usage, which could affect other packages and base R:\n%s", | ||
c_file, paste0(" ", format(idx), ":", processed_lines[idx], collapse = "\n") | ||
)) | ||
} |