MAJOR: sample: converts uint and sint in 64 bits signed integer

This patch removes the 32 bits unsigned integer and the 32 bit signed
integer. It replaces these types by a unique type 64 bit signed.

This makes easy the usage of integer and clarify signed and unsigned use.
With the previous version, signed and unsigned are used ones in place of
others, and sometimes the converter loose the sign. For example, divisions
are processed with "unsigned", if one entry is negative, the result is
wrong.

Note that the integer pattern matching and dotted version pattern matching
are already working with signed 64 bits integer values.

There is one user-visible change : the "uint()" and "sint()" sample fetch
functions which used to return a constant integer have been replaced with
a new more natural, unified "int()" function. These functions were only
introduced in the latest 1.6-dev2 so there's no impact on regular
deployments.
This commit is contained in:
Thierry FOURNIER
2015-07-06 23:43:03 +02:00
committed by Willy Tarreau
parent 5b4dd683cb
commit 07ee64ef4d
18 changed files with 584 additions and 644 deletions

View File

@@ -389,7 +389,6 @@ static int hlua_smp2lua(lua_State *L, struct sample *smp)
switch (smp->type) {
case SMP_T_SINT:
case SMP_T_BOOL:
case SMP_T_UINT:
lua_pushinteger(L, smp->data.sint);
break;
@@ -467,7 +466,6 @@ static int hlua_smp2lua_str(lua_State *L, struct sample *smp)
case SMP_T_SINT:
case SMP_T_BOOL:
case SMP_T_UINT:
case SMP_T_IPV4:
case SMP_T_IPV6:
case SMP_T_ADDR: /* This type is never used to qualify a sample. */
@@ -500,7 +498,7 @@ static int hlua_lua2smp(lua_State *L, int ud, struct sample *smp)
case LUA_TBOOLEAN:
smp->type = SMP_T_BOOL;
smp->data.uint = lua_toboolean(L, ud);
smp->data.sint = lua_toboolean(L, ud);
break;
case LUA_TSTRING:
@@ -516,7 +514,7 @@ static int hlua_lua2smp(lua_State *L, int ud, struct sample *smp)
case LUA_TTHREAD:
case LUA_TLIGHTUSERDATA:
smp->type = SMP_T_BOOL;
smp->data.uint = 0;
smp->data.sint = 0;
break;
}
return 1;
@@ -1336,7 +1334,7 @@ __LJMP static int hlua_map_new(struct lua_State *L)
case PAT_MATCH_DOM: conv.in_type = SMP_T_STR; break;
case PAT_MATCH_END: conv.in_type = SMP_T_STR; break;
case PAT_MATCH_REG: conv.in_type = SMP_T_STR; break;
case PAT_MATCH_INT: conv.in_type = SMP_T_UINT; break;
case PAT_MATCH_INT: conv.in_type = SMP_T_SINT; break;
case PAT_MATCH_IP: conv.in_type = SMP_T_ADDR; break;
default:
WILL_LJMP(luaL_error(L, "'new' doesn't support this match mode."));
@@ -1380,9 +1378,9 @@ __LJMP static inline int _hlua_map_lookup(struct lua_State *L, int str)
MAY_LJMP(check_args(L, 2, "lookup"));
desc = MAY_LJMP(hlua_checkmap(L, 1));
if (desc->pat.expect_type == SMP_T_UINT) {
smp.type = SMP_T_UINT;
smp.data.uint = MAY_LJMP(luaL_checkinteger(L, 2));
if (desc->pat.expect_type == SMP_T_SINT) {
smp.type = SMP_T_SINT;
smp.data.sint = MAY_LJMP(luaL_checkinteger(L, 2));
}
else {
smp.type = SMP_T_STR;