michael@0: /* michael@0: * Copyright (C) 2007 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef ANDROID_ERRORS_H michael@0: #define ANDROID_ERRORS_H michael@0: michael@0: #include michael@0: #include michael@0: michael@0: namespace android { michael@0: michael@0: // use this type to return error codes michael@0: #ifdef HAVE_MS_C_RUNTIME michael@0: typedef int status_t; michael@0: #else michael@0: typedef int32_t status_t; michael@0: #endif michael@0: michael@0: /* the MS C runtime lacks a few error codes */ michael@0: michael@0: /* michael@0: * Error codes. michael@0: * All error codes are negative values. michael@0: */ michael@0: michael@0: // Win32 #defines NO_ERROR as well. It has the same value, so there's no michael@0: // real conflict, though it's a bit awkward. michael@0: #ifdef _WIN32 michael@0: # undef NO_ERROR michael@0: #endif michael@0: michael@0: enum { michael@0: OK = 0, // Everything's swell. michael@0: NO_ERROR = 0, // No errors. michael@0: michael@0: UNKNOWN_ERROR = 0x80000000, michael@0: michael@0: NO_MEMORY = -ENOMEM, michael@0: INVALID_OPERATION = -ENOSYS, michael@0: BAD_VALUE = -EINVAL, michael@0: BAD_TYPE = 0x80000001, michael@0: NAME_NOT_FOUND = -ENOENT, michael@0: PERMISSION_DENIED = -EPERM, michael@0: NO_INIT = -ENODEV, michael@0: ALREADY_EXISTS = -EEXIST, michael@0: DEAD_OBJECT = -EPIPE, michael@0: FAILED_TRANSACTION = 0x80000002, michael@0: JPARKS_BROKE_IT = -EPIPE, michael@0: #if !defined(HAVE_MS_C_RUNTIME) michael@0: BAD_INDEX = -EOVERFLOW, michael@0: NOT_ENOUGH_DATA = -ENODATA, michael@0: WOULD_BLOCK = -EWOULDBLOCK, michael@0: TIMED_OUT = -ETIMEDOUT, michael@0: UNKNOWN_TRANSACTION = -EBADMSG, michael@0: #else michael@0: BAD_INDEX = -E2BIG, michael@0: NOT_ENOUGH_DATA = 0x80000003, michael@0: WOULD_BLOCK = 0x80000004, michael@0: TIMED_OUT = 0x80000005, michael@0: UNKNOWN_TRANSACTION = 0x80000006, michael@0: #endif michael@0: FDS_NOT_ALLOWED = 0x80000007, michael@0: }; michael@0: michael@0: // Restore define; enumeration is in "android" namespace, so the value defined michael@0: // there won't work for Win32 code in a different namespace. michael@0: #ifdef _WIN32 michael@0: # define NO_ERROR 0L michael@0: #endif michael@0: michael@0: }; // namespace android michael@0: michael@0: // --------------------------------------------------------------------------- michael@0: michael@0: #endif // ANDROID_ERRORS_H