00001
00014 #ifndef C4E_SYS_H
00015 #define C4E_SYS_H
00016
00017
00018
00019
00020 #include "c4e_arch.h"
00021
00022 #ifdef _lint
00023 #include "c4e_lint.h"
00024 #endif
00025
00026
00027 #ifdef C4E_CONFIG_DEBUG
00028 #include <assert.h>
00029 #endif
00030
00031
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035
00036
00044
00045
00046 typedef C4eArchUint C4eSysStatus;
00053 #if defined(C4E_LINT)
00054 typedef int C4eSysBool;
00055 #elif defined(__cplusplus) || defined(HAVE_STDBOOL_H)
00056 typedef bool C4eSysBool;
00057 #elif defined(HAVE__BOOL)
00058 typedef _Bool C4eSysBool;
00059 #else
00060 typedef C4eArchUint C4eSysBool;
00061 #endif
00062
00063
00064
00065
00066
00067
00068 #if defined(HAVE_STDBOOL_H) || defined(__cplusplus)
00069 #define C4E_FALSE C4E_SYS_CAST(C4eSysBool, false)
00070 #define C4E_TRUE C4E_SYS_CAST(C4eSysBool, true)
00071 #else
00072 #define C4E_FALSE C4E_SYS_CAST(C4eSysBool, 0U)
00073 #define C4E_TRUE C4E_SYS_CAST(C4eSysBool, 1U)
00074 #endif
00075
00076
00082 #define C4E_STATUS_OK (0U)
00083 #define C4E_STATUS_ERNG (1U)
00084 #define C4E_STATUS_EMOD (2U)
00085 #define C4E_STATUS_EKEYPRV (3U)
00086 #define C4E_STATUS_EKEYPUB (4U)
00087 #define C4E_STATUS_ELENGTH (5U)
00088 #define C4E_STATUS_ECODING (6U)
00089 #define C4E_STATUS_EASN1 (7U)
00090 #define C4E_STATUS_EVERIFY (8U)
00091 #define C4E_STATUS_EDOM (9U)
00092 #define C4E_STATUS_ERANGE (10U)
00105 #define C4E_SYS_UINT8_ZERO C4E_SYS_CAST(C4eArchUint8, 0U)
00106
00107
00111 #define C4E_SYS_UINT8_ONE C4E_SYS_CAST(C4eArchUint8, 1U)
00112
00113
00117 #define C4E_SYS_DIGIT_ZERO C4E_SYS_CAST(C4eArchDigit, 0U)
00118
00119
00123 #define C4E_SYS_DIGIT_ONE C4E_SYS_CAST(C4eArchDigit, 1U)
00124
00125
00131 #define C4E_SYS_DIGIT_MAX C4E_SYS_CAST(C4eArchDigit, ~C4E_SYS_DIGIT_ZERO)
00132
00133
00139 #define C4E_SYS_DIGIT_BITS (8U * C4E_ARCH_DIGIT_SIZE)
00140
00141
00147 #define C4E_SYS_DIGIT_MSBIT \
00148 (C4E_SYS_CAST(C4eArchDigit, C4E_SYS_DIGIT_ONE << (C4E_SYS_DIGIT_BITS - 1U)))
00149
00150
00156 #define C4E_SYS_DIGIT_LSBYTE C4E_SYS_CAST(C4eArchDigit, 0xffU)
00157
00158
00159
00165 #define C4E_SYS_DIGIT_MSBYTE \
00166 C4E_SYS_CAST(C4eArchDigit, C4E_SYS_DIGIT_LSBYTE << (C4E_SYS_DIGIT_BITS - 8U))
00167
00168
00169
00170
00171
00172
00173
00174
00182 #define C4E_SYS_VECTOR_SIZE(vec) (sizeof(vec) / sizeof(vec[0]))
00183
00184
00185
00186
00195 #define C4E_SYS_DIV_CEIL(x, m) (((x) + ((m) - 1U)) / (m))
00196
00197
00198
00199
00209 #if defined(C4E_CONFIG_DEBUG) || defined(C4E_LINT)
00210 #define C4E_ASSERT(cond) assert(cond)
00211 #else
00212 #define C4E_ASSERT(cond)
00213 #endif
00214
00215
00216
00217
00229 #define C4E_SYS_CAST(type, any) ((type)(any))
00230
00231
00232
00233
00244 #define C4E_SYS_CAST_UINT8PTR(any) ((C4eArchUint8*)(any))
00245
00246
00247
00248
00249
00250
00251
00252
00253 #ifdef __cplusplus
00254 }
00255 #endif
00256
00257
00258
00259 #endif
00260
00261
00262
00263
00264
00265