MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxCStackLimit

Function fxCStackLimit

xs/sources/xsCommon.c:592–626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590#endif
591
592char* fxCStackLimit()
593{
594 #if mxWindows
595 ULONG_PTR low, high;
596 GetCurrentThreadStackLimits_Win7(&low, &high);
597 return (char*)low + (32 * 1024);
598 #elif mxMacOSX
599 pthread_t self = pthread_self();
600 void* stackAddr = pthread_get_stackaddr_np(self);
601 size_t stackSize = pthread_get_stacksize_np(self);
602 return (char*)stackAddr - stackSize + (128 * 1024) + mxASANStackMargin;
603 #elif mxLinux
604 char* result = C_NULL;
605 pthread_attr_t attrs;
606 pthread_attr_init(&attrs);
607 if (pthread_getattr_np(pthread_self(), &attrs) == 0) {
608 void* stackAddr;
609 size_t stackSize;
610 if (pthread_attr_getstack(&attrs, &stackAddr, &stackSize) == 0) {
611 result = (char*)stackAddr + (128 * 1024) + mxASANStackMargin;
612 }
613 }
614 pthread_attr_destroy(&attrs);
615 return result;
616 #elif defined(__ets__) && !ESP32 && !defined(__ZEPHYR__)
617 extern cont_t g_cont;
618 return 192 + (char *)g_cont.stack;
619 #elif defined(__ets__) && ESP32 && !defined(__ZEPHYR__)
620 TaskStatus_t info;
621 vTaskGetInfo(NULL, &info, pdFALSE, eReady);
622 return 1024 + (char *)info.pxStackBase;
623 #else
624 return C_NULL;
625 #endif
626}
627
628#endif
629

Callers 3

fxAllocateFunction · 0.85
fxInitializeParserFunction · 0.85
fxCompileRegExpFunction · 0.85

Calls 1

Tested by

no test coverage detected