Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions openmp/runtime/cmake/LibompHandleFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ function(libomp_get_libflags libflags)
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|NetBSD|SunOS")
libomp_append(libflags_local -lm)
if (${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
libomp_append(libflags_local "-lproc")
endif()
endif()
set(libflags_local ${libflags_local} ${LIBOMP_LIBFLAGS})
libomp_setup_flags(libflags_local)
Expand Down
30 changes: 10 additions & 20 deletions openmp/runtime/src/z_Linux_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
#include <pthread_np.h>
#endif
#elif KMP_OS_SOLARIS
#include <libproc.h>
#include <procfs.h>
#include <thread.h>
#include <sys/loadavg.h>
Expand Down Expand Up @@ -2232,43 +2231,34 @@ int __kmp_is_address_mapped(void *addr) {

kvm_close(fd);
#elif KMP_OS_SOLARIS
prmap_t *cur, *map;
prxmap_t *cur, *map;
void *buf;
uintptr_t uaddr;
ssize_t rd;
int err;
int file;

int fd;
pid_t pid = getpid();
struct ps_prochandle *fd = Pgrab(pid, PGRAB_RDONLY, &err);
;

if (!fd) {
return 0;
}

char *name = __kmp_str_format("/proc/%d/map", pid);
size_t sz = (1 << 20);
file = open(name, O_RDONLY);
if (file == -1) {
char *name = __kmp_str_format("/proc/%d/xmap", pid);
fd = open(name, O_RDONLY);
if (fd == -1) {
KMP_INTERNAL_FREE(name);
return 0;
}

size_t sz = (1 << 20);
buf = KMP_INTERNAL_MALLOC(sz);

while (sz > 0 && (rd = pread(file, buf, sz, 0)) == sz) {
while (sz > 0 && (rd = pread(fd, buf, sz, 0)) == sz) {
void *newbuf;
sz <<= 1;
newbuf = KMP_INTERNAL_REALLOC(buf, sz);
buf = newbuf;
}

map = reinterpret_cast<prmap_t *>(buf);
map = reinterpret_cast<prxmap_t *>(buf);
uaddr = reinterpret_cast<uintptr_t>(addr);

for (cur = map; rd > 0; cur++, rd = -sizeof(*map)) {
if ((uaddr >= cur->pr_vaddr) && (uaddr < cur->pr_vaddr)) {
if (uaddr >= cur->pr_vaddr && uaddr < cur->pr_vaddr) {
if ((cur->pr_mflags & MA_READ) != 0 && (cur->pr_mflags & MA_WRITE) != 0) {
found = 1;
break;
Expand All @@ -2277,7 +2267,7 @@ int __kmp_is_address_mapped(void *addr) {
}

KMP_INTERNAL_FREE(map);
close(file);
close(fd);
KMP_INTERNAL_FREE(name);
#elif KMP_OS_DARWIN

Expand Down
Loading