Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit b60a04b

Browse files
Merge pull request #111 from rabbitmq/rabbitmq-server-860
Compile on OTP 19.0
2 parents e497f74 + 76f0dbb commit b60a04b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+998
-1286
lines changed

codegen.py

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def prettyType(typeName, subTypes, typesPerLine = 4):
9595
sTs = multiLineFormat(subTypes,
9696
"( ", " | ", "\n | ", " )",
9797
thingsPerLine = typesPerLine)
98-
return "-type(%s ::\n %s)." % (typeName, sTs)
98+
return "-type %s ::\n %s." % (typeName, sTs)
9999

100100
def printFileHeader():
101101
print("""%% Autogenerated code. Do not edit.
@@ -348,26 +348,25 @@ def genAmqpException(c,v,cls):
348348
349349
""")
350350
print("%% Various types")
351-
print("-ifdef(use_specs).")
352351

353352
print("""-export_type([amqp_field_type/0, amqp_property_type/0,
354353
amqp_table/0, amqp_array/0, amqp_value/0,
355354
amqp_method_name/0, amqp_method/0, amqp_method_record/0,
356355
amqp_method_field_name/0, amqp_property_record/0,
357356
amqp_exception/0, amqp_exception_code/0, amqp_class_id/0]).
358357
359-
-type(amqp_field_type() ::
358+
-type amqp_field_type() ::
360359
'longstr' | 'signedint' | 'decimal' | 'timestamp' |
361360
'unsignedbyte' | 'unsignedshort' | 'unsignedint' |
362361
'table' | 'byte' | 'double' | 'float' | 'long' |
363-
'short' | 'bool' | 'binary' | 'void' | 'array').
364-
-type(amqp_property_type() ::
362+
'short' | 'bool' | 'binary' | 'void' | 'array'.
363+
-type amqp_property_type() ::
365364
'shortstr' | 'longstr' | 'octet' | 'short' | 'long' |
366-
'longlong' | 'timestamp' | 'bit' | 'table').
365+
'longlong' | 'timestamp' | 'bit' | 'table'.
367366
368-
-type(amqp_table() :: [{binary(), amqp_field_type(), amqp_value()}]).
369-
-type(amqp_array() :: [{amqp_field_type(), amqp_value()}]).
370-
-type(amqp_value() :: binary() | % longstr
367+
-type amqp_table() :: [{binary(), amqp_field_type(), amqp_value()}].
368+
-type amqp_array() :: [{amqp_field_type(), amqp_value()}].
369+
-type amqp_value() :: binary() | % longstr
371370
integer() | % signedint
372371
{non_neg_integer(), non_neg_integer()} | % decimal
373372
amqp_table() |
@@ -379,8 +378,7 @@ def genAmqpException(c,v,cls):
379378
boolean() | % bool
380379
binary() | % binary
381380
'undefined' | % void
382-
non_neg_integer() % timestamp
383-
).
381+
non_neg_integer(). % timestamp
384382
""")
385383

386384
print(prettyType("amqp_method_name()",
@@ -410,27 +408,25 @@ def genAmqpException(c,v,cls):
410408
["%i" % ci for ci in classIds]))
411409
print(prettyType("amqp_class_name()",
412410
["%s" % c.erlangName() for c in spec.allClasses()]))
413-
print("-endif. % use_specs")
414411

415412
print("""
416413
%% Method signatures
417-
-ifdef(use_specs).
418-
-spec(version/0 :: () -> {non_neg_integer(), non_neg_integer(), non_neg_integer()}).
419-
-spec(lookup_method_name/1 :: (amqp_method()) -> amqp_method_name()).
420-
-spec(lookup_class_name/1 :: (amqp_class_id()) -> amqp_class_name()).
421-
-spec(method_id/1 :: (amqp_method_name()) -> amqp_method()).
422-
-spec(method_has_content/1 :: (amqp_method_name()) -> boolean()).
423-
-spec(is_method_synchronous/1 :: (amqp_method_record()) -> boolean()).
424-
-spec(method_record/1 :: (amqp_method_name()) -> amqp_method_record()).
425-
-spec(method_fieldnames/1 :: (amqp_method_name()) -> [amqp_method_field_name()]).
426-
-spec(decode_method_fields/2 ::
427-
(amqp_method_name(), binary()) -> amqp_method_record() | rabbit_types:connection_exit()).
428-
-spec(decode_properties/2 :: (non_neg_integer(), binary()) -> amqp_property_record()).
429-
-spec(encode_method_fields/1 :: (amqp_method_record()) -> binary()).
430-
-spec(encode_properties/1 :: (amqp_property_record()) -> binary()).
431-
-spec(lookup_amqp_exception/1 :: (amqp_exception()) -> {boolean(), amqp_exception_code(), binary()}).
432-
-spec(amqp_exception/1 :: (amqp_exception_code()) -> amqp_exception()).
433-
-endif. % use_specs
414+
-spec version() -> {non_neg_integer(), non_neg_integer(), non_neg_integer()}.
415+
-spec lookup_method_name(amqp_method()) -> amqp_method_name().
416+
-spec lookup_class_name(amqp_class_id()) -> amqp_class_name().
417+
-spec method_id(amqp_method_name()) -> amqp_method().
418+
-spec method_has_content(amqp_method_name()) -> boolean().
419+
-spec is_method_synchronous(amqp_method_record()) -> boolean().
420+
-spec method_record(amqp_method_name()) -> amqp_method_record().
421+
-spec method_fieldnames(amqp_method_name()) -> [amqp_method_field_name()].
422+
-spec decode_method_fields(amqp_method_name(), binary()) ->
423+
amqp_method_record() | rabbit_types:connection_exit().
424+
-spec decode_properties(non_neg_integer(), binary()) -> amqp_property_record().
425+
-spec encode_method_fields(amqp_method_record()) -> binary().
426+
-spec encode_properties(amqp_property_record()) -> binary().
427+
-spec lookup_amqp_exception(amqp_exception()) ->
428+
{boolean(), amqp_exception_code(), binary()}.
429+
-spec amqp_exception(amqp_exception_code()) -> amqp_exception().
434430
435431
bitvalue(true) -> 1;
436432
bitvalue(false) -> 0;

include/rabbit_msg_store.hrl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
-include("rabbit.hrl").
1818

19-
-ifdef(use_specs).
20-
2119
-type(msg() :: any()).
2220

23-
-endif.
24-
2521
-record(msg_location, {msg_id, ref_count, file, offset, total_size}).

src/app_utils.erl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
stop_applications/1, stop_applications/2, app_dependency_order/2,
2020
app_dependencies/1]).
2121

22-
-ifdef(use_specs).
23-
2422
-type error_handler() :: fun((atom(), any()) -> 'ok').
2523

2624
-spec load_applications([atom()]) -> 'ok'.
@@ -31,8 +29,6 @@
3129
-spec app_dependency_order([atom()], boolean()) -> [digraph:vertex()].
3230
-spec app_dependencies(atom()) -> [atom()].
3331

34-
-endif.
35-
3632
%%---------------------------------------------------------------------------
3733
%% Public API
3834

src/credit_flow.erl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,19 @@
6565

6666
%%----------------------------------------------------------------------------
6767

68-
-ifdef(use_specs).
69-
7068
-export_type([bump_msg/0]).
7169

7270
-opaque(bump_msg() :: {pid(), non_neg_integer()}).
7371
-type(credit_spec() :: {non_neg_integer(), non_neg_integer()}).
7472

75-
-spec(send/1 :: (pid()) -> 'ok').
76-
-spec(send/2 :: (pid(), credit_spec()) -> 'ok').
77-
-spec(ack/1 :: (pid()) -> 'ok').
78-
-spec(ack/2 :: (pid(), credit_spec()) -> 'ok').
79-
-spec(handle_bump_msg/1 :: (bump_msg()) -> 'ok').
80-
-spec(blocked/0 :: () -> boolean()).
81-
-spec(peer_down/1 :: (pid()) -> 'ok').
82-
83-
-endif.
73+
-spec send
74+
(pid()) -> 'ok';
75+
(credit_spec()) -> 'ok'.
76+
-spec ack(pid()) -> 'ok'.
77+
-spec ack(pid(), credit_spec()) -> 'ok'.
78+
-spec handle_bump_msg(bump_msg()) -> 'ok'.
79+
-spec blocked() -> boolean().
80+
-spec peer_down(pid()) -> 'ok'.
8481

8582
%%----------------------------------------------------------------------------
8683

src/gen_server2.erl

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -220,21 +220,18 @@
220220
-record(gs2_state, {parent, name, state, mod, time,
221221
timeout_state, queue, debug, prioritisers}).
222222

223-
-ifdef(use_specs).
224-
225223
%%%=========================================================================
226224
%%% Specs. These exist only to shut up dialyzer's warnings
227225
%%%=========================================================================
228226

229-
-type(gs2_state() :: #gs2_state{}).
227+
-type gs2_state() :: #gs2_state{}.
230228

231-
-spec(handle_common_termination/3 ::
232-
(any(), atom(), gs2_state()) -> no_return()).
233-
-spec(hibernate/1 :: (gs2_state()) -> no_return()).
234-
-spec(pre_hibernate/1 :: (gs2_state()) -> no_return()).
235-
-spec(system_terminate/4 :: (_, _, _, gs2_state()) -> no_return()).
229+
-spec handle_common_termination(any(), atom(), gs2_state()) -> no_return().
230+
-spec hibernate(gs2_state()) -> no_return().
231+
-spec pre_hibernate(gs2_state()) -> no_return().
232+
-spec system_terminate(_, _, _, gs2_state()) -> no_return().
236233

237-
-type(millis() :: non_neg_integer()).
234+
-type millis() :: non_neg_integer().
238235

239236
%%%=========================================================================
240237
%%% API
@@ -276,18 +273,6 @@
276273
%% for handle_pre_hibernate/1 and handle_post_hibernate/1 will result
277274
%% in warnings (the same applied for the behaviour_info before).
278275

279-
-else.
280-
281-
-export([behaviour_info/1]).
282-
283-
behaviour_info(callbacks) ->
284-
[{init,1},{handle_call,3},{handle_cast,2},{handle_info,2},
285-
{terminate,2},{code_change,3}];
286-
behaviour_info(_Other) ->
287-
undefined.
288-
289-
-endif.
290-
291276
%%% -----------------------------------------------------------------
292277
%%% Starts a generic server.
293278
%%% start(Mod, Args, Options)
@@ -625,9 +610,7 @@ extend_backoff(undefined) ->
625610
undefined;
626611
extend_backoff({backoff, InitialTimeout, MinimumTimeout, DesiredHibPeriod}) ->
627612
{backoff, InitialTimeout, MinimumTimeout, DesiredHibPeriod,
628-
{erlang:phash2([node()]),
629-
time_compat:monotonic_time(),
630-
time_compat:unique_integer()}}.
613+
rand_compat:seed(exsplus)}.
631614

632615
%%%========================================================================
633616
%%% Internal functions
@@ -767,7 +750,7 @@ adjust_timeout_state(SleptAt, AwokeAt, {backoff, CurrentTO, MinimumTO,
767750
true -> lists:max([MinimumTO, CurrentTO div 2]);
768751
false -> CurrentTO
769752
end,
770-
{Extra, RandomState1} = random:uniform_s(Base, RandomState),
753+
{Extra, RandomState1} = rand_compat:uniform_s(Base, RandomState),
771754
CurrentTO1 = Base + Extra,
772755
{backoff, CurrentTO1, MinimumTO, DesiredHibPeriod, RandomState1}.
773756

src/mirrored_supervisor.erl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@
151151
initial_childspecs,
152152
child_order}).
153153

154-
%%----------------------------------------------------------------------------
155-
156-
-ifdef(use_specs).
157-
158154
%%--------------------------------------------------------------------------
159155
%% Callback behaviour
160156
%%--------------------------------------------------------------------------
@@ -200,15 +196,6 @@
200196
-spec create_tables() -> Result when
201197
Result :: 'ok'.
202198

203-
-else.
204-
205-
-export([behaviour_info/1]).
206-
207-
behaviour_info(callbacks) -> [{init,1}];
208-
behaviour_info(_Other) -> undefined.
209-
210-
-endif.
211-
212199
%%----------------------------------------------------------------------------
213200

214201
start_link(Group, TxFun, Mod, Args) ->

src/pmon.erl

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636

3737
-record(state, {dict, module}).
3838

39-
-ifdef(use_specs).
40-
4139
%%----------------------------------------------------------------------------
4240

4341
-export_type([?MODULE/0]).
@@ -47,17 +45,15 @@
4745

4846
-type(item() :: pid() | {atom(), node()}).
4947

50-
-spec(new/0 :: () -> ?MODULE()).
51-
-spec(new/1 :: ('erlang' | 'delegate') -> ?MODULE()).
52-
-spec(monitor/2 :: (item(), ?MODULE()) -> ?MODULE()).
53-
-spec(monitor_all/2 :: ([item()], ?MODULE()) -> ?MODULE()).
54-
-spec(demonitor/2 :: (item(), ?MODULE()) -> ?MODULE()).
55-
-spec(is_monitored/2 :: (item(), ?MODULE()) -> boolean()).
56-
-spec(erase/2 :: (item(), ?MODULE()) -> ?MODULE()).
57-
-spec(monitored/1 :: (?MODULE()) -> [item()]).
58-
-spec(is_empty/1 :: (?MODULE()) -> boolean()).
59-
60-
-endif.
48+
-spec new() -> ?MODULE().
49+
-spec new('erlang' | 'delegate') -> ?MODULE().
50+
-spec monitor(item(), ?MODULE()) -> ?MODULE().
51+
-spec monitor_all([item()], ?MODULE()) -> ?MODULE().
52+
-spec demonitor(item(), ?MODULE()) -> ?MODULE().
53+
-spec is_monitored(item(), ?MODULE()) -> boolean().
54+
-spec erase(item(), ?MODULE()) -> ?MODULE().
55+
-spec monitored(?MODULE()) -> [item()].
56+
-spec is_empty(?MODULE()) -> boolean().
6157

6258
new() -> new(erlang).
6359

src/priority_queue.erl

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,28 @@
4545

4646
%%----------------------------------------------------------------------------
4747

48-
-ifdef(use_specs).
49-
5048
-export_type([q/0]).
5149

5250
-type(q() :: pqueue()).
5351
-type(priority() :: integer() | 'infinity').
5452
-type(squeue() :: {queue, [any()], [any()], non_neg_integer()}).
5553
-type(pqueue() :: squeue() | {pqueue, [{priority(), squeue()}]}).
5654

57-
-spec(new/0 :: () -> pqueue()).
58-
-spec(is_queue/1 :: (any()) -> boolean()).
59-
-spec(is_empty/1 :: (pqueue()) -> boolean()).
60-
-spec(len/1 :: (pqueue()) -> non_neg_integer()).
61-
-spec(to_list/1 :: (pqueue()) -> [{priority(), any()}]).
62-
-spec(from_list/1 :: ([{priority(), any()}]) -> pqueue()).
63-
-spec(in/2 :: (any(), pqueue()) -> pqueue()).
64-
-spec(in/3 :: (any(), priority(), pqueue()) -> pqueue()).
65-
-spec(out/1 :: (pqueue()) -> {empty | {value, any()}, pqueue()}).
66-
-spec(out_p/1 :: (pqueue()) -> {empty | {value, any(), priority()}, pqueue()}).
67-
-spec(join/2 :: (pqueue(), pqueue()) -> pqueue()).
68-
-spec(filter/2 :: (fun ((any()) -> boolean()), pqueue()) -> pqueue()).
69-
-spec(fold/3 ::
70-
(fun ((any(), priority(), A) -> A), A, pqueue()) -> A).
71-
-spec(highest/1 :: (pqueue()) -> priority() | 'empty').
72-
73-
-endif.
55+
-spec new() -> pqueue().
56+
-spec is_queue(any()) -> boolean().
57+
-spec is_empty(pqueue()) -> boolean().
58+
-spec len(pqueue()) -> non_neg_integer().
59+
-spec to_list(pqueue()) -> [{priority(), any()}].
60+
-spec from_list([{priority(), any()}]) -> pqueue().
61+
-spec in(any(), pqueue()) -> pqueue().
62+
-spec in(any(), priority(), pqueue()) -> pqueue().
63+
-spec out(pqueue()) -> {empty | {value, any()}, pqueue()}.
64+
-spec out_p(pqueue()) -> {empty | {value, any(), priority()}, pqueue()}.
65+
-spec join(pqueue(), pqueue()) -> pqueue().
66+
-spec filter(fun ((any()) -> boolean()), pqueue()) -> pqueue().
67+
-spec fold
68+
(fun ((any(), priority(), A) -> A), A, pqueue()) -> A.
69+
-spec highest(pqueue()) -> priority() | 'empty'.
7470

7571
%%----------------------------------------------------------------------------
7672

0 commit comments

Comments
 (0)