MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

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

get proper pthread_get_stacksize_np

+7 -5
+7 -5
src/silver/limits.c
··· 22 22 ULONG_PTR low, high; 23 23 GetCurrentThreadStackLimits(&low, &high); 24 24 return (size_t)(high - low); 25 + #elif defined(__APPLE__) 26 + return pthread_get_stacksize_np(pthread_self()); 25 27 #else 26 - struct rlimit rl; 27 - if (getrlimit(RLIMIT_STACK, &rl) == 0 && rl.rlim_cur != RLIM_INFINITY) 28 - return (size_t)rl.rlim_cur; 29 - 30 28 pthread_attr_t attr; 31 29 size_t sz = 0; 32 - if (pthread_attr_init(&attr) == 0) { 30 + if (pthread_getattr_np(pthread_self(), &attr) == 0) { 33 31 pthread_attr_getstacksize(&attr, &sz); 34 32 pthread_attr_destroy(&attr); 35 33 if (sz > 0) return sz; 36 34 } 35 + 36 + struct rlimit rl; 37 + if (getrlimit(RLIMIT_STACK, &rl) == 0 && rl.rlim_cur != RLIM_INFINITY) 38 + return (size_t)rl.rlim_cur; 37 39 38 40 return 8 * 1024 * 1024; 39 41 #endif