int main(int argc, char *argv[]) { if (argc<2) { printf("I need 2 arguments to add\n"); return 1; } int x = atoi(argv[1]); int y = atoi(argv[2]); cl_boot(argc, argv); read_VV(OBJNULL, init_add); int sum = lisp_add(x, y); printf("%d\n", sum); cl_shutdown(); return 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; }
static void initialize_ecl(void) { int fake_argc = 1; char *fake_argv[] = {"InternalPlugin", NULL}; if (g_cl_booted == FALSE) { // Initialize ECL cl_boot(fake_argc, fake_argv); // Use the UFFI package before we do anything. cl_use_package(1, (cl_find_package(ecl_make_keyword("UFFI")))); // Initalize the Common Lisp plugin library. // Magic name is previously known extern void I_libfoo(cl_object); read_VV(OBJNULL, I_libfoo); g_cl_booted = TRUE; } }
int ecl_boot(const char *root_dir) { int argc = 1; char *argv[256]; argv[0] = "ecl"; GC_allow_register_threads(); GC_register_my_thread((const struct GC_stack_base *)argv); GC_stackbottom = (void*)(argv+255); setenv("ECLDIR", "", 1); cl_boot(argc, argv); main_lib_ECL_HELP(); main_lib_ASDF(); main_lib_SOCKETS(); main_lib_IPHONEPSYSTEM(); si_select_package(ecl_make_simple_base_string("CL-USER", 7)); char tmp[2048]; sprintf(tmp, "(setq *default-pathnames-defaults* #p\"%s\")", root_dir); si_safe_eval(3, c_string_to_object(tmp), Cnil, OBJNULL); init_callbacks_registry(); ecl_toplevel(root_dir); return 0; }
ECL::ECL() { char *args[] = {"embench"}; cl_boot(1, args); }