blob: 1e0367749e520d81b21daf42e4eb1925fbf5c4ef [file] [log] [blame]
The Android Open Source Projectcbb10112009-03-03 19:31:44 -08001/*
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 Hughes9fbebc52018-10-16 13:17:15 -070017#pragma once
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080018
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080019#include <errno.h>
Elliott Hughes9fbebc52018-10-16 13:17:15 -070020#include <stdint.h>
21#include <sys/types.h>
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080022
23namespace android {
24
Elliott Hughes9fbebc52018-10-16 13:17:15 -070025/**
26 * The type used to return success/failure from frameworks APIs.
27 * See the anonymous enum below for valid values.
28 */
29typedef int32_t status_t;
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080030
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 Bhat1ee75702013-12-17 11:13:05 +000041
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080042enum {
Elliott Hughes643268f2018-10-08 11:10:11 -070043 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 Bhat1ee75702013-12-17 11:13:05 +000045
46 UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080047
48 NO_MEMORY = -ENOMEM,
49 INVALID_OPERATION = -ENOSYS,
50 BAD_VALUE = -EINVAL,
Ashok Bhat1ee75702013-12-17 11:13:05 +000051 BAD_TYPE = (UNKNOWN_ERROR + 1),
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080052 NAME_NOT_FOUND = -ENOENT,
53 PERMISSION_DENIED = -EPERM,
54 NO_INIT = -ENODEV,
55 ALREADY_EXISTS = -EEXIST,
56 DEAD_OBJECT = -EPIPE,
Ashok Bhat1ee75702013-12-17 11:13:05 +000057 FAILED_TRANSACTION = (UNKNOWN_ERROR + 2),
Elliott Hughes27507d82015-08-18 18:03:04 -070058#if !defined(_WIN32)
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080059 BAD_INDEX = -EOVERFLOW,
60 NOT_ENOUGH_DATA = -ENODATA,
61 WOULD_BLOCK = -EWOULDBLOCK,
Mathias Agopian641b6302009-09-07 16:32:45 -070062 TIMED_OUT = -ETIMEDOUT,
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080063 UNKNOWN_TRANSACTION = -EBADMSG,
64#else
65 BAD_INDEX = -E2BIG,
Ashok Bhat1ee75702013-12-17 11:13:05 +000066 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 Projectcbb10112009-03-03 19:31:44 -080070#endif
Ashok Bhat1ee75702013-12-17 11:13:05 +000071 FDS_NOT_ALLOWED = (UNKNOWN_ERROR + 7),
Christopher Wileyc3441e62015-11-10 11:11:08 -080072 UNEXPECTED_NULL = (UNKNOWN_ERROR + 8),
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080073};
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 Nainareab48ce2018-04-10 14:31:29 -070081} // namespace android