Example #1
0
void *wxe_main_loop(void *vpdl)
{
  int result; 
  int  argc = 1;
  char * temp = (char *) "Erlang\0";
  char ** argv = &temp;
  ErlDrvPDL pdl = (ErlDrvPDL) vpdl;
  
  driver_pdl_inc_refc(pdl);

  // ErlDrvSysInfo einfo;
  // driver_system_info(&einfo, sizeof(ErlDrvSysInfo));
  // Disable floating point execption if they are on.
  // This should be done in emulator but it's not in yet.
#ifndef _WIN32
  erts_thread_disable_fpe();
#endif
  
  result = wxEntry(argc, argv);
  // fprintf(stderr, "WXWidgets quits main loop %d \r\n", result);
  if(result >= 0 && wxe_status == WXE_INITIATED) {
    /* We are done try to make a clean exit */
    wxe_status = WXE_EXITED;
    driver_pdl_dec_refc(pdl);
    erl_drv_thread_exit(NULL);
    return NULL;
  } else {
    erl_drv_mutex_lock(wxe_status_m);
    wxe_status = WXE_ERROR;
    erl_drv_cond_signal(wxe_status_c);
    erl_drv_mutex_unlock(wxe_status_m);
    driver_pdl_dec_refc(pdl);
    return NULL;    
  }
}
Example #2
0
File: sys.c Project: weisslj/otp
void
erts_sys_main_thread(void)
{
    erts_thread_disable_fpe();
#ifdef __DARWIN__
    initialize_darwin_main_thread_pipes();
#endif
    /* Become signal receiver thread... */
#ifdef ERTS_ENABLE_LOCK_CHECK
    erts_lc_set_thread_name("signal_receiver");
#endif

    smp_sig_notify(0); /* Notify initialized */

    /* Wait for a signal to arrive... */

#ifdef __DARWIN__
    while (1) {
	/*
	 * The wx driver needs to be able to steal the main thread for Cocoa to
	 * work properly.
	 */
	fd_set readfds;
	int res;

	FD_ZERO(&readfds);
	FD_SET(erts_darwin_main_thread_pipe[0], &readfds);
	res = select(erts_darwin_main_thread_pipe[0] + 1, &readfds, NULL, NULL, NULL);
	if (res > 0 && FD_ISSET(erts_darwin_main_thread_pipe[0],&readfds)) {
	    void* (*func)(void*);
	    void* arg;
	    void *resp;
            res = read(erts_darwin_main_thread_pipe[0],&func,sizeof(void* (*)(void*)));
            if (res != sizeof(void* (*)(void*)))
                break;
            res = read(erts_darwin_main_thread_pipe[0],&arg,sizeof(void*));
            if (res != sizeof(void*))
                break;
	    resp = (*func)(arg);
	    write(erts_darwin_main_thread_result_pipe[1],&resp,sizeof(void *));
	}

        if (res == -1 && errno != EINTR)
            break;
    }
    /* Something broke with the main thread pipe, so we ignore it for now.
       Most probably erts has closed this pipe and is about to exit. */
#endif /* #ifdef __DARWIN__ */

    while (1) {
#ifdef DEBUG
	int res =
#else
	(void)
#endif
	    select(0, NULL, NULL, NULL, NULL);
	ASSERT(res < 0);
	ASSERT(errno == EINTR);
    }
}
Example #3
0
File: sys.c Project: 3112517927/otp
static void
thr_create_prepare_child(void *vtcdp)
{
    erts_thr_create_data_t *tcdp = (erts_thr_create_data_t *) vtcdp;

#ifdef ERTS_ENABLE_LOCK_COUNT
    erts_lcnt_thread_setup();
#endif

#ifndef NO_FPE_SIGNALS
    /*
     * We do not want fp exeptions in other threads than the
     * scheduler threads. We enable fpe explicitly in the scheduler
     * threads after this.
     */
    erts_thread_disable_fpe();
#endif

    erts_sched_bind_atthrcreate_child(tcdp->sched_bind_data);
}
Example #4
0
void *wxe_main_loop(void *vpdl)
{
    int result;
    int  argc = 1;
    char * temp = (char *) "Erlang";
    char * argv[] = {temp,NULL};
    ErlDrvPDL pdl = (ErlDrvPDL) vpdl;

    driver_pdl_inc_refc(pdl);

    // Disable floating point execption if they are on.
    // This should be done in emulator but it's not in yet.
#ifndef _WIN32
    erts_thread_disable_fpe();
#else
    // Setup that wxWidgets should look for cursors and icons in
    // this dll and not in werl.exe (which is the default)
    HMODULE WXEHandle = GetModuleHandle(_T("wxe_driver"));
    wxSetInstance((HINSTANCE) WXEHandle);
#endif

    wxe_ps_init();
    result = wxEntry(argc, argv);
    // fprintf(stderr, "WXWidgets quits main loop %d \r\n", result);
    if(result >= 0 && wxe_status == WXE_INITIATED) {
        /* We are done try to make a clean exit */
        wxe_status = WXE_EXITED;
        driver_pdl_dec_refc(pdl);
#ifndef __DARWIN__
        erl_drv_thread_exit(NULL);
#endif
        return NULL;
    } else {
        erl_drv_mutex_lock(wxe_status_m);
        wxe_status = WXE_ERROR;
        erl_drv_cond_signal(wxe_status_c);
        erl_drv_mutex_unlock(wxe_status_m);
        driver_pdl_dec_refc(pdl);
        return NULL;
    }
}