static void init2list(NodeList *l, NodeList **out) { for(; l; l=l->next) init2(l->n, out); }
long spu_aac_decode (void **destbuf, void *destend, void **srcbuf, void *srcend, struct spu_aac_decode_fmt *format, void *dataout, void *datain, int datalen) { long status; int need_input, need_output; int inbuf_added; int endflag; int state_decode; int state_decode_end, state_decode_really_end; int incopy, outcopy; unsigned long nblk; long err = RSACPDS_RTN_GOOD; void *_dataout; int _dataoutlen; once_again: need_input = 0; need_output = 0; inbuf_added = 0; if (state.init == 0) { if (init2 () < 0) return -1; state.init = 1; } pthread_mutex_lock (&transfer_lock); while (output_remain <= 0 && outlendata.head != NULL) { int *outlen; struct spu_aac_decode_fmt *outfmt; void *p; int tmp; datalist_sub (&outlendata, &p, &tmp, 1); outlen = p; datalist_sub (&outfmtdata, &p, &tmp, 1); outfmt = p; output_remain += *outlen; format_next = *outfmt; free (outlen); free (outfmt); } endflag = outbuf_end; state_decode_end = state.decode_end; state_decode_really_end = state.decode_really_end; transfer_flag = 1; pthread_mutex_unlock (&transfer_lock); outcopy = copy_output_buffer (destbuf, destend, &need_output, &_dataout, &_dataoutlen); incopy = copy_input_buffer (srcbuf, srcend, &need_input, &inbuf_added, datain, datalen); if (_dataoutlen != 0) { if (_dataoutlen > datalen) _dataoutlen = datalen; memcpy (dataout, _dataout, _dataoutlen); free (_dataout); } *format = format_current; if (state.open == 0) { state_decode = 0; state.decode_end = 0; state.decode_really_end = 0; state_decode_end = 0; state_decode_really_end = 0; callbk_err = 0; inbuf_end = 0; pthread_mutex_lock (&transfer_lock); outbuf_end = 0; pthread_mutex_unlock (&transfer_lock); if (inbuf_added == 0) goto unlock_ret; if ((err = middleware_open ()) < 0) goto ret; if ((err = RSACPDS_SetDecOpt(paac, 0)) < RSACPDS_RTN_GOOD) { ERR ("RSACPDS_SetDecOpt error"); goto close_and_ret; } err = RSACPDS_RTN_GOOD; state.first_block = 1; state.open = 1; need_input = 1; need_output = 0; output_remain = 0; } else { state_decode = 1; if (state_decode_really_end != 0) state_decode = 0; } status = 0; if (state_decode_end != 0) { if (state.first_block != 0) { state.first_block = 0; need_output = 1; } if (output_remain <= 0) { state_decode = 0; state.decode_end = 0; err = RSACPDS_DecodeStatus (paac, &status); if (err < RSACPDS_RTN_GOOD) { ERR ("RSACPDS_DecodeStatus error"); goto close_and_ret; } } } if (need_input != 0) stream_input_end_cb (0); if (need_output != 0) pcm_output_end_cb (0, 0); if (state_decode == 0 && state_decode_really_end == 0) { err = get_header_and_pce (status); if (err < 0) goto close_and_ret; nblk = 0; if (format_type == SPU_AAC_DECODE_SETFMT_TYPE_RAW_AAC || format_type == SPU_AAC_DECODE_SETFMT_TYPE_RAW_AACPLUS) nblk = 1; if (state.first_block != 0) nblk = 1; if (RSACPDS_Decode (paac, nblk) < RSACPDS_RTN_GOOD) { err = RSACPDS_GetStatusCode (paac); ERR ("RSACPDS_Decode error"); goto close_and_ret; } state_decode = 1; } if (inbuf_end == 2 && endflag != 0 && outbuf_copying == NULL && buflist_poll (&outbuf_used) == NULL) { if (decode_end_status != RSACPDS_ERR_DATA_EMPTY) ERR ("strange statusCode; ignored"); err = decoder_close (0); state.open = 0; goto ret; } if (callbk_err != 0) { err = -1; goto close_and_ret; } if ((inbuf_end != 0 || incopy == 0) && outcopy == 0) { pthread_mutex_lock (&transfer_done); goto once_again; } goto unlock_ret; close_and_ret: if (state.decode_end != 0 || state.decode_really_end != 0) state_decode = 0; decoder_close (state_decode); state.open = 0; ret: if (inbuf_copying != NULL) { buflist_add (&inbuf_free, inbuf_copying); inbuf_copying = NULL; } if (outbuf_current != NULL) { buflist_add (&outbuf_free, outbuf_current); outbuf_current = NULL; } do { if (inbuf_current != NULL) buflist_add (&inbuf_free, inbuf_current); inbuf_current = buflist_pop (&inbuf_used); } while (inbuf_current != NULL); do { if (outbuf_copying != NULL) buflist_add (&outbuf_free, outbuf_copying); outbuf_copying = buflist_pop (&outbuf_used); } while (outbuf_copying != NULL); while (indata.head != NULL) datalist_sub (&indata, NULL, NULL, indata.head->len); while (outdata.head != NULL) datalist_sub (&outdata, NULL, NULL, outdata.head->len); while (delaydata.head != NULL) datalist_sub (&delaydata, NULL, NULL, delaydata.head->len); unlock_ret: pthread_mutex_lock (&transfer_lock); if (transfer_flag == 0) { pthread_mutex_unlock (&transfer_lock); pthread_mutex_lock (&transfer_done); } else { transfer_flag = 0; pthread_mutex_unlock (&transfer_lock); } return err; }
int add() { init1(1); init2(1); return g1+g2; }
void f2() { std::call_once(flg2, init2(), 2, 3); std::call_once(flg2, init2(), 4, 5); }
int main(int argc, char *argv[]) { int i, s; list q; list1 q1; list2 q2; record d; personal f; record *ptr, *pt; personal *ptr2, *pt2; FILE *fp, *fp1, *fp2, *fp3, *fp4, *fp6, *fp8, *fp9, *fp10; fp1 = fopen("b.txt", "a+"); node2 *st2; init(&q); init1(&q1); init2(&q2); char a[48]; char br[32]; int m, posi, choice, roll, size, s1, s2, s3, s4, num, posii, yr, MIS; while(1) { choice = printmenu(); switch(choice) { case 1 : printf("\nEnter the Name, MIS, Branch, Year of student and the MIS before which you wish to insert the record :\n"); /*if it is the first record 'posi' can be anything*/ scanf(" %[^\n]%d%s%d%d", a, &m, br, &yr, &posi); fp = fopen("k.txt", "a+"); Add_academic(&q, a, m, br, posi, yr, fp); fclose(fp); print(&q); break; case 2 : printf("Enter the MIS of the student record to be deleted :\n"); scanf("%d", &posii); fp = fopen("k.txt", "a+"); fp4 = fopen("d.txt", "w+"); if(pt = delet_academic(&q, posii,fp,fp4)) { printf("Name:%s\n MIS:%d\n Branch:%s\n Year :%d\n", pt->name, pt->MIS, pt->branch, pt->year); } else { printf("INVALID ENTRY\n"); } print(&q); fclose(fp); fclose(fp4); break; case 3 : printf("Enter the MIS of student :\n"); scanf("%d", &roll); if(ptr = search(&q, roll)) { printf("\nName :%s\tMIS :%d\tBranch :%s\tYear :%d\n", ptr->name, ptr->MIS, ptr->branch, ptr->year); } else { printf("\nRECORD NOT FOUND\n"); } break; case 4 : printf("Enter the Name, MIS, Branch, Year of student :\n"); scanf(" %[^\n]%d%s%d", a, &m, br, &yr); fp = fopen("k.txt", "a+"); append_academic(&q, a, m, br, yr, fp); print(&q); fclose(fp); break; case 5 : size = length(&q); printf("Number of student records(academic) : %d\n", size); break; case 6 : printf("Enter the MIS of student :\n"); scanf("%d", &roll); creatingID(&q, roll); break; case 7 : fp = fopen("k.txt", "a+"); fp3 = fopen("a.txt", "r"); academicfromfile(&q, fp3, fp); print(&q); fclose(fp); fclose(fp3); break; case 8 : printf("Enter the Name, MIS, Branch and Year of student:\n"); scanf(" %[^\n]%d%s%d", a, &m, br, &yr); /*MIS should be same*/ fp = fopen("k.txt", "a+"); fp6 = fopen("n.txt", "w+"); Modify_academic(&q, m, a, br, yr, fp, fp6); print(&q); fclose(fp); fclose(fp6); break; case 9 : num = length1(&q1); printf("No of students who appeared for final exam : %d\n", num); break; case 10 : printf("Enter MIS, T1 marks of 4 subjects ,MIS before which you wish to enter the record and the semester :\n"); scanf("%d%d%d%d%d%d%d",&roll,&s1,&s2,&s3,&s4,&m, &i); T1Marks(&q1,roll,s1,s2,s3,s4,m,i); printT1(&q1, i); break; case 11 : printf("Enter MIS and T2 marks of 4 subjects and the semester :\n"); scanf("%d%d%d%d%d%d",&roll,&s1,&s2,&s3,&s4, &i); T2Marks(&q1,roll,s1,s2,s3,s4,i); printT2(&q1, i); break; case 12 : printf("Enter MIS and ESE marks of 4 subjects and the semester :\n"); scanf("%d%d%d%d%d%d",&roll,&s1,&s2,&s3,&s4,&i); ESEMarks(&q1,roll,s1,s2,s3,s4,i); printESE(&q1, i); break; case 13 : printf("Enter the MIS and the semester :\n"); scanf("%d%d", &MIS, &i); Total(&q1, MIS,i, fp1); printTOT(&q1, i); break; case 14 : printf("Enter the Name, MIS, Mobile no., Email Id of student and the MIS before which you wish to insert the record :\n"); /*if it is the first record, posi can be anything*/ scanf(" %[^\n]%d%d%s%d", a, &m, &yr, br, &posi); fp2 = fopen("c.txt", "a+"); Add2_personal(&q2, a, m, yr, br, posi, fp2); print2(&q2); fclose(fp2); break; case 15 : printf("Enter the MIS of the student record to be deleted :\n"); scanf("%d", &posii); fp2 = fopen("c.txt", "a+"); fp9 = fopen("s.txt", "w+"); if(pt2 = delet2_personal(&q2, posii,fp2, fp9)) { printf("Name:%s\n MIS:%d\n Mobile No:%d\n Email Id :%s\n", pt2->name, pt2->MISS, pt2->mobile, pt2->email_Id); } else { printf("INVALID ENTRY\n"); } print2(&q2); fclose(fp2); fclose(fp9); break; case 16 : printf("Enter the MIS of student :\n"); scanf("%d", &roll); if(ptr2 = search2(&q2, roll)) { printf("\nName :%s\tMIS :%d\tMobile No :%d\tEmail Id :%s\n", ptr2->name, ptr2->MISS, ptr2->mobile, ptr2->email_Id); } else { printf("\nRECORD NOT FOUND\n"); } break; case 17 : printf("Enter the Name, MIS, Mobile no. and Email Id of student:\n"); scanf(" %[^\n]%d%d%s", a, &m, &yr, br); /*MIS should be same*/ fp8 = fopen("w.txt", "w+"); fp2 = fopen("c.txt", "a+"); Modify2_personal(&q2, m, a, yr, br,fp2, fp8); print2(&q2); fclose(fp2); fclose(fp8); break; case 18 : printf("\nEnter the MIS of the student and the semester :\n"); scanf("%d%d", &m, &s); link(&q, &q1, &q2, m, s); break; case 19 : fp2 = fopen("c.txt", "a+"); fp10 = fopen("p.txt", "r"); personalfromfile(&q2, fp10, fp2); print2(&q2); fclose(fp2); fclose(fp10); break; case 20 : fclose(fp1); exit(1); break; } } }
void ArrayRep::resize(int lo, int hi) { int nsize = hi - lo + 1; // Validation if (nsize < 0) G_THROW( ERR_MSG("arrays.resize") ); // Destruction if (nsize == 0) { destroy(data, lobound-minlo, hibound-minlo); operator delete(data); data = 0; lobound = minlo = lo; hibound = maxhi = hi; return; } // Simple extension if (lo >= minlo && hi <= maxhi) { init1(data, lo-minlo, lobound-1-minlo); destroy(data, lobound-minlo, lo-1-minlo); init1(data, hibound+1-minlo, hi-minlo); destroy(data, hi+1-minlo, hibound-minlo); lobound = lo; hibound = hi; return; } // General case int nminlo = minlo; int nmaxhi = maxhi; if (nminlo > nmaxhi) nminlo = nmaxhi = lo; while (nminlo > lo) { int incr = nmaxhi - nminlo; nminlo -= (incr < 8 ? 8 : (incr > 32768 ? 32768 : incr)); } while (nmaxhi < hi) { int incr = nmaxhi - nminlo; nmaxhi += (incr < 8 ? 8 : (incr > 32768 ? 32768 : incr)); } // allocate int bytesize=elsize*(nmaxhi-nminlo+1); void * ndata; GPBufferBase gndata(ndata,bytesize,1); memset(ndata, 0, bytesize); // initialize init1(ndata, lo-nminlo, lobound-1-nminlo); init2(ndata, lobound-nminlo, hibound-nminlo, data, lobound-minlo, hibound-minlo); init1(ndata, hibound+1-nminlo, hi-nminlo); destroy(data, lobound-minlo, hibound-minlo); // free and replace void *tmp=data; data = ndata; ndata=tmp; minlo = nminlo; maxhi = nmaxhi; lobound = lo; hibound = hi; }
QT_BEGIN_NAMESPACE void UnixMakefileGenerator::init() { if(init_flag) return; init_flag = true; if(project->isEmpty("QMAKE_EXTENSION_SHLIB")) { if(project->isEmpty("QMAKE_CYGWIN_SHLIB")) { project->values("QMAKE_EXTENSION_SHLIB").append("so"); } else { project->values("QMAKE_EXTENSION_SHLIB").append("dll"); } } if (project->isEmpty("QMAKE_PREFIX_SHLIB")) // Prevent crash when using the empty variable. project->values("QMAKE_PREFIX_SHLIB").append(""); if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */ return; ProStringList &configs = project->values("CONFIG"); if(project->isEmpty("ICON") && !project->isEmpty("RC_FILE")) project->values("ICON") = project->values("RC_FILE"); if(project->isEmpty("QMAKE_EXTENSION_PLUGIN")) project->values("QMAKE_EXTENSION_PLUGIN").append(project->first("QMAKE_EXTENSION_SHLIB")); if(project->isEmpty("QMAKE_COPY_FILE")) project->values("QMAKE_COPY_FILE").append("$(COPY)"); if(project->isEmpty("QMAKE_STREAM_EDITOR")) project->values("QMAKE_STREAM_EDITOR").append("sed"); if(project->isEmpty("QMAKE_COPY_DIR")) project->values("QMAKE_COPY_DIR").append("$(COPY) -R"); if(project->isEmpty("QMAKE_INSTALL_FILE")) project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)"); if(project->isEmpty("QMAKE_INSTALL_DIR")) project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)"); if(project->isEmpty("QMAKE_INSTALL_PROGRAM")) project->values("QMAKE_INSTALL_PROGRAM").append("$(COPY_FILE)"); if(project->isEmpty("QMAKE_LIBTOOL")) project->values("QMAKE_LIBTOOL").append("libtool --silent"); if(project->isEmpty("QMAKE_SYMBOLIC_LINK")) project->values("QMAKE_SYMBOLIC_LINK").append("ln -f -s"); /* this should probably not be here, but I'm using it to wrap the .t files */ if(project->first("TEMPLATE") == "app") project->values("QMAKE_APP_FLAG").append("1"); else if(project->first("TEMPLATE") == "lib") project->values("QMAKE_LIB_FLAG").append("1"); else if(project->first("TEMPLATE") == "subdirs") { MakefileGenerator::init(); if(project->isEmpty("MAKEFILE")) project->values("MAKEFILE").append("Makefile"); return; /* subdirs is done */ } if (!project->isEmpty("TARGET")) project->values("TARGET") = escapeFilePaths(project->values("TARGET")); project->values("QMAKE_ORIG_TARGET") = project->values("TARGET"); project->values("QMAKE_ORIG_DESTDIR") = project->values("DESTDIR"); project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); if((!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib")) || (project->isActiveConfig("qt") && project->isActiveConfig("plugin"))) { if(configs.indexOf("dll") == -1) configs.append("dll"); } else if(!project->isEmpty("QMAKE_APP_FLAG") || project->isActiveConfig("dll")) { configs.removeAll("staticlib"); } if(!project->isEmpty("QMAKE_INCREMENTAL")) project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_INCREMENTAL"); else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") && !project->values("QMAKE_LIB_FLAG").isEmpty() && project->isActiveConfig("dll")) project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_PREBIND"); if(!project->isEmpty("QMAKE_INCDIR")) project->values("INCLUDEPATH") += project->values("QMAKE_INCDIR"); project->values("QMAKE_L_FLAG") << (project->isActiveConfig("rvct_linker") ? "--userlibpath " : project->isActiveConfig("armcc_linker") ? "-L--userlibpath=" : project->isActiveConfig("ti_linker") ? "--search_path=" : "-L"); ProStringList ldadd; if(!project->isEmpty("QMAKE_LIBDIR")) { const ProStringList &libdirs = project->values("QMAKE_LIBDIR"); for(int i = 0; i < libdirs.size(); ++i) { if(!project->isEmpty("QMAKE_LFLAGS_RPATH") && project->isActiveConfig("rpath_libdirs")) project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + libdirs[i]; project->values("QMAKE_LIBDIR_FLAGS") += "-L" + escapeFilePath(libdirs[i]); } } ldadd += project->values("QMAKE_LIBDIR_FLAGS"); if (project->isActiveConfig("mac")) { if (!project->isEmpty("QMAKE_FRAMEWORKPATH")) { const ProStringList &fwdirs = project->values("QMAKE_FRAMEWORKPATH"); for (int i = 0; i < fwdirs.size(); ++i) project->values("QMAKE_FRAMEWORKPATH_FLAGS") += "-F" + escapeFilePath(fwdirs[i]); } ldadd += project->values("QMAKE_FRAMEWORKPATH_FLAGS"); } ProStringList &qmklibs = project->values("QMAKE_LIBS"); qmklibs = ldadd + qmklibs; if(!project->isEmpty("QMAKE_RPATHDIR")) { const ProStringList &rpathdirs = project->values("QMAKE_RPATHDIR"); for(int i = 0; i < rpathdirs.size(); ++i) { if(!project->isEmpty("QMAKE_LFLAGS_RPATH")) project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + escapeFilePath(QFileInfo(rpathdirs[i].toQString()).absoluteFilePath()); } } if (!project->isEmpty("QMAKE_RPATHLINKDIR")) { const ProStringList &rpathdirs = project->values("QMAKE_RPATHLINKDIR"); for (int i = 0; i < rpathdirs.size(); ++i) { if (!project->isEmpty("QMAKE_LFLAGS_RPATHLINK")) project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATHLINK") + escapeFilePath(QFileInfo(rpathdirs[i].toQString()).absoluteFilePath()); } } if(project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS")) include_deps = true; //do not generate deps if(project->isActiveConfig("compile_libtool")) Option::obj_ext = ".lo"; //override the .o MakefileGenerator::init(); QString comps[] = { "C", "CXX", "OBJC", "OBJCXX", QString() }; for(int i = 0; !comps[i].isNull(); i++) { QString compile_flag = var("QMAKE_COMPILE_FLAG"); if(compile_flag.isEmpty()) compile_flag = "-c"; if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) { QString pchFlags = var(ProKey("QMAKE_" + comps[i] + "FLAGS_USE_PRECOMPILE")); QString pchBaseName; if(!project->isEmpty("PRECOMPILED_DIR")) { pchBaseName = Option::fixPathToTargetOS(project->first("PRECOMPILED_DIR").toQString()); if(!pchBaseName.endsWith(Option::dir_sep)) pchBaseName += Option::dir_sep; } pchBaseName += project->first("QMAKE_ORIG_TARGET").toQString(); // replace place holders pchFlags = pchFlags.replace("${QMAKE_PCH_INPUT}", fileFixify(project->first("PRECOMPILED_HEADER").toQString())); pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT_BASE}", pchBaseName); if (project->isActiveConfig("icc_pch_style")) { // icc style pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT}", pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT")); } else { // gcc style (including clang_pch_style) QString headerSuffix; if (project->isActiveConfig("clang_pch_style")) headerSuffix = project->first("QMAKE_PCH_OUTPUT_EXT").toQString(); else pchBaseName += project->first("QMAKE_PCH_OUTPUT_EXT").toQString(); pchBaseName += Option::dir_sep; QString pchOutputFile; if(comps[i] == "C") { pchOutputFile = "c"; } else if(comps[i] == "CXX") { pchOutputFile = "c++"; } else if(project->isActiveConfig("objective_c")) { if(comps[i] == "OBJC") pchOutputFile = "objective-c"; else if(comps[i] == "OBJCXX") pchOutputFile = "objective-c++"; } if(!pchOutputFile.isEmpty()) { pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT}", pchBaseName + pchOutputFile + headerSuffix); } } if (!pchFlags.isEmpty()) compile_flag += " " + pchFlags; } QString cflags; if(comps[i] == "OBJC" || comps[i] == "OBJCXX") cflags += " $(CFLAGS)"; else cflags += " $(" + comps[i] + "FLAGS)"; compile_flag += cflags + " $(INCPATH)"; QString compiler = comps[i]; if (compiler == "C") compiler = "CC"; const ProKey runComp("QMAKE_RUN_" + compiler); if(project->isEmpty(runComp)) project->values(runComp).append("$(" + compiler + ") " + compile_flag + " " + var("QMAKE_CC_O_FLAG") + "$obj $src"); const ProKey runCompImp("QMAKE_RUN_" + compiler + "_IMP"); if(project->isEmpty(runCompImp)) project->values(runCompImp).append("$(" + compiler + ") " + compile_flag + " " + var("QMAKE_CC_O_FLAG") + "\"$@\" \"$<\""); } if (project->isActiveConfig("mac") && !project->isEmpty("TARGET") && !project->isActiveConfig("compile_libtool") && ((project->isActiveConfig("build_pass") || project->isEmpty("BUILDS")))) { ProString bundle; if(project->isActiveConfig("bundle") && !project->isEmpty("QMAKE_BUNDLE_EXTENSION")) { bundle = unescapeFilePath(project->first("TARGET")); if(!project->isEmpty("QMAKE_BUNDLE_NAME")) bundle = unescapeFilePath(project->first("QMAKE_BUNDLE_NAME")); if(!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION"))) bundle += project->first("QMAKE_BUNDLE_EXTENSION"); } else if(project->first("TEMPLATE") == "app" && project->isActiveConfig("app_bundle")) { bundle = unescapeFilePath(project->first("TARGET")); if(!project->isEmpty("QMAKE_APPLICATION_BUNDLE_NAME")) bundle = unescapeFilePath(project->first("QMAKE_APPLICATION_BUNDLE_NAME")); if(!bundle.endsWith(".app")) bundle += ".app"; if(project->isEmpty("QMAKE_BUNDLE_LOCATION")) project->values("QMAKE_BUNDLE_LOCATION").append("Contents/MacOS"); project->values("QMAKE_PKGINFO").append(project->first("DESTDIR") + bundle + "/Contents/PkgInfo"); project->values("QMAKE_BUNDLE_RESOURCE_FILE").append(project->first("DESTDIR") + bundle + "/Contents/Resources/empty.lproj"); } else if(project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib") && ((!project->isActiveConfig("plugin") && project->isActiveConfig("lib_bundle")) || (project->isActiveConfig("plugin") && project->isActiveConfig("plugin_bundle")))) { bundle = unescapeFilePath(project->first("TARGET")); if(project->isActiveConfig("plugin")) { if(!project->isEmpty("QMAKE_PLUGIN_BUNDLE_NAME")) bundle = unescapeFilePath(project->first("QMAKE_PLUGIN_BUNDLE_NAME")); if(!project->isEmpty("QMAKE_BUNDLE_EXTENSION") && !bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION"))) bundle += project->first("QMAKE_BUNDLE_EXTENSION"); else if(!bundle.endsWith(".plugin")) bundle += ".plugin"; if(project->isEmpty("QMAKE_BUNDLE_LOCATION")) project->values("QMAKE_BUNDLE_LOCATION").append("Contents/MacOS"); } else { if(!project->isEmpty("QMAKE_FRAMEWORK_BUNDLE_NAME")) bundle = unescapeFilePath(project->first("QMAKE_FRAMEWORK_BUNDLE_NAME")); if(!project->isEmpty("QMAKE_BUNDLE_EXTENSION") && !bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION"))) bundle += project->first("QMAKE_BUNDLE_EXTENSION"); else if(!bundle.endsWith(".framework")) bundle += ".framework"; } } if(!bundle.isEmpty()) { project->values("QMAKE_BUNDLE") = ProStringList(bundle); project->values("ALL_DEPS") += project->first("QMAKE_PKGINFO"); project->values("ALL_DEPS") += project->first("QMAKE_BUNDLE_RESOURCE_FILE"); } else { project->values("QMAKE_BUNDLE").clear(); project->values("QMAKE_BUNDLE_LOCATION").clear(); } } else { //no bundling here project->values("QMAKE_BUNDLE").clear(); project->values("QMAKE_BUNDLE_LOCATION").clear(); } if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES")) project->values("DISTFILES") += project->values("QMAKE_INTERNAL_INCLUDED_FILES"); project->values("DISTFILES") += project->projectFile(); init2(); project->values("QMAKE_INTERNAL_PRL_LIBS") << "QMAKE_LIBS"; if(!project->isEmpty("QMAKE_MAX_FILES_PER_AR")) { bool ok; int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(&ok); ProStringList ar_sublibs, objs = project->values("OBJECTS"); if(ok && max_files > 5 && max_files < (int)objs.count()) { QString lib; for(int i = 0, obj_cnt = 0, lib_cnt = 0; i != objs.size(); ++i) { if((++obj_cnt) >= max_files) { if(lib_cnt) { lib.sprintf("lib%s-tmp%d.a", project->first("QMAKE_ORIG_TARGET").toLatin1().constData(), lib_cnt); ar_sublibs << lib; obj_cnt = 0; } lib_cnt++; } } } if(!ar_sublibs.isEmpty()) { project->values("QMAKE_AR_SUBLIBS") = ar_sublibs; project->values("QMAKE_INTERNAL_PRL_LIBS") << "QMAKE_AR_SUBLIBS"; } } if(project->isActiveConfig("compile_libtool")) { static const char * const libtoolify[] = { "QMAKE_RUN_CC", "QMAKE_RUN_CC_IMP", "QMAKE_RUN_CXX", "QMAKE_RUN_CXX_IMP", "QMAKE_LINK_THREAD", "QMAKE_LINK", "QMAKE_AR_CMD", "QMAKE_LINK_SHLIB_CMD", 0 }; for (int i = 0; libtoolify[i]; i++) { ProStringList &l = project->values(libtoolify[i]); if(!l.isEmpty()) { QString libtool_flags, comp_flags; if (!strncmp(libtoolify[i], "QMAKE_LINK", 10) || !strcmp(libtoolify[i], "QMAKE_AR_CMD")) { libtool_flags += " --mode=link"; if(project->isActiveConfig("staticlib")) { libtool_flags += " -static"; } else { if(!project->isEmpty("QMAKE_LIB_FLAG")) { int maj = project->first("VER_MAJ").toInt(); int min = project->first("VER_MIN").toInt(); int pat = project->first("VER_PAT").toInt(); comp_flags += " -version-info " + QString::number(10*maj + min) + ":" + QString::number(pat) + ":0"; if (strcmp(libtoolify[i], "QMAKE_AR_CMD")) { QString rpath = Option::output_dir; if(!project->isEmpty("DESTDIR")) { rpath = project->first("DESTDIR").toQString(); if(QDir::isRelativePath(rpath)) rpath.prepend(Option::output_dir + Option::dir_sep); } comp_flags += " -rpath " + Option::fixPathToTargetOS(rpath, false); } } } if(project->isActiveConfig("plugin")) libtool_flags += " -module"; } else { libtool_flags += " --mode=compile"; } l.first().prepend("$(LIBTOOL)" + libtool_flags + " "); if(!comp_flags.isEmpty()) l.first() += comp_flags; } } } }
rtError rtScriptDuk::init() { rtLogInfo(__FUNCTION__); char const* s = getenv("RT_TEST_GC"); if (s && strlen(s) > 0) mTestGc = true; else mTestGc = false; if (mTestGc) rtLogWarn("*** PERFORMANCE WARNING *** : gc being invoked in render thread"); // TODO Please make this better... less hard coded... //0123456 789ABCDEF012 345 67890ABCDEF #if ENABLE_V8_HEAP_PARAMS #ifdef ENABLE_NODE_V_6_9 static const char *args2 = "rtNode\0-e\0console.log(\"rtNode Initalized\");\0\0"; static const char *argv2[] = {&args2[0], &args2[7], &args2[10], NULL}; #else rtLogWarn("v8 old heap space configured to 64mb\n"); static const char *args2 = "rtNode\0--expose-gc\0--max_old_space_size=64\0-e\0console.log(\"rtNode Initalized\");\0\0"; static const char *argv2[] = {&args2[0], &args2[7], &args2[19], &args2[43], &args2[46], NULL}; #endif // ENABLE_NODE_V_6_9 #else #ifdef ENABLE_NODE_V_6_9 #ifndef ENABLE_DEBUG_MODE static const char *args2 = "rtNode\0-e\0console.log(\"rtNode Initalized\");\0\0"; static const char *argv2[] = {&args2[0], &args2[7], &args2[10], NULL}; #endif //!ENABLE_DEBUG_MODE #else static const char *args2 = "rtNode\0--expose-gc\0-e\0console.log(\"rtNode Initalized\");\0\0"; static const char *argv2[] = {&args2[0], &args2[7], &args2[19], &args2[22], NULL}; #endif // ENABLE_NODE_V_6_9 #endif //ENABLE_V8_HEAP_PARAMS #ifndef ENABLE_DEBUG_MODE int argc = sizeof(argv2)/sizeof(char*) - 1; static args_t aa(argc, (char**)argv2); s_gArgs = &aa; char **argv = aa.argv; #endif #ifdef RUNINMAIN #ifdef WIN32 __rt_main_thread__ = GetCurrentThreadId(); #else __rt_main_thread__ = pthread_self(); // NB #endif #endif nodePath(); #ifdef ENABLE_NODE_V_6_9 rtLogWarn("rtNode::rtNode() calling init \n"); #ifdef ENABLE_DEBUG_MODE init2(); #else init2(argc, argv); #endif #else #ifdef ENABLE_DEBUG_MODE init2(); #else init2(argc, argv); #endif #endif // ENABLE_NODE_V_6_9 return RT_OK; }
int main(int argc, char *argv[]) { FILE *pFile2,*pFile1; FILE *pipe_gp1; double start1,start2,end1,end2,time1,time2; int r,i=0,rand(void); pFile1 = fopen ("Data/GUIDED-n-file1.dat" , "w"); pFile2 = fopen ("Data/GUIDED-n-file2.dat" , "w"); if (pFile1 == NULL || pFile2 ==NULL) perror ("Error opening file"); for(i=0;i<100;i++) { init1(); start1 = omp_get_wtime(); for (r=0; r<reps; r++){ loop1(); } end1 = omp_get_wtime(); valid1(); time1 = (float)(end1-start1); //printf("Total time for %d reps of loop 1 = %f\n",reps, time1); init2(); start2 = omp_get_wtime(); for (r=0; r<reps; r++){ loop2(); } end2 = omp_get_wtime(); valid2(); time2 = (float)(end2-start2); // printf("Total time for %d reps of loop 2 = %f\n",reps, time2); // printf("This file is functional\n"); // Write everything in the file, before plotting. fprintf(pFile1,"%lf\t%d\t%lf\n",(i+1)*time1,i+1,time1); fprintf(pFile2,"%lf\t%d\t%lf\n",(i+1)*time2,i+1,time2); } printf("\n\t\t\tWritten to 'GUIDED-n-file1.dat & GUIDED-n-file2.dat'\n\n"); fclose(pFile1); fclose(pFile2); // Gnu-plot script pipe_gp1 = popen("gnuplot","w"); fputs("set terminal wxt 0\n ", pipe_gp1); fputs("unset key\n ", pipe_gp1); fputs("set hidden3d\n ", pipe_gp1); fputs("set dgrid3d 50,50\n ", pipe_gp1); fputs("set title '3DPlot1'\n ", pipe_gp1); fputs("set xlabel'Random Axis Arrangement (for 3-d plot)'\n ", pipe_gp1); fputs("set ylabel 'Iteration Number'\n ", pipe_gp1); fputs("set zlabel 'Time taken for 100 iterations'\n ", pipe_gp1); fputs("splot 'Data/GUIDED-n-file1.dat' u 1:2:3 w lines \n ", pipe_gp1); fputs("set terminal png size 1200,800\n ", pipe_gp1); fputs("set output 'Plots/GUIDED-n-3dplot1.png'\n ", pipe_gp1); fputs("replot\n ", pipe_gp1); fputs("reset\n ", pipe_gp1); fputs("set terminal wxt 0\n ", pipe_gp1); fputs("unset key\n ", pipe_gp1); fputs("set title '2DPlot1'\n ", pipe_gp1); fputs("set xlabel 'Iteration Number'\n ", pipe_gp1); fputs("set ylabel 'Time taken for 100 iterations'\n ", pipe_gp1); fputs("plot 'Data/GUIDED-n-file1.dat' u 2:3 w lines \n ", pipe_gp1); fputs("set terminal png size 1200,800\n ", pipe_gp1); fputs("set output 'Plots/GUIDED-n-2dplot1.png'\n ", pipe_gp1); fputs("replot\n ", pipe_gp1); fputs("reset\n ", pipe_gp1); fputs("set terminal wxt 0\n ", pipe_gp1); fputs("unset key\n ", pipe_gp1); fputs("set hidden3d\n ", pipe_gp1); fputs("set dgrid3d 50,50\n ", pipe_gp1); fputs("set title 'Plot2'\n ", pipe_gp1); fputs("set xlabel'Random Axis Arrangement (for 3-d plot)'\n ", pipe_gp1); fputs("set ylabel 'Iteration Number'\n ", pipe_gp1); fputs("set zlabel 'Time taken for 100 iterations'\n ", pipe_gp1); fputs("splot 'Data/GUIDED-n-file2.dat' u 1:2:3 w lines \n ", pipe_gp1); fputs("set terminal png size 1200,800\n ", pipe_gp1); fputs("set output 'Plots/GUIDED-n-3dplot2.png'\n ", pipe_gp1); fputs("replot\n ", pipe_gp1); fputs("reset\n ", pipe_gp1); fputs("set terminal wxt 0\n ", pipe_gp1); fputs("unset key\n ", pipe_gp1); fputs("set title '2DPlot1'\n ", pipe_gp1); fputs("set xlabel 'Iteration Number'\n ", pipe_gp1); fputs("set ylabel 'Time taken for 100 iterations'\n ", pipe_gp1); fputs("plot 'Data/GUIDED-n-file2.dat' u 2:3 w lines \n ", pipe_gp1); fputs("set terminal png size 1200,800\n ", pipe_gp1); fputs("set output 'Plots/GUIDED-n-2dplot2.png'\n ", pipe_gp1); fputs("replot\n ", pipe_gp1); pclose(pipe_gp1); printf("\n\t\t\tPlots at 'GUIDED-n-plot1.png & GUIDED-n-plot2.png' for loop1 & loop2 (100I)\n\n"); }
int main (int __argc, char *__argv[]) { peo :: init( __argc, __argv ); if (getNodeRank()==1) std::cout<<"\n\nTest : PSO Worst Position\n\n"; rng.reseed (10); RingTopology topologyMig; eoGenContinue < Indi > genContPara (10); eoCombinedContinue <Indi> continuatorPara (genContPara); eoCheckPoint<Indi> checkpoint(continuatorPara); peoEvalFunc<Indi, double, const Indi& > plainEval(f); peoPopEval< Indi > eval(plainEval); eoUniformGenerator < double >uGen (0, 1.); eoInitFixedLength < Indi > random (2, uGen); eoUniformGenerator < double >sGen (-1., 1.); eoVelocityInitFixedLength < Indi > veloRandom (2, sGen); eoFirstIsBestInit < Indi > localInit; eoRealVectorBounds bndsFlight(2,0,1.); eoStandardFlight < Indi > flight(bndsFlight); eoPop < Indi > pop; pop.append (10, random); eoLinearTopology<Indi> topology(2); eoRealVectorBounds bnds(2,-1.,1.); eoStandardVelocity < Indi > velocity (topology,1,0.5,2.,bnds); eoInitializer <Indi> init(eval,veloRandom,localInit,topology,pop); eoPeriodicContinue< Indi > mig_cont( 2 ); peoPSOSelect<Indi> mig_selec(topology); peoWorstPositionReplacement<Indi> mig_replac; eoContinuator<Indi> cont(mig_cont, pop); eoSelector <Indi, eoPop<Indi> > mig_select (mig_selec,1,pop); eoReplace <Indi, eoPop<Indi> > mig_replace (mig_replac,pop); eoGenContinue < Indi > genContPara2 (10); eoCombinedContinue <Indi> continuatorPara2 (genContPara2); eoCheckPoint<Indi> checkpoint2(continuatorPara2); peoEvalFunc<Indi, double, const Indi& > plainEval2(f); peoPopEval< Indi > eval2(plainEval2); eoUniformGenerator < double >uGen2 (0, 1.); eoInitFixedLength < Indi > random2 (2, uGen2); eoUniformGenerator < double >sGen2 (-1., 1.); eoVelocityInitFixedLength < Indi > veloRandom2 (2, sGen2); eoFirstIsBestInit < Indi > localInit2; eoRealVectorBounds bndsFlight2(2,0,1.); eoStandardFlight < Indi > flight2(bndsFlight2); eoPop < Indi > pop2; pop2.append (10, random2); eoLinearTopology<Indi> topology2(2); eoRealVectorBounds bnds2(2,-1.,1.); eoStandardVelocity < Indi > velocity2 (topology2,1,0.5,2.,bnds2); eoInitializer <Indi> init2(eval2,veloRandom2,localInit2,topology2,pop2); eoPeriodicContinue< Indi > mig_cont2( 2 ); peoPSOSelect<Indi> mig_selec2(topology2); peoWorstPositionReplacement<Indi> mig_replac2; eoContinuator<Indi> cont2(mig_cont2,pop2); eoSelector <Indi, eoPop<Indi> > mig_select2 (mig_selec2,1,pop2); eoReplace <Indi, eoPop<Indi> > mig_replace2 (mig_replac2,pop2); peoAsyncIslandMig< eoPop<Indi>, eoPop<Indi> > mig(cont,mig_select, mig_replace, topologyMig); checkpoint.add( mig ); peoAsyncIslandMig< eoPop<Indi>, eoPop<Indi> > mig2(cont2,mig_select2, mig_replace2, topologyMig); checkpoint2.add( mig2 ); eoSyncEasyPSO <Indi> psa(init,checkpoint,eval, velocity, flight); peoWrapper parallelPSO( psa, pop); eval.setOwner(parallelPSO); mig.setOwner(parallelPSO); eoSyncEasyPSO <Indi> psa2(init2,checkpoint2,eval2, velocity2, flight2); peoWrapper parallelPSO2( psa2, pop2); eval2.setOwner(parallelPSO2); mig2.setOwner(parallelPSO2); peo :: run(); peo :: finalize(); if (getNodeRank()==1) { pop.sort(); pop2.sort(); std::cout << "Final population :\n" << pop << std::endl; std::cout << "Final population :\n" << pop2 << std::endl; } }