*/
#include <stdio.h>
+#include <stdint.h>
#include <inttypes.h>
#include <ctype.h>
#include <string.h>
//#define debug_printf(args...) printf(args)
#define debug_printf(args...) do {} while(0)
-/* XXX to remove ? there should be something better */
-#define U08_MIN 0x00
-#define U08_MAX 0xFF
-#define U16_MIN 0x0000
-#define U16_MAX 0xFFFF
-#define U32_MIN 0x00000000
-#define U32_MAX 0xFFFFFFFF
-#define S08_MIN 0x80
-#define S08_MAX 0x7F
-#define S16_MIN 0x8000
-#define S16_MAX 0x7FFF
-#define S32_MIN 0x80000000
-#define S32_MAX 0x7FFFFFFF
-
-
struct cmdline_token_ops cmdline_token_num_ops = {
.parse = cmdline_parse_num,
.complete_get_nb = NULL,
add_to_res(unsigned int c, unsigned int *res, unsigned int base)
{
/* overflow */
- if ( (U32_MAX - c) / base < *res ) {
+ if ( (UINT32_MAX - c) / base < *res ) {
return -1;
}
case HEX_OK:
case OCTAL_OK:
case BIN_OK:
- if ( nd.type == INT8 && res1 <= S08_MAX ) {
+ if ( nd.type == INT8 && res1 <= INT8_MAX ) {
if (res)
*(int8_t *)res = (int8_t) res1;
return (buf-srcbuf);
}
- else if ( nd.type == INT16 && res1 <= S16_MAX ) {
+ else if ( nd.type == INT16 && res1 <= INT16_MAX ) {
if (res)
*(int16_t *)res = (int16_t) res1;
return (buf-srcbuf);
}
- else if ( nd.type == INT32 && res1 <= S32_MAX ) {
+ else if ( nd.type == INT32 && res1 <= INT32_MAX ) {
if (res)
*(int32_t *)res = (int32_t) res1;
return (buf-srcbuf);
}
- else if ( nd.type == UINT8 && res1 <= U08_MAX ) {
+ else if ( nd.type == UINT8 && res1 <= UINT8_MAX ) {
if (res)
*(uint8_t *)res = (uint8_t) res1;
return (buf-srcbuf);
}
- else if (nd.type == UINT16 && res1 <= U16_MAX ) {
+ else if (nd.type == UINT16 && res1 <= UINT16_MAX ) {
if (res)
*(uint16_t *)res = (uint16_t) res1;
return (buf-srcbuf);
break;
case DEC_NEG_OK:
- if ( nd.type == INT8 && res1 <= S08_MAX + 1 ) {
+ if ( nd.type == INT8 && res1 <= INT8_MAX + 1 ) {
if (res)
*(int8_t *)res = - (int8_t) res1;
return (buf-srcbuf);
}
- else if ( nd.type == INT16 && res1 <= (uint16_t)S16_MAX + 1 ) {
+ else if ( nd.type == INT16 && res1 <= (uint16_t)INT16_MAX + 1 ) {
if (res)
*(int16_t *)res = - (int16_t) res1;
return (buf-srcbuf);
}
- else if ( nd.type == INT32 && res1 <= (uint32_t)S32_MAX + 1 ) {
+ else if ( nd.type == INT32 && res1 <= (uint32_t)INT32_MAX + 1 ) {
if (res)
*(int32_t *)res = - (int32_t) res1;
return (buf-srcbuf);