[Openmp-commits] [PATCH] D149890: [OpenMP][libomp] Allow white spcaes in OMP_TARGET_OFFLOAD value
Hansang Bae via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Mon Jun 5 15:42:36 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd46706b1f75: [OpenMP][libomp] Allow white spaces in OMP_TARGET_OFFLOAD value (authored by hbae).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149890/new/
https://reviews.llvm.org/D149890
Files:
openmp/runtime/src/kmp_settings.cpp
Index: openmp/runtime/src/kmp_settings.cpp
===================================================================
--- openmp/runtime/src/kmp_settings.cpp
+++ openmp/runtime/src/kmp_settings.cpp
@@ -282,6 +282,25 @@
kmp_setting_t **rivals // List of rival settings (must include current one).
);
+// Helper struct that trims heading/trailing white spaces
+struct kmp_trimmed_str_t {
+ kmp_str_buf_t buf;
+ kmp_trimmed_str_t(const char *str) {
+ __kmp_str_buf_init(&buf);
+ size_t len = KMP_STRLEN(str);
+ if (len == 0)
+ return;
+ const char *begin = str;
+ const char *end = str + KMP_STRLEN(str) - 1;
+ SKIP_WS(begin);
+ while (begin < end && *end == ' ')
+ end--;
+ __kmp_str_buf_cat(&buf, begin, end - begin + 1);
+ }
+ ~kmp_trimmed_str_t() { __kmp_str_buf_free(&buf); }
+ const char *get() { return buf.str; }
+};
+
// -----------------------------------------------------------------------------
// Helper parse functions.
@@ -1385,14 +1404,13 @@
// OpenMP 5.0: OMP_TARGET_OFFLOAD
static void __kmp_stg_parse_target_offload(char const *name, char const *value,
void *data) {
- const char *next = value;
- const char *scan = next;
-
+ kmp_trimmed_str_t value_str(value);
+ const char *scan = value_str.get();
__kmp_target_offload = tgt_default;
- SKIP_WS(next);
- if (*next == '\0')
+
+ if (*scan == '\0')
return;
- scan = next;
+
if (!__kmp_strcasecmp_with_sentinel("mandatory", scan, 0)) {
__kmp_target_offload = tgt_mandatory;
} else if (!__kmp_strcasecmp_with_sentinel("disabled", scan, 0)) {
@@ -1402,7 +1420,6 @@
} else {
KMP_WARNING(SyntaxErrorUsing, name, "DEFAULT");
}
-
} // __kmp_stg_parse_target_offload
static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149890.528612.patch
Type: text/x-patch
Size: 1822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230605/bb25a777/attachment.bin>
More information about the Openmp-commits
mailing list