• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU)
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 #ifndef SPAWN_EXT_H
13 #define SPAWN_EXT_H
14 
15 #include <stddef.h>
16 #include <stdint.h>
17 #include <fcntl.h>
18 #include <pthread.h>
19 #include "tee_uuid.h"
20 
21 #ifndef SPAWN_EXT_STRUCT
22 #define SPAWN_EXT_STRUCT
23 
24 typedef int tid_t;
25 
26 typedef struct spawn_ext {
27     uint64_t uuid_valid;
28     TEE_UUID uuid;
29 } spawn_uuid_t;
30 
31 typedef struct {
32     unsigned version;
33     uint64_t stack_size;
34     uint64_t heap_size;
35     unsigned int flags;
36     spawn_uuid_t uuid;
37     int32_t ptid;
38 } posix_spawnattr_t;
39 
40 typedef struct {
41     int __pad0[2];
42     void *__actions;
43     int __pad[16];
44 } posix_spawn_file_actions_t;
45 
46 #endif
47 
48 int getuuid(pid_t pid, spawn_uuid_t *uuid);
49 
50 int spawnattr_init(posix_spawnattr_t *attr);
51 
52 void spawnattr_setuuid(posix_spawnattr_t *attr, const spawn_uuid_t *uuid);
53 
54 int spawnattr_setheap(posix_spawnattr_t *attr, size_t size);
55 
56 int spawnattr_setstack(posix_spawnattr_t *attr, size_t size);
57 
58 int32_t thread_terminate(pthread_t thread);
59 
60 int posix_spawn_ex(pid_t *pid, const char *path,
61                    const posix_spawn_file_actions_t *file_action,
62                    const posix_spawnattr_t *attrp, char **argv, char **envp,
63                    int *tid);
64 
65 size_t getstacksize(void);
66 
67 #endif
68