Пример #1
0
int main(int argc,char** argv)
{
  SOCKET_INIT
    signal(SIGINT,ctrl_c);
  int ret = main_func(argc,argv);
#ifdef COMMAND_MODE
  while(1)
  {
    char input_buf[8192]={0};
    char *argv_list[ARGC_MAXCOUNT]={"lcx"};
    printf(">");
    int argc_count = 1;
    int flag = 0;
    int i;
    for(i=0;i<8192;++i)
    {
      input_buf[i] = getchar();
      if(input_buf[i] == '\n' || input_buf[i] == -1 )
      {
        input_buf[i] = '\0';
      }
      if(input_buf[i]=='\0' || argc_count>=ARGC_MAXCOUNT-2)
      {
        break;
      }
      if(flag ==0 && input_buf[i]!=' ' && input_buf[i]!='\0' )
      {
        flag = 1;
        argv_list[argc_count] = input_buf+i;
        ++argc_count;
      }
      else if(flag ==1 && (input_buf[i]==' ' || input_buf[i]=='\0') )
      {
        flag = 0;
        input_buf[i] = '\0';
      }
    }
    argv_list[argc_count] = NULL;
#ifdef LCX_DEBUG
    putchar('\n');
    for(i=0;i<argc_count;++i)
    {
      printf("argv[%d]: %s\n",i,argv_list[i]);
    }
#endif
    ret = main_func(argc_count,argv_list);
  }
#endif
  return ret;
}
Пример #2
0
int 
main(int argc, char *argv[]) {
	/* ORBit2-2.7.6 leaks on shutdown with about 700KB */
	/* LEAK_DETECT_WITH_TOLERANCE (1, main_func (argc,argv), 20); */
	main_func (argc, argv);
	exit (0);
}
Пример #3
0
int main(int argc_, char ** argv_)
{
#if USE_EMBEDDED_COMPILER
    if (argc_ >= 2 && 0 == strcmp(argv_[1], "-cc1"))
        return mainEntryClickHouseClang(argc_, argv_);
#endif

#if USE_TCMALLOC
    /** Without this option, tcmalloc returns memory to OS too frequently for medium-sized memory allocations
      *  (like IO buffers, column vectors, hash tables, etc.),
      *  that lead to page faults and significantly hurts performance.
      */
    MallocExtension::instance()->SetNumericProperty("tcmalloc.aggressive_memory_decommit", false);
#endif

    std::vector<char *> argv(argv_, argv_ + argc_);

    /// Print a basic help if nothing was matched
    MainFunc main_func = printHelp;

    for (auto & application : clickhouse_applications)
    {
        if (isClickhouseApp(application.first, argv))
        {
            main_func = application.second;
            break;
        }
    }

    return main_func(static_cast<int>(argv.size()), argv.data());
}
Пример #4
0
template<class T> static void wrapper_func(const T *U, const T *E, int32_t *L, const int nLabels, const int nNodes, const int Eoffset, T *en, const int nChains, const int Eoff) 
{
    int n, m = 2 * nLabels * sizeof(T) + nLabels * (nNodes-1) * sizeof(int);
    int8_t *tmp_buf = (int8_t *)mxMalloc(m*omp_get_num_procs());
    /* Use all the processors we can */
    if (en) {
#pragma omp parallel for if (nChains > 10) num_threads(omp_get_num_procs())
        for (n = 0; n < nChains; ++n) {
            en[n] = main_func(&U[n*nNodes*nLabels], &E[n*Eoff], &L[n*nNodes], nLabels, nNodes, Eoffset, tmp_buf+m*omp_get_thread_num());
        }
    } else {
#pragma omp parallel for if (nChains > 10) num_threads(omp_get_num_procs())
        for (n = 0; n < nChains; ++n) {
            main_func(&U[n*nNodes*nLabels], &E[n*Eoff], &L[n*nNodes], nLabels, nNodes, Eoffset, tmp_buf+m*omp_get_thread_num());
        }
    }
    mxFree(tmp_buf);
}
Пример #5
0
int do_run_main(int (*main_func)(AppData&), AppData& app_data)
{
	std::ostream& errstr = app_data.errstr();
	try
	{
		return main_func(app_data);
	}
	catch(ShaderVariableError& sve)
	{
		errstr << "Shader variable error";
		print_error_common(sve, errstr);
		sve.Cleanup();
	}
	catch(ProgramBuildError& pbe)
	{
		errstr << "Program build error";
		print_error_common(pbe, errstr);
		errstr << "Build log:" << std::endl;
		errstr << pbe.Log() << std::endl;
		pbe.Cleanup();
	}
	catch(LimitError& le)
	{
		errstr << "Limit error";
		print_error_common(le, errstr);
		errstr << "Value " << le.Value() << " exceeds limit ";
		errstr << le.Limit() << std::endl;
		le.Cleanup();
	}
	catch(Error& err)
	{
		errstr << "GL error";
		print_error_common(err, errstr);
		err.Cleanup();
	}
	catch(std::system_error& sye)
	{
		errstr << "System error";
		print_std_error_common(sye, errstr);
		errstr << "Error code: " << sye.code() << std::endl;
		errstr << std::endl;
	}
	catch(std::runtime_error& rte)
	{
		errstr << "Runtime error";
		print_std_error_common(rte, errstr);
		errstr << std::endl;
	}
	catch(std::exception& se)
	{
		errstr << "Error";
		print_std_error_common(se, errstr);
		errstr << std::endl;
	}
	return 1;
}
Пример #6
0
int main(int argc, char* argv[]) {

	concurrit::Concurrit::InstallSignalHandler();

	MainFuncType main_func = reinterpret_cast<MainFuncType>(dlsym(RTLD_DEFAULT, "__main__"));
	if(main_func == NULL) {
		assert("dlsym init of __main__ failed.\n");
	}
	dlerror(); // Clear any existing error

	// do call
	return main_func(argc, argv);
}
Пример #7
0
static int child_main(HANDLE hev,int (*main_func)(int, char **), int argc, char **argv)
{
	// Keep EVT_RUNNING open until exit
	running_event = hev;

	// Install console handler
	SetConsoleCtrlHandler(child_console_handler, TRUE/*add*/);

	// Install restart handler
	atexit(child_exit);

	// Continue in main_func() to do the real work
	return main_func(argc, argv);
}
Пример #8
0
/** Start the main task */
static int main_worker (int id, 
                        int(*main_func)(struct generic_task_desc *,void*),
                        void * main_args) {

    workers[id].worker_thr = thread_self();
    workers[id].id = id;
    workers[id].core_id = disp_get_core_id();

    struct generic_task_desc * _tweed_top_ = NULL;
    
    thread_set_tls(&(workers[id]));

    int ret = main_func(_tweed_top_, main_args);
    
    // signal exit to other workers 
    do_quit = 1;

    return ret;
}
Пример #9
0
		int operator()(void) const
		{
			main_func(data);
			return 0;
		}
Пример #10
0
PRIVATE void setup_one_class( char *dllname ) {

    unsigned long i;
    //LPluginData *plugindata = safe_malloc( sizeof( LPluginData ) );
    void *dll_handle;
    AEMainFunc main_func;
    AEffect *tmp_effect;
    InputSignalDescriptor *inputdescr;
    OutputSignalDescriptor *outputdescr;
    ControlDescriptor *controls;
    char *generatorpath;

    GeneratorClass *k;
    
    char *basename = g_path_get_basename( dllname );
    basename[strlen(basename)-4] = 0;

    dll_handle = WineLoadLibrary( dllname );
    main_func = WineGetProcAddress( dll_handle, "main" );
    
    
    tmp_effect = main_func( &master_callback );
    
    


//    for( i=0; i<psDescriptor->PortCount; i++ ) {
//	
//	LADSPA_PortDescriptor PortDescriptor=psDescriptor->PortDescriptors[i];
//
//	if( LADSPA_IS_PORT_INPUT( PortDescriptor ) ) 
//
//	    if( LADSPA_IS_PORT_CONTROL(PortDescriptor) )
//		plugindata->inevent = g_list_append( plugindata->inevent, (gpointer) i );
//	    else
//		plugindata->insig = g_list_append( plugindata->insig, (gpointer) i );
//
//	else
//
//	    if( LADSPA_IS_PORT_CONTROL( PortDescriptor ) ) 
//		plugindata->outevent = g_list_append( plugindata->outevent, (gpointer) i );
//	    else
//		plugindata->outsig = g_list_append( plugindata->outsig, (gpointer) i );
//    } 

    // Add 1 for NULL termination
    inputdescr = safe_malloc( sizeof( InputSignalDescriptor ) * (tmp_effect->numInputs + 1) );
    outputdescr= safe_malloc( sizeof( OutputSignalDescriptor ) * (tmp_effect->numOutputs + 1) );
    controls = safe_malloc( sizeof( ControlDescriptor ) * (tmp_effect->numParams + 1) );


	
    //printf( "Input Signals:\n" );
    for( i=0; i<tmp_effect->numInputs; i++ )
    {
	inputdescr[i].name  = g_strdup_printf( "input_%d", (int)i );
	inputdescr[i].flags = SIG_FLAG_REALTIME;
    }
    inputdescr[i].name = NULL;
   
    //printf( "Output Signals:\n" );
    for( i=0; i<tmp_effect->numOutputs; i++ )
    {
	outputdescr[i].name  = g_strdup_printf( "output_%d", (int)i );
	outputdescr[i].flags = SIG_FLAG_REALTIME;
	outputdescr[i].d.realtime = output_generators[i];
    }
    outputdescr[i].name = NULL;

    for( i=0; i<tmp_effect->numParams; i++ )
    {
	controls[i].kind = CONTROL_KIND_KNOB;

	controls[i].name = safe_malloc( 30 );

	tmp_effect->dispatcher( tmp_effect, effGetParamName, i, 0, controls[i].name, 0 );

	controls[i].min = 0.0;
	
	controls[i].max = 1.0;

	controls[i].step = 0.01;
	controls[i].page = 0.01;

	controls[i].size = 0;
	controls[i].allow_direct_edit = TRUE;
	controls[i].is_dst_gen = TRUE;
	controls[i].queue_number = i;


	controls[i].initialize = NULL;
	controls[i].destroy = NULL;
	controls[i].refresh = control_VST_Data_updater;
	controls[i].refresh_data = (void *)i;
    }
    
    controls[i].kind = CONTROL_KIND_NONE;
   
    //printf( "Menu : %s\n", get_lrdf_menuname( psDescriptor->UniqueID ) );
    k = gen_new_generatorclass_with_different_tag( basename, 
				g_strdup_printf( "vst-%d", (int) tmp_effect->uniqueID ), FALSE,
				tmp_effect->numParams, 0,
				inputdescr, outputdescr, controls,
				init_instance, destroy_instance,
				init_instance, NULL);

    for( i=0; i<tmp_effect->numParams; i++ ) {

	gen_configure_event_input(k, i, controls[i].name, evt_input_handler);
    }

    //printf( "Output Events:\n" );
   
    
    //printf( "inserting: %s %x\n", psDescriptor->Label, psDescriptor );
    //XXX: Is it necessary to add both tags ? Should be handled by the generator resolution.
    
    g_hash_table_insert(MainFuncIndex, k->tag, main_func);

	
    generatorpath = g_strdup_printf( "VST%2d/%s", (plugin_count++) / 20, basename );



    gencomp_register_generatorclass(k, FALSE, generatorpath,
	    PIXMAPDIRIFY(GENERATOR_CLASS_PIXMAP),
	    NULL);
	
    free( generatorpath );
    
    //printf("Plugin Name: \"%s\"\n", psDescriptor->Name);
    //printf("Plugin Label: \"%s\"\n", psDescriptor->Label);
    //printf("Plugin Unique ID: %lu\n", psDescriptor->UniqueID);
    //printf("Maker: \"%s\"\n", psDescriptor->Maker);
    //printf("Copyright: \"%s\"\n", psDescriptor->Copyright);
}
Пример #11
0
int notmain_add(void) {
    return static_func() + main_func();
}
Пример #12
0
		int operator()(void) const
		{
			os::CriticalSection cs("OGLplus example");
			Application::ParseCommandLineOptions(argc, argv);
			return main_func(argc, argv);
		}
Пример #13
0
int do_ucos (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	printf("Start UC/OS\n");
	main_func();
}