1 /* 2 * Copyright (c) 2022-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 _ADAPT_SYS_PTHREADTYPES_H 32 #define _ADAPT_SYS_PTHREADTYPES_H 33 34 #define pthread_attr_t __pthread_attr_t_discard 35 #define pthread_mutex_t __pthread_mutex_t_discard 36 #define pthread_mutexattr_t __pthread_mutexattr_t_discard 37 #define pthread_cond_t __pthread_cond_t_discard 38 #define pthread_condattr_t __pthread_condattr_t_discard 39 #define pthread_once_t __pthread_once_t_discard 40 #define pthread_barrierattr_t __pthread_barrierattr_t_discard 41 42 #include_next <sys/_pthreadtypes.h> 43 44 #undef pthread_attr_t 45 #undef pthread_mutex_t 46 #undef pthread_mutexattr_t 47 #undef pthread_cond_t 48 #undef pthread_condattr_t 49 #undef pthread_once_t 50 #undef pthread_barrierattr_t 51 52 #include "los_config.h" 53 54 #define CPU_SETSIZE 32 55 typedef struct cpu_set_t { unsigned long __bits[CPU_SETSIZE/(8 * sizeof(unsigned long int))]; } cpu_set_t; 56 57 typedef struct { 58 unsigned int detachstate; 59 unsigned int schedpolicy; 60 struct sched_param schedparam; 61 unsigned int inheritsched; 62 unsigned int scope; 63 unsigned int stackaddr_set; 64 void *stackaddr; 65 unsigned int stacksize_set; 66 size_t stacksize; 67 #ifdef LOSCFG_KERNEL_SMP 68 cpu_set_t cpuset; 69 #endif 70 } pthread_attr_t; 71 72 typedef int pthread_once_t; 73 typedef struct { int clock; } pthread_condattr_t; 74 typedef struct { unsigned __attr; } pthread_barrierattr_t; 75 76 #define PTHREAD_KEYS_MAX 128 77 #define PTHREAD_STACK_MIN LOS_TASK_MIN_STACK_SIZE 78 #define PTHREAD_DESTRUCTOR_ITERATIONS 4 79 #define PTHREAD_ATTR_STACKSIZE LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE 80 #define PTHREAD_PRIORITY_SCHEDULING SCHED_OTHER 81 #define PTHREAD_THREADS_MAX (LOSCFG_BASE_CORE_TSK_LIMIT + 1) 82 #define PTHREAD_MUTEXATTR_INITIALIZER { PTHREAD_MUTEX_RECURSIVE } 83 84 #endif /* !_ADAPT_SYS_PTHREADTYPES_H */ 85