wasi.c 865 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (C) 2023 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include <pthread.h>
  6. #include <stdio.h>
  7. #include <unistd.h>
  8. struct member {
  9. int a;
  10. char *b;
  11. } temp = { 8, "zieckey" };
  12. void *
  13. create(void *arg)
  14. {
  15. printf("new thread ... \n");
  16. sleep(5);
  17. pthread_exit(&temp);
  18. }
  19. int
  20. main(int argc, char *argv[])
  21. {
  22. int error;
  23. pthread_t tid;
  24. struct member *c;
  25. error = pthread_create(&tid, NULL, create, NULL);
  26. if (error) {
  27. printf("new thread is not created ... \n");
  28. return -1;
  29. }
  30. printf("main ... \n");
  31. error = pthread_join(tid, (void *)&c);
  32. if (error) {
  33. printf("new thread is not exit ... \n");
  34. return -2;
  35. }
  36. printf("c->a = %d \n", c->a);
  37. printf("c->b = %s \n", c->b);
  38. sleep(1);
  39. return 0;
  40. }