|
59 | 59 | #include <sys/sysctl.h>
|
60 | 60 | #include <sys/user.h>
|
61 | 61 | #include <pthread_np.h>
|
| 62 | +#if KMP_OS_DRAGONFLY |
| 63 | +#include <kvm.h> |
| 64 | +#endif |
62 | 65 | #elif KMP_OS_NETBSD || KMP_OS_OPENBSD
|
63 | 66 | #include <sys/types.h>
|
64 | 67 | #include <sys/sysctl.h>
|
@@ -1042,9 +1045,7 @@ extern "C" void __kmp_reap_monitor(kmp_info_t *th) {
|
1042 | 1045 | #else
|
1043 | 1046 | // Empty symbol to export (see exports_so.txt) when
|
1044 | 1047 | // monitor thread feature is disabled
|
1045 |
| -extern "C" void __kmp_reap_monitor(kmp_info_t *th) { |
1046 |
| - (void)th; |
1047 |
| -} |
| 1048 | +extern "C" void __kmp_reap_monitor(kmp_info_t *th) { (void)th; } |
1048 | 1049 | #endif // KMP_USE_MONITOR
|
1049 | 1050 |
|
1050 | 1051 | void __kmp_reap_worker(kmp_info_t *th) {
|
@@ -2133,7 +2134,47 @@ int __kmp_is_address_mapped(void *addr) {
|
2133 | 2134 | lw += cursz;
|
2134 | 2135 | }
|
2135 | 2136 | kmpc_free(buf);
|
| 2137 | +#elif KMP_OS_DRAGONFLY |
| 2138 | + char err[_POSIX2_LINE_MAX]; |
| 2139 | + kinfo_proc *proc; |
| 2140 | + vmspace sp; |
| 2141 | + vm_map *cur; |
| 2142 | + vm_map_entry entry, *c; |
| 2143 | + struct proc p; |
| 2144 | + kvm_t *fd; |
| 2145 | + uintptr_t uaddr; |
| 2146 | + int num; |
| 2147 | + |
| 2148 | + fd = kvm_openfiles(nullptr, nullptr, nullptr, O_RDONLY, err); |
| 2149 | + if (!fd) { |
| 2150 | + return 0; |
| 2151 | + } |
| 2152 | + |
| 2153 | + proc = kvm_getprocs(fd, KERN_PROC_PID, getpid(), &num); |
| 2154 | + |
| 2155 | + if (kvm_read(fd, static_cast<uintptr_t>(proc->kp_paddr), &p, sizeof(p)) != |
| 2156 | + sizeof(p) || |
| 2157 | + kvm_read(fd, reinterpret_cast<uintptr_t>(p.p_vmspace), &sp, sizeof(sp)) != |
| 2158 | + sizeof(sp)) { |
| 2159 | + kvm_close(fd); |
| 2160 | + return 0; |
| 2161 | + } |
| 2162 | + |
| 2163 | + (void)rc; |
| 2164 | + cur = &sp.vm_map; |
| 2165 | + uaddr = reinterpret_cast<uintptr_t>(addr); |
| 2166 | + for (c = kvm_vm_map_entry_first(fd, cur, &entry); c; |
| 2167 | + c = kvm_vm_map_entry_next(fd, c, &entry)) { |
| 2168 | + if ((uaddr >= entry.ba.start) && (uaddr <= entry.ba.end)) { |
| 2169 | + if ((entry.protection & VM_PROT_READ) != 0 && |
| 2170 | + (entry.protection & VM_PROT_WRITE) != 0) { |
| 2171 | + found = 1; |
| 2172 | + break; |
| 2173 | + } |
| 2174 | + } |
| 2175 | + } |
2136 | 2176 |
|
| 2177 | + kvm_close(fd); |
2137 | 2178 | #elif KMP_OS_DARWIN
|
2138 | 2179 |
|
2139 | 2180 | /* On OS X*, /proc pseudo filesystem is not available. Try to read memory
|
@@ -2212,9 +2253,9 @@ int __kmp_is_address_mapped(void *addr) {
|
2212 | 2253 | }
|
2213 | 2254 | #elif KMP_OS_WASI
|
2214 | 2255 | found = (int)addr < (__builtin_wasm_memory_size(0) * PAGESIZE);
|
2215 |
| -#elif KMP_OS_DRAGONFLY || KMP_OS_SOLARIS || KMP_OS_AIX |
| 2256 | +#elif KMP_OS_SOLARIS || KMP_OS_AIX |
2216 | 2257 |
|
2217 |
| - // FIXME(DragonFly, Solaris, AIX): Implement this |
| 2258 | + // FIXME(Solaris, AIX): Implement this |
2218 | 2259 | found = 1;
|
2219 | 2260 |
|
2220 | 2261 | #else
|
|
0 commit comments