this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Various improvements and fixes, deeper alt sysroot support

+137 -7
+2
src/libSystem/CMakeLists.txt
··· 59 59 libc/pthread.cpp 60 60 libc/sysconf.cpp 61 61 libc/net.cpp 62 + libc/getpwent.cpp 63 + libc/signals.cpp 62 64 common/auto.cpp 63 65 common/path.cpp 64 66 )
+26
src/libSystem/kernel-bsd/fopsmisc.cpp
··· 7 7 #include <sys/stat.h> 8 8 #include <unistd.h> 9 9 #include <cstring> 10 + #include <string> 11 + #include <cstdlib> 12 + #include <iostream> 13 + #include <limits.h> 14 + 15 + extern char g_sysroot[PATH_MAX]; 10 16 11 17 int __darwin_access(const char *pathname, int mode) 12 18 { 19 + //std::cout << "access: " << pathname << std::endl; 20 + if ((mode & W_OK) == 0 && g_sysroot[0]) 21 + { 22 + // Try to apply a sysroot prefix 23 + const char* prefixed; 24 + std::string lpath = g_sysroot; 25 + 26 + lpath += '/'; 27 + lpath += pathname; 28 + 29 + prefixed = translatePathCI(lpath.c_str()); 30 + if (::access(prefixed, F_OK) == 0) 31 + { 32 + int rv = ::access(prefixed, mode); 33 + if (rv == -1) 34 + errnoOut(); 35 + return rv; 36 + } 37 + } 38 + 13 39 return AutoPathErrno<int>(access, pathname, mode); 14 40 } 15 41
+26 -1
src/libSystem/kernel-bsd/io.cpp
··· 6 6 #include "libc/darwin_errno_codes.h" 7 7 #include "common/path.h" 8 8 #include "common/auto.h" 9 + #include <limits.h> 9 10 #include <errno.h> 11 + 12 + extern char g_sysroot[PATH_MAX]; 10 13 11 14 int __darwin_open(const char* path, int flags, mode_t mode) 12 15 { ··· 65 68 fprintf(stderr, "Unsupported open flag=%d\n", flags); 66 69 return -1; 67 70 } 71 + 72 + // Apply sysroot 73 + //std::cout << "File: " << path << std::endl; 74 + //std::cout << "Sysroot: " << g_sysroot << std::endl; 75 + // std::cout << "Flag: " << (linux_flags & O_RDONLY) << std::endl; 76 + if ( (linux_flags & O_ACCMODE) == 0 && g_sysroot[0]) 77 + { 78 + const char* prefixed; 79 + std::string lpath = g_sysroot; 80 + 81 + lpath += '/'; 82 + lpath += path; 83 + 84 + prefixed = translatePathCI(lpath.c_str()); 85 + 86 + if (::access(prefixed, F_OK) == 0) 87 + path = prefixed; 88 + else 89 + path = translatePathCI(path); 90 + } 91 + else 92 + path = translatePathCI(path); 68 93 69 - int rv = open(translatePathCI(path), linux_flags, mode); 94 + int rv = open(path, linux_flags, mode); 70 95 if (rv == -1) 71 96 errnoOut(); 72 97 return rv;
+5 -2
src/libSystem/kernel-bsd/sockets.cpp
··· 87 87 int __darwin_select(int fd, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout) 88 88 { 89 89 struct timeval backup; 90 - memcpy(&backup, timeout, sizeof(backup)); // emulate BSD behavior 90 + 91 + if (timeout) 92 + memcpy(&backup, timeout, sizeof(backup)); // emulate BSD behavior 91 93 92 94 int rv = ::select(fd, readfds, writefds, exceptfds, timeout); 93 95 if (rv == -1) 94 96 errnoOut(); 95 97 96 - memcpy(timeout, &backup, sizeof(backup)); 98 + if (timeout) 99 + memcpy(timeout, &backup, sizeof(backup)); 97 100 return rv; 98 101 } 99 102
+21
src/libSystem/kernel-bsd/stat.cpp
··· 6 6 #include <sys/types.h> 7 7 #include <sys/stat.h> 8 8 #include <unistd.h> 9 + #include <limits.h> 10 + 11 + extern char g_sysroot[PATH_MAX]; 9 12 10 13 static void convertStat64(struct stat64* linux_buf, struct __darwin_stat64* mac) 11 14 { ··· 49 52 { 50 53 TRACE2(path, mac); 51 54 struct stat64 linux_buf; 55 + 56 + if (g_sysroot[0]) 57 + { 58 + const char* prefixed; 59 + std::string lpath = g_sysroot; 60 + 61 + lpath += '/'; 62 + lpath += path; 63 + 64 + prefixed = translatePathCI(lpath.c_str()); 65 + if (::access(prefixed, F_OK) == 0) 66 + path = prefixed; 67 + else 68 + path = translatePathCI(path); 69 + } 70 + else 71 + path = translatePathCI(path); 72 + 52 73 int ret = stat64(translatePathCI(path), &linux_buf); 53 74 if (ret == -1) 54 75 errnoOut();
+1 -1
src/libSystem/kernel-mach/host.cpp
··· 60 60 return KERN_FAILURE; 61 61 } 62 62 63 - memset(info, 0, *info_cnt); 63 + memset(info, 0, sizeof(*info)); 64 64 65 65 #if defined(__i386__) 66 66 info->cpu_type = CPU_TYPE_I386;
+23 -1
src/libSystem/libc/dir.cpp
··· 7 7 #include "common/path.h" 8 8 #include <cstdlib> 9 9 #include <cstring> 10 + #include <limits.h> 11 + 12 + extern char g_sysroot[PATH_MAX]; 10 13 11 14 static darwin_dirent* convertDirent(const struct dirent* ent); 12 15 static darwin_dirent64* convertDirent64(const struct dirent* ent); ··· 84 87 DIR* __darwin_opendir(const char *name) 85 88 { 86 89 TRACE1(name); 87 - DIR* rv = opendir(translatePathCI(name)); 90 + 91 + if (g_sysroot[0]) 92 + { 93 + const char* prefixed; 94 + std::string lpath = g_sysroot; 95 + 96 + lpath += '/'; 97 + lpath += name; 98 + 99 + prefixed = translatePathCI(lpath.c_str()); 100 + 101 + if (::access(prefixed, F_OK) == 0) 102 + name = prefixed; 103 + else 104 + name = translatePathCI(name); 105 + } 106 + else 107 + name = translatePathCI(name); 108 + 109 + DIR* rv = opendir(name); 88 110 if (!rv) 89 111 errnoOut(); 90 112 return rv;
+3
src/libSystem/libc/directmap.lst
··· 17 17 CC_MD5_Update;MD5_Update 18 18 CC_MD5_Final;MD5_Final 19 19 CC_MD5;MD5 20 + CC_SHA1_Init;SHA1_Init 21 + CC_SHA1_Update;SHA1_Update 22 + CC_SHA1_Final;SHA1_Final 20 23 __darwin_atexit;__cxa_atexit 21 24 __darwin_select$1050;__darwin_select 22 25 __darwin_warn;__darwin__warn
+15
src/libSystem/libc/directmap.nasm
··· 95 95 CC_MD5: 96 96 jmp MD5 WRT ..plt 97 97 98 + global CC_SHA1_Init 99 + extern SHA1_Init 100 + CC_SHA1_Init: 101 + jmp SHA1_Init WRT ..plt 102 + 103 + global CC_SHA1_Update 104 + extern SHA1_Update 105 + CC_SHA1_Update: 106 + jmp SHA1_Update WRT ..plt 107 + 108 + global CC_SHA1_Final 109 + extern SHA1_Final 110 + CC_SHA1_Final: 111 + jmp SHA1_Final WRT ..plt 112 + 98 113 global __darwin_atexit 99 114 extern __cxa_atexit 100 115 __darwin_atexit:
+4 -1
src/libSystem/libc/pthread.h
··· 9 9 #define __DARWIN_PTHREAD_PROCESS_SHARED 1 10 10 #define __DARWIN_PTHREAD_PROCESS_PRIVATE 2 11 11 12 - struct __darwin_pthread_rwlock_t 12 + struct __darwin_pthread_rwlock_t // 200 bytes on Darwin 13 13 { 14 14 enum { SIGNATURE_MACRO_INITIALIZED = 0x2da8b3b4, SIGNATURE_NATIVE_INITIALIZED = 0x12345678 }; 15 15 uint32_t signature; ··· 21 21 uint32_t signature; 22 22 pthread_mutex_t native; // this will fit on Linux (40 vs 64) 23 23 }; 24 + 25 + static_assert(sizeof(pthread_mutex_t) <= 60, "pthread_mutex_t is too big on this platform!"); 26 + static_assert(sizeof(pthread_rwlock_t) <= 196, "pthread_rwlock_t is too big on this platform!"); 24 27 25 28 extern "C" 26 29 {
+5
src/libSystem/libc/string.cpp
··· 23 23 b[i] = pattern4[i % 16]; 24 24 } 25 25 26 + int __mb_cur_max() 27 + { 28 + return MB_CUR_MAX; 29 + } 30 + 26 31 int ___mb_cur_max() 27 32 { 28 33 return MB_CUR_MAX;
+1
src/libSystem/libc/string.h
··· 11 11 void memset_pattern8(char* b, const char* pattern4, size_t len); 12 12 void memset_pattern16(char* b, const char* pattern4, size_t len); 13 13 14 + int __mb_cur_max(); 14 15 int ___mb_cur_max(); 15 16 int __toupper(int c); 16 17 int __tolower(int c);
+3
src/libSystem/libc/sysconf.cpp
··· 11 11 case DARWIN_SC_PAGESIZE: 12 12 name = _SC_PAGESIZE; 13 13 break; 14 + case DARWIN_SC_GETPW_R_SIZE_MAX: 15 + name = _SC_GETPW_R_SIZE_MAX; 16 + break; 14 17 default: 15 18 break; 16 19 }
+2 -1
src/libSystem/libc/sysconf.h
··· 2 2 #define LIBC_SYSCONF_H 3 3 4 4 enum { 5 - DARWIN_SC_PAGESIZE = 29 5 + DARWIN_SC_PAGESIZE = 29, 6 + DARWIN_SC_GETPW_R_SIZE_MAX = 71 6 7 }; 7 8 8 9 extern "C" long __darwin_sysconf(int name);