SST/macro
sstmac_pthread_impl.h
Go to the documentation of this file.
1 /*
2  * This file is part of SST/macroscale:
3  * The macroscale architecture simulator from the SST suite.
4  * Copyright (c) 2009 Sandia Corporation.
5  * This software is distributed under the BSD License.
6  * Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
7  * the U.S. Government retains certain rights in this software.
8  * For more information, see the LICENSE file in the top
9  * SST/macroscale directory.
10  */
11 
12 #ifndef SSTMAC_SOFTWARE_PROCESS_PTHREAD_IMPL_H_INCLUDED
13 #define SSTMAC_SOFTWARE_PROCESS_PTHREAD_IMPL_H_INCLUDED
14 
15 #include <stdlib.h>
16 #include <stdint.h>
17 
18 //these have to be macros, to avoid pthread conflicts
19 #define sstmac_pthread_t int
20 #define sstmac_pthread_cond_t int
21 #define sstmac_pthread_mutex_t int
22 #define sstmac_pthread_spinlock_t int
23 #define sstmac_pthread_once_t int
24 #define sstmac_pthread_cond_attr int
25 #define sstmac_pthread_mutexattr_t int
26 
28 typedef void (*sstmac_pthread_key_destructor_fxn)(void*);
29 
30 #define SSTMAC_PTHREAD_ONCE_INIT 0
31 #define SSTMAC_PTHREAD_MUTEX_INITIALIZER -1
32 #define SSTMAC_PTHREAD_COND_INITIALIZER -1
33 
34 #define SSTMAC_PTHREAD_THREADS_MAX 1000
35 #define SSTMAC_PTHREAD_KEYS_MAX 10000
36 #define SSTMAC_PTHREAD_STACK_MIN 16384
37 #define SSTAMC_PTHREAD_CREATE_DETACHED 0
38 #define SSTMAC_PTHREAD_CREATE_JOINABLE 1
39 
40 #undef PTHREAD_SCOPE_PROCESS
41 #define PTHREAD_SCOPE_PROCESS 0
42 
43 #undef PTHREAD_SCOPE_SYSTEM
44 #define PTHREAD_SCOPE_SYSTEM 1
45 
48 
49 #ifdef __cplusplus
50 #include <cstring>
51 extern "C"
52 {
53 #endif
54 
55 typedef struct {
56  uint64_t cpumask;
58 
59 int
61  const sstmac_pthread_attr_t * attr, void *
62  (*start_routine)(void *), void * arg);
63 
64 void
65 SSTMAC_pthread_exit(void *retval);
66 
67 int
68 SSTMAC_pthread_join(sstmac_pthread_t thread, void ** status);
69 
72 
73 int
75 
76 int
78  const sstmac_pthread_mutexattr_t *attr);
79 
80 int
81 SSTMAC_pthread_attr_setaffinity_np(sstmac_pthread_attr_t *attr, size_t cpusetsize, const sstmac_cpu_set_t *cpuset);
82 
83 int
85 
86 int
88 
89 int
91 
92 int
93 SSTMAC_pthread_attr_getstack(sstmac_pthread_attr_t* attr, void** stack, size_t* stacksize);
94 
95 int
96 SSTMAC_pthread_kill(sstmac_pthread_t thr, int signal);
97 
98 int
100 
101 int
103 
104 int
106 
107 int
109 
110 int
112 
113 int
115 
116 int
118 
119 int
121 
122 int
124 
125 int
127 
128 int
130  const sstmac_pthread_cond_attr *attr);
131 
132 int
134 
135 int
137  sstmac_pthread_mutex_t * mutex);
138 
139 int
141  sstmac_pthread_mutex_t * mutex, const struct timespec * abstime);
142 
143 int
145 
146 int
148 
149 int
151  (*init_routine)(void));
152 
153 int
155  (* dest_routine)(void *));
156 
157 int
159 
160 int
161 SSTMAC_pthread_setspecific(sstmac_pthread_key_t key, const void * pointer);
162 
163 void *
165 
166 void
168  (*routine)(void *), void *routine_arg);
169 
170 void
171 SSTMAC_pthread_cleanup_pop(int execute);
172 
173 int
175 
176 int
178 
179 int
181  size_t * stacksize);
182 
183 int
185 
186 int
188  int *state);
189 
190 int
192 
193 int
195 
196 int
198 
199 int
201 
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #endif
207 
int SSTMAC_pthread_attr_setaffinity_np(sstmac_pthread_attr_t *attr, size_t cpusetsize, const sstmac_cpu_set_t *cpuset)
void(* sstmac_pthread_key_destructor_fxn)(void *)
int SSTMAC_pthread_cond_init(sstmac_pthread_cond_t *cond, const sstmac_pthread_cond_attr *attr)
int SSTMAC_pthread_attr_setscope(sstmac_pthread_attr_t *, int scope)
int SSTMAC_pthread_key_delete(sstmac_pthread_key_t key)
int SSTMAC_pthread_once(sstmac_pthread_once_t *once_init, void(*init_routine)(void))
int SSTMAC_pthread_mutex_destroy(sstmac_pthread_mutex_t *mutex)
#define sstmac_pthread_cond_attr
int SSTMAC_pthread_mutexattr_destroy(sstmac_pthread_mutexattr_t *attr)
#define sstmac_pthread_t
int SSTMAC_pthread_spin_init(sstmac_pthread_spinlock_t *lock, int pshared)
int SSTMAC_pthread_cond_broadcast(sstmac_pthread_cond_t *cond)
int SSTMAC_pthread_create(sstmac_pthread_t *thread, const sstmac_pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
int SSTMAC_pthread_attr_getaffinity_np(sstmac_pthread_attr_t attr, size_t cpusetsize, sstmac_cpu_set_t *cpuset)
int SSTMAC_pthread_spin_unlock(sstmac_pthread_spinlock_t *lock)
int SSTMAC_pthread_attr_getstack(sstmac_pthread_attr_t *attr, void **stack, size_t *stacksize)
void SSTMAC_pthread_cleanup_pop(int execute)
#define sstmac_pthread_mutexattr_t
int SSTMAC_pthread_cond_timedwait(sstmac_pthread_cond_t *cond, sstmac_pthread_mutex_t *mutex, const struct timespec *abstime)
int SSTMAC_pthread_equal(sstmac_pthread_t thread_1, sstmac_pthread_t thread_2)
int SSTMAC_pthread_join(sstmac_pthread_t thread, void **status)
int SSTMAC_pthread_spin_trylock(sstmac_pthread_spinlock_t *lock)
int SSTMAC_pthread_attr_init(sstmac_pthread_attr_t *attr)
int SSTMAC_pthread_attr_destroy(sstmac_pthread_attr_t *attr)
int SSTMAC_pthread_mutex_trylock(sstmac_pthread_mutex_t *mutex)
int SSTMAC_pthread_cond_wait(sstmac_pthread_cond_t *cond, sstmac_pthread_mutex_t *mutex)
int sstmac_pthread_key_t
#define sstmac_pthread_mutex_t
#define sstmac_pthread_once_t
int SSTMAC_pthread_yield()
void SSTMAC_pthread_cleanup_push(void(*routine)(void *), void *routine_arg)
int SSTMAC_pthread_cond_destroy(sstmac_pthread_cond_t *cond)
int SSTMAC_pthread_attr_setdetachstate(sstmac_pthread_attr_t *attr, int state)
#define sstmac_pthread_spinlock_t
int SSTMAC_pthread_mutex_unlock(sstmac_pthread_mutex_t *mutex)
int SSTMAC_pthread_detach(sstmac_pthread_t)
int SSTMAC_pthread_mutexattr_init(sstmac_pthread_mutexattr_t *attr)
int SSTMAC_pthread_cond_signal(sstmac_pthread_cond_t *cond)
int SSTMAC_pthread_spin_lock(sstmac_pthread_spinlock_t *lock)
#define sstmac_pthread_cond_t
int SSTMAC_pthread_key_create(sstmac_pthread_key_t *key, void(*dest_routine)(void *))
int SSTMAC_pthread_mutex_lock(sstmac_pthread_mutex_t *mutex)
int SSTMAC_pthread_spin_destroy(sstmac_pthread_spinlock_t *lock)
void * SSTMAC_pthread_getspecific(sstmac_pthread_key_t key)
int SSTMAC_pthread_attr_getstacksize(sstmac_pthread_attr_t *attr, size_t *stacksize)
int SSTMAC_pthread_kill(sstmac_pthread_t thr, int signal)
void SSTMAC_pthread_exit(void *retval)
int SSTMAC_pthread_attr_getdetachstate(const sstmac_pthread_attr_t *attr, int *state)
sstmac_pthread_t SSTMAC_pthread_self()
int SSTMAC_pthread_setspecific(sstmac_pthread_key_t key, const void *pointer)
int SSTMAC_pthread_attr_setstacksize(sstmac_pthread_attr_t *attr, size_t stacksize)
int SSTMAC_pthread_attr_getscope(sstmac_pthread_attr_t *, int *scope)
int SSTMAC_pthread_mutex_init(sstmac_pthread_mutex_t *mutex, const sstmac_pthread_mutexattr_t *attr)