e144d6fee8001b559221e0c6fa2c7af68dce261b
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning_base_library / library / src / _pbCSection.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /*******************************************************************************
18 * $Header::                                                                   $
19 * $Revision::                                                                 $
20 *******************************************************************************/
21
22 /****************************************************************************
23  * File name        :_pbCSection.cpp
24  * System name      :GPF
25  * Subsystem name   :_CWORD64_API Critical Section Function
26  * Title            :Critical Section Function Definition File
27  ****************************************************************************/
28
29 #include <fcntl.h>
30 #include <sys/mman.h>
31 #include <vehicle_service/positioning_base_library.h>
32 #include "WPF_STD_private.h"
33 #include "_pbInternalProc.h"
34
35
36 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
37 * MODULE    : PbDeleteCriticalSection()
38 * ABSTRACT  : Specify a critical section object that is not owned and free all resources used by that object.
39 * NOTE      :
40 * ARGUMENT  : LPCRITICAL_SECTION lp_critical_section
41 * RETURN    : VOID defined
42 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
43 VOID PbDeleteCriticalSection(LPCRITICAL_SECTION lp_critical_section) {  // LCOV_EXCL_START 8:dead code
44     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
45     int32                    lret = EOK;
46
47     if (lp_critical_section == NULL) {
48         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
49                         "_CWORD64_api.dll:%s:LINE %d\r\n Parameter ERROR In PbDeleteCriticalSection\r\n",
50                         LTEXT(__FILE__), __LINE__);
51     } else {
52         lret = pthread_mutex_destroy(lp_critical_section);
53         if (lret != EOK) {
54             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
55                             "_CWORD64_api.dll:%s:LINE %d\r\n ERROR ... ErrNo[%d] In PbDeleteCriticalSection\r\n",
56                             LTEXT(__FILE__), __LINE__, lret);
57         }
58     }
59
60     return;
61 }
62 // LCOV_EXCL_STOP
63
64 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
65 * MODULE    : PbEnterCriticalSection()
66 * ABSTRACT  : Wait to take ownership of the specified critical section object
67 * NOTE      :
68 * ARGUMENT  : LPCRITICAL_SECTION lp_critical_section
69 * RETURN    : VOID defined
70 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
71 VOID PbEnterCriticalSection(LPCRITICAL_SECTION lp_critical_section) {  // LCOV_EXCL_START 8:dead code
72     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
73     int32                    lret = EOK;
74
75     if (lp_critical_section == NULL) {
76         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
77                         "_CWORD64_api.dll:%s:LINE %d\r\n Parameter ERROR In PbEnterCriticalSection\r\n",
78                        LTEXT(__FILE__), __LINE__);
79     } else {
80         lret = pthread_mutex_lock(lp_critical_section);
81         if (lret != EOK) {
82             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
83                         "_CWORD64_api.dll:%s:LINE %d\r\n ERROR ... ErrNo[%d] In PbEnterCriticalSection\r\n",
84                         LTEXT(__FILE__), __LINE__, lret);
85         }
86     }
87
88     return;
89 }
90 // LCOV_EXCL_STOP
91
92 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
93 * MODULE    : PbInitializeCriticalSection
94 * ABSTRACT  : Initialize the specified critical section object.
95 * NOTE      :
96 * ARGUMENT  : LPCRITICAL_SECTION lp_critical_section
97 * RETURN    : VOID defined
98 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
99 VOID PbInitializeCriticalSection(LPCRITICAL_SECTION lp_critical_section) {  // LCOV_EXCL_START 8:dead code
100     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
101 }
102 // LCOV_EXCL_STOP
103
104 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
105 * MODULE    : PbLeaveCriticalSection
106 * ABSTRACT  : Discard ownership of the specified critical section object.
107 * NOTE      :
108 * ARGUMENT  : LPCRITICAL_SECTION lp_critical_section
109 * RETURN    : VOID defined
110 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
111 VOID PbLeaveCriticalSection(LPCRITICAL_SECTION lp_critical_section ) {  // LCOV_EXCL_START 8:dead code
112     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
113     int32                    lret = EOK;
114
115     if (lp_critical_section == NULL) {
116         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
117                                "_CWORD64_api.dll:%s:LINE %d\r\n Parameter ERROR In PbLeaveCriticalSection\r\n",
118                        LTEXT(__FILE__), __LINE__);
119     } else {
120         lret = pthread_mutex_unlock(lp_critical_section);
121         if (lret != EOK) {
122             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
123                                    "_CWORD64_api.dll:%s:LINE %d\r\n ERROR ... ErrNo[%d] In PbLeaveCriticalSection\r\n",
124                            LTEXT(__FILE__), __LINE__, lret);
125         }
126     }
127
128     return;
129 }
130 // LCOV_EXCL_STOP
131