BOOL udpioInit(UDPIO *up, int port, int to, LOGIO *lp) { static struct sockaddr_in addr; static char *fid = "udpioInit"; #ifdef WIN32 WSADATA lpWSAData; #endif /* WIN32 */ if (up == NULL) { errno = EINVAL; return FALSE; } #ifdef WIN32 if (WSAStartup(MAKEWORD(2,2), &lpWSAData) != 0){ logioMsg(up->lp, LOG_ERR, "%s: WSAStartup", fid); return FALSE; } #endif /* WIN32 */ up->lp = lp; if ((up->sd = socket(AF_INET, SOCK_DGRAM, 0)) == INVALID_SOCKET) { logioMsg(up->lp, LOG_ERR, "%s: socket: %s", fid, strerror(errno)); return FALSE; } if (to > 0) { up->to.tv_sec = (time_t) to / MSEC_PER_SEC;; up->to.tv_usec = (suseconds_t) (to - up->to.tv_sec * MSEC_PER_SEC) * USEC_PER_MSEC; utilSetNonBlockingSocket(up->sd); } else { up->to.tv_sec = 0; up->to.tv_usec = 0; } memset((void *) &addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl(INADDR_ANY); addr.sin_port = htons((short) port); if (bind(up->sd, (struct sockaddr *) &addr, sizeof(addr)) != 0) { logioMsg(up->lp, LOG_ERR, "%s: bind %s", fid, strerror(errno)); return FALSE; } InitStats(&up->stats.xmit); InitStats(&up->stats.recv); up->start = up->stats.xmit.tstamp = up->stats.recv.tstamp = utilTimeStamp(); return TRUE; }
int main(int c, char **a) { OE oe = OperatingEnvironment_New(); InitStats(oe); init_polynomial(); if (oe) { MR mr = 0; int i = 0; MiniMacs mm = setup_generic_minimacs(oe, a[1]); if (mm == 0) { printf("Uable to create MiniMacs Instance, leaving\n"); return 42; } printf("Inviting 1 party to computate on port 2020\n"); mm->invite(1,2020); mm->init_heap(6); C(mm->secret_input(0,0,Data_shallow("Rasmus",7))); C(mm->open(0)); C(mm->secret_input(0,1,Data_shallow("\001",1))); C(mm->secret_input(0,2,Data_shallow("\001",1))); C(mm->mul(3,1,2)); C(mm->open(3)); SymmetricMiniMacs_destroy( & mm ); } PrintMeasurements(oe); failure: return 0; }
void IN_Start(void) { int i; AM_Stop(); SN_StopAllSequences(); // InFine handles the text. if(!deathmatch) { gameaction = ga_leavemap; return; } GL_SetFilter(0); InitStats(); LoadPics(); intermission = true; interstate = 0; skipintermission = false; intertime = 0; for(i = 0; i < MAXPLAYERS; i++) { players[i].messageTics = 0; players[i].message[0] = 0; } }
int main(int c, char **a) { char * material = 0, * bdt_material=0; char * ip = "127.0.0.1"; uint count = 0, i = 0; OE oe = OperatingEnvironment_LinuxNew(); MiniMacs mm = 0; int * pids = 0; InitStats(oe); init_polynomial(); if (c < 3 || c > 5) { printf("multirun <material> <bdt_material> <count> [< server >]\n"); return -1; } if ( c >= 3 ) { material = a[1]; bdt_material = a[2]; } if (c >= 4) { count = atoi(a[3]); } if (c >= 5) { ip =a[4]; } // No bit encoder mm=BitWiseMulPar2MiniMacs_DefaultLoadNew(oe, material, bdt_material, False); if (!mm) { printf("Unable to create MiniMacs, see errors above.\n"); return -1; } printf("Multirun CAES\n"); printf("material taken from: %s\n",material); printf("ip: %s\n", ip); printf("count: %u\n",count); pids = (int*)oe->getmem(sizeof(int)*count); for( i = 0; i < count; ++i) { pids[i] = fork(); if (pids[i] == 0) { return run(ip,i,count,oe,mm); } } CHECK_POINT_S("TOTAL"); for(i = 0;i < count;++i) { wait(pids[i]); } CHECK_POINT_E("TOTAL"); PrintMeasurements(oe); }
int main(int c, char **a) { char * material = 0, * bdt_material=0; char * ip = "127.0.0.1"; uint count = 0, i = 0; OE oe = OperatingEnvironment_LinuxNew(); MiniMacs mm = 0; int * pids = 0; InitStats(oe); init_polynomial(); if (c < 3 || c > 5) { printf("multirun <material> <bdt_material> <count> [< server >]\n"); return -1; } if ( c >= 3 ) { material = a[1]; bdt_material = a[2]; } if (c >= 4) { count = atoi(a[3]); } if (c >= 5) { ip =a[4]; } // loads the preprocessing material making MiniMac ready mm=BitWiseMulPar2MiniMacs_DefaultLoadFFTNew(oe, material, bdt_material, True); printf("Multirun CAES\n"); printf("material taken from: %s\n",material); printf("ip: %s\n", ip); printf("count: %u\n",count); pids = (int*)oe->getmem(sizeof(int)*count); // create processes for parallel execution ({count} of them) for( i = 0; i < count; ++i) { pids[i] = fork(); if (pids[i] == 0) { return run(ip,i,count,oe,mm); } } // wait for everybody to complete CHECK_POINT_S("TOTAL"); for(i = 0;i < count;++i) { wait(pids[i]); } CHECK_POINT_E("TOTAL"); PrintMeasurements(oe); }
int main(int c, char **a) { char * material = 0; char * ip = "127.0.0.1"; uint count = 0, i = 0; OE oe = OperatingEnvironment_LinuxNew(); MiniMacs mm = 0; int * pids = 0; InitStats(oe); init_polynomial(); if (c < 2 || c > 4) { printf("multirun <material> <count> [< server >]\n"); return -1; } if ( c >= 2 ) { material = a[1]; } if (c >= 3) { count = atoi(a[2]); } if (c >= 4) { ip =a[3]; } mm=GenericFFTMiniMacs_new(oe,a[1]); printf("Multirun CAES\n"); printf("material taken from: %s\n",material); printf("ip: %s\n", ip); printf("count: %u\n",count); pids = (int*)oe->getmem(sizeof(int)*count); for( i = 0; i < count; ++i) { pids[i] = fork(); if (pids[i] == 0) { return run(material,ip,i,oe,mm); } } CHECK_POINT_S("TOTAL"); for(i = 0;i < count;++i) { wait(pids[i]); } CHECK_POINT_E("TOTAL"); PrintMeasurements(oe); }
int main (void) { int i,j; M3EcSystemShm * sys; RT_TASK *task; pthread_t ptsys; int cntr=0; signal(SIGINT, endme); sys = rtai_malloc (nam2num(SHMNAM_M3MKMD),1); int ns=sys->slaves_active; InitStats(); printf("Found %d active M3 EtherCAT slaves\n",ns); if (ns==0) { printf("No slaves available. Exiting...\n"); return 0; } rt_allow_nonroot_hrt(); if (!(task = rt_task_init_schmod(nam2num("M3MAIN"), RT_TASK_PRIORITY, 0, 0, SCHED_FIFO, 0xF))) { rt_shm_free(nam2num(SHMNAM_M3MKMD)); printf("Cannot init the RTAI task %s\n","M3MAIN"); return 0; } hst=rt_thread_create((void*)rt_system_thread, sys, 10000); usleep(100000); //Let start up if (!sys_thread_active) { rt_task_delete(task); rt_shm_free(nam2num(SHMNAM_M3MKMD)); printf("Startup of thread failed.\n",0); return 0; } while(!end) { //SysEcShmPrettyPrint(sys); usleep(250000); } printf("Removing RT thread...\n",0); sys_thread_end=1; rt_thread_join(hst); if (sys_thread_active)printf("Real-time thread did not shutdown correctly\n"); rt_task_delete(task); rt_shm_free(nam2num(SHMNAM_M3MKMD)); return 0; }
int main(int c, char **a) { OE oe = (OE)OperatingEnvironment_LinuxNew(); MiniMacs mm = 0; Data input = 0; uint count=0,i=0; init_polynomial(); mm = GenericMiniMacs_DefaultLoadNew(oe,a[1]); InitStats(oe); if (!mm) { oe->p("Error could not create instance of MiniMacs"); OperatingEnvironment_LinuxDestroy(&oe); return -1; } { CliArg arg = (CliArg)oe->getmem(sizeof(*arg)); arg->file = a[2]; arg->oe = oe; oe->newthread(client,arg); } mm->init_heap(2); mm->invite(1,8080); printf("Got client ... \n"); input = Data_new(oe, mm->get_ltext()); for(i = 0; i < mm->get_ltext(); ++i) { input->data[i] = 'r'; } mm->secret_input(0,0,input); for(count = 0; count < COUNT; ++count) { CHECK_POINT_S("Mul server"); mm->mul(1,0,0); CHECK_POINT_E("Mul server"); } usleep(5); PrintMeasurements(oe); return 0; }
void IN_Start(void) { int i; I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); InitStats(); LoadPics(); intermission = true; interstate = 0; skipintermission = false; intertime = 0; AM_Stop(); for (i = 0; i < MAXPLAYERS; i++) { players[i].messageTics = 0; players[i].message[0] = 0; } SN_StopAllSequences(); }
int main(int c, char **args) { OE oe = OperatingEnvironment_LinuxNew(); int i=0,a=0; InitStats(oe); CHECK_POINT_S(__FUNCTION__); for( i = 0; i < 1024;++i) { a+=i*i; } CHECK_POINT_E(__FUNCTION__); PrintMeasurements(oe); OperatingEnvironment_LinuxDestroy(&oe); return 0; }
int main(int argc, char *argv[]) { char * labFn, *listfn, *s; int i,fidx; MLFEntry *me = NULL; Transcription *t; void InitStats(char *listfn); void GatherStats(Transcription *t); void OutputStats(void); if(InitShell(argc,argv,hlstats_version,hlstats_vc_id)<SUCCESS) HError(1300,"HLStats: InitShell failed"); InitMem(); InitMath(); InitWave(); InitLabel(); InitLM(); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(0); SetConfParms(); enterId=GetLabId("!ENTER",TRUE); /* All sentences should or are coerced */ exitId=GetLabId("!EXIT",TRUE); /* to start enterId and end exitId */ nullId=GetLabId("!NULL",TRUE); /* Name for words not in list */ while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(1319,"HLStats: Bad switch %s; must be single letter",s); switch(s[0]){ case 'b': doBigram = TRUE; if (NextArg() != STRINGARG) HError(1319,"HLStats: Ngram output file name expected"); bigFile = GetStrArg(); break; case 'c': doLCount = TRUE; lCountLimit = GetChkedInt(0,100000,s); break; case 'd': doDurs = TRUE; break; case 'f': bigFloor = GetChkedFlt(0.0,1000.0,s); break; case 'h': hSize = GetChkedInt(1,2,s); break; case 'l': doList = TRUE; if (NextArg() != STRINGARG) HError(1319,"HLStats: Output label list file name expected"); listFile = GetStrArg(); break; case 'o': doBOff = TRUE; break; case 'p': doPCount = TRUE; pCountLimit = GetChkedInt(0,100000,s); break; case 's': if (NextArg() != STRINGARG) HError(1319,"HLStats: ENTER label name expected"); enterId=GetLabId(GetStrArg(),TRUE); if (NextArg() != STRINGARG) HError(1319,"HLStats: EXIT label name expected"); exitId=GetLabId(GetStrArg(),TRUE); break; case 't': bigThresh = GetChkedInt(0,100,s); break; case 'u': uniFloor = GetChkedFlt(0.0,1000.0,s); break; case 'G': if (NextArg() != STRINGARG) HError(1319,"HLStats: Input label File format expected"); if((ff = Str2Format(GetStrArg())) == ALIEN) HError(-1389,"HLStats: Warning ALIEN Label file format set"); break; case 'I': if (NextArg() != STRINGARG) HError(1319,"HLStats: Input MLF file name expected"); LoadMasterFile(GetStrArg()); break; case 'T': if (NextArg() != INTARG) HError(1319,"HLStats: Trace value expected"); trace = GetChkedInt(0,017,s); break; default: HError(1319,"HLStats: Unknown switch %s",s); } } if (NextArg()!=STRINGARG) HError(1319,"HLStats: Label list file name expected"); listfn = GetStrArg(); if (!(doDurs || doBigram || doList || doLCount || doPCount)) HError(1330,"HLStats: Nothing to do!"); InitStats(listfn); i=0; while (NumArgs()>0) { if (NextArg()!=STRINGARG) HError(1319,"HLStats: Input label file name expected"); labFn = GetStrArg(); if (IsMLFFile(labFn)) { fidx = NumMLFFiles(); if ((me=GetMLFTable()) != NULL) { while(me->next != NULL) me=me->next; LoadMasterFile(labFn); me=me->next; } else { LoadMasterFile(labFn); me=GetMLFTable(); } while (me != NULL) { if (me->type == MLF_IMMEDIATE && me->def.immed.fidx == fidx) { if (trace&T_FIL) { printf(" Processing file %s\n",me->pattern); fflush(stdout); } t = LOpen(&tmpHeap,me->pattern,ff); if (t->numLists<1) HError(-1330,"HLStats: Empty file %s",me->pattern); else GatherStats(t),i++; Dispose(&tmpHeap,t); } me = me->next; if ((trace&T_BAS) && !(trace&T_FIL) && NumMLFEntries()>5000 && i%1000==0) printf(". "),fflush(stdout); } if ((trace&T_BAS) && !(trace&T_FIL) && NumMLFEntries()>5000) printf("\n"); } else { if (trace&T_FIL) { printf(" Processing file %s\n",labFn); fflush(stdout); } t = LOpen(&tmpHeap,labFn,ff); if (t->numLists<1) HError(-1330,"HLStats: Empty file %s",me->pattern); else GatherStats(t),i++; Dispose(&tmpHeap,t); } } if (trace&T_MEM) PrintAllHeapStats(); OutputStats(); if (trace&T_MEM) PrintAllHeapStats(); Exit(0); return (0); /* never reached -- make compiler happy */ }
int main(int c, char **a) { printf("Aarhus University - Multiparty Computation AES\n"); printf("All rights reserved (C)\n"); if (c == 2 || c == 3 || c == 4) { MiniMacsRep * singles = 0; MiniMacsRep ** pairs = 0; MiniMacsTripleRep * triples; uint lsingles = 0; uint lpairs = 0; uint ltriples = 0; MiniMacs comp = 0; CArena arena = 0; OE oe = 0; uint myid = 0; char * ipaddr = "any"; uint port = 2020; if (c == 1) { printf("caes <raw_material> [<client>] \n"); return 0; } oe = OperatingEnvironment_LinuxNew(); arena = CArena_new(oe); init_polynomial(); InitStats(oe); printf(oe->get_version());printf("\n"); printf("Loading material from file %s ... \n", a[1]); load_shares(a[1], &triples, <riples, &singles, &lsingles, &pairs, &lpairs ); comp = GenericMiniMacs_DefaultNew(oe,arena, singles, lsingles, pairs, lpairs, triples, ltriples ); if (ltriples == 0 && lpairs == 0 && lsingles == 0) { printf("Loading %s failed ...\n", a[1]); return -1; } myid = minimacs_rep_whoami(singles[0]); if(myid == 0) { uint no = minimacs_rep_no_players(singles[0]); if (c >= 3) { port = atoi(a[2]); } if (no == 0) return -1; no--; printf("Waiting for %u players to connect on %s:%u.\n",no,ipaddr,port); comp->invite(no,port); } else { if (c >= 3) { ipaddr = a[2]; } else { ipaddr = "127.0.0.1"; } if (c >= 4) { port = atoi(a[3]); } comp->connect(ipaddr,port); } { byte key[128] = {0}; byte pltxt[128] = {0}; mpc_aes(comp,pltxt,key,0,0,0); } PrintMeasurements(oe); } else { printf("Usage %s <preprocessed material>\n",a[0]); return 0; } return 0; }