wasi_thread_start.h 639 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (C) 2022 Amazon.com Inc. or its affiliates. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef WASI_THREAD_START_H
  6. #define WASI_THREAD_START_H
  7. #define STACK_SIZE 32 * 1024 // same as the main stack
  8. typedef struct {
  9. void *stack;
  10. } start_args_t;
  11. static inline int
  12. start_args_init(start_args_t *start_args)
  13. {
  14. start_args->stack = malloc(STACK_SIZE);
  15. if (!start_args->stack) {
  16. return 0;
  17. }
  18. start_args->stack += STACK_SIZE;
  19. return 1;
  20. }
  21. static inline void
  22. start_args_deinit(start_args_t *start_args)
  23. {
  24. free(start_args->stack - STACK_SIZE);
  25. }
  26. #endif