Skip to content
Snippets Groups Projects
Commit cab962b6 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Bug#748599: review fixes.

Instead of trying to do a platform-safe but lower-speed
integer extraction from network, add a configuration check
for rare platforms and refuse to compile on them.
Keep the code simple for x86.
parent 39fb14a3
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ project(tarantool)
include(CheckLibraryExists)
include(CheckIncludeFile)
include(CheckCCompilerFlag)
include(TestBigEndian)
find_program(ECHO echo)
find_program(CAT cat)
find_program(GIT git)
......@@ -44,6 +45,24 @@ else()
message (FATAL_ERROR "Unsupported platform -- ${CMAKE_SYSTEM_NAME}")
endif()
test_big_endian(HAVE_BYTE_ORDER_BIG_ENDIAN)
#
# We do not perform host-to-network byte order translation,
# and simply assume the machine is little-endian.
# We also do not bother with trying to avoid unaligned
# word access. Refuse to compile on rare hardware such as
# Sparc or Itanium.
#
if (${HAVE_BYTE_ORDER_BIG_ENDIAN} OR
${CMAKE_SYSTEM_PROCESSOR} STREQUAL "sparc" OR
${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ia64" OR
${CMAKE_SYSTEM_PROCESSOR} MATCHES "^alpha")
message (FATAL_ERROR "Unsupported architecture -- ${CMAKE_SYSTEM_PROCESSOR}, ")
message (FATAL_ERROR "Tarantool currently only supports little-endian hardware")
message (FATAL_ERROR "with unaligned word access.")
endif()
#
# Some versions of GNU libc define non-portable __libc_stack_end
# which we use to determine the end (or beginning, actually) of
......
......@@ -123,15 +123,9 @@ int tnt_execute_raw(struct tnt_connection *tnt, const char *message,
if (tnt_res) {
memset(tnt_res, 0, sizeof *tnt_res);
int ret_code = buf[12];
int b = 256;
int i = 13;
while (i < 16) {
ret_code += (buf[i++] * b);
b *= 256;
}
tnt_res->errcode = ret_code; /* see iproto.h */
/* @fixme: we may want to support big-endian some
* day. */
tnt_res->errcode = * (uint32_t*) (buf+12); /* see iproto.h */
}
return 0;
}
......@@ -35,6 +35,10 @@
* Set if this is a GNU system and libc has __libc_stack_end.
*/
#cmakedefine HAVE_LIBC_STACK_END 1
/*
* Defined if this is a big-endian system.
*/
#cmakedefine HAVE_BYTE_ORDER_BIG_ENDIAN 1
/*
* vim: syntax=c
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment