Android Native代码中的status_t定义
16lz
2021-01-23
定义在Android/system/core/include/utils/Errors.h中,小提示,Android代码中遇到的symbol,既不是Linux中提供的定义,使用source insight又找不到的情况下,可以去Android/system/core/include/目录找找,可能会有意想不到的收获哦。
定义如下:
1/*2 * Copyright (C) 2007 The Android Open Source Project3 *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 at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */1617#ifndef ANDROID_ERRORS_H18#define ANDROID_ERRORS_H1920#include 21#include 2223namespace android {2425// use this type to return error codes26#ifdef _WIN3227typedef int status_t;28#else29typedef int32_t status_t;30#endif3132/* the MS C runtime lacks a few error codes */3334/*35 * Error codes.36 * All error codes are negative values.37 */3839// Win32 #defines NO_ERROR as well. It has the same value, so there's no40// real conflict, though it's a bit awkward.41#ifdef _WIN3242# undef NO_ERROR43#endif4445enum {46 OK = 0, // Everything's swell.47 NO_ERROR = 0, // No errors.4849 UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value5051 NO_MEMORY = -ENOMEM,52 INVALID_OPERATION = -ENOSYS,53 BAD_VALUE = -EINVAL,54 BAD_TYPE = (UNKNOWN_ERROR + 1),55 NAME_NOT_FOUND = -ENOENT,56 PERMISSION_DENIED = -EPERM,57 NO_INIT = -ENODEV,58 ALREADY_EXISTS = -EEXIST,59 DEAD_OBJECT = -EPIPE,60 FAILED_TRANSACTION = (UNKNOWN_ERROR + 2),61#if !defined(_WIN32)62 BAD_INDEX = -EOVERFLOW,63 NOT_ENOUGH_DATA = -ENODATA,64 WOULD_BLOCK = -EWOULDBLOCK,65 TIMED_OUT = -ETIMEDOUT,66 UNKNOWN_TRANSACTION = -EBADMSG,67#else68 BAD_INDEX = -E2BIG,69 NOT_ENOUGH_DATA = (UNKNOWN_ERROR + 3),70 WOULD_BLOCK = (UNKNOWN_ERROR + 4),71 TIMED_OUT = (UNKNOWN_ERROR + 5),72 UNKNOWN_TRANSACTION = (UNKNOWN_ERROR + 6),73#endif74 FDS_NOT_ALLOWED = (UNKNOWN_ERROR + 7),75 UNEXPECTED_NULL = (UNKNOWN_ERROR + 8),76};7778// Restore define; enumeration is in "android" namespace, so the value defined79// there won't work for Win32 code in a different namespace.80#ifdef _WIN3281# define NO_ERROR 0L82#endif8384}; // namespace android8586// ---------------------------------------------------------------------------8788#endif // ANDROID_ERRORS_H89
所以,我们看到的status_t不过是int类型而已,只是取值有些枚举值已经定义好,当然也可以自己扩展。
更多相关文章
- 自定义ListView中的分割线(转)
- Android 自定义实现TextView单行超出部分显示为省略号
- Android 自定义控件实现刮刮卡效果 真的就只是刮刮卡么
- 自定义控件及效果
- Android菜鸟的成长笔记(6)——剖析源码学自定义主题Theme
- Android与iOS自定义URL Scheme唤醒app
- 为android开放类增加自定义成员方法