Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
f1f3d019
Commit
f1f3d019
authored
11 years ago
by
Dmitry Simonenko
Browse files
Options
Downloads
Patches
Plain Diff
fix bigendian convertion (support for old CentOS'es).
parent
6136ea89
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/box/box_lua.cc
+8
-7
8 additions, 7 deletions
src/box/box_lua.cc
with
8 additions
and
7 deletions
src/box/box_lua.cc
+
8
−
7
View file @
f1f3d019
...
@@ -42,7 +42,8 @@ extern "C" {
...
@@ -42,7 +42,8 @@ extern "C" {
#include
<lj_ctype.h>
#include
<lj_ctype.h>
#include
<lj_cdata.h>
#include
<lj_cdata.h>
#include
<lj_cconv.h>
#include
<lj_cconv.h>
#include
<endian.h>
#include
<arpa/inet.h>
#include
<lib/bit/bit.h>
}
/* extern "C" */
}
/* extern "C" */
#include
"pickle.h"
#include
"pickle.h"
...
@@ -1507,7 +1508,7 @@ lbox_pack(struct lua_State *L)
...
@@ -1507,7 +1508,7 @@ lbox_pack(struct lua_State *L)
/* signed and unsigned 16-bit big endian integers */
/* signed and unsigned 16-bit big endian integers */
if
(
field
.
type
!=
NUM
||
field
.
u32
>
UINT16_MAX
)
if
(
field
.
type
!=
NUM
||
field
.
u32
>
UINT16_MAX
)
luaL_error
(
L
,
"box.pack: expected 16-bit int"
);
luaL_error
(
L
,
"box.pack: expected 16-bit int"
);
u16
=
hto
be16
(
(
uint16_t
)
field
.
u32
);
u16
=
hto
ns
(
(
uint16_t
)
field
.
u32
);
luaL_addlstring
(
&
b
,
(
char
*
)
&
u16
,
sizeof
(
u16
));
luaL_addlstring
(
&
b
,
(
char
*
)
&
u16
,
sizeof
(
u16
));
break
;
break
;
case
'I'
:
case
'I'
:
...
@@ -1521,7 +1522,7 @@ lbox_pack(struct lua_State *L)
...
@@ -1521,7 +1522,7 @@ lbox_pack(struct lua_State *L)
/* signed and unsigned 32-bit big endian integers */
/* signed and unsigned 32-bit big endian integers */
if
(
field
.
type
!=
NUM
)
if
(
field
.
type
!=
NUM
)
luaL_error
(
L
,
"box.pack: expected 32-bit int"
);
luaL_error
(
L
,
"box.pack: expected 32-bit int"
);
u32
=
hto
be32
(
field
.
u32
);
u32
=
hto
nl
(
field
.
u32
);
luaL_addlstring
(
&
b
,
(
char
*
)
&
u32
,
sizeof
(
uint32_t
));
luaL_addlstring
(
&
b
,
(
char
*
)
&
u32
,
sizeof
(
uint32_t
));
break
;
break
;
case
'L'
:
case
'L'
:
...
@@ -1548,7 +1549,7 @@ lbox_pack(struct lua_State *L)
...
@@ -1548,7 +1549,7 @@ lbox_pack(struct lua_State *L)
}
else
{
}
else
{
luaL_error
(
L
,
"box.pack: expected 64-bit int"
);
luaL_error
(
L
,
"box.pack: expected 64-bit int"
);
}
}
u64
=
htobe
64
(
u64
);
u64
=
bswap_u
64
(
u64
);
luaL_addlstring
(
&
b
,
(
char
*
)
&
u64
,
sizeof
(
u64
));
luaL_addlstring
(
&
b
,
(
char
*
)
&
u64
,
sizeof
(
u64
));
break
;
break
;
case
'd'
:
case
'd'
:
...
@@ -1683,7 +1684,7 @@ lbox_unpack(struct lua_State *L)
...
@@ -1683,7 +1684,7 @@ lbox_unpack(struct lua_State *L)
break
;
break
;
case
'n'
:
case
'n'
:
CHECK_SIZE
(
s
+
1
);
CHECK_SIZE
(
s
+
1
);
u16buf
=
be16
toh
(
*
(
uint16_t
*
)
s
);
u16buf
=
n
toh
s
(
*
(
uint16_t
*
)
s
);
lua_pushnumber
(
L
,
u16buf
);
lua_pushnumber
(
L
,
u16buf
);
s
+=
2
;
s
+=
2
;
break
;
break
;
...
@@ -1695,7 +1696,7 @@ lbox_unpack(struct lua_State *L)
...
@@ -1695,7 +1696,7 @@ lbox_unpack(struct lua_State *L)
break
;
break
;
case
'N'
:
case
'N'
:
CHECK_SIZE
(
s
+
3
);
CHECK_SIZE
(
s
+
3
);
u32buf
=
be32
toh
(
*
(
uint32_t
*
)
s
);
u32buf
=
n
toh
l
(
*
(
uint32_t
*
)
s
);
lua_pushnumber
(
L
,
u32buf
);
lua_pushnumber
(
L
,
u32buf
);
s
+=
4
;
s
+=
4
;
break
;
break
;
...
@@ -1706,7 +1707,7 @@ lbox_unpack(struct lua_State *L)
...
@@ -1706,7 +1707,7 @@ lbox_unpack(struct lua_State *L)
break
;
break
;
case
'q'
:
case
'q'
:
CHECK_SIZE
(
s
+
7
);
CHECK_SIZE
(
s
+
7
);
luaL_pushnumber64
(
L
,
b
e64toh
(
*
(
uint64_t
*
)
s
));
luaL_pushnumber64
(
L
,
b
swap_u64
(
*
(
uint64_t
*
)
s
));
s
+=
8
;
s
+=
8
;
break
;
break
;
case
'd'
:
case
'd'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment