• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved.
3  *
4  * UniProton is licensed under Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *          http://license.coscl.org.cn/MulanPSL2
8  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11  * See the Mulan PSL v2 for more details.
12  * Create: 2022-11-15
13  * Description: 信号量头文件
14  */
15 #ifndef _SEMAPHORE_H
16 #define _SEMAPHORE_H
17 
18 #include "time.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #define O_CREAT        0100
25 #define O_EXCL         0200
26 #define O_NOCTTY       0400
27 #define O_TRUNC       01000
28 #define O_APPEND      02000
29 #define O_NONBLOCK    04000
30 #define O_DSYNC      010000
31 #define O_SYNC     04010000
32 #define O_RSYNC    04010000
33 #define O_DIRECTORY  040000
34 #define O_NOFOLLOW  0100000
35 #define O_CLOEXEC  02000000
36 
37 #define MAX_POSIX_SEMAPHORE_NAME_LEN    31
38 #define SEM_FAILED                      ((sem_t *)0)
39 
40 typedef struct {
41     unsigned short semHandle;
42     unsigned short reserve;
43     unsigned int refCount;
44 } sem_t;
45 
46 int    sem_destroy(sem_t *);
47 int    sem_getvalue(sem_t *__restrict, int *__restrict);
48 int    sem_init(sem_t *, int, unsigned);
49 int    sem_post(sem_t *);
50 int    sem_timedwait(sem_t *__restrict, const struct timespec *__restrict);
51 int    sem_trywait(sem_t *);
52 int    sem_wait(sem_t *);
53 sem_t *sem_open(const char *, int, ...);
54 int    sem_close(sem_t *);
55 int    sem_unlink(const char *);
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 #endif /* _SEMAPHORE_H */
62