• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @defgroup posix POSIX
3  * @defgroup pthread Thread
4  * @ingroup posix
5  */
6 
7 #ifndef _PTHREAD_H
8 #define _PTHREAD_H
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #ifdef __LITEOS__
14 #include "bits/pthread_types.h"
15 #include "los_list.h"
16 #include "los_task_pri.h"
17 #endif
18 
19 #include <features.h>
20 
21 #ifdef __LITEOS__
22 typedef struct {
23 	LOS_DL_LIST stMuxList; /**< Mutex blocking linked list*/
24 	LosTaskCB* pstOwner;   /**< Task that involves the mutex*/
25 	UINT16 usMuxCount;     /**< Mutex counter value*/
26 } MUX_CB_P;
27 #endif
28 
29 #define __NEED_time_t
30 #define __NEED_clockid_t
31 #define __NEED_struct_timespec
32 #define __NEED_sigset_t
33 #define __NEED_pthread_t
34 #define __NEED_pthread_attr_t
35 #define __NEED_pthread_mutexattr_t
36 #define __NEED_pthread_condattr_t
37 #define __NEED_pthread_rwlockattr_t
38 #define __NEED_pthread_barrierattr_t
39 #define __NEED_pthread_mutex_t
40 #define __NEED_pthread_cond_t
41 #define __NEED_pthread_rwlock_t
42 #define __NEED_pthread_barrier_t
43 #define __NEED_pthread_spinlock_t
44 #define __NEED_pthread_key_t
45 #define __NEED_pthread_once_t
46 #define __NEED_size_t
47 
48 
49 #include <bits/alltypes.h>
50 
51 #include <sched.h>
52 #include <time.h>
53 
54 #ifdef __LITEOS__
55 typedef struct pthread_mutexattr {
56 	UINT8 protocol;     /**< Mutex protocol. The value range is [0, 2].*/
57 	UINT8 prioceiling;  /**< Upper priority limit of a mutex. The value range is [0, 31].*/
58 	UINT8 type;         /**< Mutex type. The value range is [0, 2].*/
59 	UINT8 reserved;     /**< Reserved.*/
60 } pthread_mutexattr_t;
61 
62 typedef struct pthread_mutex {
63 	pthread_mutexattr_t stAttr;  /**< Mutex attributes object*/
64 	MUX_CB_P stLock;             /**< Mutex operation object*/
65 } pthread_mutex_t;
66 
67 typedef struct {
68 	clockid_t clock;
69 } pthread_condattr_t;
70 
71 typedef struct pthread_cond {
72 	volatile int count;      /**< The number of tasks blocked by condition */
73 	EVENT_CB_S event;        /**< Event object*/
74 	pthread_mutex_t* mutex;  /**< Mutex locker for condition variable protection */
75 	volatile int value;      /**< Condition variable state value*/
76 } pthread_cond_t;
77 #endif
78 
79 #define PTHREAD_CREATE_JOINABLE 0
80 #define PTHREAD_CREATE_DETACHED 1
81 
82 #define PTHREAD_MUTEX_NORMAL 0
83 #define PTHREAD_MUTEX_DEFAULT 0
84 #define PTHREAD_MUTEX_RECURSIVE 1
85 #define PTHREAD_MUTEX_ERRORCHECK 2
86 #ifdef __LITEOS__
87 #define PTHREAD_MUTEX_RECURSIVE_NP 1
88 #define PTHREAD_MUTEX_ERRORCHECK_NP 2
89 #endif
90 
91 #define PTHREAD_MUTEX_STALLED 0
92 #define PTHREAD_MUTEX_ROBUST 1
93 
94 #define PTHREAD_PRIO_NONE 0
95 #define PTHREAD_PRIO_INHERIT 1
96 #define PTHREAD_PRIO_PROTECT 2
97 
98 #define PTHREAD_INHERIT_SCHED 0
99 #define PTHREAD_EXPLICIT_SCHED 1
100 
101 #define PTHREAD_SCOPE_SYSTEM 0
102 #define PTHREAD_SCOPE_PROCESS 1
103 
104 /**
105  * @ingroup pthread
106  * Define a condition variable to be shared between threads within the same process.
107  */
108 #define PTHREAD_PROCESS_PRIVATE 0
109 
110 /**
111  * @ingroup pthread
112  * Define a condition variable to be shared among multiple processes.
113  */
114 #define PTHREAD_PROCESS_SHARED 1
115 
116 #ifdef __LITEOS__
117 #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
118     { { PTHREAD_PRIO_INHERIT, OS_TASK_PRIORITY_LOWEST, PTHREAD_MUTEX_RECURSIVE_NP, 0 }, \
119     { { (struct LOS_DL_LIST *)NULL, (struct LOS_DL_LIST *)NULL }, \
120     (LosTaskCB *)NULL, 0 } }
121 
122 #define PTHREAD_MUTEX_INITIALIZER \
123     { { PTHREAD_PRIO_INHERIT, OS_TASK_PRIORITY_LOWEST, 0, 0 }, \
124     { { (struct LOS_DL_LIST *)NULL, (struct LOS_DL_LIST *)NULL }, \
125     (LosTaskCB *)NULL, 0 } }
126 
127 #define PTHREAD_COND_INITIALIZER { -1, { 0, { NULL, NULL } }, NULL, -1 }
128 #endif
129 
130 #define PTHREAD_RWLOCK_INITIALIZER {{{0}}}
131 #define PTHREAD_ONCE_INIT 0
132 
133 
134 #define PTHREAD_CANCEL_ENABLE 0
135 #define PTHREAD_CANCEL_DISABLE 1
136 #define PTHREAD_CANCEL_MASKED 2
137 
138 #define PTHREAD_CANCEL_DEFERRED 0
139 #define PTHREAD_CANCEL_ASYNCHRONOUS 1
140 
141 #define PTHREAD_CANCELED ((void *)-1)
142 
143 
144 #define PTHREAD_BARRIER_SERIAL_THREAD (-1)
145 
146 
147 int pthread_create(pthread_t *__restrict, const pthread_attr_t *__restrict, void *(*)(void *), void *__restrict);
148 
149 /**
150  * @ingroup pthread
151  *
152  * @par Description:
153  * This API is used to mark a thread as detached. When a detached thread terminates, its resources are automatically released back to Huawei LiteOS without the need for another thread to join with the terminated thread.
154  *
155  * @param pthread  [IN]  ID of the thread to be marked as detached.
156  *
157  * @attention
158  * <ul>
159  * <li>None.</li>
160  * </ul>
161  *
162  * @retval    #int   If the call succeeds, pthread_detach() shall return 0; otherwise, an error number shall be returned to indicate the error.
163  *
164  * @retval  #ESRCH   The target thread cannot be marked (the thread does not exist or has exited).
165  * @retval  #EINVAL  The target thread is already marked as detached.
166  * @retval  #ENOERR  The thread is successfully marked.
167  *
168  * @par Dependency:
169  * <ul><li>pthread.h</li></ul>
170  * @see pthread_join
171  */
172 int pthread_detach(pthread_t);
173 #ifndef __LITEOS__
174 _Noreturn void pthread_exit(void *);
175 #else
176 /**
177  * @ingroup pthread
178  *
179  * @par Description:
180  * This API is used to terminate the current thread, and the return value contains only one parameter.
181  *
182  * @param   retval  [OUT] Pointer to the thread return value.
183  *
184  * @attention
185  * <ul>
186  * <li>Thread termination does not release any application visible process resources, including, but not limited to,
187  * mutexes and file descriptors.</li>
188  * </ul>
189  *
190  * @retval  #void None.
191  *
192  * @par Dependency:
193  * <ul><li>pthread.h</li></ul>
194  * @see pthread_create | pthread_join
195  */
196 void pthread_exit(void *);
197 #endif
198 
199 /* Wait for the thread to terminate. If thread_return is not NULL then
200  * the retval from the thread's call to pthread_exit() is stored at thread_return.
201  */
202 /**
203  * @ingroup pthread
204  *
205  * @par Description:
206  * This API is used to wait for a thread to terminate and reclaim its resources.
207  *
208  * @param   pthread          [IN]  ID of the target thread (the waited thread).
209  * @param   thread_return    [OUT] Return value sent to the waiting thread.
210  *
211  * @attention
212  * <ul>
213  * <li>A thread cannot be waited for by multiple threads. If a thread is waited for by multiple threads, ESRCH will be returned.</li>
214  * </ul>
215  *
216  * @retval  #int  If successful, the pthread_join() function shall return zero; otherwise, an error number shall be returned to indicate the error.
217  *
218  * @retval  #ESRCH     The target thread is not joinable (the thread does not exist, or has exited, or is waited for by another thread).
219  * @retval  #EDEADLK   A deadlock results because a thread is waiting for itself to terminate.
220  * @retval  #EINVAL    The target thread is not joinable.
221  * @retval  #ENOERR    The target thread is successfully joined with.
222  *
223  * @par Dependency:
224  * <ul><li>pthread.h</li></ul>
225  * @see pthread_detach
226  */
227 int pthread_join(pthread_t, void **);
228 
229 #ifdef __GNUC__
230 __attribute__((const))
231 #endif
232 
233 /**
234  * @ingroup pthread
235  *
236  * @par Description:
237  * This API is used to acquire the thread identifier of the calling thread.
238  *
239  * @attention
240  * <ul>
241  * <li>None.</li>
242  * </ul>
243  *
244  * @retval pthread_t Thread ID [0,LOSCFG_BASE_CORE_TSK_LIMIT].
245  *
246  * @par Dependency:
247  * <ul><li>pthread.h</li></ul>
248  * @see None
249  */
250 pthread_t pthread_self(void);
251 
252 /* Compare two thread identifiers. */
253 /**
254  * @ingroup pthread
255  *
256  * @par Description:
257  * This API is used to compare whether two thread IDs belong to the same thread.
258  *
259  * @param thread1  [IN]  ID of the thread 1 being compared.
260  * @param thread2  [IN]  ID of the thread 2 being compared.
261  *
262  * @attention
263  * <ul>
264  * <li>Just compare the thread ID, not judge the validity of the thread ID.</li>
265  * </ul>
266  *
267  * @retval  #int Any value other than 0  mean that two threads are equal.
268  * @retval  #0  The two threads are unequal.
269  *
270  * @par Dependency:
271  * <ul><li>pthread.h</li></ul>
272  * @see None
273  */
274 int pthread_equal(pthread_t, pthread_t);
275 #ifndef __cplusplus
276 #define pthread_equal(x,y) ((x)==(y))
277 #endif
278 
279 int pthread_setcancelstate(int, int *);
280 int pthread_setcanceltype(int, int *);
281 void pthread_testcancel(void);
282 int pthread_cancel(pthread_t);
283 
284 /* Get scheduling policy and parameters for the thread */
285 /**
286  * @ingroup pthread
287  *
288  * @par Description:
289  * This API is used to acquire the scheduling policy and priority of a thread.
290  *
291  * @param  pthread  [IN]  ID of the thread whose scheduling policy is to be read.
292  * @param  policy   [OUT] Acquired scheduling policy.
293  * @param  param    [OUT] Acquired scheduling priority.
294  *
295  * @attention
296  * <ul>
297  * <li>None.</li>
298  * </ul>
299  *
300  * @retval #int If successful, the pthread_getschedparam() function shall return zero; otherwise, an error number shall be returned to indicate the error.
301  *
302  * @retval  #EINVAL   invalid parameter.
303  * @retval  #ENOERR   The scheduling policy and priority of the thread is successfully acquired.
304  *
305  * @par Dependency:
306  * <ul><li>pthread.h</li></ul>
307  * @see pthread_setschedparam
308  */
309 int pthread_getschedparam(pthread_t, int *__restrict, struct sched_param *__restrict);
310 
311 /* Set scheduling policy and parameters for the thread */
312 /**
313  * @ingroup pthread
314  *
315  * @par Description:
316  * This API is used to set the scheduling policy and priority of a thread.
317  *
318  * @param  pthread  [IN] ID of the thread whose scheduling policy is to be set.
319  * @param  policy   [IN] Specified scheduling policy.
320  * @param  param    [IN] Pointer to the scheduling priority.
321  *
322  * @attention
323  * <ul>
324  * <li>The scheduling policy must be SCHED_OTHER, SCHED_FIFO, or SCHED_RR.</li>
325  * <li>Only SCHED_RR is supported now. An error code will be returned if the value is set to the other two scheduling policies.</li>
326  * <li>The content priority specified by the param parameter must fall within the OS priority range[0,31].</li>
327  * <li>A smaller priority value indicates a higher priority.</li>
328  * </ul>
329  *
330  * @retval  #int  If successful, the pthread_setschedparam() function shall return zero; otherwise, an error number shall be returned to indicate the error.
331  *
332  * @retval  #EINVAL   invalid parameter.
333  * @retval  #ENOERR   The scheduling policy and priority of the thread is successfully set.
334  *
335  * @par Dependency:
336  * <ul><li>pthread.h</li></ul>
337  * @see pthread_getschedparam
338  */
339 int pthread_setschedparam(pthread_t, int, const struct sched_param *);
340 int pthread_setschedprio(pthread_t, int);
341 
342 /* Call init_routine just the once per control variable. */
343 /**
344  * @ingroup pthread
345  *
346  * @par  Decription:
347  * This API is used to call the initialization routine at most once.
348  *
349  * @param  once_control  [IN/OUT]  Once-control parameter.
350  * @param  init_routine  [IN]      Initialization routine function.
351  *
352  * @attention
353  * <ul>
354  * <li>The control variable once_control must be statically initialized using PTHREAD_ONCE_INIT. Otherwise, this API will not work as expected.</li>
355  * </ul>
356  *
357  * @retval  #int     Upon successful completion, pthread_once() shall return zero; otherwise, an error number shall be returned to indicate the error.
358  * @retval  #EINVAL  One or more parameters are invalid.
359  *
360  * @par Dependency:
361  * <ul><li>pthread.h</li></ul>
362  * @see None
363  */
364 int pthread_once(pthread_once_t *, void (*)(void));
365 
366 int pthread_mutex_init(pthread_mutex_t *__restrict, const pthread_mutexattr_t *__restrict);
367 int pthread_mutex_lock(pthread_mutex_t *);
368 int pthread_mutex_unlock(pthread_mutex_t *);
369 int pthread_mutex_trylock(pthread_mutex_t *);
370 int pthread_mutex_timedlock(pthread_mutex_t *__restrict, const struct timespec *__restrict);
371 int pthread_mutex_destroy(pthread_mutex_t *);
372 int pthread_mutex_consistent(pthread_mutex_t *);
373 
374 int pthread_mutex_getprioceiling(const pthread_mutex_t *__restrict, int *__restrict);
375 int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict, int, int *__restrict);
376 
377 /**
378  * @ingroup pthread
379  * @par Description:
380  * This API is used to initialize a condition variable.
381  *
382  * @param cond  [OUT]  Condition variable object.
383  * @param attr  [IN]   Condition variable attribute. The passed value and the default value of this parameter can be only set to PTHREAD_PROCESS_PRIVATE.
384  *
385  * @attention
386  * <ul>
387  * <li>A condition variable cannot be initialized by multiple threads. When a condition variable needs to be reinitialized, it must not have been used.</li>
388  * </ul>
389  *
390  * @retval  #EINVAL  One or more parameters are invalid.
391  * @retval  #ENOERR  The condition variable is successfully initialized.
392  * @retval  #ENOMEM  Failed to allocate in-memory resources for the operation.
393  *
394  * @par Dependency:
395  * <ul><li>pthread.h</li></ul>
396  *
397  * @see pthread_cond_destroy
398  *
399  */
400 int pthread_cond_init(pthread_cond_t *__restrict, const pthread_condattr_t *__restrict);
401 
402 /**
403  * @ingroup pthread
404  * @par Description:
405  * This API is used to destroy a condition variable.
406  *
407  * @param cond  [IN]  Condition variable object.
408  *
409  * @attention
410  * <ul>
411  * <li>The condition variable is using memory and not destroyed.</li>
412  * </ul>
413  *
414  * @retval  #ENVAIL  The parameter is invalid.
415  * @retval  #EBUSY   The condition variable is being in use.
416  * @retval  #ENOERR  The condition variable is successfully destroyed.
417  *
418  * @par Dependency:
419  * <ul><li>pthread.h</li></ul>
420  *
421  * @see pthread_cond_init
422  *
423  */
424 int pthread_cond_destroy(pthread_cond_t *);
425 
426 /**
427  * @ingroup pthread
428  * @par Description:
429  * A thread has been being blocked on a condition variable and waits to be awoken by the condition variable.
430  *
431  * @param cond   [IN]  Condition variable object.
432  * @param mutex  [IN]  Mutex object.
433  * @attention
434  * <ul>
435  * <li>None.</li>
436  * </ul>
437  *
438  * @retval  #ENVAIL  One or more parameters are invalid.
439  * @retval  #ENOERR  The thread is successfully awoken.
440  *
441  * @par Dependency:
442  * <ul><li>pthread.h</li></ul>
443  *
444  * @see pthread_cond_signal | pthread_cond_broadcast
445  *
446  */
447 int pthread_cond_wait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict);
448 
449 /**
450  * @ingroup pthread
451  * @par Description:
452  * A thread has been being blocked on a condition variable and is awoken until the set relative time has passed or the thread obtains a condition variable.
453  *
454  * @param cond     [IN]    Condition variable object.
455  * @param mutex    [IN]     Mutex object.
456  * @param abstime  [IN]    Time object.
457  *
458  * @attention
459  * <ul>
460  * <li>The waiting time is a relative time.</li>
461  * <li> Setting the timeout interval to a past time period is not supported.</li>
462  * </ul>
463  *
464  * @retval  #ENOERR     The thread receives a signal and is successfully awoken.
465  * @retval  #ENVAIL     One or more parameters are invalid.
466  * @retval  #ETIMEDOUT  The waiting time has passed.
467  * @retval  #ENOMEM     Failed to allocate in-memory resources for the operation.
468  *
469  * @par Dependency:
470  * <ul><li>pthread.h</li></ul>
471  *
472  * @see pthread_cond_wait
473  *
474  */
475 int pthread_cond_timedwait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, const struct timespec *__restrict);
476 
477 /**
478  * @ingroup pthread
479  * @par Description:
480  * This API is used to unblock all threads blocked on a condition variable and wake all these threads.
481  *
482  * @param cond  [IN]  Condition variable object.
483  *
484  * @attention
485  * <ul>
486  * <li>None.</li>
487  * </ul>
488  *
489  * @retval  #ENVAIL  The parameter is invalid.
490  * @retval  #ENOERR  All threads blocked on this condition variable are successfully unblocked.
491  *
492  * @par Dependency:
493  * <ul><li>pthread.h</li></ul>
494  *
495  * @see pthread_cond_wait
496  *
497  */
498 int pthread_cond_broadcast(pthread_cond_t *);
499 
500 /**
501  * @ingroup pthread
502  * @par Description:
503  * This API is used to unblock a thread blocked on a condition variable and wakes this thread.
504  *
505  * @param cond  [IN]  Condition variable object.
506  *
507  * @attention
508  * <ul>
509  * <li>None.</li>
510  * </ul>
511  *
512  * @retval  #ENVAIL  The parameter is invalid.
513  * @retval  #ENOERR  The thread is successfully unlocked.
514  *
515  * @par Dependency:
516  * <ul><li>pthread.h</li></ul>
517  *
518  * @see pthread_cond_wait
519  *
520  */
521 int pthread_cond_signal(pthread_cond_t *);
522 
523 int pthread_rwlock_init(pthread_rwlock_t *__restrict, const pthread_rwlockattr_t *__restrict);
524 int pthread_rwlock_destroy(pthread_rwlock_t *);
525 int pthread_rwlock_rdlock(pthread_rwlock_t *);
526 int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
527 int pthread_rwlock_timedrdlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict);
528 int pthread_rwlock_wrlock(pthread_rwlock_t *);
529 int pthread_rwlock_trywrlock(pthread_rwlock_t *);
530 int pthread_rwlock_timedwrlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict);
531 int pthread_rwlock_unlock(pthread_rwlock_t *);
532 
533 int pthread_spin_init(pthread_spinlock_t *, int);
534 int pthread_spin_destroy(pthread_spinlock_t *);
535 int pthread_spin_lock(pthread_spinlock_t *);
536 int pthread_spin_trylock(pthread_spinlock_t *);
537 int pthread_spin_unlock(pthread_spinlock_t *);
538 
539 int pthread_barrier_init(pthread_barrier_t *__restrict, const pthread_barrierattr_t *__restrict, unsigned);
540 int pthread_barrier_destroy(pthread_barrier_t *);
541 int pthread_barrier_wait(pthread_barrier_t *);
542 int pthread_key_create(pthread_key_t *, void (*)(void *));
543 int pthread_key_delete(pthread_key_t);
544 void *pthread_getspecific(pthread_key_t);
545 int pthread_setspecific(pthread_key_t, const void *);
546 
547 /* Thread attribute handling. */
548 
549 /**
550  * @ingroup pthread
551  *
552  * @par Description:
553  * This API is used to initialize a thread attributes object into default attributes.
554  *
555  * @param attr  [IN] Pointer to the thread attributes object to be initialized.
556  *
557  * @attention
558  * <ul>
559  * <li>Default thread attributes</li>
560  * <li>detachstate                 = PTHREAD_CREATE_JOINABLE</li>
561  * <li>schedpolicy                 = SCHED_RR</li>
562  * <li>schedparam.sched_priority   = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO</li>
563  * <li>inheritsched                = PTHREAD_INHERIT_SCHED</li>
564  * <li>scope                       = PTHREAD_SCOPE_SYSTEM</li>
565  * <li>stackaddr_set               = 0</li>
566  * <li>stackaddr                   = NULL</li>
567  * <li>stacksize_set               = 1</li>
568  * <li>stacksize                   = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE</li>
569  * </ul>
570  *
571  * @retval  #int  Upon successful completion, pthread_attr_init() shall return a value of 0; otherwise, an error number shall be returned to indicate the error.
572  *
573  * @retval  #EINVAL  The input parameter is NULL.
574  * @retval  #ENOERR  The thread attributes object is successfully initialized.
575  *
576  * @par Dependency:
577  * <ul><li>pthread.h</li></ul>
578  * @see pthread_attr_destroy
579  */
580 int pthread_attr_init(pthread_attr_t *);
581 
582 /* Destroy thread attributes object */
583 /**
584  * @ingroup pthread
585  *
586  * @par Dependency:
587  * This API is used to destroy a thread attributes object.
588  *
589  * @param attr  [IN] Pointer to the thread attributes object to be destroyed.
590  *
591  * @attention
592  * <ul>
593  * <li>This API does not take effect on Huawei LiteOS. In fact, nothing has been done in this API.</li>
594  * </ul>
595  *
596  * @retval  #int  Upon successful completion, pthread_attr_destroy() shall return a value of 0; otherwise, an error number shall be returned to indicate the error.
597  *
598  * @retval  #EINVAL  The input parameter is NULL.
599  * @retval  #ENOERR  The thread attributes object is successfully destroyed.
600  *
601  * @par Dependency:
602  * <ul><li>pthread.h</li></ul>
603  * @see pthread_attr_init
604  */
605 int pthread_attr_destroy(pthread_attr_t *);
606 
607 int pthread_attr_getguardsize(const pthread_attr_t *__restrict, size_t *__restrict);
608 int pthread_attr_setguardsize(pthread_attr_t *, size_t);
609 
610 /* Get current minimal stack size. */
611 /**
612  * @ingroup pthread
613  *
614  * @par Description:
615  * This API is used to acquire the stack size attribute of a thread attribute object.
616  *
617  * @param attr       [IN]  Pointer to the thread attributes object to be read.
618  * @param stacksize  [OUT] Pointer to the acquired stack size.
619  *
620  * @attention
621  * <ul>
622  * <li>None.</li>
623  * </ul>
624  *
625  * @retval   #int   Upon successful completion, pthread_attr_getstacksize() shall return a value of 0; otherwise, an error number shall be returned to indicate the error.
626  * The pthread_attr_getstacksize() function stores the stacksize attribute value in stacksize if successful.
627  *
628  * @retval  #EINVAL  invalid parameter, or the stack size left unspecified.
629  * @retval  #ENOERR  The stack size attribute is successfully acquired.
630  *
631  * @par Dependency:
632  * <ul><li>pthread.h</li></ul>
633  * @see pthread_attr_setstacksize
634  */
635 int pthread_attr_getstacksize(const pthread_attr_t *__restrict, size_t *__restrict);
636 
637 /* Set minimum creation stack size. */
638 /**
639  * @ingroup pthread
640  *
641  * @par Description:
642  * This API is used to set the stack size attribute of a thread attribute object.
643  *
644  * @param attr       [OUT] Pointer to the thread attributes object to be set.
645  * @param stacksize  [IN]  Specified stack size.
646  *
647  * @attention
648  * <ul>
649  * <li>The stack size must fall within an appropriate range and be greater than PTHREAD_STACK_MIN.
650  * If the stack size attribute is left unspecified, the default stack size will be used.</li>
651  * </ul>
652  *
653  * @retval  #int Upon successful completion, pthread_attr_setstacksize() shall return a value of 0; otherwise, an error number shall be returned to indicate the error.
654  *
655  * @retval  #EINVAL  invalid parameter.
656  * @retval  #ENOERR  The stack size attribute is successfully set.
657  *
658  * @par Dependency:
659  * <ul><li>pthread.h</li></ul>
660  * @see pthread_attr_getstacksize
661  */
662 int pthread_attr_setstacksize(pthread_attr_t *, size_t);
663 
664 /* Get the detachstate attribute */
665 /**
666  * @ingroup pthread
667  *
668  * @par Description:
669  * This API is used to acquire the detach state attribute of a thread attributes object.
670  *
671  * @param  attr         [IN]  Pointer to the thread attributes object to be read.
672  * @param  detachstate  [OUT] Pointer to the acquired detach state attribute.
673  *
674  * @attention
675  * <ul>
676  * <li>Detachstate shall be set to either PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE.</li>
677  * </ul>
678  *
679  * @retval   int   Upon successful completion, pthread_attr_getdetachstate() shall return a value of 0; otherwise, an error number shall be returned to indicate the error.
680  * The pthread_attr_getdetachstate() function stores the value of the detachstate attribute in detachstate if successful.
681  *
682  * @retval  #EINVAL    invalid parameter.
683  * @retval  #ENOERR    The detach state attribute is successfully acquired.
684  *
685  * @par Dependency:
686  * <ul><li>pthread.h</li></ul>
687  * @see pthread_attr_setdetachstate
688  */
689 int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
690 
691 /* Set the detachstate attribute */
692 /**
693  * @ingroup pthread
694  *
695  * @par Description:
696  * This API is used to set the detach state attribute of a thread attributes object.
697  *
698  * @param attr         [OUT] Pointer to the thread attributes object to be set.
699  * @param detachstate  [IN]  Detach state attribute.
700  *
701  * @attention
702  * <ul>
703  * <li>The detach state attribute must be either PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED. Otherwise, the attempt to set the detach state attribute will fail.</li>
704  * </ul>
705  *
706  * @retval   #int   Upon successful completion, pthread_attr_setdetachstate() shall return a value of 0; otherwise, an error number shall be returned to indicate the error.
707  *
708  * @retval  #EINVAL  invalid parameter.
709  * @retval  #ENOERR  The detach state attribute is successfully set.
710  *
711  * @par Dependency:
712  * <ul><li>pthread.h</li></ul>
713  * @see pthread_attr_getdetachstate
714  */
715 int pthread_attr_setdetachstate(pthread_attr_t *, int);
716 int pthread_attr_getstack(const pthread_attr_t *__restrict, void **__restrict, size_t *__restrict);
717 int pthread_attr_setstack(pthread_attr_t *, void *, size_t);
718 
719 #ifdef __LITEOS__
720 /* Set starting address of stack. Whether this is at the start or end of
721  * the memory block allocated for the stack depends on whether the stack
722  * grows up or down.
723  */
724 /**
725  * @ingroup pthread
726  *
727  * @par Description:
728  * This API is used to set the stack address attribute of a thread attributes object. This attribute specifies the start address of a stack.
729  *
730  * @param attr       [OUT] Pointer to the thread attributes object to be set.
731  * @param stackaddr  [IN]  Specified stack address.
732  *
733  * @attention
734  * <ul>
735  * <li>This API does not take effect on Huawei LiteOS Kernel.</li>
736  * </ul>
737  *
738  * @retval  #int  Upon successful completion, pthread_attr_setstackaddr() shall return a value of 0; otherwise, an error number shall be returned to indicate the error.
739  *
740  * @retval  #EINVAL  invalid parameter.
741  * @retval  #ENOERR  The stack address attribute is successfully set.
742  *
743  * @par Dependency:
744  * <ul><li>pthread.h</li></ul>
745  * @see pthread_attr_getstackaddr
746  */
747 int pthread_attr_setstackaddr(pthread_attr_t *, void *);
748 
749 /* Get any previously set stack address. */
750 /**
751  * @ingroup pthread
752  *
753  * @par Description:
754  * This API is used to acquire the stack address attribute of a thread attributes object. This attribute specifies the starting address of a stack.
755  *
756  * @param attr       [IN]  Pointer to the thread attributes object to be read.
757  * @param stackaddr  [OUT] Pointer to the acquired starting address of stack.
758  *
759  * @attention
760  * <ul>
761  * <li>This API does not take effect on Huawei LiteOS Kernel.</li>
762  * </ul>
763  *
764  * @retval  #int  Upon successful completion, pthread_attr_getstackaddr() shall return a value of 0; otherwise, an error number shall be returned to indicate the error.
765  *
766  * @retval  #EINVAL  invalid parameter.
767  * @retval  #ENOERR  The stack address attribute is successfully acquired.
768  *
769  * @par Dependency:
770  * <ul><li>pthread.h</li></ul>
771  * @see pthread_attr_setstackaddr
772  */
773 int pthread_attr_getstackaddr(const pthread_attr_t *, void **);
774 #endif
775 
776 /* Get scheduling contention scope */
777 /**
778  * @ingroup pthread
779  *
780  * @par Description:
781  * This API is used to acquire the contention scope attribute of a thread attributes object.
782  *
783  * @param attr   [IN]  Pointer to the thread attributes object to be read.
784  * @param scope  [OUT] Pointer to the acquired contention scope attribute.
785  *
786  * @attention
787  * <ul>
788  * <li>None.</li>
789  * </ul>
790  *
791  * @retval  #int  If successful, the pthread_attr_getscope() function shall return zero; otherwise, an error number shall be returned to indicate the error.
792  *
793  * @retval  #EINVAL  invalid parameter.
794  * @retval  #ENOERR  The contention scope attribute is successfully acquired.
795  *
796  * @par Dependency:
797  * <ul><li>pthread.h</li></ul>
798  * @see pthread_attr_setscope
799  */
800 int pthread_attr_getscope(const pthread_attr_t *__restrict, int *__restrict);
801 
802 /* Set scheduling contention scope */
803 /**
804  * @ingroup pthread
805  *
806  * @par Description:
807  * This API is used to set the contention scope attribute of a thread attributes object.
808  *
809  * @param  attr   [OUT] Pointer to the thread attributes object to be set.
810  * @param  scope  [IN]  Contention scope attribute.
811  *
812  * @attention
813  * <ul>
814  * <li>The contention scope attribute can only be PTHREAD_SCOPE_SYSTEM. PTHREAD_SCOPE_PROCES is not supported.</li>
815  * </ul>
816  *
817  * @retval   #int     If successful, the pthread_attr_setscope() function shall return zero; otherwise, an error number shall be returned to indicate the error.
818  *
819  * @retval  #EINVAL   invalid parameter.
820  * @retval  #ENOTSUP  The specified contention scope attribute value is not supported.
821  * @retval  #ENOERR   The contention scope attribute is successfully set.
822  *
823  * @par Dependency:
824  * <ul><li>pthread.h</li></ul>
825  * @see pthread_attr_getscope
826  */
827 int pthread_attr_setscope(pthread_attr_t *, int);
828 
829 /* Get scheduling policy */
830 /**
831  * @ingroup pthread
832  *
833  * @par Description:
834  * This API is used to acquire the scheduling policy attribute of a thread attributes object.
835  *
836  * @param attr    [IN]  Pointer to the thread attributes object to be read.
837  * @param policy  [OUT] Pointer to the acquired scheduling policy attribute.
838  *
839  * @attention
840  * <ul>
841  * <li>None.</li>
842  * </ul>
843  *
844  * @retval #int  If successful, the pthread_attr_getschedpolicy() function shall return zero; otherwise, an error number shall be returned to indicate the error.
845  *
846  * @retval  #EINVAL  invalid parameter.
847  * @retval  #ENOERR  The scheduling policy attribute is successfully obtained.
848  *
849  * @par Dependency:
850  * <ul><li>pthread.h</li></ul>
851  * @see pthread_attr_setschedpolicy
852  */
853 int pthread_attr_getschedpolicy(const pthread_attr_t *__restrict, int *__restrict);
854 
855 /* Set scheduling policy */
856 /**
857  * @ingroup pthread
858  *
859  * @par Description:
860  * This API is used to set the scheduling policy attribute of a thread attributes object.
861  *
862  * @param attr    [OUT] Pointer to the thread attributes object to be set.
863  * @param policy  [IN]  Scheduling policy attribute.
864  *
865  * @attention
866  * <ul>
867  * <li>The scheduling policy attribute is SCHED_OTHER, SCHED_FIFO, or SCHED_RR.</li>
868  * <li>Only SCHED_RR is supported now. An error code will be returned if the value is set to the other two scheduling policies.</li>
869  * </ul>
870  *
871  * @retval   #int  If successful, the pthread_attr_setschedpolicy() function shall return zero; otherwise, an error number shall be returned to indicate the error.
872  *
873  * @retval  #EINVAL    invalid parameter.
874  * @retval  #ENOERR    The scheduling policy attribute is successfully set.
875  *
876  * @par Dependency:
877  * <ul><li>pthread.h</li></ul>
878  * @see pthread_attr_getschedpolicy
879  */
880 int pthread_attr_setschedpolicy(pthread_attr_t *, int);
881 
882 /* Get scheduling parameters */
883 /**
884  * @ingroup pthread
885  *
886  * @par Description:
887  * This API is used to acquire the scheduling parameter attributes of a thread attributes object. The scheduling parameter attributes indicate the thread priorities.
888  *
889  * @param  attr   [IN]  Pointer to the thread attributes object to be read.
890  * @param  param  [OUT] Pointer to the acquired scheduling parameter attributes object.
891  *
892  * @attention
893  * <ul>
894  * <li>None.</li>
895  * </ul>
896  *
897  * @retval  #int  If successful, the pthread_attr_getschedparam() function shall return zero; otherwise, an error number shall be returned to indicate the error.
898  *
899  * @retval  #EINVAL  invalid parameter.
900  * @retval  #ENOERR  The scheduling parameter attributes are successfully acquired.
901  *
902  * @par Dependency:
903  * <ul><li>pthread.h</li></ul>
904  * @see pthread_attr_setschedparam
905  */
906 int pthread_attr_getschedparam(const pthread_attr_t *__restrict, struct sched_param *__restrict);
907 
908 /* Set scheduling parameters */
909 /**
910  * @ingroup pthread
911  *
912  * @par Description:
913  * This API is used to set the scheduling parameter attributes of a thread attributes object. The scheduling parameter attributes indicate thread priorities.
914  *
915  * @param  attr   [OUT] Pointer to the thread attributes object to be set.
916  * @param  param  [IN]  Pointer to the scheduling parameter attributes object.
917  *
918  *@attention
919  * <ul>
920  * <li>The priority of the scheduling parameter attributes must be in the range of [0, 31].</li>
921  * </ul>
922  *
923  * @retval   #int   If successful, the pthread_attr_setschedparam() function shall return zero; otherwise, an error number shall be returned to indicate the error.
924  *
925  * @retval  #EINVAL    invalid parameter.
926  * @retval  #ENOTSUP   made to set the attribute to an unsupported value.
927  * @retval  #ENOERR    The scheduling parameter attributes are successfully set.
928  *
929  * @par Dependency:
930  * <ul><li>pthread.h</li></ul>
931  * @see pthread_attr_getschedparam
932  */
933 int pthread_attr_setschedparam(pthread_attr_t *__restrict, const struct sched_param *__restrict);
934 
935 /* Get scheduling inheritance attribute */
936 /**
937  * @ingroup pthread
938  *
939  * @par Description:
940  * This API is used to acquire the inherit scheduler attribute of a thread attributes object.
941  *
942  * @param  attr     [IN]  Pointer to the thread attributes object to be read.
943  * @param  inherit  [OUT] Pointer to the acquired inherit scheduler attribute.
944  *
945  * @attention
946  * <ul>
947  * <li>None.</li>
948  * </ul>
949  *
950  * @retval  #int  If successful, the pthread_attr_getinheritsched() function shall return zero; otherwise, an error number shall be returned to indicate the error.
951  *
952  * @retval  #EINVAL   invalid parameter.
953  * @retval  #ENOERR   The inherit scheduler attribute is successfully acquired.
954  *
955  * @par Dependency:
956  * <ul><li>pthread.h</li></ul>
957  * @see pthread_attr_setinheritsched
958  */
959 int pthread_attr_getinheritsched(const pthread_attr_t *__restrict, int *__restrict);
960 
961 /* Set scheduling inheritance attribute */
962 /**
963  * @ingroup pthread
964  *
965  * @par Description:
966  * This API is used to set the inherit scheduler attribute of a thread attributes object.
967  *
968  * @param  attr     [OUT] Pointer to the thread attributes object to be set.
969  * @param  inherit  [IN]  Inherit scheduler attribute.
970  *
971  * @attention
972  * <ul>
973  * <li>The inherit scheduler attribute must be either PTHREAD_INHERIT_SCHED or PTHREAD_EXPLICIT_SCHED.</li>
974  * </ul>
975  *
976  * @retval   #int     If successful, the pthread_attr_setinheritsched() function shall return zero; otherwise, an error number shall be returned to indicate the error.
977  * @retval  #EINVAL    invalid parameter.
978  * @retval  #ENOERR    The inherit scheduler attribute is successfully set.
979  *
980  * @par Dependency:
981  * <ul><li>pthread.h</li></ul>
982  * @see pthread_attr_getinheritsched
983  */
984 int pthread_attr_setinheritsched(pthread_attr_t *, int);
985 
986 int pthread_mutexattr_destroy(pthread_mutexattr_t *);
987 int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *__restrict, int *__restrict);
988 int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__restrict, int *__restrict);
989 int pthread_mutexattr_getpshared(const pthread_mutexattr_t *__restrict, int *__restrict);
990 int pthread_mutexattr_getrobust(const pthread_mutexattr_t *__restrict, int *__restrict);
991 int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict, int *__restrict);
992 int pthread_mutexattr_init(pthread_mutexattr_t *);
993 int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
994 int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
995 int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
996 int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int);
997 int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
998 
999 /**
1000  * @ingroup pthread
1001  * @par Description:
1002  * This API is used to initialize the condition variable attribute.
1003  * This API does not task effect on Huawei LiteOS Kernel.
1004  *
1005  * @param attr  [OUT]  Condition variable attribute.
1006  *
1007  * @attention
1008  * <ul>
1009  * <li>The condition variable attribute can be only set to PTHREAD_PROCESS_PRIVATE.</li>
1010  * </ul>
1011  *
1012  * @retval  #ENVAIL  The parameter is invalid.
1013  * @retval  #ENOERR  The condition variable attribute is successfully initialized.
1014  *
1015  * @par Dependency:
1016  * <ul><li>pthread.h</li></ul>
1017  *
1018  * @see pthread_condattr_setpshared | pthread_condattr_getpshared
1019  *
1020  */
1021 int pthread_condattr_init(pthread_condattr_t *);
1022 
1023 /**
1024  * @ingroup pthread
1025  * @par Description:
1026  * This API is used to destroy the condition variable attribute.
1027  *
1028  * @param attr [IN]  Condition variable attribute.
1029  *
1030  * @attention
1031  * <ul>
1032  * <li>The condition variable attribute can be only set to PTHREAD_PROCESS_PRIVATE.</li>
1033  * <li>This API does not task effect on Huawei LiteOS Kernel.</li>
1034  * </ul>
1035  *
1036  * @retval  #ENVAIL  The parameter is invalid.
1037  * @retval  #ENOERR  The condition variable attribute is successfully destroied.
1038  *
1039  * @par Dependency:
1040  * <ul><li>pthread.h</li></ul>
1041  *
1042  * @see pthread_condattr_init
1043  *
1044  */
1045 int pthread_condattr_destroy(pthread_condattr_t *);
1046 int pthread_condattr_setclock(pthread_condattr_t *, clockid_t);
1047 
1048 /**
1049  * @ingroup pthread
1050  * @par Description:
1051  * This API is used to set the condition variable attribute.
1052  *
1053  * @param attr     [IN]   Condition variable attribute.
1054  * @param pshared  [OUT]  Condition variable attribute, which is always PTHREAD_PROCESS_PRIVATE.
1055  *
1056  * @attention
1057  * <ul>
1058  * <li>The condition variable attribute can be only set to PTHREAD_PROCESS_PRIVATE.</li>
1059  * <li>This API does not task effect on Huawei LiteOS Kernel.</li>
1060  * </ul>
1061  *
1062  * @retval  #ENVAIL  One or more parameters are invalid.
1063  * @retval  #ENOERR  The condition variable attribute is successfully set.
1064  *
1065  * @par Dependency:
1066  * <ul><li>pthread.h</li></ul>
1067  *
1068  * @see pthread_condattr_getpshared
1069  *
1070  */
1071 int pthread_condattr_setpshared(pthread_condattr_t *, int);
1072 int pthread_condattr_getclock(const pthread_condattr_t *__restrict, clockid_t *__restrict);
1073 
1074 /**
1075  * @ingroup pthread
1076  * @par Description:
1077  * This API is used to obtain the condition variable attribute.
1078  *
1079  * @param attr     [IN]   Condition variable attribute.
1080  * @param pshared  [OUT]  Obtained condition variable attribute, which is always PTHREAD_PROCESS_PRIVATE.
1081  *
1082  * @attention
1083  * <ul>
1084  * <li>The condition variable attribute can be only set to PTHREAD_PROCESS_PRIVATE.</li>
1085  * <li>This API does not task effect on Huawei LiteOS Kernel.</li>
1086  * </ul>
1087  *
1088  * @retval  #ENVAIL  One or more parameters are invalid.
1089  * @retval  #ENOERR  The condition variable attribute is successfully obtained.
1090  *
1091  * @par Dependency:
1092  * <ul><li>pthread.h</li></ul>
1093  *
1094  * @see pthread_condattr_setpshared
1095  *
1096  */
1097 int pthread_condattr_getpshared(const pthread_condattr_t *__restrict, int *__restrict);
1098 
1099 int pthread_rwlockattr_init(pthread_rwlockattr_t *);
1100 int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
1101 int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
1102 int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *__restrict, int *__restrict);
1103 
1104 int pthread_barrierattr_destroy(pthread_barrierattr_t *);
1105 int pthread_barrierattr_getpshared(const pthread_barrierattr_t *__restrict, int *__restrict);
1106 int pthread_barrierattr_init(pthread_barrierattr_t *);
1107 int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int);
1108 
1109 /**
1110  * @ingroup pthread
1111  * @par Description:
1112  * The function is not supported.
1113  *
1114  * @attention
1115  * <ul>
1116  * <li>The function is not supported.</li>
1117  * </ul>
1118  *
1119  * @retval #int  zero.
1120  *
1121  * @par Dependency:
1122  * <ul><li>pthread.h</li></ul>
1123  *
1124  * @see None
1125  *
1126  */
1127 int pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
1128 
1129 int pthread_getconcurrency(void);
1130 int pthread_setconcurrency(int);
1131 
1132 int pthread_getcpuclockid(pthread_t, clockid_t *);
1133 
1134 #ifndef __LITEOS__
1135 struct __ptcb {
1136 	void (*__f)(void *);
1137 	void *__x;
1138 	struct __ptcb *__next;
1139 };
1140 
1141 void _pthread_cleanup_push(struct __ptcb *, void (*)(void *), void *);
1142 void _pthread_cleanup_pop(struct __ptcb *, int);
1143 #endif
1144 
1145 struct pthread_cleanup_buffer {
1146 	void (*routine)(void *);
1147 	void *arg;
1148 	struct pthread_cleanup_buffer *next;
1149 };
1150 #define pthread_cleanup_push(routine, arg) do { struct pthread_cleanup_buffer cb; pthread_cleanup_push_inner(&cb, routine, arg);
1151 #define pthread_cleanup_pop(arg) pthread_cleanup_pop_inner(&cb, (arg)); } while(0)
1152 
1153 #ifdef _GNU_SOURCE
1154 struct cpu_set_t;
1155 
1156 /**
1157  * @ingroup pthread
1158  *
1159  * @par Description:
1160  * This API is used to get the cpu affinity mask from the thread.
1161  *
1162  * @param   pthread      [IN]  ID of the thread whose affinity mask is to be read.
1163  * @param   cpusetsize   [IN]  Size of cpuset in bytes.
1164  * @param   cpuset       [OUT] Pointer to the cpu affinity mask.
1165  *
1166  * @attention
1167  * <ul>
1168  * <li>None.</li>
1169  * </ul>
1170  *
1171  * @retval  #EINVAL    Invalid parameter.
1172  * @retval  #ENOERR    The cpu affinity mask of the thread is successfully acquired.
1173  *
1174  * @par Dependency:
1175  * <ul><li>pthread.h</li></ul>
1176  *
1177  * @see pthread_setaffinity_np
1178  *
1179  */
1180 int pthread_getaffinity_np(pthread_t, size_t, struct cpu_set_t *);
1181 
1182 /**
1183  * @ingroup pthread
1184  *
1185  * @par Description:
1186  * This API is used to set the cpu affinity mask for the thread.
1187  *
1188  * @param   pthread      [IN] ID of the thread whose affinity mask is to be set.
1189  * @param   cpusetsize   [IN] Size of cpuset in bytes.
1190  * @param   cpuset       [IN] Pointer to the cpu affinity mask.
1191  *
1192  * @attention
1193  * <ul>
1194  * <li>The cpu affinity mask attributes must be in the range of [1, LOSCFG_KERNEL_CPU_MASK].</li>
1195  * </ul>
1196  *
1197  * @retval  #EINVAL    Invalid parameter.
1198  * @retval  #ENOERR    The cpu affinity mask of the thread is successfully set.
1199  *
1200  * @par Dependency:
1201  * <ul><li>pthread.h</li></ul>
1202  *
1203  * @see pthread_getaffinity_np
1204  *
1205  */
1206 int pthread_setaffinity_np(pthread_t, size_t, const struct cpu_set_t *);
1207 #ifdef __LITEOS__
1208 /**
1209  * @ingroup pthread
1210  *
1211  * @par Description:
1212  * This API is used to set the cpu affinity mask attributes of a thread attributes object.
1213  *
1214  * @param   attr         [OUT] Pointer to the thread attributes object to be set.
1215  * @param   cpusetsize   [IN]  Size of cpuset in bytes.
1216  * @param   cpuset       [IN]  Pointer to the cpu affinity mask.
1217  *
1218  * @attention
1219  * <ul>
1220  * <li>The cpu affinity mask attributes must be in the range of [1, LOSCFG_KERNEL_CPU_MASK].</li>
1221  * </ul>
1222  *
1223  * @retval  #EINVAL    Invalid parameter.
1224  * @retval  #ENOERR    The cpu affinity mask attributes are successfully set.
1225  *
1226  * @par Dependency:
1227  * <ul><li>pthread.h</li></ul>
1228  *
1229  * @see pthread_attr_getaffinity_np
1230  *
1231  */
1232 int pthread_attr_setaffinity_np(pthread_attr_t *attr, size_t cpusetsize, const cpu_set_t *cpuset);
1233 
1234 /**
1235  * @ingroup pthread
1236  *
1237  * @par Description:
1238  * This API is used to get the cpu affinity mask attributes of a thread attributes object.
1239  *
1240  * @param   attr         [IN]  Pointer to the thread attributes object to be read.
1241  * @param   cpusetsize   [IN]  Size of cpuset in bytes.
1242  * @param   cpuset       [OUT] Pointer to the cpu affinity mask.
1243  *
1244  * @attention
1245  * <ul>
1246  * <li>None.</li>
1247  * </ul>
1248  *
1249  * @retval  #EINVAL    Invalid parameter.
1250  * @retval  #ENOERR    The cpu affinity mask attributes are successfully acquired.
1251  *
1252  * @par Dependency:
1253  * <ul><li>pthread.h</li></ul>
1254  *
1255  * @see pthread_attr_setaffinity_np
1256  *
1257  */
1258 int pthread_attr_getaffinity_np(const pthread_attr_t *attr, size_t cpusetsize, cpu_set_t *cpuset);
1259 #endif
1260 int pthread_getattr_np(pthread_t, pthread_attr_t *);
1261 int pthread_setname_np(pthread_t, const char *);
1262 int pthread_getattr_default_np(pthread_attr_t *);
1263 int pthread_setattr_default_np(const pthread_attr_t *);
1264 int pthread_tryjoin_np(pthread_t, void **);
1265 int pthread_timedjoin_np(pthread_t, void **, const struct timespec *);
1266 #endif
1267 
1268 #if _REDIR_TIME64
1269 __REDIR(pthread_mutex_timedlock, __pthread_mutex_timedlock_time64);
1270 __REDIR(pthread_cond_timedwait, __pthread_cond_timedwait_time64);
1271 __REDIR(pthread_rwlock_timedrdlock, __pthread_rwlock_timedrdlock_time64);
1272 __REDIR(pthread_rwlock_timedwrlock, __pthread_rwlock_timedwrlock_time64);
1273 #ifdef _GNU_SOURCE
1274 __REDIR(pthread_timedjoin_np, __pthread_timedjoin_np_time64);
1275 #endif
1276 #endif
1277 
1278 #ifdef __cplusplus
1279 }
1280 #endif
1281 #endif
1282