Skip to content

Commit

Permalink
erts: Add some erlang:process_flag/2 functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
psyeugenic committed Jan 12, 2012
1 parent 0f70505 commit 41c0850
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions erts/emulator/beam/bif.c
Expand Up @@ -868,7 +868,7 @@ BIF_RETTYPE spawn_opt_1(BIF_ALIST_1)
if (is_tuple(limit)) {
tpl = tuple_val(limit);

if (*tp2 != make_arityval(2))
if (*tpl != make_arityval(2))
goto error;

/* reuse vars */
Expand Down Expand Up @@ -1636,6 +1636,9 @@ BIF_RETTYPE process_flag_2(BIF_ALIST_2)
BIF_RET(old_value);
}
else if (BIF_ARG_1 == am_limits) {
/* lots here can be refactored with spawn_opt
* this should be broken out
*/
if (is_tuple(BIF_ARG_2)) {
Eterm *tp = tuple_val(BIF_ARG_2);
if (arityval(tp[0]) == 2) {
Expand All @@ -1644,16 +1647,50 @@ BIF_RETTYPE process_flag_2(BIF_ALIST_2)
old_value = make_small(LIMIT_HEAP_SIZE(BIF_P));
LIMIT_HEAP_SIZE(BIF_P) = i;
BIF_RET(old_value);
} else {
goto error;
}
}
} else if (is_list(BIF_ARG_2)) {
/* will this be the real one? */
goto error;
} else {
goto error;

Eterm limits = BIF_ARG_2;
Eterm limit, arg, limitval;
Eterm *tpl;

while (is_list(limits)) {
limit = CAR(list_val(limits));
if (is_tuple(limit)) {
tpl = tuple_val(limit);

if (*tpl != make_arityval(2))
goto error;

arg = tpl[1];
limitval = tpl[2];

if (arg == am_heap_size && is_small(limitval)) {
Sint heap_size = signed_val(limitval);

if (heap_size < 0) {
goto error;
} else {
old_value = make_small(LIMIT_HEAP_SIZE(BIF_P));
LIMIT_HEAP_SIZE(BIF_P) = heap_size;
BIF_RET(old_value);
}
} else /* not heap_size */
goto error;
} else /* not a is_tuple */
goto error;

limits = CDR(list_val(limits));
}

/* is proper list
if (is_not_nil(limits)) {
goto error;
}
*/
}
goto error;
} else if (BIF_ARG_1 == am_min_bin_vheap_size) {
Sint i;
if (!is_small(BIF_ARG_2)) {
Expand Down

0 comments on commit 41c0850

Please sign in to comment.