File: test_proxy_to_pthread_stack.c

package info (click to toggle)
emscripten 3.1.69%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 121,860 kB
  • sloc: ansic: 636,110; cpp: 425,974; javascript: 78,401; python: 58,404; sh: 49,154; pascal: 5,237; makefile: 3,366; asm: 2,415; lisp: 1,869
file content (32 lines) | stat: -rw-r--r-- 866 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#define _GNU_SOURCE
#include <stdint.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <emscripten.h>

int main(void) {
  pthread_attr_t attr;
  int rtn = pthread_getattr_np(pthread_self(), &attr);
  assert(rtn == 0);
  size_t stacksize = 0;
  rtn = pthread_attr_getstacksize(&attr, &stacksize);
  assert(rtn == 0);
  printf("stack size %zd\n", stacksize);

  // This test is run with STACK_SIZE=128k so we always expect that to be
  // the ammount of stack we have in main()
  assert(stacksize == 128*1024);

  // This test is run with DEFAULT_PTHREAD_STACK_SIZE=64k.  This would fail if
  // this thread were run with only 64k of stack.
  int8_t data[65*1024];
  memset(data, 0xa0, sizeof(data));
  EM_ASM(checkStackCookie());
  printf("data address %p\n", data);

  printf("success\n");
  return 0;
}