• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3  * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this list of
9  *    conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12  *    of conditions and the following disclaimer in the documentation and/or other materials
13  *    provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16  *    to endorse or promote products derived from this software without specific prior written
17  *    permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #include "los_mux.h"
33 #include "los_queue.h"
34 #include "los_sem.h"
35 #include "los_task.h"
36 
37 
map_errno(UINT32 err)38 int map_errno(UINT32 err)
39 {
40     if (err == LOS_OK) {
41         return ENOERR;
42     }
43     switch (err) {
44         case LOS_ERRNO_QUEUE_INVALID:
45         case LOS_ERRNO_QUEUE_WRITE_PTR_NULL:
46         case LOS_ERRNO_QUEUE_WRITESIZE_ISZERO:
47         case LOS_ERRNO_QUEUE_SIZE_TOO_BIG:
48         case LOS_ERRNO_QUEUE_CREAT_PTR_NULL:
49         case LOS_ERRNO_QUEUE_PARA_ISZERO:
50         case LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG:
51             errno = EINVAL;
52             break;
53         case LOS_ERRNO_QUEUE_ISFULL:
54         case LOS_ERRNO_QUEUE_ISEMPTY:
55             errno = EAGAIN;
56             break;
57         case LOS_ERRNO_QUEUE_CREATE_NO_MEMORY:
58             errno = ENOSPC;
59             break;
60         case LOS_ERRNO_QUEUE_TIMEOUT:
61             errno = ETIMEDOUT;
62             break;
63         case LOS_ERRNO_QUEUE_CB_UNAVAILABLE:
64             errno = ENFILE;
65             break;
66         case LOS_ERRNO_QUEUE_READ_IN_INTERRUPT:
67         case LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT:
68             errno = EINTR;
69             break;
70         case LOS_ERRNO_TSK_ID_INVALID:
71         case LOS_ERRNO_TSK_PTR_NULL:
72         case LOS_ERRNO_TSK_NAME_EMPTY:
73         case LOS_ERRNO_TSK_ENTRY_NULL:
74         case LOS_ERRNO_TSK_PRIOR_ERROR:
75         case LOS_ERRNO_TSK_STKSZ_TOO_LARGE:
76         case LOS_ERRNO_TSK_STKSZ_TOO_SMALL:
77         case LOS_ERRNO_TSK_NOT_CREATED:
78         case LOS_ERRNO_TSK_CPU_AFFINITY_MASK_ERR:
79         case OS_ERROR:
80         case LOS_ERRNO_SEM_INVALID:
81         case LOS_ERRNO_SEM_UNAVAILABLE:
82             errno = EINVAL;
83             break;
84         case LOS_ERRNO_TSK_TCB_UNAVAILABLE:
85         case LOS_ERRNO_TSK_MP_SYNC_RESOURCE:
86         case LOS_ERRNO_SEM_ALL_BUSY:
87             errno = ENOSPC;
88             break;
89         case LOS_ERRNO_TSK_NO_MEMORY:
90         case LOS_ERRNO_SEM_OVERFLOW:
91             errno = ENOMEM;
92             break;
93         case LOS_ERRNO_SEM_PENDED:
94         case LOS_ERRNO_EVENT_SHOULD_NOT_DESTROY:
95             errno = EBUSY;
96             break;
97         case LOS_ERRNO_SEM_PEND_IN_LOCK:
98             errno = EPERM;
99             break;
100         case LOS_ERRNO_SEM_PEND_INTERR:
101             errno = EINTR;
102             break;
103         case LOS_ERRNO_SEM_TIMEOUT:
104             errno = ETIMEDOUT;
105             break;
106         default:
107             errno = EINVAL;
108             break;
109     }
110     return errno;
111 }
112 
113