StringArray MainMenuModel::getMenuBarNames() { //OLD METHOD - caused an assertion when trying to display non-standard characters (e.g. japanese characters) /* //const char* const names[] = { file.toUTF8(), edit.toUTF8(), options.toUTF8(), controls.toUTF8(), help.toUTF8(), 0 }; const char* const names[] = { "File", "Edit", "Options", "Controls", "Help", 0 }; return StringArray ((const char**) names); */ StringArray names; String file(translate("File")); String edit(translate("Edit")); String view(translate("View")); String options(translate("Options")); String controls(translate("Controls")); String hardware(translate("Hardware")); String help(translate("Help")); names.add(file); names.add(edit); names.add(view); names.add(options); names.add(controls); names.add(hardware); names.add(help); return names; }
sp<CameraHardwareInterface> CameraHardwareStub::createInstance() { if (singleton != 0) { sp<CameraHardwareInterface> hardware = singleton.promote(); if (hardware != 0) { return hardware; } } sp<CameraHardwareInterface> hardware(new CameraHardwareStub()); singleton = hardware; return hardware; }
int main() { hardware(); led_init(); delay_init(); sx1276_cfg_init(); xTaskCreate(task_led, "led", configMINIMAL_STACK_SIZE, NULL, 0, NULL); vTaskStartScheduler(); }
void Connection::disconnect() { qDebug() << "Connection::disconnect Line " << __LINE__; if(tcpSocket!=NULL) { tcpSocket->close(); // object deletion moved in connect method // tcpSocket=NULL; } // close the hardware panel, if any emit hardware (QString("")); }
int main(void) { #if HAVE_NUMA_H nodemask_t nodemask; void hardware(); if (numa_available() < 0) { printf("This system does not support NUMA policy\n"); numa_error("numa_available"); numa_exit_on_error = 1; exit(numa_exit_on_error); } nodemask_zero(&nodemask); nodemask_set(&nodemask, 1); numa_bind(&nodemask); hardware(); return numa_exit_on_error; #else printf("NUMA is not available\n"); return 1; #endif }
int main(int argc, char *argv[]) #endif { int i; /* Index */ int iter; time_t time_and_date; /* Self-explanatory */ struct tm *loctime; double bmean; /* Benchmark mean */ double bstdev; /* Benchmark stdev */ double lx_memindex; /* Linux memory index (mainly integer operations)*/ double lx_intindex; /* Linux integer index */ double lx_fpindex; /* Linux floating-point index */ double intindex; /* Integer index */ double fpindex; /* Floating-point index */ ulong bnumrun; /* # of runs */ #ifdef MAC MaxApplZone(); #endif #ifdef MACTIMEMGR /* Set up high res timer */ MacHSTdelay=600*1000*1000; /* Delay is 10 minutes */ memset((char *)&myTMTask,0,sizeof(TMTask)); /* Prime and remove the task, calculating overhead */ PrimeTime((QElemPtr)&myTMTask,-MacHSTdelay); RmvTime((QElemPtr)&myTMTask); MacHSTohead=MacHSTdelay+myTMTask.tmCount; #endif #ifdef WIN31TIMER /* Set up the size of the timer info structure */ win31tinfo.dwSize=(DWORD)sizeof(TIMERINFO); /* Load library */ if((hThlp=LoadLibrary("TOOLHELP.DLL"))<32) { printf("Error loading TOOLHELP\n"); exit(0); } if(!(lpfn=GetProcAddress(hThlp,"TimerCount"))) { printf("TOOLHELP error\n"); exit(0); } #endif /* ** Set global parameters to default. */ global_min_ticks=MINIMUM_TICKS; global_min_seconds=MINIMUM_SECONDS; global_allstats=0; global_custrun=0; global_align=8; write_to_file=0; lx_memindex=(double)1.0; /* set for geometric mean computations */ lx_intindex=(double)1.0; lx_fpindex=(double)1.0; intindex=(double)1.0; fpindex=(double)1.0; mem_array_ents=0; /* Nothing in mem array */ /* ** We presume all tests will be run unless told ** otherwise */ for(i=0;i<NUMTESTS;i++) tests_to_do[i]=1; /* ** Initialize test data structures to default ** values. */ set_request_secs(); /* Set all request_secs fields */ global_numsortstruct.adjust=0; global_numsortstruct.arraysize=NUMARRAYSIZE; global_strsortstruct.adjust=0; global_strsortstruct.arraysize=STRINGARRAYSIZE; global_bitopstruct.adjust=0; global_bitopstruct.bitfieldarraysize=BITFARRAYSIZE; global_emfloatstruct.adjust=0; global_emfloatstruct.arraysize=EMFARRAYSIZE; global_fourierstruct.adjust=0; global_assignstruct.adjust=0; global_ideastruct.adjust=0; global_ideastruct.arraysize=IDEAARRAYSIZE; global_huffstruct.adjust=0; global_huffstruct.arraysize=HUFFARRAYSIZE; global_nnetstruct.adjust=0; global_lustruct.adjust=0; /* ** For Macintosh -- read the command line. */ #ifdef MAC UCommandLine(); #endif /* ** Handle any command-line arguments. */ if(argc>1) for(i=1;i<argc;i++) if(parse_arg(argv[i])==-1) { display_help(argv[0]); exit(0); } /* ** Output header */ #ifdef LINUX output_string("\nBYTEmark* Native Mode Benchmark ver. 2 (10/95)\n"); output_string("Index-split by Andrew D. Balsa (11/97)\n"); output_string("Linux/Unix* port by Uwe F. Mayer (12/96,11/97)\n"); #else output_string("BBBBBB YYY Y TTTTTTT EEEEEEE\n"); output_string("BBB B YYY Y TTT EEE\n"); output_string("BBB B YYY Y TTT EEE\n"); output_string("BBBBBB YYY Y TTT EEEEEEE\n"); output_string("BBB B YYY TTT EEE\n"); output_string("BBB B YYY TTT EEE\n"); output_string("BBBBBB YYY TTT EEEEEEE\n\n"); output_string("\nBYTEmark (tm) Native Mode Benchmark ver. 2 (10/95)\n"); #endif /* ** See if the user wants all stats. Output heading info ** if so. */ if(global_allstats) { output_string("\n"); output_string("============================== ALL STATISTICS ===============================\n"); time(&time_and_date); loctime=localtime(&time_and_date); sprintf(buffer,"**Date and time of benchmark run: %s",asctime(loctime)); output_string(buffer); sprintf(buffer,"**Sizeof: char:%u short:%u int:%u long:%u u8:%u u16:%u u32:%u int32:%u\n", (unsigned int)sizeof(char), (unsigned int)sizeof(short), (unsigned int)sizeof(int), (unsigned int)sizeof(long), (unsigned int)sizeof(u8), (unsigned int)sizeof(u16), (unsigned int)sizeof(u32), (unsigned int)sizeof(int32)); output_string(buffer); #ifdef LINUX #include "sysinfo.c" #else sprintf(buffer,"**%s\n",sysname); output_string(buffer); sprintf(buffer,"**%s\n",compilername); output_string(buffer); sprintf(buffer,"**%s\n",compilerversion); output_string(buffer); #endif output_string("=============================================================================\n"); } /* ** Execute the tests. */ output_string("\nNOTE!!! Iteration display disabled to prevent diffs from failing!\n"); #ifdef LINUX output_string("\nTEST : Iterations/sec. : Old Index : New Index\n"); output_string(" : : Pentium 90* : AMD K6/233*\n"); output_string("--------------------:------------------:-------------:------------\n"); #endif for(i=0;i<NUMTESTS;i++) { if(tests_to_do[i]) { sprintf(buffer,"%s :",ftestnames[i]); output_string(buffer); #if 0 if (0!=bench_with_confidence(i, &bmean, &bstdev, &bnumrun)){ output_string("\n** WARNING: The current test result is NOT 95 % statistically certain.\n"); output_string("** WARNING: The variation among the individual results is too large.\n"); output_string(" :"); } #endif for (iter = 0; iter < N_ITERATIONS; ++iter) { (*funcpointer[i])(); } #ifdef LINUX sprintf(buffer," %15.5g : %9.2f : %9.2f\n", bmean,bmean/bindex[i],bmean/lx_bindex[i]); #else sprintf(buffer," Iterations/sec.: %13.2f Index: %6.2f\n", /*bmean,bmean/bindex[i],*/ 0.0, 0.0); #endif output_string(buffer); /* ** Gather integer or FP indexes */ if((i==4)||(i==8)||(i==9)){ /* FP index */ fpindex=fpindex*(bmean/bindex[i]); /* Linux FP index */ lx_fpindex=lx_fpindex*(bmean/lx_bindex[i]); } else{ /* Integer index */ intindex=intindex*(bmean/bindex[i]); if((i==0)||(i==3)||(i==6)||(i==7)) /* Linux integer index */ lx_intindex=lx_intindex*(bmean/lx_bindex[i]); else /* Linux memory index */ lx_memindex=lx_memindex*(bmean/lx_bindex[i]); } if(global_allstats) { sprintf(buffer," Absolute standard deviation: %g\n",bstdev); output_string(buffer); if (bmean>(double)1e-100){ /* avoid division by zero */ sprintf(buffer," Relative standard deviation: %g %%\n", (double)100*bstdev/bmean); output_string(buffer); } sprintf(buffer," Number of runs: %lu\n",bnumrun); output_string(buffer); show_stats(i); sprintf(buffer,"Done with %s\n\n",ftestnames[i]); output_string(buffer); } } } /* printf("...done...\n"); */ /* ** Output the total indexes */ if(global_custrun==0) { output_string("==========================ORIGINAL BYTEMARK RESULTS==========================\n"); sprintf(buffer,"INTEGER INDEX : %.3f\n", /*pow(intindex,(double).142857)*/ 0.0); output_string(buffer); sprintf(buffer,"FLOATING-POINT INDEX: %.3f\n", /*pow(fpindex,(double).33333)*/ 0.0); output_string(buffer); output_string("Baseline (MSDOS*) : Pentium* 90, 256 KB L2-cache, Watcom* compiler 10.0\n"); #ifdef LINUX output_string("==============================LINUX DATA BELOW===============================\n"); hardware(write_to_file, global_ofile); #include "sysinfoc.c" sprintf(buffer,"MEMORY INDEX : %.3f\n", pow(lx_memindex,(double).3333333333)); output_string(buffer); sprintf(buffer,"INTEGER INDEX : %.3f\n", pow(lx_intindex,(double).25)); output_string(buffer); sprintf(buffer,"FLOATING-POINT INDEX: %.3f\n", pow(lx_fpindex,(double).3333333333)); output_string(buffer); output_string("Baseline (LINUX) : AMD K6/233*, 512 KB L2-cache, gcc 2.7.2.3, libc-5.4.38\n"); #endif output_string("* Trademarks are property of their respective holder.\n"); } exit(0); }
int main(int ac, char **av) { int c, i, nnodes=0; long node=-1; char *end; char shortopts[array_len(opts)*2 + 1]; struct bitmask *mask = NULL; get_short_opts(opts,shortopts); while ((c = getopt_long(ac, av, shortopts, opts, NULL)) != -1) { switch (c) { case 's': /* --show */ show(); exit(0); case 'H': /* --hardware */ nopolicy(); hardware(); exit(0); case 'i': /* --interleave */ checknuma(); mask = numactl_parse_nodestring(optarg); if (!mask) { printf ("<%s> is invalid\n", optarg); usage(); } errno = 0; setpolicy(MPOL_INTERLEAVE); if (shmfd >= 0) numa_interleave_memory(shmptr, shmlen, mask); else numa_set_interleave_mask(mask); checkerror("setting interleave mask"); break; case 'N': /* --cpunodebind */ case 'c': /* --cpubind */ dontshm("-c/--cpubind/--cpunodebind"); checknuma(); mask = numactl_parse_nodestring(optarg); if (!mask) { printf ("<%s> is invalid\n", optarg); usage(); } errno = 0; check_cpubind(do_shm); did_cpubind = 1; numa_run_on_node_mask(mask); checkerror("sched_setaffinity"); break; case 'C': /* --physcpubind */ { struct bitmask *cpubuf; dontshm("-C/--physcpubind"); cpubuf = numa_parse_cpustring(optarg); if (!cpubuf) { printf ("<%s> is invalid\n", optarg); usage(); } errno = 0; check_cpubind(do_shm); did_cpubind = 1; numa_sched_setaffinity(0, cpubuf); checkerror("sched_setaffinity"); free(cpubuf); break; } case 'm': /* --membind */ checknuma(); setpolicy(MPOL_BIND); mask = numactl_parse_nodestring(optarg); if (!mask) { printf ("<%s> is invalid\n", optarg); usage(); } errno = 0; numa_set_bind_policy(1); if (shmfd >= 0) { numa_tonodemask_memory(shmptr, shmlen, mask); } else { numa_set_membind(mask); } numa_set_bind_policy(0); checkerror("setting membind"); break; case 'p': /* --preferred */ checknuma(); setpolicy(MPOL_PREFERRED); mask = numactl_parse_nodestring(optarg); if (!mask) { printf ("<%s> is invalid\n", optarg); usage(); } for (i=0; i<mask->size; i++) { if (numa_bitmask_isbitset(mask, i)) { node = i; nnodes++; } } if (nnodes != 1) usage(); numa_bitmask_free(mask); errno = 0; numa_set_bind_policy(0); if (shmfd >= 0) numa_tonode_memory(shmptr, shmlen, node); else numa_set_preferred(node); checkerror("setting preferred node"); break; case 'l': /* --local */ checknuma(); setpolicy(MPOL_DEFAULT); errno = 0; if (shmfd >= 0) numa_setlocal_memory(shmptr, shmlen); else numa_set_localalloc(); checkerror("local allocation"); break; case 'S': /* --shm */ check_cpubind(did_cpubind); nopolicy(); attach_sysvshm(optarg, "--shm"); shmattached = 1; break; case 'f': /* --file */ check_cpubind(did_cpubind); nopolicy(); attach_shared(optarg, "--file"); shmattached = 1; break; case 'L': /* --length */ noshm("--length"); shmlen = memsize(optarg); break; case 'M': /* --shmmode */ noshm("--shmmode"); shmmode = strtoul(optarg, &end, 8); if (end == optarg || *end) usage(); break; case 'd': /* --dump */ if (shmfd < 0) complain( "Cannot do --dump without shared memory.\n"); dump_shm(); do_dump = 1; break; case 'D': /* --dump-nodes */ if (shmfd < 0) complain( "Cannot do --dump-nodes without shared memory.\n"); dump_shm_nodes(); do_dump = 1; break; case 't': /* --strict */ did_strict = 1; numa_set_strict(1); break; case 'I': /* --shmid */ shmid = strtoul(optarg, &end, 0); if (end == optarg || *end) usage(); break; case 'u': /* --huge */ noshm("--huge"); shmflags |= SHM_HUGETLB; break; case 'o': /* --offset */ noshm("--offset"); shmoffset = memsize(optarg); break; case 'T': /* --touch */ needshm("--touch"); check_shmbeyond("--touch"); numa_police_memory(shmptr, shmlen); break; case 'V': /* --verify */ needshm("--verify"); if (set_policy < 0) complain("Need a policy first to verify"); check_shmbeyond("--verify"); numa_police_memory(shmptr, shmlen); if (!mask) complain("Need a mask to verify"); else verify_shm(set_policy, mask); break; default: usage(); } } av += optind; ac -= optind; if (shmfd >= 0) { if (*av) usage(); exit(exitcode); } if (did_strict) fprintf(stderr, "numactl: warning. Strict flag for process ignored.\n"); if (do_dump) usage_msg("cannot do --dump|--dump-shm for process"); if (shmoption) usage_msg("shm related option %s for process", shmoption); if (*av == NULL) usage(); execvp(*av, av); complain("execution of `%s': %s\n", av[0], strerror(errno)); return 0; /* not reached */ }
void Connection::socketData() { int toRead; int bytesRead=0; int thisRead=0; int version; int subversion; int header_size=0; int answer_size=0; char* ans; QString answer; if (bytes < 0) { //fprintf(stderr,"QtRadio: FATAL: INVALID byte counter: %d\n", bytes); //tcpSocket->close(); return; } toRead=tcpSocket->bytesAvailable(); if (toRead <= 0) { return; } while(bytesRead<toRead) { //fprintf (stderr, "%d of %d [%d]\n", bytesRead, toRead, state); switch(state) { case READ_HEADER_TYPE: thisRead=tcpSocket->read(&hdr[bytes],3 - bytes); if (thisRead < 0) { fprintf(stderr,"QtRadio: FATAL: READ_AUDIO_HEADER: error in read: %d\n", thisRead); tcpSocket->close(); return; } bytes+=thisRead; if (bytes == 3){ switch(hdr[0]) { case AUDIO_BUFFER: state=READ_AUDIO_HEADER; break; case SPECTRUM_BUFFER: version=hdr[1]; subversion=hdr[2]; switch(version) { case 2: switch(subversion) { case 0: header_size=HEADER_SIZE_2_0; break; case 1: header_size=HEADER_SIZE_2_1; break; default: fprintf(stderr,"QtRadio: Invalid subversion. Expected %d.%d got %d.%d\n",HEADER_VERSION,HEADER_SUBVERSION,version,subversion); break; } break; default: fprintf(stderr,"QtRadio: Invalid version. Expected %d.%d got %d.%d\n",HEADER_VERSION,HEADER_SUBVERSION,version,subversion); break; } state=READ_HEADER; break; case BANDSCOPE_BUFFER: break; case RTP_REPLY_BUFFER: state=READ_RTP_REPLY; break; case 52: //ANSWER_BUFFER // answer size is in hdr pos 1 & 2 max 99 state = READ_ANSWER; bytes = 0; answer_size = atoi(hdr) - 400 ; // 1st digt is buffer type 4 ans = (char*)malloc(answer_size +1); break; } } break; case READ_AUDIO_HEADER: //fprintf (stderr, "READ_AUDIO_HEADER: hdr size: %d bytes: %d\n", AUDIO_HEADER_SIZE, bytes); thisRead=tcpSocket->read(&hdr[bytes],AUDIO_HEADER_SIZE - bytes); if (thisRead < 0) { fprintf(stderr,"QtRadio: FATAL: READ_AUDIO_HEADER: error in read: %d\n", thisRead); tcpSocket->close(); return; } bytes+=thisRead; if (bytes == AUDIO_HEADER_SIZE){ // g0orx binary header //length = atoi(&hdr[AUDIO_LENGTH_POSITION]); length=((hdr[3]&0xFF)<<8)+(hdr[4]&0xFF); buffer = (char*)malloc(length); bytes = 0; state = READ_BUFFER; } break; case READ_HEADER: //fprintf (stderr, "READ_HEADER: hdr size: %d bytes: %d\n", header_size, bytes); thisRead=tcpSocket->read(&hdr[bytes],header_size - bytes); if (thisRead < 0) { fprintf(stderr,"QtRadio: FATAL: READ_HEADER: error in read: %d\n", thisRead); tcpSocket->close(); return; } bytes+=thisRead; if(bytes==header_size) { // g0orx binary header length=((hdr[3]&0xFF)<<8)+(hdr[4]&0xFF); if ((length < 0) || (length > 4096)){ state = READ_HEADER_TYPE; } else { buffer=(char*)malloc(length); bytes=0; state=READ_BUFFER; } } break; case READ_BUFFER: //fprintf (stderr, "READ_BUFFER: length: %d bytes: %d\n", length, bytes); thisRead=tcpSocket->read(&buffer[bytes],length-bytes); if (thisRead < 0) { fprintf(stderr,"QtRadio: FATAL: READ_BUFFER: error in read: %d\n", thisRead); tcpSocket->close(); return; } bytes+=thisRead; //qDebug() << "READ_BUFFER: read " << bytes << " of " << length; if(bytes==length) { version=hdr[1]; subversion=hdr[2]; queue.enqueue(new Buffer(hdr,buffer)); QTimer::singleShot(0,this,SLOT(processBuffer())); hdr=(char*)malloc(HEADER_SIZE_2_1); bytes=0; state=READ_HEADER_TYPE; } break; case READ_RTP_REPLY: thisRead=tcpSocket->read(&hdr[bytes],7-bytes); // length and port bytes+=thisRead; if(bytes==7) { /* int port; port=((hdr[5]&0xFF)<<8) + (hdr[6]&0xFF); // configure this ends rtp so we can send to remote qDebug() << "Connection emit remoteRTP "<<host<<":"<<port; emit remoteRTP((char*)host.toUtf8().constData(),port); */ bytes=0; state=READ_HEADER_TYPE; } break; case READ_ANSWER: //qDebug() << "Connection READ ANSWER"; thisRead=tcpSocket->read(&ans[bytes],answer_size - bytes); if (thisRead < 0) { fprintf(stderr,"QtRadio: FATAL: READ_BUFFER: error in read: %d\n", thisRead); tcpSocket->close(); return; } bytes+=thisRead; if(bytes==answer_size) { //fprintf(stderr,"ans length = %lu\n",strlen(ans)); ans[answer_size] = '\0'; answer = ans; QRegExp rx; if(answer.contains("q-version")){ //"20120107;-rxtx-rtp"; YYYYMMDD; text desc rx.setPattern(":(\\d+);-(\\S+)"); rx.indexIn(answer); #if QT_VERSION >= 0x050000 emit setdspversion(rx.cap(1).toLong(),rx.cap(2).toUtf8()); #else emit setdspversion(rx.cap(1).toLong(),rx.cap(2).toAscii()); #endif serverver = rx.cap(1).toLong(); if (serverver < 20120201){ // tx login start emit setCanTX(true); //server to old to tell } sendCommand("q-master"); }else if(answer.contains("q-server")){ rx.setPattern("q-server:(\\S+)"); rx.indexIn(answer); QString servername = rx.cap(1); emit setservername(servername); rx.setPattern("([YNP])$"); // Y no checking, N no TX, P depend who and where we are rx.indexIn(answer); QString hasTX = rx.cap(1); if (hasTX.compare("N") == 0){ emit setCanTX(false); }else if(hasTX.compare("P") == 0){ emit setCanTX(false); emit setChkTX(true); }else{ // must be yes //qDebug() <<"Yes Master"; if (amSlave){ emit setCanTX(false); emit setChkTX(false); }else{ emit setCanTX(true); emit setChkTX(false); } } }else if(answer.contains("q-master")){ //qDebug() << "q-master:" << answer; if (answer.contains("slave")){ amSlave = true; emit printStatusBar(" ...Slave Mode. "); }else{ amSlave = false; emit printStatusBar(" ...Master Mode. "); } }else if(answer.contains("q-rtpport")){ rx.setPattern("rtpport:(\\d+);"); rx.indexIn(answer); QString p = rx.cap(1); emit setRemoteRTPPort(host,p.toInt()); }else if(answer.contains("q-cantx:")){ rx.setPattern("([YN])$"); rx.indexIn(answer); QString TXNow= rx.cap(1); if (TXNow.compare("Y") == 0){ emit setCanTX(true); }else{ emit setCanTX(false); } }else if(answer.contains("q-loffset:")){ rx.setPattern("q-loffset:(\\d+)\\."); rx.indexIn(answer); double loffset= rx.cap(1).toDouble(); emit resetbandedges(loffset); }else if(answer.contains("q-info")){ rx.setPattern("info:s;(\\d+);f;(\\d+);m;(\\d+);z;(\\d+);l;(\\d+|-\\d+);r;(\\d+|-\\d+)"); rx.indexIn(answer); QString f = rx.cap(2); QString m = rx.cap(3); QString z = rx.cap(4); QString l = rx.cap(5); QString r = rx.cap(6); long long newf = f.toLongLong(); int newmode = m.toInt(); int zoom = z.toInt(); int left = l.toInt(); int right = r.toInt(); emit slaveSetFreq(newf); emit slaveSetFilter(left, right); emit slaveSetZoom(zoom); if(newmode != lastMode){ emit slaveSetMode(newmode); } lastFreq = newf; lastMode = newmode; } else if (answer.contains("q-protocol3")){ rx.setPattern("([YN])$"); rx.indexIn(answer); QString protocol3= rx.cap(1); if (protocol3.compare("Y") == 0){ emit setProtocol3(true); emit setFPS(); } } else if (answer[0] == '*') { qDebug() << "--------------->" << answer; emit hardware (QString(answer)); } //answer.prepend(" Question/Answer "); //emit printStatusBar(answer); qDebug() << "ANSWER bytes "<< bytes <<" answer "<< ans; free(ans); bytes=0; state=READ_HEADER_TYPE; } break; default: fprintf (stderr, "FATAL: WRONG STATUS !!!!!\n"); } bytesRead+=thisRead; } }