Exemple #1
0
const LV2_Descriptor*
lv2_descriptor(uint32_t index)
{
	int lv2_desc_index;

	initialize_plugin_internals();
	initialize_ecl();

	// Trampoline this request to the ECL side, then unpack the resultant
	// return value into something suitable for the caller.

	cl_object obj = 
		cl_funcall(2, c_string_to_object("lv2-descriptor"),
			MAKE_FIXNUM(index));

	printf("C: lv2_descriptor got from lisp:");
	cl_pprint(1, obj);
	cl_princ(1, c_string_to_object("#\\Newline"));

	if (obj == Cnil) {
		// Don't make an association in this case.
		return NULL;
	}

	// Associate the lisp description with a C address of a real LV2_Descriptor
	lv2_desc_index = da_allocate();
	da_associate(lv2_desc_index, obj);

	// The application will use this to talk about this specific plugin.
	return da_get_address(lv2_desc_index);
}
Exemple #2
0
static void primop_table_ref(long argc) {
    object o = sp[1];
    long i = the_long(2,o);
    o = *sp++;
    TYPE_CHECK(TABLE_P(o),1,"table",o);
    if (i < 0 || i >= TABLE_COUNT(o))
        error(MAKE_FIXNUM(i),"index out of range");
    *sp = TABLE_ELEMENTS(o)[i*2+1];
}
Exemple #3
0
static void primop_substring_ix(long argc) {
	object s1 = *sp++;
	object s2 = *sp;
	char *s;
	TYPE_CHECK(STRING_P(s1),1,"string",s1);
	TYPE_CHECK(STRING_P(s2),1,"string",s2);
	s = strstr(STRING_VALUE(s1), STRING_VALUE(s2));
	if (s)
		*sp = MAKE_FIXNUM(s - STRING_VALUE(s1));
	else
		*sp = false_object;
}
Exemple #4
0
int main(int narg, char **argv)
{
        pthread_t child_thread;
        int i, code;

        /*
         * First of all, we have to initialize the ECL environment.
         * This should be done from the main thread.
         */
        cl_boot(narg, argv);

        /*
         * Here we spawn 10 threads using the OS functions. The
         * current version is for Unix and uses pthread_create.
         * Since we have included <gc.h>, pthread_create will be
         * replaced with the appropiate routine from the garbage
         * collector.
         */
        cl_object sym_print = c_string_to_object("PRINT");

        /*
         * This array will keep the forms we want to evaluate from
         * being garbage collected.
         */
        volatile cl_object forms[4];

        for (i = 0; i < 4; i++) {
                forms[i] = cl_list(2, sym_print, MAKE_FIXNUM(i));
                code = pthread_create(&child_thread, NULL, thread_entry_point,
                                      (void*)forms[i]);
                if (code) {
                        printf("Unable to create thread\n");
                        exit(1);
                }
        }

        /*
         * Here we wait for the last thread to finish.
         */
        pthread_join(child_thread, NULL);

        return 0;
}
Exemple #5
0
static void primop_table_count(long argc) {
    object o = *sp;
    TYPE_CHECK(TABLE_P(o),1,"table",o);
    *sp = MAKE_FIXNUM(TABLE_COUNT(o));
}
Exemple #6
0
static void primop_char_to_integer(long argc) {
	unsigned char c = the_char(1,sp[0]);
	*sp = MAKE_FIXNUM(c);
}
Exemple #7
0
static void primop_string_length(long argc) {
	object o = *sp;
	TYPE_CHECK(STRING_P(o),1,"string",o);
	*sp = MAKE_FIXNUM(STRING_LENGTH(o));
}
Exemple #8
0
void arch_set_pseudo_atomic_interrupted(os_context_t *context)
{
    /* 0x000f0001 is the syscall number for BREAK_POINT. */
    SetSymbolValue(PSEUDO_ATOMIC_INTERRUPTED,MAKE_FIXNUM(0x000f0001),0);
}