• 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 
13 #ifndef CHCORE_PTHREAD_H
14 #define CHCORE_PTHREAD_H
15 
16 #include <chcore/type.h>
17 
18 #ifndef __NEED_pthread_t
19 #define __NEED_pthread_t
20 #endif
21 
22 #ifndef __NEED_pthread_attr_t
23 #define __NEED_pthread_attr_t
24 #endif
25 
26 #if __SIZEOF_POINTER__ == 4
27 #define CHCORE_PTHREAD_DEFAULT_STACK_SIZE (1 << 20)
28 #define CHCORE_PTHREAD_DEFAULT_GUARD_SIZE 4096
29 #else
30 #define CHCORE_PTHREAD_DEFAULT_STACK_SIZE (8 << 20)
31 #define CHCORE_PTHREAD_DEFAULT_GUARD_SIZE 8192
32 #endif
33 
34 #include <bits/alltypes.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* Chcore pthread_create: return the thread_cap */
41 cap_t chcore_pthread_create(pthread_t *__restrict,
42                             const pthread_attr_t *__restrict, void *(*)(void *),
43                             void *__restrict);
44 cap_t chcore_pthread_create_shadow(pthread_t *__restrict,
45                                    const pthread_attr_t *__restrict,
46                                    void *(*)(void *), void *__restrict);
47 cap_t chcore_pthread_create_register_cb(pthread_t *__restrict,
48                                         const pthread_attr_t *__restrict,
49                                         void *(*)(void *), void *__restrict);
50 void chcore_pthread_wake_joiner(pthread_t thread);
51 int chcore_pthread_get_tid(pthread_t thread);
52 
53 #ifdef __cplusplus
54 }
55 #endif
56 
57 #endif