posix.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See
  3. // https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
  4. // information.
  5. //
  6. // Significant parts of this file are derived from cloudabi-utils. See
  7. // https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
  8. // for license information.
  9. //
  10. // The upstream file contains the following copyright notice:
  11. //
  12. // Copyright (c) 2016-2018 Nuxi, https://nuxi.nl/
  13. #ifndef POSIX_H
  14. #define POSIX_H
  15. #include "bh_platform.h"
  16. #include "locking.h"
  17. struct fd_entry;
  18. struct fd_prestat;
  19. struct syscalls;
  20. struct fd_table {
  21. struct rwlock lock;
  22. struct fd_entry *entries;
  23. size_t size;
  24. size_t used;
  25. };
  26. struct fd_prestats {
  27. struct rwlock lock;
  28. struct fd_prestat *prestats;
  29. size_t size;
  30. size_t used;
  31. };
  32. struct argv_environ_values {
  33. const char *argv_buf;
  34. size_t argv_buf_size;
  35. char **argv_list;
  36. size_t argc;
  37. char *environ_buf;
  38. size_t environ_buf_size;
  39. char **environ_list;
  40. size_t environ_count;
  41. };
  42. bool
  43. fd_table_init(struct fd_table *);
  44. bool
  45. fd_table_insert_existing(struct fd_table *, __wasi_fd_t, int);
  46. bool
  47. fd_prestats_init(struct fd_prestats *);
  48. bool
  49. fd_prestats_insert(struct fd_prestats *, const char *, __wasi_fd_t);
  50. bool
  51. argv_environ_init(struct argv_environ_values *argv_environ, char *argv_buf,
  52. size_t argv_buf_size, char **argv_list, size_t argc,
  53. char *environ_buf, size_t environ_buf_size,
  54. char **environ_list, size_t environ_count);
  55. void
  56. argv_environ_destroy(struct argv_environ_values *argv_environ);
  57. void
  58. fd_table_destroy(struct fd_table *ft);
  59. void
  60. fd_prestats_destroy(struct fd_prestats *pt);
  61. #endif