1 | /* |
---|---|
2 | * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
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 | * A copy of the License is located at |
7 | * |
8 | * http://aws.amazon.com/apache2.0 |
9 | * |
10 | * or in the "license" file accompanying this file. This file is distributed |
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
12 | * express or implied. See the License for the specific language governing |
13 | * permissions and limitations under the License. |
14 | */ |
15 | |
16 | #ifndef AWS_COMMON_POSIX_COMMON_INL |
17 | #define AWS_COMMON_POSIX_COMMON_INL |
18 | |
19 | #include <aws/common/common.h> |
20 | |
21 | #include <errno.h> |
22 | |
23 | AWS_EXTERN_C_BEGIN |
24 | |
25 | static inline int aws_private_convert_and_raise_error_code(int error_code) { |
26 | switch (error_code) { |
27 | case 0: |
28 | return AWS_OP_SUCCESS; |
29 | case EINVAL: |
30 | return aws_raise_error(AWS_ERROR_MUTEX_NOT_INIT); |
31 | case EBUSY: |
32 | return aws_raise_error(AWS_ERROR_MUTEX_TIMEOUT); |
33 | case EPERM: |
34 | return aws_raise_error(AWS_ERROR_MUTEX_CALLER_NOT_OWNER); |
35 | case ENOMEM: |
36 | return aws_raise_error(AWS_ERROR_OOM); |
37 | case EDEADLK: |
38 | return aws_raise_error(AWS_ERROR_THREAD_DEADLOCK_DETECTED); |
39 | default: |
40 | return aws_raise_error(AWS_ERROR_MUTEX_FAILED); |
41 | } |
42 | } |
43 | |
44 | AWS_EXTERN_C_END |
45 | |
46 | #endif /* AWS_COMMON_POSIX_COMMON_INL */ |
47 |