1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without modification, 5 * are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, this list of 8 * conditions and the following disclaimer. 9 * 10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 * of conditions and the following disclaimer in the documentation and/or other materials 12 * provided with the distribution. 13 * 14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 * to endorse or promote products derived from this software without specific prior written 16 * permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef IT_POSIX_PTHREAD_H 32 #define IT_POSIX_PTHREAD_H 33 34 #include "sched.h" 35 #include "signal.h" 36 #include "semaphore.h" 37 #include "sched.h" 38 #include "osTest.h" 39 #include "pthread.h" 40 #include "limits.h" 41 #include "unistd.h" 42 #include "mqueue.h" 43 #include "signal.h" 44 45 /* Some routines are part of the XSI Extensions */ 46 #ifndef WITHOUT_XOPEN 47 #define _XOPEN_SOURCE 600 48 #endif 49 50 #define PTHREAD_IS_ERROR (-1) 51 #define PTHREAD_PRIORITY_TEST 20 52 #define PTHREAD_DEFAULT_STACK_SIZE (LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE) 53 #define PTHREAD_KEY_NUM 10 54 #define THREAD_NUM 3 55 #define PTHREAD_TIMEOUT (THREAD_NUM * 2) 56 #define PTHREAD_INTHREAD_TEST 0 /* Control going to or is already for Thread */ 57 #define PTHREAD_INMAIN_TEST 1 /* Control going to or is already for Main */ 58 #define INVALID_PSHARED_VALUE (-100) 59 #define NUM_OF_CONDATTR 10 60 #define RUNTIME 5 61 #define PTHREAD_THREADS_NUM 3 62 #define TCOUNT 5 // Number of single-threaded polling 63 #define COUNT_LIMIT 7 // The number of times the signal is sent 64 #define HIGH_PRIORITY 5 65 #define LOW_PRIORITY 10 66 #define PTHREAD_EXIT_VALUE ((void *)100) /* The return code of the thread when using pthread_exit(). */ 67 68 #define PTHREAD_EXISTED_NUM TASK_EXISTED_NUM 69 #define PTHREAD_EXISTED_SEM_NUM SEM_EXISTED_NUM 70 71 /* We are testing conformance to IEEE Std 1003.1, 2003 Edition */ 72 #define _POSIX_C_SOURCE 200112L 73 74 #define PTHREAD_MUTEX_RECURSIVE 0 75 #define PTHREAD_MUTEX_ERRORCHECK 0 76 77 #define PRIORITY_OTHER (-1) 78 #define PRIORITY_FIFO 20 79 #define PRIORITY_RR 20 80 81 #ifdef LOSCFG_AARCH64 82 #define PTHREAD_STACK_MIN_TEST (PTHREAD_STACK_MIN * 3) 83 #else 84 #define PTHREAD_STACK_MIN_TEST PTHREAD_STACK_MIN 85 #endif 86 87 pthread_t TestPthreadSelf(void); 88 89 VOID ItPosixPthread001(VOID); 90 VOID ItPosixPthread002(VOID); 91 VOID ItPosixPthread003(VOID); 92 VOID ItPosixPthread004(VOID); 93 VOID ItPosixPthread005(VOID); 94 VOID ItPosixPthread006(VOID); 95 VOID ItPosixPthread007(VOID); 96 VOID ItPosixPthread008(VOID); 97 VOID ItPosixPthread009(VOID); 98 VOID ItPosixPthread010(VOID); 99 VOID ItPosixPthread011(VOID); 100 VOID ItPosixPthread012(VOID); 101 VOID ItPosixPthread013(VOID); 102 VOID ItPosixPthread014(VOID); 103 VOID ItPosixPthread015(VOID); 104 VOID ItPosixPthread016(VOID); 105 VOID ItPosixPthread017(VOID); 106 VOID ItPosixPthread018(VOID); 107 VOID ItPosixPthread019(VOID); 108 VOID ItPosixPthread020(VOID); 109 VOID ItPosixPthread021(VOID); 110 VOID ItPosixPthread022(VOID); 111 VOID ItPosixPthread023(VOID); 112 VOID ItPosixPthread024(VOID); 113 VOID ItPosixPthread025(VOID); 114 115 #endif /* IT_POSIX_PTHREAD_H */ 116