Skip to content

Commit

Permalink
simplify, comment
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed Aug 3, 2024
1 parent 40d4fc5 commit 85f1c7e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .ci/linters/c/omp_set_num_threads_linter.R
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")
))
}

0 comments on commit 85f1c7e

Please sign in to comment.