Fix thrift_binary_protocol to be hipe-compatible
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666468 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/alterl/src/thrift_binary_protocol.erl b/lib/alterl/src/thrift_binary_protocol.erl
index 4bb5880..fce6c42 100644
--- a/lib/alterl/src/thrift_binary_protocol.erl
+++ b/lib/alterl/src/thrift_binary_protocol.erl
@@ -152,7 +152,7 @@
%%
read(This, message_begin) ->
- case read(This, i32) of
+ case read(This, ui32) of
{ok, Sz} when Sz band ?VERSION_MASK =:= ?VERSION_1 ->
%% we're at version 1
{ok, Name} = read(This, string),
@@ -253,6 +253,15 @@
Else -> Else
end;
+%% unsigned ints aren't used by thrift itself, but it's used for the parsing
+%% of the packet version header. Without this special function BEAM works fine
+%% but hipe thinks it received a bad version header.
+read(This, ui32) ->
+ case read(This, 4) of
+ {ok, <<Val:32/integer-unsigned-big, _/binary>>} -> {ok, Val};
+ Else -> Else
+ end;
+
read(This, i64) ->
case read(This, 8) of
{ok, <<Val:64/integer-signed-big, _/binary>>} -> {ok, Val};