Lines Matching refs:fp
63 void ApiGen::printHeader(FILE *fp) const in printHeader()
65 fprintf(fp, "// Generated Code - DO NOT EDIT !!\n"); in printHeader()
66 fprintf(fp, "// generated by 'emugen'\n"); in printHeader()
71 FILE *fp = fopen(filename.c_str(), "wt"); in genProcTypes() local
72 if (fp == NULL) { in genProcTypes()
76 printHeader(fp); in genProcTypes()
80 fprintf(fp, "#ifndef __%s_%s_proc_t_h\n", basename, sideString(side)); in genProcTypes()
81 fprintf(fp, "#define __%s_%s_proc_t_h\n", basename, sideString(side)); in genProcTypes()
82 fprintf(fp, "\n\n"); in genProcTypes()
83 fprintf(fp, "\n#include \"%s_types.h\"\n",basename); in genProcTypes()
84 fprintf(fp, "#ifdef _MSC_VER\n"); in genProcTypes()
85 fprintf(fp, "#include <stdint.h>\n"); in genProcTypes()
86 fprintf(fp, "#endif\n"); in genProcTypes()
87 fprintf(fp, "#ifndef %s_APIENTRY\n",basename); in genProcTypes()
88 fprintf(fp, "#define %s_APIENTRY \n",basename); in genProcTypes()
89 fprintf(fp, "#endif\n"); in genProcTypes()
95 fprintf(fp, "typedef "); in genProcTypes()
96 e->retval().printType(fp); in genProcTypes()
97 … fprintf(fp, " (%s_APIENTRY *%s_%s_proc_t) (", basename, e->name().c_str(), sideString(side)); in genProcTypes()
98 if (side == CLIENT_SIDE) { fprintf(fp, "void * ctx"); } in genProcTypes()
99 if (e->customDecoder() && side == SERVER_SIDE) { fprintf(fp, "void *ctx"); } in genProcTypes()
106 …f (j != 0 || side == CLIENT_SIDE || (side == SERVER_SIDE && e->customDecoder())) fprintf(fp, ", "); in genProcTypes()
107 evars[j].printType(fp); in genProcTypes()
110 fprintf(fp, ");\n"); in genProcTypes()
113 fprintf(fp, "typedef "); in genProcTypes()
114 e->retval().printType(fp); in genProcTypes()
115 … fprintf(fp, " (%s_APIENTRY *%s_dec_%s_proc_t) (", basename, e->name().c_str(), sideString(side)); in genProcTypes()
122 if (j != 0) fprintf(fp, ", "); in genProcTypes()
123 evars[j].printType(fp); in genProcTypes()
126 fprintf(fp, ");\n"); in genProcTypes()
129 fprintf(fp, "\n\n#endif\n"); in genProcTypes()
135 FILE *fp = fopen(filename.c_str(), "wt"); in genFuncTable() local
136 if (fp == NULL) { in genFuncTable()
140 printHeader(fp); in genFuncTable()
142 fprintf(fp, "#ifndef __%s_%s_ftable_t_h\n", m_basename.c_str(), sideString(side)); in genFuncTable()
143 fprintf(fp, "#define __%s_%s_ftable_t_h\n", m_basename.c_str(), sideString(side)); in genFuncTable()
144 fprintf(fp, "\n\n"); in genFuncTable()
145 fprintf(fp, "static const struct _%s_funcs_by_name {\n", m_basename.c_str()); in genFuncTable()
146 fprintf(fp, in genFuncTable()
155 fprintf(fp, "\t{\"%s\", (void*)%s},\n", e->name().c_str(), e->name().c_str()); in genFuncTable()
157 fprintf(fp, "};\n"); in genFuncTable()
158 …fprintf(fp, "static const int %s_num_funcs = sizeof(%s_funcs_by_name) / sizeof(struct _%s_funcs_by… in genFuncTable()
160 fprintf(fp, "\n\n#endif\n"); in genFuncTable()
166 FILE *fp = fopen(filename.c_str(), "wt"); in genContext() local
167 if (fp == NULL) { in genContext()
171 printHeader(fp); in genContext()
173 fprintf(fp, "#ifndef __%s_%s_context_t_h\n", m_basename.c_str(), sideString(side)); in genContext()
174 fprintf(fp, "#define __%s_%s_context_t_h\n", m_basename.c_str(), sideString(side)); in genContext()
176 fprintf(fp, "\n#include \"%s_%s_proc.h\"\n", in genContext()
179 fprintf(fp, "\n#include \"%s_types.h\"\n", m_basename.c_str()); in genContext()
183 fprintf(fp, "#include %s\n", contextHeaders[i].c_str()); in genContext()
185 fprintf(fp, "\n"); in genContext()
187 fprintf(fp, "\nstruct %s_%s_context_t {\n\n", in genContext()
194 … fprintf(fp, "\t%s_dec_%s_proc_t %s;\n", e->name().c_str(), sideString(side), e->name().c_str()); in genContext()
195 … fprintf(fp, "\t%s_%s_proc_t %s_dec;\n", e->name().c_str(), sideString(side), e->name().c_str()); in genContext()
197 … fprintf(fp, "\t%s_%s_proc_t %s;\n", e->name().c_str(), sideString(side), e->name().c_str()); in genContext()
202 fprintf(fp, "\tvirtual ~%s_%s_context_t() {}\n", m_basename.c_str(), sideString(side)); in genContext()
205 fprintf(fp, "\n\ttypedef %s_%s_context_t *CONTEXT_ACCESSOR_TYPE(void);\n", in genContext()
207 fprintf(fp, "\tstatic void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);\n"); in genContext()
211 …fprintf(fp, "\tint initDispatchByName( void *(*getProc)(const char *name, void *userData), void *u… in genContext()
215 fprintf(fp, "\tvirtual void setError(unsigned int error){ (void)error; }\n"); in genContext()
216 fprintf(fp, "\tvirtual unsigned int getError(){ return 0; }\n"); in genContext()
219 fprintf(fp, "};\n"); in genContext()
221 fprintf(fp, "\n#endif\n"); in genContext()
222 fclose(fp); in genContext()
235 FILE *fp = fopen(filename.c_str(), "wt"); in genEntryPoints() local
236 if (fp == NULL) { in genEntryPoints()
241 printHeader(fp); in genEntryPoints()
242 fprintf(fp, "#include <stdio.h>\n"); in genEntryPoints()
243 fprintf(fp, "#include <stdlib.h>\n"); in genEntryPoints()
244 fprintf(fp, "#include \"%s_%s_context.h\"\n", m_basename.c_str(), sideString(side)); in genEntryPoints()
245 fprintf(fp, "\n"); in genEntryPoints()
247 fprintf(fp, "extern \"C\" {\n"); in genEntryPoints()
250 fprintf(fp, "\t"); at(i).print(fp, false); fprintf(fp, ";\n"); in genEntryPoints()
252 fprintf(fp, "};\n\n"); in genEntryPoints()
254 fprintf(fp, "#ifndef GET_CONTEXT\n"); in genEntryPoints()
255 fprintf(fp, "static %s_%s_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;\n", in genEntryPoints()
258 fprintf(fp, in genEntryPoints()
261 fprintf(fp, "#define GET_CONTEXT %s_%s_context_t * ctx = getCurrentContext()\n", in genEntryPoints()
263 fprintf(fp, "#endif\n\n"); in genEntryPoints()
268 e->print(fp); in genEntryPoints()
269 fprintf(fp, "{\n"); in genEntryPoints()
270 fprintf(fp, "\tGET_CONTEXT;\n"); in genEntryPoints()
278 fprintf(fp, "\t%s\n", e->vars()[j].paramCheckExpression().c_str()); in genEntryPoints()
281 fprintf(fp, "\t%sctx->%s(%s", in genEntryPoints()
289 fprintf(fp, "%s %s", in genEntryPoints()
294 fprintf(fp, ");\n"); in genEntryPoints()
295 fprintf(fp, "}\n\n"); in genEntryPoints()
297 fclose(fp); in genEntryPoints()
304 FILE *fp = fopen(filename.c_str(), "wt"); in genOpcodes() local
305 if (fp == NULL) { in genOpcodes()
310 printHeader(fp); in genOpcodes()
311 fprintf(fp, "#ifndef __GUARD_%s_opcodes_h_\n", m_basename.c_str()); in genOpcodes()
312 fprintf(fp, "#define __GUARD_%s_opcodes_h_\n\n", m_basename.c_str()); in genOpcodes()
314 … fprintf(fp, "#define OP_%s \t\t\t\t\t%u\n", at(i).name().c_str(), (unsigned int)i + m_baseOpcode); in genOpcodes()
316 fprintf(fp, "#define OP_last \t\t\t\t\t%u\n", (unsigned int)size() + m_baseOpcode); in genOpcodes()
317 fprintf(fp,"\n\n#endif\n"); in genOpcodes()
318 fclose(fp); in genOpcodes()
324 FILE *fp = fopen(filename.c_str(), "wt"); in genAttributesTemplate() local
325 if (fp == NULL) { in genAttributesTemplate()
332 fprintf(fp, "#"); in genAttributesTemplate()
333 at(i).print(fp); in genAttributesTemplate()
334 fprintf(fp, "%s\n\n", at(i).name().c_str()); in genAttributesTemplate()
337 fclose(fp); in genAttributesTemplate()
343 FILE *fp = fopen(filename.c_str(), "wt"); in genEncoderHeader() local
344 if (fp == NULL) { in genEncoderHeader()
349 printHeader(fp); in genEncoderHeader()
352 fprintf(fp, "\n#ifndef GUARD_%s\n", classname.c_str()); in genEncoderHeader()
353 fprintf(fp, "#define GUARD_%s\n\n", classname.c_str()); in genEncoderHeader()
355 fprintf(fp, "#include \"gfxstream/guest/ChecksumCalculator.h\"\n"); in genEncoderHeader()
356 fprintf(fp, "#include \"gfxstream/guest/IOStream.h\"\n"); in genEncoderHeader()
358 fprintf(fp, "#include \"%s_%s_context.h\"\n\n\n", m_basename.c_str(), sideString(CLIENT_SIDE)); in genEncoderHeader()
361 fprintf(fp, "#include %s\n", m_encoderHeaders[i].c_str()); in genEncoderHeader()
363 fprintf(fp, "\n"); in genEncoderHeader()
367 fprintf(fp, "struct %s : public %s_%s_context_t {\n\n", in genEncoderHeader()
369 fprintf(fp, "\tgfxstream::guest::IOStream *m_stream;\n"); in genEncoderHeader()
370 fprintf(fp, "\tgfxstream::guest::ChecksumCalculator *m_checksumCalculator;\n\n"); in genEncoderHeader()
372 …fprintf(fp, "\t%s(gfxstream::guest::IOStream *stream, gfxstream::guest::ChecksumCalculator *checks… in genEncoderHeader()
373 fprintf(fp, "\tvirtual uint64_t lockAndWriteDma(void*, uint32_t) { return 0; }\n"); in genEncoderHeader()
374 fprintf(fp, "};\n\n"); in genEncoderHeader()
378 fprintf(fp, "#endif // GUARD_%s\n", classname.c_str()); in genEncoderHeader()
380 fclose(fp); in genEncoderHeader()
430 static int writeVarEncodingSize(Var& var, bool excludeOutVars, FILE* fp) in writeVarEncodingSize() argument
434 fprintf(fp, "%u", (unsigned int) var.type()->bytes()); in writeVarEncodingSize()
438 fprintf(fp, "8"); in writeVarEncodingSize()
443 fprintf(fp, "0"); in writeVarEncodingSize()
445 fprintf(fp, "__size_%s", var.name().c_str()); in writeVarEncodingSize()
451 static void writeVarEncodingExpression(Var& var, FILE* fp) in writeVarEncodingExpression() argument
458 …fprintf(fp, "\t*(uint64_t *)(ptr) = ctx->lockAndWriteDma(%s, __size_%s); ptr += 8;\n", varname, va… in writeVarEncodingExpression()
460 fprintf(fp, "\tmemcpy(ptr, &__size_%s, 4); ptr += 4;\n", varname); in writeVarEncodingExpression()
465 fprintf(fp, "\tif (%s != NULL) ", varname); in writeVarEncodingExpression()
467 fprintf(fp, "\t"); in writeVarEncodingExpression()
471 fprintf(fp, "%s;", var.packExpression().c_str()); in writeVarEncodingExpression()
473 fprintf(fp, "memcpy(ptr, %s, __size_%s);", in writeVarEncodingExpression()
477 fprintf(fp, "ptr += __size_%s;\n", varname); in writeVarEncodingExpression()
483 fprintf(fp, "\t\tmemcpy(ptr, &%s, %u); ptr += %u;\n", in writeVarEncodingExpression()
492 static void writeVarLargeEncodingExpression(Var& var, FILE* fp) in writeVarLargeEncodingExpression() argument
496 fprintf(fp, "\tstream->writeFully(&__size_%s,4);\n", varname); in writeVarLargeEncodingExpression()
497 fprintf(fp, "\tif (useChecksum) checksumCalculator->addBuffer(&__size_%s,4);\n", varname); in writeVarLargeEncodingExpression()
499 fprintf(fp, "\tif (%s != NULL) {\n", varname); in writeVarLargeEncodingExpression()
502 fprintf(fp, "%s", var.writeExpression().c_str()); in writeVarLargeEncodingExpression()
505 fprintf(fp, "\t\t%s;\n", var.guestPackExpression().c_str()); in writeVarLargeEncodingExpression()
507 fprintf(fp, "\t\tstream->writeFully(%s, __size_%s);\n", varname, varname); in writeVarLargeEncodingExpression()
509 …fprintf(fp, "\t\tif (useChecksum) checksumCalculator->addBuffer(%s, __size_%s);\n", varname, varna… in writeVarLargeEncodingExpression()
511 if (var.nullAllowed()) fprintf(fp, "\t}\n"); in writeVarLargeEncodingExpression()
515 static void writeEncodingChecksumValidatorOnReturn(const char* funcName, FILE* fp) { in writeEncodingChecksumValidatorOnReturn() argument
516 fprintf(fp, "\tif (useChecksum) {\n" in writeEncodingChecksumValidatorOnReturn()
531 FILE* fp) { in addGuestTimePrinting() argument
533 fprintf(fp, "\tclock_gettime(CLOCK_REALTIME, &ts1);\n"); in addGuestTimePrinting()
534 …fprintf(fp, "\tlong timeDiff = ts1.tv_sec*1000000 + ts1.tv_nsec/1000 - (ts0.tv_sec*1000000 + ts0.t… in addGuestTimePrinting()
536 …fprintf(fp, "\tlong timeDiff2 = ts1.tv_sec*1000000 + ts1.tv_nsec/1000 - (ts2.tv_sec*1000000 + ts2.… in addGuestTimePrinting()
537 … fprintf(fp, "\tALOGW(\"%s: %%ld (%%ld) us\\n\", timeDiff, timeDiff2);\n", e->name().c_str()); in addGuestTimePrinting()
539 fprintf(fp, "\tALOGW(\"%s: %%ld us\\n\", timeDiff);\n", e->name().c_str()); in addGuestTimePrinting()
544 static void addEncoderDebugLog(const EntryPoint* e, FILE* fp) { in addEncoderDebugLog() argument
545 fprintf(fp, "\tENCODER_DEBUG_LOG(\"%s(", e->name().c_str()); in addEncoderDebugLog()
551 fprintf(fp, ", "); in addEncoderDebugLog()
553 fprintf(fp, "%s:%s", var.name().c_str(), var.type()->printFormat().c_str()); in addEncoderDebugLog()
556 fprintf(fp, ")\""); in addEncoderDebugLog()
559 fprintf(fp, ", %s", var.name().c_str()); in addEncoderDebugLog()
562 fprintf(fp, ");\n"); in addEncoderDebugLog()
567 FILE *fp = fopen(filename.c_str(), "wt"); in genEncoderImpl() local
568 if (fp == NULL) { in genEncoderImpl()
573 printHeader(fp); in genEncoderImpl()
574 fprintf(fp, "\n\n"); in genEncoderImpl()
575 fprintf(fp, "#include <string.h>\n"); in genEncoderImpl()
576 fprintf(fp, "#include \"%s_opcodes.h\"\n\n", m_basename.c_str()); in genEncoderImpl()
577 fprintf(fp, "#include \"%s_enc.h\"\n\n\n", m_basename.c_str()); in genEncoderImpl()
578 fprintf(fp, "#include <vector>\n\n"); in genEncoderImpl()
579 fprintf(fp, "#include <stdio.h>\n\n"); in genEncoderImpl()
580 fprintf(fp, "#include \"aemu/base/Tracing.h\"\n\n"); in genEncoderImpl()
581 fprintf(fp, "#include \"EncoderDebug.h\"\n\n"); in genEncoderImpl()
584 fprintf(fp, "using gfxstream::guest::ChecksumCalculator;\n\n"); in genEncoderImpl()
585 fprintf(fp, "using gfxstream::guest::IOStream;\n\n"); in genEncoderImpl()
586 fprintf(fp, "namespace {\n\n"); in genEncoderImpl()
589 fprintf(fp, in genEncoderImpl()
604 e->print(fp, true, "_enc", /* classname + "::" */"", "void *self"); in genEncoderImpl()
605 fprintf(fp, "{\n"); in genEncoderImpl()
607 addEncoderDebugLog(e, fp); in genEncoderImpl()
609 fprintf(fp, "\tAEMU_SCOPED_TRACE(\"%s encode\");\n", e->name().c_str()); in genEncoderImpl()
612 fprintf(fp, "\tstruct timespec ts0, ts1;\n"); in genEncoderImpl()
613 fprintf(fp, "\tclock_gettime(CLOCK_REALTIME, &ts0);\n"); in genEncoderImpl()
617 fprintf(fp, "\n\t%s *ctx = (%s *)self;\n", in genEncoderImpl()
620 fprintf(fp, "\tIOStream *stream = ctx->m_stream;\n" in genEncoderImpl()
638 fprintf(fp, "\tconst unsigned int __size_%s = ", varname); in genEncoderImpl()
642 fprintf(fp, "%s;\n", buff); in genEncoderImpl()
657 fprintf(fp, "\t unsigned char *ptr;\n"); in genEncoderImpl()
658 fprintf(fp, "\t unsigned char *buf;\n"); in genEncoderImpl()
659 fprintf(fp, "\t const size_t sizeWithoutChecksum = 8"); in genEncoderImpl()
662 fprintf(fp, " + "); in genEncoderImpl()
663 npointers += writeVarEncodingSize(evars[j], true, fp); in genEncoderImpl()
666 fprintf(fp, " + %zu*4", npointers); in genEncoderImpl()
668 fprintf(fp, ";\n"); in genEncoderImpl()
671 fprintf(fp, "\t const size_t checksumSize = checksumCalculator->checksumByteSize();\n"); in genEncoderImpl()
674 fprintf(fp, "\t const size_t totalSize = sizeWithoutChecksum + checksumSize;\n"); in genEncoderImpl()
697 fprintf(fp, "\tbuf = stream->alloc(totalSize);\n"); in genEncoderImpl()
702 fprintf(fp, "\tbuf = stream->alloc("); in genEncoderImpl()
706 fprintf(fp,"8"); plus = " + "; in genEncoderImpl()
711 fprintf(fp, "%s", plus); plus = " + "; in genEncoderImpl()
712 npointers += writeVarEncodingSize(evars[j], false, fp); in genEncoderImpl()
715 fprintf(fp, "%s%zu*4", plus, npointers); plus = " + "; in genEncoderImpl()
718 fprintf(fp,");\n"); in genEncoderImpl()
720 fprintf(fp, "\tptr = buf;\n"); in genEncoderImpl()
724 … fprintf(fp, "\tint tmp = OP_%s;memcpy(ptr, &tmp, 4); ptr += 4;\n", e->name().c_str()); in genEncoderImpl()
725 fprintf(fp, "\tmemcpy(ptr, &totalSize, 4); ptr += 4;\n\n"); in genEncoderImpl()
729 … fprintf(fp, "\n\tif (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);\n"); in genEncoderImpl()
735 writeVarEncodingExpression(evars[j],fp); in genEncoderImpl()
738 fprintf(fp, "\n\tif (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);\n"); in genEncoderImpl()
741 fprintf(fp, "\tstream->flush();\n"); in genEncoderImpl()
748 writeVarLargeEncodingExpression(evars[j], fp); in genEncoderImpl()
757 fprintf(fp, "\tunsigned char *ptr;\n"); in genEncoderImpl()
758 fprintf(fp, "\tunsigned char *buf;\n"); in genEncoderImpl()
759 fprintf(fp, "\tconst size_t sizeWithoutChecksum = 8"); in genEncoderImpl()
767 fprintf(fp, " + %s", buff); in genEncoderImpl()
769 fprintf(fp, " + %u * 4;\n", (unsigned int)npointers); in genEncoderImpl()
771 fprintf(fp, "\t const size_t checksumSize = checksumCalculator->checksumByteSize();\n"); in genEncoderImpl()
773 fprintf(fp, "\t const size_t totalSize = sizeWithoutChecksum + checksumSize;\n"); in genEncoderImpl()
776 fprintf(fp, "\tptr = buf = stream->alloc(totalSize);\n\n"); in genEncoderImpl()
779 fprintf(fp, "\tint tmp = OP_%s; memcpy(ptr, &tmp, 4); ptr += 4;\n", e->name().c_str()); in genEncoderImpl()
780 fprintf(fp, "\tmemcpy(ptr, &totalSize, 4); ptr += 4;\n\n"); in genEncoderImpl()
784 writeVarEncodingExpression(evars[j], fp); in genEncoderImpl()
787 fprintf(fp, "\tif (useChecksum) checksumCalculator->addBuffer(buf, ptr - buf);\n"); in genEncoderImpl()
792 fprintf(fp, "\tbuf = stream->alloc(checksumSize);\n"); in genEncoderImpl()
793 … fprintf(fp, "\tif (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);\n\n"); in genEncoderImpl()
795 …fprintf(fp, "\tif (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += check… in genEncoderImpl()
812 fprintf(fp, "\tstream->flush();\n"); in genEncoderImpl()
813 fprintf(fp, "\tstruct timespec ts2;\n"); in genEncoderImpl()
814 fprintf(fp, "\tclock_gettime(CLOCK_REALTIME, &ts2);\n"); in genEncoderImpl()
818 fprintf(fp, "\tif (%s != NULL) {\n",varname); in genEncoderImpl()
823 fprintf(fp, "%s%s;\n", indent, evars[j].guestUnpackExpression().c_str()); in genEncoderImpl()
826 … fprintf(fp, "%s// Skip readback for var %s as it's DMA\n", indent, varname); in genEncoderImpl()
828 fprintf(fp, "%sstream->readback(%s, __size_%s);\n", in genEncoderImpl()
833 fprintf(fp, "%s// Skip checksum for var %s as it's DMA\n", indent, varname); in genEncoderImpl()
835 … fprintf(fp, "%sif (useChecksum) checksumCalculator->addBuffer(%s, __size_%s);\n", in genEncoderImpl()
839 fprintf(fp, "\t}\n"); in genEncoderImpl()
852 fprintf(fp, "\tstream->flush();\n"); in genEncoderImpl()
854 addGuestTimePrinting(e, hasTimeBeforeReadback, fp); in genEncoderImpl()
855 fprintf(fp, "\t return NULL;\n"); in genEncoderImpl()
860 fprintf(fp, "\tstream->flush();\n"); in genEncoderImpl()
861 fprintf(fp, "\tstruct timespec ts2;\n"); in genEncoderImpl()
862 fprintf(fp, "\tclock_gettime(CLOCK_REALTIME, &ts2);\n"); in genEncoderImpl()
866 fprintf(fp, "\n\t%s retval;\n", e->retval().type()->name().c_str()); in genEncoderImpl()
867 … fprintf(fp, "\tstream->readback(&retval, %u);\n",(unsigned) e->retval().type()->bytes()); in genEncoderImpl()
868 fprintf(fp, "\tif (useChecksum) checksumCalculator->addBuffer(&retval, %u);\n", in genEncoderImpl()
870 writeEncodingChecksumValidatorOnReturn(e->name().c_str(), fp); in genEncoderImpl()
871 addGuestTimePrinting(e, hasTimeBeforeReadback, fp); in genEncoderImpl()
872 fprintf(fp, "\treturn retval;\n"); in genEncoderImpl()
874 if (e->flushOnEncode()) fprintf(fp, "\tstream->flush();\n"); in genEncoderImpl()
875 if (hasReadbackChecksum) writeEncodingChecksumValidatorOnReturn(e->name().c_str(), fp); in genEncoderImpl()
876 addGuestTimePrinting(e, hasTimeBeforeReadback, fp); in genEncoderImpl()
878 fprintf(fp, "}\n\n"); in genEncoderImpl()
881 fprintf(fp, "} // namespace\n\n"); in genEncoderImpl()
884 …fprintf(fp, "%s::%s(IOStream *stream, ChecksumCalculator *checksumCalculator)\n{\n", classname.c_s… in genEncoderImpl()
885 fprintf(fp, "\tm_stream = stream;\n"); in genEncoderImpl()
886 fprintf(fp, "\tm_checksumCalculator = checksumCalculator;\n\n"); in genEncoderImpl()
891 fprintf(fp, in genEncoderImpl()
897 fprintf(fp, in genEncoderImpl()
903 fprintf(fp, "}\n\n"); in genEncoderImpl()
907 fclose(fp); in genEncoderImpl()
914 FILE *fp = fopen(filename.c_str(), "wt"); in genDecoderHeader() local
915 if (fp == NULL) { in genDecoderHeader()
920 printHeader(fp); in genDecoderHeader()
923 fprintf(fp, "\n#ifndef GUARD_%s\n", classname.c_str()); in genDecoderHeader()
924 fprintf(fp, "#define GUARD_%s\n\n", classname.c_str()); in genDecoderHeader()
926 fprintf(fp, "#include \"render-utils/IOStream.h\"\n"); in genDecoderHeader()
927 fprintf(fp, "#include \"ChecksumCalculator.h\"\n"); in genDecoderHeader()
928 fprintf(fp, "#include \"%s_%s_context.h\"\n\n\n", m_basename.c_str(), sideString(SERVER_SIDE)); in genDecoderHeader()
930 fprintf(fp, "#include \"time.h\"\n"); in genDecoderHeader()
934 fprintf(fp, "#include %s\n", m_decoderHeaders[i].c_str()); in genDecoderHeader()
936 fprintf(fp, "\n"); in genDecoderHeader()
938 fprintf(fp, "namespace gfxstream {\n\n"); in genDecoderHeader()
940 fprintf(fp, "struct %s : public %s_%s_context_t {\n\n", in genDecoderHeader()
942 …fprintf(fp, "\tsize_t decode(void *buf, size_t bufsize, IOStream *stream, ChecksumCalculator* chec… in genDecoderHeader()
943 fprintf(fp, "\n};\n\n"); in genDecoderHeader()
945 fprintf(fp, "} // namespace gfxstream\n\n"); in genDecoderHeader()
947 fprintf(fp, "#endif // GUARD_%s\n", classname.c_str()); in genDecoderHeader()
949 fclose(fp); in genDecoderHeader()
955 FILE *fp = fopen(filename.c_str(), "wt"); in genContextImpl() local
956 if (fp == NULL) { in genContextImpl()
960 printHeader(fp); in genContextImpl()
964 fprintf(fp, "\n\n#include <string.h>\n"); in genContextImpl()
965 fprintf(fp, "#include \"%s_%s_context.h\"\n\n\n", m_basename.c_str(), sideString(side)); in genContextImpl()
966 fprintf(fp, "#include <stdio.h>\n\n"); in genContextImpl()
968 …fprintf(fp, "int %s::initDispatchByName(void *(*getProc)(const char *, void *userData), void *user… in genContextImpl()
972 fprintf(fp, "\t%s = (%s_dec_%s_proc_t) getProc(\"%s\", userData);\n", in genContextImpl()
978 fprintf(fp, "\t%s = (%s_%s_proc_t) getProc(\"%s\", userData);\n", in genContextImpl()
985 fprintf(fp, "\treturn 0;\n"); in genContextImpl()
986 fprintf(fp, "}\n\n"); in genContextImpl()
987 fclose(fp); in genContextImpl()
993 FILE *fp = fopen(filename.c_str(), "wt"); in genDecoderImpl() local
994 if (fp == NULL) { in genDecoderImpl()
999 printHeader(fp); in genDecoderImpl()
1014 fprintf(fp, "\n\n#include <string.h>\n"); in genDecoderImpl()
1015 fprintf(fp, "#include \"%s_opcodes.h\"\n\n", m_basename.c_str()); in genDecoderImpl()
1016 fprintf(fp, "#include \"%s_dec.h\"\n\n\n", m_basename.c_str()); in genDecoderImpl()
1017 fprintf(fp, "#include \"ProtocolUtils.h\"\n\n"); in genDecoderImpl()
1018 fprintf(fp, "#include \"ChecksumCalculatorThreadInfo.h\"\n\n"); in genDecoderImpl()
1019 fprintf(fp, "#include \"host-common/logging.h\"\n\n"); in genDecoderImpl()
1020 fprintf(fp, "#include <stdio.h>\n\n"); in genDecoderImpl()
1022 fprintf(fp, "namespace gfxstream {\n\n"); in genDecoderImpl()
1024 …fprintf(fp, "typedef unsigned int tsize_t; // Target \"size_t\", which is 32-bit for now. It may o… in genDecoderImpl()
1026 fprintf(fp, in genDecoderImpl()
1039 …fprintf(fp, "size_t %s::decode(void *buf, size_t len, IOStream *stream, ChecksumCalculator* checks… in genDecoderImpl()
1040 fprintf(fp, in genDecoderImpl()
1048 fprintf(fp, in genDecoderImpl()
1053 fprintf(fp, in genDecoderImpl()
1059 fprintf(fp, in genDecoderImpl()
1066 fprintf(fp, "\t\tswitch(opcode) {\n"); in genDecoderImpl()
1091 fprintf(fp, "\t\tcase OP_%s: {\n", e->name().c_str()); in genDecoderImpl()
1092 fprintf(fp, "\t\t\tandroid::base::beginTrace(\"%s decode\");\n", e->name().c_str()); in genDecoderImpl()
1095 fprintf(fp, "\t\t\tstruct timespec ts0, ts1, ts2;\n"); in genDecoderImpl()
1096 fprintf(fp, "\t\t\tclock_gettime(CLOCK_REALTIME, &ts0);\n"); in genDecoderImpl()
1112 fprintf(fp, "\t\t\tclock_gettime(CLOCK_REALTIME, &ts2);\n"); in genDecoderImpl()
1118 fprintf(fp, "\t\t\t*(%s *)(&tmpBuf[%s]) = ", retvalType.c_str(), in genDecoderImpl()
1124 fprintf(fp, "\t\t\tthis->%s_dec(", e->hostApiName().c_str()); in genDecoderImpl()
1126 fprintf(fp, "\t\t\tthis->%s(", e->hostApiName().c_str()); in genDecoderImpl()
1129 fprintf(fp, "this"); // add a context to the call in genDecoderImpl()
1133 fprintf(fp, "\t\t\t#ifdef CHECK_GL_ERRORS\n"); in genDecoderImpl()
1134 fprintf(fp, "\t\t\tGLint err = this->glGetError();\n"); in genDecoderImpl()
1135 … fprintf(fp, "\t\t\tif (err) fprintf(stderr, \"%s Error (pre-call): 0x%%X before %s\\n\", err);\n", in genDecoderImpl()
1137 fprintf(fp, "\t\t\t#endif\n"); in genDecoderImpl()
1140 fprintf(fp, in genDecoderImpl()
1146 fprintf(fp, ", "); in genDecoderImpl()
1164 fprintf(fp, ", "); in genDecoderImpl()
1167 fprintf(fp, ", "); in genDecoderImpl()
1172 fprintf(fp, in genDecoderImpl()
1183 fprintf(fp, "var_%s", var_name); in genDecoderImpl()
1190 fprintf(fp, in genDecoderImpl()
1201 fprintf(fp, "var_%s", var_name); in genDecoderImpl()
1208 fprintf(fp, in genDecoderImpl()
1218 fprintf(fp, in genDecoderImpl()
1224 fprintf(fp, in genDecoderImpl()
1235 fprintf(fp, in genDecoderImpl()
1242 fprintf(fp, in genDecoderImpl()
1247 fprintf(fp, in genDecoderImpl()
1255 fprintf(fp, in genDecoderImpl()
1262 fprintf(fp, in genDecoderImpl()
1270 fprintf(fp, in genDecoderImpl()
1276 fprintf(fp, in genDecoderImpl()
1283 fprintf(fp, in genDecoderImpl()
1296 fprintf(fp, in genDecoderImpl()
1300 fprintf(fp, in genDecoderImpl()
1310 fprintf(fp, in genDecoderImpl()
1317 fprintf(fp, in genDecoderImpl()
1325 fprintf(fp, "\t\t\tvoid* forPacking_%s = nullptr;\n", var_name); in genDecoderImpl()
1328 fprintf(fp, "\t\t\t%s;\n", v->hostPackTmpAllocExpression().c_str()); in genDecoderImpl()
1332 fprintf(fp, in genDecoderImpl()
1338 fprintf(fp, in genDecoderImpl()
1344 fprintf(fp, in genDecoderImpl()
1351 fprintf(fp, in genDecoderImpl()
1359 fprintf(fp, in genDecoderImpl()
1365 fprintf(fp, in genDecoderImpl()
1370 fprintf(fp, in genDecoderImpl()
1374 fprintf(fp, in genDecoderImpl()
1380 fprintf(fp, in genDecoderImpl()
1386 fprintf(fp, in genDecoderImpl()
1392 fprintf(fp, in genDecoderImpl()
1407 fprintf(fp, in genDecoderImpl()
1425 fprintf(fp, ");\n"); in genDecoderImpl()
1436 fprintf(fp, in genDecoderImpl()
1447 fprintf(fp, in genDecoderImpl()
1451 fprintf(fp, in genDecoderImpl()
1458 fprintf(fp, in genDecoderImpl()
1467 fprintf(fp, in genDecoderImpl()
1479 fprintf(fp, "\t\t\tclock_gettime(CLOCK_REALTIME, &ts1);\n");
1480 …fprintf(fp, "\t\t\tlong timeDiff = ts1.tv_sec*1000000 + ts1.tv_nsec/1000 - (ts0.tv_sec*1000000 + t…
1481 …fprintf(fp, "\t\t\tlong timeDiff2 = ts1.tv_sec*1000000 + ts1.tv_nsec/1000 - (ts2.tv_sec*1000000 + …
1482 fprintf(fp, "\t\t\tprintf(\"(timing) %%4ld.%%06ld %s: %%ld (%%ld) us\\n\", "
1485 fprintf(fp, "\t\t\tSET_LASTCALL(\"%s\");\n", e->name().c_str());
1486 fprintf(fp, "\t\t\tandroid::base::endTrace();\n");
1487 fprintf(fp, "\t\t\tbreak;\n");
1488 fprintf(fp, "\t\t}\n");
1492 fprintf(fp, "\t\tdefault:\n");
1493 fprintf(fp, "\t\t\treturn ptr - (unsigned char*)buf;\n");
1494 fprintf(fp, "\t\t} //switch\n");
1496 fprintf(fp, "\t\t#ifdef CHECK_GL_ERRORS\n");
1497 fprintf(fp, "\t\tGLint err = this->glGetError();\n");
1498 …fprintf(fp, "\t\tif (err) fprintf(stderr, \"%s Error (post-call): 0x%%X in %%s\\n\", err, lastCall…
1499 fprintf(fp, "\t\t#endif\n");
1502 fprintf(fp, "\t\tptr += packetLen;\n");
1503 fprintf(fp, "\t} // while\n");
1504 fprintf(fp, "\treturn ptr - (unsigned char*)buf;\n");
1505 fprintf(fp, "}\n");
1507 fprintf(fp, "} // namespace gfxstream\n\n");
1509 fclose(fp);
1538 FILE *fp = fopen(attribFilename.c_str(), "rt"); in readAttributes() local
1539 if (fp == NULL) { in readAttributes()
1549 while (fgets(buf, sizeof(buf), fp) != NULL) { in readAttributes()