Skip to content

Commit

Permalink
erl_arith.c: Remove obsolete macros
Browse files Browse the repository at this point in the history
The MAX() macro is defined in another header file.

The DECLARE_TMP() macro was needed for the halfword runtime system.
  • Loading branch information
bjorng committed Aug 25, 2023
1 parent d469b0a commit 164c9cd
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions erts/emulator/beam/erl_arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@
#include "big.h"
#include "atom.h"

#ifndef MAX
# define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif

#define DECLARE_TMP(VariableName,N,P) Eterm VariableName[2]
#define ARG_IS_NOT_TMP(Arg,Tmp) ((Arg) != make_big((Tmp)))

static ERTS_INLINE void maybe_shrink(Process* p, Eterm* hp, Eterm res, Uint alloc)
{
Uint actual;
Expand Down Expand Up @@ -154,7 +147,7 @@ erts_shift(Process* p, Eterm arg1, Eterm arg2, int right)
{
Sint i;
Sint ires;
DECLARE_TMP(tmp_big1,0,p);
Eterm tmp_big1[2];
Eterm* bigp;
Uint need;

Expand Down Expand Up @@ -720,16 +713,15 @@ erts_mixed_times(Process* p, Eterm arg1, Eterm arg2)
} else if (arg2 == SMALL_ONE) {
return(arg1);
} else {
DeclareTmpHeap(big_res,3,p);
UseTmpHeap(3,p);
Eterm big_res[3];

/*
* The following code is optimized for the case that
* result is small (which should be the most common case
* in practice).
*/
res = small_times(signed_val(arg1), signed_val(arg2), big_res);
if (is_small(res)) {
UnUseTmpHeap(3,p);
return res;
} else {
/*
Expand All @@ -751,7 +743,6 @@ erts_mixed_times(Process* p, Eterm arg1, Eterm arg2)
if (arity > 1) {
*hp = big_res[2];
}
UnUseTmpHeap(3,p);
return res;
}
}
Expand Down Expand Up @@ -1162,9 +1153,7 @@ int erts_int_div_rem(Process* p, Eterm arg1, Eterm arg2, Eterm *q, Eterm *r)
Eterm quotient, remainder;
Eterm lhs, rhs;
int cmp;

DECLARE_TMP(tmp_big1,0,p);
DECLARE_TMP(tmp_big2,1,p);
Eterm tmp_big1[2], tmp_big2[2];

lhs = arg1;
rhs = arg2;
Expand Down Expand Up @@ -1244,8 +1233,7 @@ int erts_int_div_rem(Process* p, Eterm arg1, Eterm arg2, Eterm *q, Eterm *r)
Eterm
erts_int_div(Process* p, Eterm arg1, Eterm arg2)
{
DECLARE_TMP(tmp_big1,0,p);
DECLARE_TMP(tmp_big2,1,p);
Eterm tmp_big1[2], tmp_big2[2];
int ires;

switch (NUMBER_CODE(arg1, arg2)) {
Expand Down Expand Up @@ -1296,8 +1284,7 @@ erts_int_div(Process* p, Eterm arg1, Eterm arg2)
Eterm
erts_int_rem(Process* p, Eterm arg1, Eterm arg2)
{
DECLARE_TMP(tmp_big1,0,p);
DECLARE_TMP(tmp_big2,1,p);
Eterm tmp_big1[2], tmp_big2[2];
int ires;

switch (NUMBER_CODE(arg1, arg2)) {
Expand Down Expand Up @@ -1348,8 +1335,7 @@ erts_int_rem(Process* p, Eterm arg1, Eterm arg2)

Eterm erts_band(Process* p, Eterm arg1, Eterm arg2)
{
DECLARE_TMP(tmp_big1,0,p);
DECLARE_TMP(tmp_big2,1,p);
Eterm tmp_big1[2], tmp_big2[2];
Eterm* hp;
dsize_t sz1, sz2, sz;
int need;
Expand Down Expand Up @@ -1391,8 +1377,7 @@ Eterm erts_band(Process* p, Eterm arg1, Eterm arg2)

Eterm erts_bor(Process* p, Eterm arg1, Eterm arg2)
{
DECLARE_TMP(tmp_big1,0,p);
DECLARE_TMP(tmp_big2,1,p);
Eterm tmp_big1[2], tmp_big2[2];
Eterm* hp;
int need;

Expand All @@ -1419,8 +1404,7 @@ Eterm erts_bor(Process* p, Eterm arg1, Eterm arg2)

Eterm erts_bxor(Process* p, Eterm arg1, Eterm arg2)
{
DECLARE_TMP(tmp_big1,0,p);
DECLARE_TMP(tmp_big2,1,p);
Eterm tmp_big1[2], tmp_big2[2];
Eterm* hp;
int need;

Expand Down

0 comments on commit 164c9cd

Please sign in to comment.