musl-stacksize.patch 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. --- a/src/c11/impl/threads_posix.c 2022-10-04 16:30:04.564345425 -0400
  2. +++ b/src/c11/impl/threads_posix.c 2022-10-04 16:43:51.794135619 -0400
  3. @@ -255,18 +255,33 @@
  4. thrd_create(thrd_t *thr, thrd_start_t func, void *arg)
  5. {
  6. struct impl_thrd_param *pack;
  7. +#ifdef __GLIBC__
  8. + pthread_attr_t *attrp = NULL;
  9. +#else
  10. + pthread_attr_t attr = { 0 };
  11. + pthread_attr_init(&attr);
  12. + pthread_attr_setstacksize(&attr, 8388608);
  13. + pthread_attr_t *attrp = &attr;
  14. +#endif
  15. assert(thr != NULL);
  16. pack = (struct impl_thrd_param *)malloc(sizeof(struct impl_thrd_param));
  17. if (!pack) return thrd_nomem;
  18. pack->func = func;
  19. pack->arg = arg;
  20. - if (pthread_create(thr, NULL, impl_thrd_routine, pack) != 0) {
  21. + if (pthread_create(thr, attrp, impl_thrd_routine, pack) != 0) {
  22. +#ifndef __GLIBC__
  23. + pthread_attr_destroy(&attr);
  24. +#endif
  25. free(pack);
  26. return thrd_error;
  27. }
  28. +#ifndef __GLIBC__
  29. + pthread_attr_destroy(&attr);
  30. +#endif
  31. return thrd_success;
  32. }
  33. +
  34. // 7.25.5.2
  35. thrd_t
  36. thrd_current(void)