1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "utils.h"
17 #include "fillp_function.h"
18 #include "log.h"
19 #include "epoll.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 
EpDelRdlnode(struct EventPoll * ep,struct EpItem * epi)26 void EpDelRdlnode(struct EventPoll *ep, struct EpItem *epi)
27 {
28     if (!HLISTNODE_LINKED(&epi->rdlNode)) {
29         return;
30     }
31 
32     HlistDelete(&ep->rdList, &epi->rdlNode);
33 }
34 
35 /**
36  *  Add epitem to eventpoll->rdllist
37  *  scb is the core pointer
38  */
EpSocketReady(struct EventPoll * scb,struct EpItem * epiItem)39 void EpSocketReady(struct EventPoll *scb, struct EpItem *epiItem)
40 {
41     if ((scb == FILLP_NULL_PTR) || (epiItem == FILLP_NULL_PTR)) {
42         FILLP_LOGERR("NULL Pointer");
43         return;
44     }
45     if (!HLISTNODE_LINKED(&epiItem->rdlNode)) {
46         HlistAddTail(&scb->rdList, &epiItem->rdlNode);
47     }
48 
49     if (!SYS_ARCH_ATOMIC_READ(&scb->semSignalled)) {
50         (void)SYS_ARCH_ATOMIC_SET(&scb->semSignalled, 1);
51         (void)SYS_ARCH_SEM_POST(&scb->waitSem);
52     }
53 
54     return;
55 }
56 
57 #ifdef __cplusplus
58 }
59 #endif
60