- Timestamp:
- Jan 18, 2009 4:08:13 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kbuild.c
r2243 r2247 40 40 #if defined(__APPLE__) 41 41 # include <mach-o/dyld.h> 42 #endif 43 #if defined(__FreeBSD__) 44 # include <dlfcn.h> 45 # include <sys/link_elf.h> 42 46 #endif 43 47 … … 133 137 rc = readlink("/proc/curproc/file", szTmp, GET_PATH_MAX - 1); 134 138 if (rc < 0 || rc == GET_PATH_MAX - 1) 139 { 140 /* /proc is optional, try rtdl. */ 141 void *hExe = dlopen(NULL, 0); 135 142 rc = -1; 143 if (hExe) 144 { 145 struct link_map const *pLinkMap = 0; 146 if (dlinfo(hExe, RTLD_DI_LINKMAP, &pLinkMap) == 0) 147 { 148 const char *pszImageName = pLinkMap->l_name; 149 size_t cchImageName = strlen(pszImageName); 150 if (cchImageName < GET_PATH_MAX) 151 { 152 memcpy(szTmp, pszImageName, cchImageName + 1); 153 rc = 0; 154 } 155 } 156 } 157 } 136 158 else 137 159 szTmp[rc] = '\0'; 138 160 139 #elif defined(__gnu_linux__) /** @todo find proper define... */161 #elif defined(__gnu_linux__) || defined(__linux__) 140 162 rc = readlink("/proc/self/exe", szTmp, GET_PATH_MAX - 1); 141 163 if (rc < 0 || rc == GET_PATH_MAX - 1)
Note:
See TracChangeset
for help on using the changeset viewer.