File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -233,7 +233,20 @@ OSModuleHandle OSUtil::getOSModuleHandle(const void *VirtAddr) {
233233 return reinterpret_cast <OSModuleHandle>(Res.dli_fbase );
234234}
235235
236- std::string OSUtil::getCurrentDSODir () { return " " ; }
236+ std::string OSUtil::getCurrentDSODir () {
237+ auto CurrentFunc = reinterpret_cast <const void *>(&getCurrentDSODir);
238+ Dl_info Info;
239+ int RetCode = dladdr (CurrentFunc, &Info);
240+ if (0 == RetCode) {
241+ // This actually indicates an error
242+ return " " ;
243+ }
244+
245+ auto Path = std::string (Info.dli_fname );
246+ auto LastSlashPos = Path.find_last_of (' /' );
247+
248+ return Path.substr (0 , LastSlashPos);
249+ }
237250
238251#endif // __SYCL_RT_OS
239252
Original file line number Diff line number Diff line change @@ -39,12 +39,12 @@ bool isSameDir(const char* LHS, const char* RHS) {
3939 struct stat StatBuf;
4040 if (stat (LHS, &StatBuf)) {
4141 perror (" stat failed" );
42- exit (EXIT_FAILURE) ;
42+ return false ;
4343 }
4444 ino_t InodeLHS = StatBuf.st_ino ;
4545 if (stat (RHS, &StatBuf)) {
4646 perror (" stat failed" );
47- exit (EXIT_FAILURE) ;
47+ return false ;
4848 }
4949 ino_t InodeRHS = StatBuf.st_ino ;
5050 return InodeRHS == InodeLHS;
You can’t perform that action at this time.
0 commit comments