1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @file common_timer_errors.h 18 * 19 * @brief Provides the values of the <b>Code</b> segment in <b>ErrCode</b> 20 * for the Timer module in the commonlibrary subsystem. 21 */ 22 23 #ifndef UTILS_COMMON_TIMER_ERRORS_H 24 #define UTILS_COMMON_TIMER_ERRORS_H 25 26 #include <cerrno> 27 #include "errors.h" 28 #include "common_errors.h" 29 30 namespace OHOS { 31 namespace Utils { 32 33 /** 34 * ErrCode layout 35 * 36 * +-----+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 37 * | Bit |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|09|08|07|06|05|04|03|02|01|00| 38 * +-----+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 39 * |Field|Reserved| Subsystem | Module | Code | 40 * +-----+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 41 * 42 * In this file, the subsystem is "SUBSYS_COMMON", and the module is 43 * "MODULE_TIMER". 44 */ 45 46 using ErrCode = int; 47 48 // The error codes can be used only for the Timer module. 49 /** 50 * @brief Provides the base error codes of the Timer module 51 * in the commonlibrary subsystem. 52 */ 53 constexpr ErrCode COMMON_TIMER_ERR_OFFSET = ErrCodeOffset(SUBSYS_COMMON, MODULE_TIMER); 54 55 /** 56 * @brief Enumerates the values of the <b>Code</b> segment in <b>ErrCode</b> 57 * for the Timer module. 58 * 59 * @var TIMER_ERR_OK Indicates an operation success. 60 * @var TIMER_ERR_DEAL_FAILED Indicates an operation failure. 61 * @var TIMER_ERR_BADF Indicates a bad file descriptor. 62 * @var TIMER_ERR_INVALID_VALUE Indicates an invalid value. 63 */ 64 enum { 65 TIMER_ERR_OK = 0, 66 TIMER_ERR_DEAL_FAILED = COMMON_TIMER_ERR_OFFSET + EAGAIN, 67 TIMER_ERR_BADF = COMMON_TIMER_ERR_OFFSET + EBADF, 68 TIMER_ERR_INVALID_VALUE = COMMON_TIMER_ERR_OFFSET + EINVAL 69 }; 70 71 } // Utils 72 } // OHOS 73 74 #endif 75