The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 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 | |
Elliott Hughes | 9fbebc5 | 2018-10-16 13:17:15 -0700 | [diff] [blame] | 17 | #pragma once |
The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | #include <errno.h> |
Elliott Hughes | 9fbebc5 | 2018-10-16 13:17:15 -0700 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | |
| 23 | namespace android { |
| 24 | |
Elliott Hughes | 9fbebc5 | 2018-10-16 13:17:15 -0700 | [diff] [blame] | 25 | /** |
| 26 | * The type used to return success/failure from frameworks APIs. |
| 27 | * See the anonymous enum below for valid values. |
| 28 | */ |
| 29 | typedef int32_t status_t; |
The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
| 31 | /* |
| 32 | * Error codes. |
| 33 | * All error codes are negative values. |
| 34 | */ |
| 35 | |
| 36 | // Win32 #defines NO_ERROR as well. It has the same value, so there's no |
| 37 | // real conflict, though it's a bit awkward. |
| 38 | #ifdef _WIN32 |
| 39 | # undef NO_ERROR |
| 40 | #endif |
Ashok Bhat | 1ee7570 | 2013-12-17 11:13:05 +0000 | [diff] [blame] | 41 | |
The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | enum { |
Elliott Hughes | 643268f | 2018-10-08 11:10:11 -0700 | [diff] [blame] | 43 | OK = 0, // Preferred constant for checking success. |
| 44 | NO_ERROR = OK, // Deprecated synonym for `OK`. Prefer `OK` because it doesn't conflict with Windows. |
Ashok Bhat | 1ee7570 | 2013-12-17 11:13:05 +0000 | [diff] [blame] | 45 | |
| 46 | UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value |
The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | |
| 48 | NO_MEMORY = -ENOMEM, |
| 49 | INVALID_OPERATION = -ENOSYS, |
| 50 | BAD_VALUE = -EINVAL, |
Ashok Bhat | 1ee7570 | 2013-12-17 11:13:05 +0000 | [diff] [blame] | 51 | BAD_TYPE = (UNKNOWN_ERROR + 1), |
The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | NAME_NOT_FOUND = -ENOENT, |
| 53 | PERMISSION_DENIED = -EPERM, |
| 54 | NO_INIT = -ENODEV, |
| 55 | ALREADY_EXISTS = -EEXIST, |
| 56 | DEAD_OBJECT = -EPIPE, |
Ashok Bhat | 1ee7570 | 2013-12-17 11:13:05 +0000 | [diff] [blame] | 57 | FAILED_TRANSACTION = (UNKNOWN_ERROR + 2), |
Elliott Hughes | 27507d8 | 2015-08-18 18:03:04 -0700 | [diff] [blame] | 58 | #if !defined(_WIN32) |
The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | BAD_INDEX = -EOVERFLOW, |
| 60 | NOT_ENOUGH_DATA = -ENODATA, |
| 61 | WOULD_BLOCK = -EWOULDBLOCK, |
Mathias Agopian | 641b630 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 62 | TIMED_OUT = -ETIMEDOUT, |
The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | UNKNOWN_TRANSACTION = -EBADMSG, |
| 64 | #else |
| 65 | BAD_INDEX = -E2BIG, |
Ashok Bhat | 1ee7570 | 2013-12-17 11:13:05 +0000 | [diff] [blame] | 66 | NOT_ENOUGH_DATA = (UNKNOWN_ERROR + 3), |
| 67 | WOULD_BLOCK = (UNKNOWN_ERROR + 4), |
| 68 | TIMED_OUT = (UNKNOWN_ERROR + 5), |
| 69 | UNKNOWN_TRANSACTION = (UNKNOWN_ERROR + 6), |
The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | #endif |
Ashok Bhat | 1ee7570 | 2013-12-17 11:13:05 +0000 | [diff] [blame] | 71 | FDS_NOT_ALLOWED = (UNKNOWN_ERROR + 7), |
Christopher Wiley | c3441e6 | 2015-11-10 11:11:08 -0800 | [diff] [blame] | 72 | UNEXPECTED_NULL = (UNKNOWN_ERROR + 8), |
The Android Open Source Project | cbb1011 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | // Restore define; enumeration is in "android" namespace, so the value defined |
| 76 | // there won't work for Win32 code in a different namespace. |
| 77 | #ifdef _WIN32 |
| 78 | # define NO_ERROR 0L |
| 79 | #endif |
| 80 | |
Pirama Arumuga Nainar | eab48ce | 2018-04-10 14:31:29 -0700 | [diff] [blame] | 81 | } // namespace android |