blob: 0b75b1926c1d9b95f149b5f53d63333721e4ea66 [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
17#ifndef ANDROID_ERRORS_H
18#define ANDROID_ERRORS_H
19
20#include <sys/types.h>
21#include <errno.h>
22
23namespace android {
24
25// use this type to return error codes
26#ifdef HAVE_MS_C_RUNTIME
27typedef int status_t;
28#else
29typedef int32_t status_t;
30#endif
31
32/* the MS C runtime lacks a few error codes */
33
34/*
35 * Error codes.
36 * All error codes are negative values.
37 */
38
39// Win32 #defines NO_ERROR as well. It has the same value, so there's no
40// real conflict, though it's a bit awkward.
41#ifdef _WIN32
42# undef NO_ERROR
43#endif
44
45enum {
46 OK = 0, // Everything's swell.
47 NO_ERROR = 0, // No errors.
48
49 UNKNOWN_ERROR = 0x80000000,
50
51 NO_MEMORY = -ENOMEM,
52 INVALID_OPERATION = -ENOSYS,
53 BAD_VALUE = -EINVAL,
54 BAD_TYPE = 0x80000001,
55 NAME_NOT_FOUND = -ENOENT,
56 PERMISSION_DENIED = -EPERM,
57 NO_INIT = -ENODEV,
58 ALREADY_EXISTS = -EEXIST,
59 DEAD_OBJECT = -EPIPE,
60 FAILED_TRANSACTION = 0x80000002,
61 JPARKS_BROKE_IT = -EPIPE,
62#if !defined(HAVE_MS_C_RUNTIME)
63 BAD_INDEX = -EOVERFLOW,
64 NOT_ENOUGH_DATA = -ENODATA,
65 WOULD_BLOCK = -EWOULDBLOCK,
Mathias Agopian641b6302009-09-07 16:32:45 -070066 TIMED_OUT = -ETIMEDOUT,
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080067 UNKNOWN_TRANSACTION = -EBADMSG,
68#else
69 BAD_INDEX = -E2BIG,
70 NOT_ENOUGH_DATA = 0x80000003,
71 WOULD_BLOCK = 0x80000004,
72 TIMED_OUT = 0x80000005,
73 UNKNOWN_TRANSACTION = 0x80000006,
74#endif
Dianne Hackborn6c31a2f2011-09-28 23:19:47 -040075 FDS_NOT_ALLOWED = 0x80000007,
The Android Open Source Projectcbb10112009-03-03 19:31:44 -080076};
77
78// Restore define; enumeration is in "android" namespace, so the value defined
79// there won't work for Win32 code in a different namespace.
80#ifdef _WIN32
81# define NO_ERROR 0L
82#endif
83
84}; // namespace android
85
86// ---------------------------------------------------------------------------
87
88#endif // ANDROID_ERRORS_H