1edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project/*
2edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Copyright (C) 2007 The Android Open Source Project
3edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
4edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
5edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * you may not use this file except in compliance with the License.
6edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * You may obtain a copy of the License at
7edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
8edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
9edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
10edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
11edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
12edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * See the License for the specific language governing permissions and
14edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * limitations under the License.
15edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project */
16edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
17edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#ifndef ANDROID_ERRORS_H
18edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#define ANDROID_ERRORS_H
19edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
20edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <sys/types.h>
21edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <errno.h>
22edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
23edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectnamespace android {
24edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
25edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// use this type to return error codes
26edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#ifdef HAVE_MS_C_RUNTIME
27edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projecttypedef int         status_t;
28edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#else
29edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projecttypedef int32_t     status_t;
30edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#endif
31edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
32edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project/* the MS C runtime lacks a few error codes */
33edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
34edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project/*
35edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Error codes.
36edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * All error codes are negative values.
37edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project */
38edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
39edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// Win32 #defines NO_ERROR as well.  It has the same value, so there's no
40edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// real conflict, though it's a bit awkward.
41edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#ifdef _WIN32
42edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project# undef NO_ERROR
43edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#endif
44edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
45edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectenum {
46edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    OK                = 0,    // Everything's swell.
47edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    NO_ERROR          = 0,    // No errors.
48edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
49edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    UNKNOWN_ERROR       = 0x80000000,
50edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
51edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    NO_MEMORY           = -ENOMEM,
52edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    INVALID_OPERATION   = -ENOSYS,
53edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    BAD_VALUE           = -EINVAL,
54edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    BAD_TYPE            = 0x80000001,
55edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    NAME_NOT_FOUND      = -ENOENT,
56edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    PERMISSION_DENIED   = -EPERM,
57edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    NO_INIT             = -ENODEV,
58edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    ALREADY_EXISTS      = -EEXIST,
59edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    DEAD_OBJECT         = -EPIPE,
60edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    FAILED_TRANSACTION  = 0x80000002,
61edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    JPARKS_BROKE_IT     = -EPIPE,
62edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#if !defined(HAVE_MS_C_RUNTIME)
63edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    BAD_INDEX           = -EOVERFLOW,
64edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    NOT_ENOUGH_DATA     = -ENODATA,
65edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    WOULD_BLOCK         = -EWOULDBLOCK,
66cbb288bfe89f585bf48371bd31b2d4aafa32f32eMathias Agopian    TIMED_OUT           = -ETIMEDOUT,
67edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    UNKNOWN_TRANSACTION = -EBADMSG,
68edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#else
69edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    BAD_INDEX           = -E2BIG,
70edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    NOT_ENOUGH_DATA     = 0x80000003,
71edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    WOULD_BLOCK         = 0x80000004,
72edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    TIMED_OUT           = 0x80000005,
73edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    UNKNOWN_TRANSACTION = 0x80000006,
74edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#endif
758938ed2c8e906fc332301b64787728d4d34da571Dianne Hackborn    FDS_NOT_ALLOWED     = 0x80000007,
76edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project};
77edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
78edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// Restore define; enumeration is in "android" namespace, so the value defined
79edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// there won't work for Win32 code in a different namespace.
80edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#ifdef _WIN32
81edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project# define NO_ERROR 0L
82edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#endif
83edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
84edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project}; // namespace android
85edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
86edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// ---------------------------------------------------------------------------
87edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
88edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#endif // ANDROID_ERRORS_H
89