int main (int argc, char *argv[]) { int i, j, b; bdescr *a[ARRSIZE]; srand(SEED); hs_init(&argc, &argv); // repeatedly sweep though the array, allocating new random-sized // objects and deallocating the old ones. for (i=0; i < LOOPS; i++) { for (j=0; j < ARRSIZE; j++) { if (i > 0) { IF_DEBUG(block_alloc, debugBelch("A%d: freeing %p, %d blocks @ %p\n", j, a[j], a[j]->blocks, a[j]->start)); freeGroup_lock(a[j]); DEBUG_ONLY(checkFreeListSanity()); } b = (rand() % MAXALLOC) + 1; a[j] = allocGroup_lock(b); IF_DEBUG(block_alloc, debugBelch("A%d: allocated %p, %d blocks @ %p\n", j, a[j], b, a[j]->start)); // allocating zero blocks isn't allowed DEBUG_ONLY(checkFreeListSanity()); } } for (j=0; j < ARRSIZE; j++) { freeGroup_lock(a[j]); } // this time, sweep forwards allocating new blocks, and then // backwards deallocating them. for (i=0; i < LOOPS; i++) { for (j=0; j < ARRSIZE; j++) { b = (rand() % MAXALLOC) + 1; a[j] = allocGroup_lock(b); IF_DEBUG(block_alloc, debugBelch("B%d,%d: allocated %p, %d blocks @ %p\n", i, j, a[j], b, a[j]->start)); DEBUG_ONLY(checkFreeListSanity()); } for (j=ARRSIZE-1; j >= 0; j--) { IF_DEBUG(block_alloc, debugBelch("B%d,%d: freeing %p, %d blocks @ %p\n", i, j, a[j], a[j]->blocks, a[j]->start)); freeGroup_lock(a[j]); DEBUG_ONLY(checkFreeListSanity()); } } DEBUG_ONLY(checkFreeListSanity()); hs_exit(); // will do a memory leak test exit(0); }
int c_main(void) { hs_init(0, 0); hsMain(); hs_exit(); return 0; }
void Foo_init (void) { int argc = 1; char *arg = ""; char **argv = &arg; hs_init(&argc, &argv); hs_add_root(__stginit_Foo); }
void pandoc_init() { int argc = 1; static char* args[] = {"libpandoc"}; char** argv = args; hs_init(&argc, &argv); }
int main(int argc, char *argv[]) { hs_init(&argc,&argv); // load test input int n1 = 5; TPoint proto[5] = {{0,0},{0.5,0},{1,0},{1,1},{0,1}}; int n2 = 4; TPoint target[4] = {{1.1,0.1},{1.1,0.9},{-0.1,0.9},{-0.1,0.1}}; // output int m; TPoint *res; double h[3][3]; hfun(n1,proto,n2,target,&m,&res,h); printf("%d\n", m); int k; for (k=0; k<m; k++) { printf("px=%f py=%f\n",res[k].x,res[k].y); } int j; for (j=0; j<3; j++) { for (k=0; k<3; k++) { printf("%f\n",h[j][k]); } } free(res); hs_exit(); return 0; }
int main (void) { /* set pin 5 of PORTB for output*/ DDRB |= _BV(DDB5); //D13 setupADC(); hs_init(); hs_start(SERIAL_PORT, BAUD); while (1) { if (hs_available(SERIAL_PORT)) { u8Value = hs_getChar(SERIAL_PORT); if (u8Value == 'h') { /* set pin 5 high to turn led on */ PORTB |= _BV(PORTB5); _delay_ms(BLINK_DELAY_MS); /* set pin 5 low to turn led off */ PORTB &= ~_BV(PORTB5); _delay_ms(BLINK_DELAY_MS); } } } return 0; }
int SDL_main(int argc, char *argv[]) { int i; #ifdef __APPLE__ void * pool = objc_msgSend((id)objc_lookUpClass("NSAutoreleasePool"), sel_getUid("alloc")); objc_msgSend(pool, sel_getUid("init")); #endif hs_init(&argc, &argv); #ifdef __GLASGOW_HASKELL__ hs_add_root(__stginit_RectanglesMain); #endif rectangles_main(); hs_exit(); #ifdef __APPLE__ objc_msgSend(pool, sel_getUid("release")); #endif return 0; }
int main (int argc, char *argv[]) { hs_init(&argc,&argv); // check that we can call hs_thread_done() without having made any // Haskell calls: hs_thread_done(); // check that we can call hs_thread_done() and then make another Haskell // call: int i; for (i=0; i < 1000; i++) { f(3); hs_thread_done(); } // check that we can call hs_thread_done() twice: hs_thread_done(); hs_thread_done(); // check that hs_thread_done() from child threads works: pthread_t pid; for (i=0; i < 1000; i++) { pthread_create(&pid, NULL, thread, NULL); pthread_join(pid, NULL); } hs_exit(); exit(0); }
int ark_init(void) { int argc = 2; char *argv[] = { "+RTS", "-A32m", 0 }; char **pargv = argv; // Initialize Haskell runtime hs_init(&argc, &pargv); }
static void library_init(void) { /* This seems to be a no-op, but it makes the GHCRTS envvar work. */ static char *argv[] = { STR(CalculatorFinance) ".so", 0 }, **argv_ = argv; static int argc = 1; hs_init(&argc, &argv_); hs_add_root(CAT(__stginit_, CalculatorFinance)); }
static void do_hs_init() { int argc = 1; char *name = "mod_ghc"; // char *argv[] = { name , "+RTS","--install-signal-handlers=no",NULL}; char *argv[] = { name , NULL}; char **argvx = (char **)argv; fprintf(stderr, "============> hs_init %d\n", getpid() ); hs_init(&argc, &argvx); }
static void library_init(void) { /* This seems to be a no-op, but it makes the GHCRTS envvar work. */ static char *argv[] = { STR(MODULE) ".so", 0 }, **argv_ = argv; static int argc = 1; printf("Loading library OfxPlugin and initializing rts\n"); hs_init(&argc, &argv_); hs_add_root(CAT(__stginit_, MODULE)); }
EQ_API HsBool eq_begin_runtime() { char **argv = internArgv; int argc = 1; lastResult = NULL; hs_init(&argc, &argv); hs_add_root(__stginit_FormulaDll); return HS_BOOL_TRUE; }
int main(int argc, char *argv[]) { hs_init(&argc, &argv); test_fixture_start(); run_test(basic_test); run_test(foreignptr_test); test_fixture_end(); hs_exit(); return 0; }
int main(int argc, char *argv[]) { // Haskell setup hs_init(&argc, &argv); #ifdef __GLASGOW_HASKELL__ hs_add_root(__stginit_DhekziLauncher); #endif launch(); }
int main(int argc, char *argv[]) { hs_init(&argc,&argv); if (jhc_setjmp(&jhc_uncaught)) jhc_error("Uncaught Exception"); else _amain(); hs_exit(); return 0; }
void safe_hs_init() { char ** argv = malloc(sizeof(char**) * 1); int argc = 1; argv[0]="haskell_extension"; if (! loaded) { loaded=1; // printf("really loading haskell runtime\n"); hs_init(&argc, &argv); } }
HsBool mylib_init(void) { int argc = 0; // char *argv[] = { "+RTS", "-A32m", NULL }; char *argv[] = { NULL }; char **pargv = argv; hs_init(&argc, &pargv); return HS_BOOL_TRUE; }
int main(int argc, char *argv[]) { int *p; hs_init(&argc, &argv); p = hs_eval_i("\"an ill-typed string\""); if (p == NULL) printf("failed!\n"); else printf("%d\n",*p); hs_exit(); return 0; }
int main(int argc, char *argv[]) { int *p; hs_init(&argc, &argv); p = hs_eval_i("show $ case 1 + 2 in{-wrong-} x -> x"); if (p == NULL) printf("failed!\n"); else printf("%d\n",*p); hs_exit(); return 0; }
int main(int argc, char *argv[]) { char *p; hs_init(&argc, &argv); p = hs_eval_s("show $ let fibs = 1:1:zipWith (+) fibs (tail fibs) in fibs !! 20"); if (p == NULL) printf("failed!\n"); else printf("%s\n",p); hs_exit(); return 0; }
void HsStart() { int argc = 1; char* argv[] = {"ghcDll", NULL}; // argv must end with NULL // Initialize Haskell runtime char** args = argv; hs_init(&argc, &args); // Tell Haskell about all root modules hs_add_root(__stginit_Voidp); }
int main(int argc, char *argv[]) { hs_init(&argc, &argv); #ifdef __GLASGOW_HASKELL__ hs_add_root(__stginit_SDLWrapper); #endif haskell_main(); hs_exit(); return 0; }
void haskell_init(void) { int argc = 1; char* argv[] = {HS_PLUGIN_NAME, NULL}; // argv must end with NULL // Initialize Haskell runtime char** args = argv; hs_init(&argc, &args); // Tell Haskell about all root modules hs_add_root(__stginit_Main); }
static void cpu_pre_run(void) { int cpunum; logerror("Machine reset\n"); begin_resource_tracking(); /* read hi scores information from hiscore.dat */ hs_open(Machine->gamedrv->name); hs_init(); /* initialize the various timers (suspends all CPUs at startup) */ cpu_inittimers(); watchdog_counter = -1; /* reset sound chips */ sound_reset(); /* first pass over CPUs */ for (cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++) { /* enable all CPUs (except for audio CPUs if the sound is off) */ if (!(Machine->drv->cpu[cpunum].cpu_flags & CPU_AUDIO_CPU) || Machine->sample_rate != 0) cpunum_resume(cpunum, SUSPEND_ANY_REASON); else cpunum_suspend(cpunum, SUSPEND_REASON_DISABLE, 1); /* reset the interrupt state */ cpuint_reset_cpu(cpunum); /* reset the total number of cycles */ cpu[cpunum].totalcycles = 0; cpu[cpunum].localtime = 0; } vblank = 0; /* do this AFTER the above so machine_init() can use cpu_halt() to hold the */ /* execution of some CPUs, or disable interrupts */ if (Machine->drv->machine_init) (*Machine->drv->machine_init)(); /* now reset each CPU */ for (cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++) cpunum_reset(cpunum, Machine->drv->cpu[cpunum].reset_param, cpu_irq_callbacks[cpunum]); /* reset the globals */ cpu_vblankreset(); current_frame = 0; state_save_dump_registry(); }
//void __attribute__ ((dllexport)) void __cdecl HsStart() { // Initialise all external functions. int argc = 1; char * argv[] = {"ghcDll", NULL}; char ** args = argv; hs_init(&argc, &args); //hs_add_root(__stginit_MorphologicalFilter); //HsInitCallbacks(NULL); }
/* Ensure that global variables are initialized. */ static void sparkle_init(JNIEnv *env, int init_rts) { int argc = 0; char *argv[] = { NULL }; /* or e.g { "+RTS", "-A1G", "-H1G", NULL }; */ char **pargv = argv; pthread_spin_lock(&sparkle_init_lock); if(!sparkle_initialized) { if(init_rts) hs_init(&argc, &pargv); sparkle_initialized = 1; } pthread_spin_unlock(&sparkle_init_lock); }
int main(int argc, char *argv[]) { int i; hs_init(&argc, &argv); for (i = 0; i < 5; i++) { printf("%d\n", foo(2500)); } hs_exit(); return 0; }
int main (void) { setupADC(); hs_init(); hs_start(SERIAL_PORT, BAUD); while (1) { u8Value = adc_read(ADC_IN); hs_writeChar(SERIAL_PORT, 'h'); hs_writeChar(SERIAL_PORT, '\n'); _delay_ms(1000); } return 0; }
int main(int argc, char *argv[]) { int i; hs_init(&argc, &argv); #ifdef __GLASGOW_HASKELL__ hs_add_root(__stginit_Safe); #endif printf("Main thread: %d\n", (int)pthread_self()); i = fibonacci_hs(42); printf("Fibonacci: %d\n", i); print_numcaps(); hs_exit(); return 0; }