[PATCH] D46712: Port msan_test.cc to NetBSD
Kamil Rytarowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 18 18:15:23 PDT 2018
krytarowski added inline comments.
================
Comment at: lib/msan/tests/msan_test.cc:3081
+#if defined(__FreeBSD__) || defined(__NetBSD__)
static void GetProgramPath(char *buf, size_t sz) {
+#if defined(__FreeBSD__)
----------------
krytarowski wrote:
> vitalybuka wrote:
> > Could please make it:
> >
> > ```
> > #if defined(__FreeBSD__)
> > // entire function
> > #elif defined(__NetBSD__)
> > // entire function
> > #elif defined(__GLIBC__)
> > // entire function
> > #else
> > # error "TODO: port this"
> > #endif
> > ```
> There is an informal tradition to reuse the same code in FreeBSD and NetBSD, ifdefing only the MIB part.
For example here:
```
lib/sanitizer_common/sanitizer_linux.cc-#if SANITIZER_FREEBSD || SANITIZER_NETBSD
lib/sanitizer_common/sanitizer_linux.cc-#if SANITIZER_FREEBSD
lib/sanitizer_common/sanitizer_linux.cc: const int Mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
lib/sanitizer_common/sanitizer_linux.cc-#else
lib/sanitizer_common/sanitizer_linux.cc: const int Mib[4] = {CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME};
lib/sanitizer_common/sanitizer_linux.cc-#endif
```
I will commit it as is, and on request change it to separated functions.
Repository:
rL LLVM
https://reviews.llvm.org/D46712
More information about the llvm-commits
mailing list