1 /* 2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this list of 9 * conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 12 * of conditions and the following disclaimer in the documentation and/or other materials 13 * provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 16 * to endorse or promote products derived from this software without specific prior written 17 * permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _HWLITEOS_POSIX_PPRIVATE_H 33 #define _HWLITEOS_POSIX_PPRIVATE_H 34 35 #include "los_process.h" 36 #include "pthread.h" 37 #include "sys/types.h" 38 #include "los_sem_pri.h" 39 #include "los_task_pri.h" 40 41 #ifdef __cplusplus 42 #if __cplusplus 43 extern "C" { 44 #endif /* __cplusplus */ 45 #endif /* __cplusplus */ 46 47 #define PTHREAD_DATA_NAME_MAX 20 48 /* 49 * Thread control data structure 50 * Per-thread information needed by POSIX 51 */ 52 typedef struct { 53 pthread_attr_t attr; /* Current thread attributes */ 54 pthread_t id; /* My thread ID */ 55 LosTaskCB *task; /* pointer to Huawei LiteOS thread object */ 56 CHAR name[PTHREAD_DATA_NAME_MAX]; /* name string for debugging */ 57 UINT8 state; /* Thread state */ 58 UINT8 cancelstate; /* Cancel state of thread */ 59 volatile UINT8 canceltype; /* Cancel type of thread */ 60 volatile UINT8 canceled; /* pending cancel flag */ 61 struct pthread_cleanup_buffer *cancelbuffer; /* stack of cleanup buffers */ 62 UINT32 freestack; /* stack malloced, must be freed */ 63 UINT32 stackmem; /* base of stack memory area only valid if freestack == true */ 64 VOID **thread_data; /* Per-thread data table pointer */ 65 } _pthread_data; 66 67 /* 68 * Values for the state field. These are solely concerned with the 69 * states visible to POSIX. The thread's run state is stored in the 70 * struct _pthread_data about thread object. 71 * Note: numerical order here is important, do not rearrange. 72 */ 73 #define PTHREAD_STATE_FREE 0 /* This structure is free for reuse */ 74 #define PTHREAD_STATE_DETACHED 1 /* The thread is running but detached */ 75 #define PTHREAD_STATE_RUNNING 2 /* The thread is running and will wait to join when it exits */ 76 #define PTHREAD_STATE_JOIN 3 /* The thread has exited and is waiting to be joined */ 77 #define PTHREAD_STATE_EXITED 4 /* The thread has exited and is ready to be reaped */ 78 #define PTHREAD_STATE_ALRDY_JOIN 5 /* The thread state is in join */ 79 80 81 #ifdef __cplusplus 82 #if __cplusplus 83 } 84 #endif /* __cplusplus */ 85 #endif /* __cplusplus */ 86 87 #endif 88