New fast list functions

This commit is contained in:
Justin Ethier 2018-12-04 22:54:53 -05:00
parent 1a586b188c
commit 07dd9c7ef5
3 changed files with 30 additions and 42 deletions

View file

@ -397,6 +397,9 @@ object Cyc_fast_sum(void *data, object ptr, object x, object y);
object Cyc_fast_sub(void *data, object ptr, object x, object y);
object Cyc_fast_mul(void *data, object ptr, object x, object y);
object Cyc_fast_div(void *data, object ptr, object x, object y);
object Cyc_fast_list_2(void *data, object ptr, object x, object y);
object Cyc_fast_list_3(void *data, object ptr, object a1, object a2, object a3);
object Cyc_fast_list_4(void *data, object ptr, object a1, object a2, object a3, object a4);
object Cyc_bit_unset(void *data, object n1, object n2);
object Cyc_bit_set(void *data, object n1, object n2);
object Cyc_num_op_va_list(void *data, int argc,

View file

@ -1153,48 +1153,6 @@ typedef struct { pair_type a; pair_type b; } list_2_type;
typedef struct { pair_type a; pair_type b; pair_type c;} list_3_type;
typedef struct { pair_type a; pair_type b; pair_type c; pair_type d;} list_4_type;
#define set_list_2_as_expr(l, a1, a2) \
(set_pair_as_expr(&(((list_2_type *)(l))->b), a2, NULL), \
set_pair_as_expr(&(((list_2_type *)(l))->a), a1, &(((list_2_type *)(l))->b)))
// DEPRECATED
#define make_list_1(l, a1) \
make_pair(l, a1, NULL);
#define make_list_2(l, a1, a2) \
make_pair(l##__2, a2, NULL); \
make_pair(l, a1, &l##__2);
#define make_list_3(l, a1, a2, a3) \
make_pair(l##__3, a3, NULL); \
make_pair(l##__2, a2, &l##__3); \
make_pair(l, a1, &l##__2);
#define make_list_4(l, a1, a2, a3, a4) \
make_pair(l##__4, a4, NULL); \
make_pair(l##__3, a3, &l##__4); \
make_pair(l##__2, a2, &l##__3); \
make_pair(l, a1, &l##__2);
#define alloca_list_1(l, a1) \
alloca_pair(l, a1, NULL);
#define alloca_list_2(l, a1, a2) \
alloca_pair(l##__2, a2, NULL); \
alloca_pair(l, a1, l##__2);
#define alloca_list_3(l, a1, a2, a3) \
alloca_pair(l##__3, a3, NULL); \
alloca_pair(l##__2, a2, l##__3); \
alloca_pair(l, a1, l##__2);
#define alloca_list_4(l, a1, a2, a3, a4) \
alloca_pair(l##__4, a4, NULL); \
alloca_pair(l##__3, a3, l##__4); \
alloca_pair(l##__2, a2, l##__3); \
alloca_pair(l, a1, l##__2);
// END DEPRECATED
/**
* Create a pair with a single value.
* This is useful to create an object that can be modified.

View file

@ -1259,6 +1259,33 @@ list assoc_cdr(void *data, object x, list l)
}
/* END member and assoc */
object Cyc_fast_list_2(void *data, object ptr, object a1, object a2)
{
list_2_type *l = (list_2_type *)ptr;
set_pair( ((pair)(&(l->b))), a2, NULL);
set_pair( ((pair)(&(l->a))), a1, ((pair)(&(l->b))));
return ptr;
}
object Cyc_fast_list_3(void *data, object ptr, object a1, object a2, object a3)
{
list_3_type *l = (list_3_type *)ptr;
set_pair( ((pair)(&(l->c))), a3, NULL);
set_pair( ((pair)(&(l->b))), a2, ((pair)(&(l->c))));
set_pair( ((pair)(&(l->a))), a1, ((pair)(&(l->b))));
return ptr;
}
object Cyc_fast_list_4(void *data, object ptr, object a1, object a2, object a3, object a4)
{
list_4_type *l = (list_4_type *)ptr;
set_pair( ((pair)(&(l->d))), a4, NULL);
set_pair( ((pair)(&(l->c))), a3, ((pair)(&(l->d))));
set_pair( ((pair)(&(l->b))), a2, ((pair)(&(l->c))));
set_pair( ((pair)(&(l->a))), a1, ((pair)(&(l->b))));
return ptr;
}
// Internal function, do not use this anywhere outside the runtime
object Cyc_heap_alloc_port(void *data, port_type *stack_p)
{