/* return pointer to the body of @idx-th entry in @coord */ static directory_entry_format *entry_at(const coord_t * coord /* coord of * item */ , int idx /* index of unit */ ) { return (directory_entry_format *) address(coord, (int)offset_of(coord, idx)); }
/* * Allocate a FontDescriptor, initializing the FontType and rid from the * gs_font. */ int pdf_font_descriptor_alloc(gx_device_pdf *pdev, pdf_font_descriptor_t **ppfd, gs_font_base *font, bool embed) { pdf_font_descriptor_t *pfd; pdf_base_font_t *pbfont; int code = pdf_base_font_alloc(pdev, &pbfont, font, (font->orig_FontMatrix.xx == 0 && font->orig_FontMatrix.xy == 0 ? &font->FontMatrix : &font->orig_FontMatrix), false); if (code < 0) return code; code = pdf_alloc_resource(pdev, resourceFontDescriptor, font->id, (pdf_resource_t **)&pfd, -1L); if (code < 0) { gs_free_object(pdev->pdf_memory, pbfont, "pdf_font_descriptor_alloc(base_font)"); return code; } memset(&pfd->common.values, 0, sizeof(*pfd) - offset_of(pdf_font_descriptor_t, common.values)); pfd->base_font = pbfont; pfd->FontType = font->FontType; pfd->embed = embed; *ppfd = pfd; return 0; }
static int get_memory_map_entry(uint32_t * token, struct memory_map_entry * entry) { struct memory_map_entry buf; struct registers regs; regs.eax = 0xE820; regs.ebx = *token; regs.ecx = sizeof(struct memory_map_entry); regs.edx = 0x534D4150; regs.es = segment_of(&buf); regs.di = offset_of(&buf); bios_call(®s, 0x15); if ((regs.flags & 1) != 0) /* CF set - error */ return 1; if (regs.eax != 0x534D4150) return 2; *token = regs.ebx; entry->address = buf.address; entry->size = buf.size; entry->type = buf.type; entry->ext = buf.ext; return 0; }
static inline jpeg_compress_data * cinfo2jcd(j_common_ptr cinfo) { /* We use the offset of cinfo in jpeg_compress data here, but we */ /* could equally well have used jpeg_decompress_data. */ return (jpeg_compress_data *) ((byte *)cinfo - offset_of(jpeg_compress_data, cinfo)); }
static void gs_jpeg_error_exit(j_common_ptr cinfo) { jpeg_stream_data *jcomdp = (jpeg_stream_data *) ((char *)cinfo - offset_of(jpeg_compress_data, cinfo)); longjmp(find_jmp_buf(jcomdp->exit_jmpbuf), 1); }
static void coput(Staticfgw *S, int c, cde *de, int n, int *cexp1st, char *ot, int voff, int nn, real *oc, char *Not) { cexp1 *ce; expr_v *v, *v0; int i, i1, j, je, k; linpart *L, *Le; real t; if (cexp1st) { j = cexp1st[0]; ce = S->cexps1_ + j; v0 = S->v; } else /* silence buggy "not-initialized" warnings */ { ce = 0; v0 = 0; j = 0; } for(i = 0; i < n; i++) { if (cexp1st) { je = cexp1st[i1 = i + 1]; i1 += voff; while(j < je) { k = S->com1off + j++; (*pf)(nl, "V%d %d %d\n", k, ce->nlin, i1); L = ce->L; for(Le = L + ce->nlin; L < Le; L++) { v = (expr_v*)((char*)L->v.rp - offset_of(expr_v,v)); k = (int)(v - v0); (*pf)(nl, "%d %g\n", k, L->fac); } eput(S, ce->e); ce++; } } if (ot) (*pf)(nl, "%c%d %d\n", c, i, ot[i]); else (*pf)(nl, "%c%d\n", c, i); eput(S, de[i].e); } t = 0.; for(n += nn; i < n; i++) { if (ot) { (*pf)(nl, "%c%d %d\n", c, i, Not ? *Not++ : 0); if (oc) t = *oc++; } else (*pf)(nl, "%c%d\n", c, i); (*pf)(nl, "n%g\n", t); } }
int ccci_ipc_base_req( void *addr_phy, int *len) { if (addr_phy==NULL) return CCCI_INVALID_PARAM; if (len==NULL) return CCCI_INVALID_PARAM; *(int *)addr_phy = (int)ccci_ipc_smem_base_phy+offset_of(CCCI_IPC_MEM,buffer); *len = sizeof(CCCI_IPC_BUFFER); return CCCI_SUCCESS; }
static void gs_jpeg_emit_message(j_common_ptr cinfo, int msg_level) { if (msg_level < 0) { /* GS policy is to ignore IJG warnings when Picky=0, * treat them as errors when Picky=1. */ jpeg_stream_data *jcomdp = (jpeg_stream_data *) ((char *)cinfo - offset_of(jpeg_compress_data, cinfo)); if (jcomdp->Picky) gs_jpeg_error_exit(cinfo); } /* Trace messages are always ignored. */ }
void SpatialHash::get_neighbors(Index ctr, Cells& neighbors) const { Index idx; for (int k = -1; k <= 1; ++k) { idx[0] = ctr[0] + k; for (int j = -1; j <= 1; ++j) { idx[1] = ctr[1] + j; for (int i = -1; i <= 1; ++i) { idx[2] = ctr[2] + i; Pts* cell = this->cells_[offset_of(idx)]; neighbors.push_back(cell); } } } }
static boolean dctd_fill_input_buffer(j_decompress_ptr dinfo) { jpeg_decompress_data *jddp = (jpeg_decompress_data *) ((char *)dinfo - offset_of(jpeg_decompress_data, dinfo)); if (!jddp->input_eod) return FALSE; /* normal case: suspend processing */ /* Reached end of source data without finding EOI */ WARNMS(dinfo, JWRN_JPEG_EOF); /* Insert a fake EOI marker */ dinfo->src->next_input_byte = fake_eoi; dinfo->src->bytes_in_buffer = 2; jddp->faked_eoi = true; /* so process routine doesn't use next_input_byte */ return TRUE; }
static void dctd_skip_input_data(j_decompress_ptr dinfo, long num_bytes) { struct jpeg_source_mgr *src = dinfo->src; jpeg_decompress_data *jddp = (jpeg_decompress_data *) ((char *)dinfo - offset_of(jpeg_decompress_data, dinfo)); if (num_bytes > 0) { if (num_bytes > src->bytes_in_buffer) { jddp->skip += num_bytes - src->bytes_in_buffer; src->next_input_byte += src->bytes_in_buffer; src->bytes_in_buffer = 0; return; } src->next_input_byte += num_bytes; src->bytes_in_buffer -= num_bytes; } }
static int length_offset_in_bytes() { return (int) (offset_of(Array<T>, _length)); }
// interpreter support (offsets in bytes) static int holder_method_offset() { return offset_of(compiledICHolderOopDesc, _holder_method); }
// Stub generator support static int top_offset_in_bytes() { return offset_of(JNIHandleBlock, _top); }
constexpr explicit kernel_list(U Type::*member) : offset_(offset_of(member)) { }
int fg_write_ASL(ASL *a, const char *stub, NewVCO *nu, int flags) { ASL_fg *asl = (ASL_fg*)a; FILE *nl; Pf *pf; Staticfgw S; SufDesc *sd, *sd0; cexp *ce, *cee; char buf[256], *nbuf, *ts; const char *eol, *name, *obase, *s; efunc *rops[N_OPS]; expr_v *v; func_info *fi; int ak, c, i, j, *ip, *ipe, n, nnc, nne, nno, nnr, nnv, nnzc, nnzo; int nx, oblen, rflag; linpart *L, *Le; real *r, *re, t; static NewVCO nu0; ASL_CHECK(a, ASL_read_fg, "fg_write"); if ((comc1 && !c_cexp1st) || (como1 && !o_cexp1st)) return ASL_writeerr_badcexp1st; nnc = nne = nno = nnr = nnv = nnzc = nnzo = 0; if (!nu || (nu->nnv == 0 && nu->nnc == 0 && nu->nno == 0)) nu = &nu0; else { nnc = nu->nnc; nno = nu->nno; nnv = nu->nnv; if ((nnv <= 0 || nnc < 0 || nno < 0 || nnc + nno <= 0 || nnc > 0) && !nu->LUnc) return ASL_writeerr_badNewVCO; if (LUcheck(nnv, nu->LUnv, nu->Unv, 0, 0)) return ASL_writeerr_badNewVCO; n = n_var + nnv; if (nnc) { if (LUcheck(nnc, nu->LUnc, nu->Unc, &nnr, &nne)) return ASL_writeerr_badNewVCO; if (ogcheck(n, nnc, nu->newc, &nnzc)) return ASL_writeerr_badNewVCO; } if (nno) { if (ogcheck(n, nno, nu->newo, &nnzo)) return ASL_writeerr_badNewVCO; if ((s = nu->ot)) for(i = 0; i < nno; i++) if (s[i] & ~1) return ASL_writeerr_badNewVCO; if ((r = nu->oc)) for(re = r + nno; r < re; r++) { if ((t = *r) <= negInfinity || t >= Infinity || t != t) return ASL_writeerr_badNewVCO; } } } S.r_ops_ = rops; for(i = 0; i < N_OPS; i++) rops[i] = (efunc*)(unsigned long)i; s = name = obase = stub; while(*s) switch(*s++) { case '/': case '\\': obase = s; } c = s - stub; nbuf = 0; oblen = s - obase; if (c <= 3 || strcmp(s - 3, ".nl")) { ts = buf; if (c + 4 > sizeof(buf)) ts = nbuf = (char*)Malloc(c+4); memcpy(ts, stub, c); strcpy(ts+c, ".nl"); name = ts; } else oblen -= 3; nl = fopen(name, "wb"); if (nbuf) free(nbuf); if (!nl) return ASL_writeerr_openfail; i = setjmp(S.wjb); if (i) { fclose(nl); return ASL_writeerr_badrops; } if (flags & ASL_write_ASCII) { ak = 0; c = 'g'; pf = aprintf; } else { ak = Arith_Kind_ASL; c = 'b'; pf = bprintf; } S.nl_ = nl; S.pf_ = pf; eol = (char*)(flags & ASL_write_CR ? "\r\n" : "\n"); fprintf(nl, "%c%d", c, n = ampl_options[0]); for(i = 1; i <= n; i++) fprintf(nl, " %d", ampl_options[i]); if (ampl_options[2] == 3) fprintf(nl, " %.g", ampl_vbtol); fprintf(nl, "\t# problem %.*s%s", oblen, obase, eol); fprintf(nl, " %d %d %d %d", n_var + nnv, n_con + nnc, n_obj + nno, nranges + nnr); s = ""; if ((n = n_eqn + nne) >= 0) { fprintf(nl, " %d", n); s = ", eqns"; } fprintf(nl, "\t# vars, constraints, objectives, ranges%s%s", s, eol); if (n_cc | nlcc) fprintf(nl, " %d %d %d %d%s%s", nlc, nlo, n_cc, nlcc, "\t# nonlinear constrs, objs; ccons: lin, nonlin", eol); else fprintf(nl, " %d %d\t# nonlinear constraints, objectives%s", nlc, nlo, eol); fprintf(nl, " %d %d\t# network constraints: nonlinear, linear%s", nlnc, lnc, eol); fprintf(nl, " %d %d %d%s%s", nlvc, nlvo, nlvb, "\t# nonlinear vars in constraints, objectives, both", eol); s = ""; fprintf(nl, " %d %d", nwv, nfunc); if (ak | asl->i.flags) { fprintf(nl, " %d %d", ak, asl->i.flags); s = "; arith, flags"; } fprintf(nl, "\t# linear network variables; functions%s%s", s, eol); fprintf(nl, " %d %d %d %d %d%s%s", nbv, niv, nlvbi, nlvci, nlvoi, "\t# discrete variables: binary, integer, nonlinear (b,c,o)", eol); fprintf(nl, " %d %d\t# nonzeros in Jacobian, gradients%s", nzc + nnzc, nzo + nnzo, eol); fprintf(nl, " 0 0\t# max name lengths: constraints, variables%s", eol); fprintf(nl, " %d %d %d %d %d\t# common exprs: b,c,o,c1,o1%s", comb, comc, como, comc1, como1, eol); for(i = 0; i < nfunc; i++) { fi = funcs[i]; fi->findex = i; /* for eput */ (*pf)(nl, "F%d %d %d %s\n", i, fi->ftype, fi->nargs, fi->name); } for(i = 0; i < 4; i++) { if (!(sd = asl->i.suffixes[i])) continue; nx = (&asl->i.n_var_)[i]; for(sd = sd0 = reverse(sd); sd; sd = sd->next) { n = rflag = 0; if (sd->kind & ASL_Sufkind_real) { rflag = ASL_Sufkind_real; r = sd->u.r; re = r + nx; while(r < re) if (*r++) n++; } else { ip = sd->u.i; ipe = ip + nx; while(ip < ipe) if (*ip++) n++; } if (!n) continue; (*pf)(nl, "S%d %d %s\n", i | rflag, n, sd->sufname); j = 0; if (rflag) { r = sd->u.r; for(; j < nx; j++) if (r[j]) (*pf)(nl, "%d %g\n", j, r[j]); } else { ip = sd->u.i; for(; j < nx; j++) if (ip[j]) (*pf)(nl, "%d %d\n", j, ip[j]); } } reverse(sd0); } ce = cexps; n = n_var + nnv; S.v = var_e; for(cee = ce + comb + comc + como; ce < cee; ce++) { (*pf)(nl, "V%d %d %d\n", n++, ce->nlin, 0); L = ce->L; for(Le = L + ce->nlin; L < Le; L++) { v = (expr_v*)((char*)L->v.rp - offset_of(expr_v,v)); (*pf)(nl, "%d %g\n", (int)(v - S.v), L->fac); } eput(&S, ce->e); } S.cexps1_ = asl->I.cexps1_; S.nv0 = n_var; S.com1off = S.nv0 + comb + comc + como; coput(&S, 'C', con_de, n_con, c_cexp1st, 0, 0, nnc, 0, 0); coput(&S, 'O', obj_de, n_obj, o_cexp1st, objtype, n_con, nno, nu->oc, nu->ot); iguess(pf, nl, 'd', pi0, havepi0, n_con, nnc, nu->d0); iguess(pf, nl, 'x', X0, havex0, n_var, nnv, nu->x0); br(pf, nl, 'r', LUrhs, Urhsx, n_con); br(pf, nl, 0, nu->LUnc, nu->Unc, nnc); br(pf, nl, 'b', LUv, Uvx, n_var); br(pf, nl, 0, nu->LUnv, nu->Unv, nnv); if (A_vals) k1put(pf, nl, A_colstarts, A_vals, A_rownos, n_con, n_var, nnv, nnc, nu->newc); else k2put(pf, nl, Cgrad, n_con, n_var, 1, nnv, nnc, nu->newc); Gput(pf, nl, 'G', 0, n_obj, Ograd); Gput(pf, nl, 'G', n_obj, nno, nu->newo); fclose(nl); return 0; }
ENUM_PTRS_END_PROC static RELOC_PTRS_BEGIN(font_data_reloc_ptrs) { ref_struct_reloc_ptrs(vptr, offset_of(font_data, u.type42.mru_sfnts_index)/*size*/, pstype, gcst); }
// Protected access to pad information for sub-class use static int pad_offset_in_bytes() { return offset_of(arrayOopDesc,_pad); }
int generateJvmOffsets(GEN_variant gen_variant) { int index = 0; /* It is used to generate JvmOffsetsIndex.h */ int pointer_size = sizeof(void *); int data_model = (pointer_size == 4) ? PR_MODEL_ILP32 : PR_MODEL_LP64; gen_prologue(gen_variant); GEN_VALUE(DATA_MODEL, data_model); GEN_VALUE(POINTER_SIZE, pointer_size); #if defined(TIERED) GEN_VALUE(COMPILER, 3); #elif COMPILER1 GEN_VALUE(COMPILER, 1); #elif COMPILER2 GEN_VALUE(COMPILER, 2); #else GEN_VALUE(COMPILER, 0); #endif // COMPILER1 && COMPILER2 printf("\n"); GEN_OFFS(CollectedHeap, _reserved); GEN_OFFS(MemRegion, _start); GEN_OFFS(MemRegion, _word_size); GEN_SIZE(HeapWord); printf("\n"); GEN_OFFS(VMStructEntry, typeName); GEN_OFFS(VMStructEntry, fieldName); GEN_OFFS(VMStructEntry, address); GEN_SIZE(VMStructEntry); printf("\n"); GEN_VALUE(MAX_METHOD_CODE_SIZE, max_method_code_size); #if defined(sparc) || defined(__sparc) GEN_VALUE(OFFSET_interpreter_frame_method, 2 * pointer_size); /* L2 in saved window */ GEN_VALUE(OFFSET_interpreter_frame_sender_sp, 13 * pointer_size); /* I5 in saved window */ // Fake value for consistency. It is not going to be used. GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, 0xFFFF); #elif defined(i386) || defined(__i386) || defined(__amd64) GEN_VALUE(OFFSET_interpreter_frame_sender_sp, -1 * pointer_size); GEN_VALUE(OFFSET_interpreter_frame_method, -3 * pointer_size); GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, -7 * pointer_size); #endif GEN_OFFS(Klass, _name); GEN_OFFS(constantPoolOopDesc, _pool_holder); printf("\n"); GEN_VALUE(OFFSET_HeapBlockHeader_used, offset_of(HeapBlock::Header, _used)); GEN_OFFS(oopDesc, _metadata); printf("\n"); GEN_VALUE(AccessFlags_NATIVE, JVM_ACC_NATIVE); GEN_VALUE(constMethodOopDesc_has_linenumber_table, constMethodOopDesc::_has_linenumber_table); GEN_OFFS(AccessFlags, _flags); GEN_OFFS(symbolOopDesc, _length); GEN_OFFS(symbolOopDesc, _body); printf("\n"); GEN_OFFS(methodOopDesc, _constMethod); GEN_OFFS(methodOopDesc, _constants); GEN_OFFS(methodOopDesc, _access_flags); printf("\n"); GEN_OFFS(constMethodOopDesc, _flags); GEN_OFFS(constMethodOopDesc, _code_size); GEN_OFFS(constMethodOopDesc, _name_index); GEN_OFFS(constMethodOopDesc, _signature_index); printf("\n"); GEN_OFFS(CodeHeap, _memory); GEN_OFFS(CodeHeap, _segmap); GEN_OFFS(CodeHeap, _log2_segment_size); printf("\n"); GEN_OFFS(VirtualSpace, _low_boundary); GEN_OFFS(VirtualSpace, _high_boundary); GEN_OFFS(VirtualSpace, _low); GEN_OFFS(VirtualSpace, _high); printf("\n"); GEN_OFFS(CodeBlob, _name); GEN_OFFS(CodeBlob, _header_size); GEN_OFFS(CodeBlob, _instructions_offset); GEN_OFFS(CodeBlob, _data_offset); GEN_OFFS(CodeBlob, _oops_offset); GEN_OFFS(CodeBlob, _oops_length); GEN_OFFS(CodeBlob, _frame_size); printf("\n"); GEN_OFFS(nmethod, _method); GEN_OFFS(nmethod, _scopes_data_offset); GEN_OFFS(nmethod, _scopes_pcs_offset); GEN_OFFS(nmethod, _handler_table_offset); GEN_OFFS(nmethod, _deoptimize_offset); GEN_OFFS(nmethod, _orig_pc_offset); GEN_OFFS(PcDesc, _pc_offset); GEN_OFFS(PcDesc, _scope_decode_offset); printf("\n"); GEN_OFFS(NarrowOopStruct, _base); GEN_OFFS(NarrowOopStruct, _shift); printf("\n"); GEN_VALUE(SIZE_HeapBlockHeader, sizeof(HeapBlock::Header)); GEN_SIZE(oopDesc); GEN_SIZE(constantPoolOopDesc); printf("\n"); GEN_SIZE(PcDesc); GEN_SIZE(methodOopDesc); GEN_SIZE(constMethodOopDesc); GEN_SIZE(nmethod); GEN_SIZE(CodeBlob); GEN_SIZE(BufferBlob); GEN_SIZE(SingletonBlob); GEN_SIZE(RuntimeStub); GEN_SIZE(SafepointBlob); gen_epilogue(gen_variant); printf("\n"); fflush(stdout); return 0; }
/* Write the definition of a Type 1 font. */ int psf_write_type1_font(stream *s, gs_font_type1 *pfont, int options, gs_glyph *orig_subset_glyphs, uint orig_subset_size, const gs_const_string *alt_font_name, int lengths[3]) { stream *es = s; long start = stell(s); param_printer_params_t ppp; printer_param_list_t rlist; gs_param_list *const plist = (gs_param_list *)&rlist; stream AXE_stream; stream_AXE_state AXE_state; byte AXE_buf[200]; /* arbitrary */ stream exE_stream; stream_exE_state exE_state; byte exE_buf[200]; /* arbitrary */ psf_outline_glyphs_t glyphs; int lenIV = pfont->data.lenIV; int (*write_CharString)(stream *, const void *, uint) = stream_write; int code = psf_get_type1_glyphs(&glyphs, pfont, orig_subset_glyphs, orig_subset_size); if (code < 0) return code; /* Initialize the parameter printer. */ ppp = param_printer_params_default; ppp.item_suffix = " def\n"; ppp.print_ok = (options & WRITE_TYPE1_ASCIIHEX ? 0 : PRINT_BINARY_OK) | PRINT_HEX_NOT_OK; code = s_init_param_printer(&rlist, &ppp, s); if (code < 0) return code; /* Write the font header. */ stream_puts(s, "%!FontType1-1.0: "); write_font_name(s, pfont, alt_font_name, false); stream_puts(s, "\n11 dict begin\n"); /* Write FontInfo. */ stream_puts(s, "/FontInfo 5 dict dup begin"); { gs_font_info_t info; int code = pfont->procs.font_info((gs_font *)pfont, NULL, (FONT_INFO_COPYRIGHT | FONT_INFO_NOTICE | FONT_INFO_FAMILY_NAME | FONT_INFO_FULL_NAME), &info); if (code >= 0) { write_font_info(s, "Copyright", &info.Copyright, info.members & FONT_INFO_COPYRIGHT); write_font_info(s, "Notice", &info.Notice, info.members & FONT_INFO_NOTICE); write_font_info(s, "FamilyName", &info.FamilyName, info.members & FONT_INFO_FAMILY_NAME); write_font_info(s, "FullName", &info.FullName, info.members & FONT_INFO_FULL_NAME); } } stream_puts(s, "\nend readonly def\n"); /* Write the main font dictionary. */ stream_puts(s, "/FontName "); write_font_name(s, pfont, alt_font_name, true); stream_puts(s, " def\n"); code = write_Encoding(s, pfont, options, glyphs.subset_glyphs, glyphs.subset_size, glyphs.notdef); if (code < 0) return code; pprintg6(s, "/FontMatrix [%g %g %g %g %g %g] readonly def\n", pfont->FontMatrix.xx, pfont->FontMatrix.xy, pfont->FontMatrix.yx, pfont->FontMatrix.yy, pfont->FontMatrix.tx, pfont->FontMatrix.ty); write_uid(s, &pfont->UID); pprintg4(s, "/FontBBox {%g %g %g %g} readonly def\n", pfont->FontBBox.p.x, pfont->FontBBox.p.y, pfont->FontBBox.q.x, pfont->FontBBox.q.y); { static const gs_param_item_t font_items[] = { {"FontType", gs_param_type_int, offset_of(gs_font_type1, FontType)}, {"PaintType", gs_param_type_int, offset_of(gs_font_type1, PaintType)}, {"StrokeWidth", gs_param_type_float, offset_of(gs_font_type1, StrokeWidth)}, gs_param_item_end }; code = gs_param_write_items(plist, pfont, NULL, font_items); if (code < 0) return code; } { const gs_type1_data *const pdata = &pfont->data; write_float_array(plist, "WeightVector", pdata->WeightVector.values, pdata->WeightVector.count); } stream_puts(s, "currentdict end\n"); /* Write the Private dictionary. */ if (lenIV < 0 && (options & WRITE_TYPE1_WITH_LENIV)) { /* We'll have to encrypt the CharStrings. */ lenIV = 0; write_CharString = stream_write_encrypted; } if (options & WRITE_TYPE1_EEXEC) { stream_puts(s, "currentfile eexec\n"); lengths[0] = stell(s) - start; start = stell(s); if (options & WRITE_TYPE1_ASCIIHEX) { s_init(&AXE_stream, s->memory); s_init_state((stream_state *)&AXE_state, &s_AXE_template, NULL); AXE_state.EndOfData = false; s_init_filter(&AXE_stream, (stream_state *)&AXE_state, AXE_buf, sizeof(AXE_buf), es); es = &AXE_stream; } s_init(&exE_stream, s->memory); s_init_state((stream_state *)&exE_state, &s_exE_template, NULL); exE_state.cstate = 55665; s_init_filter(&exE_stream, (stream_state *)&exE_state, exE_buf, sizeof(exE_buf), es); es = &exE_stream; /* * Note: eexec encryption always writes/skips 4 initial bytes, not * the number of initial bytes given by pdata->lenIV. */ stream_puts(es, "****"); } code = write_Private(es, pfont, glyphs.subset_glyphs, glyphs.subset_size, glyphs.notdef, lenIV, write_CharString, &ppp); if (code < 0) return code; stream_puts(es, "dup/FontName get exch definefont pop\n"); if (options & WRITE_TYPE1_EEXEC) { if (options & (WRITE_TYPE1_EEXEC_PAD | WRITE_TYPE1_EEXEC_MARK)) stream_puts(es, "mark "); stream_puts(es, "currentfile closefile\n"); s_close_filters(&es, s); lengths[1] = stell(s) - start; start = stell(s); if (options & WRITE_TYPE1_EEXEC_PAD) { int i; for (i = 0; i < 8; ++i) stream_puts(s, "\n0000000000000000000000000000000000000000000000000000000000000000"); stream_puts(s, "\ncleartomark\n"); } lengths[2] = stell(s) - start; } else { lengths[0] = stell(s) - start; lengths[1] = lengths[2] = 0; } /* Wrap up. */ s_release_param_printer(&rlist); return 0; }
/* * Write the Private dictionary. This is a separate procedure only for * readability. write_CharString is a parameter so that we can encrypt * Subrs and CharStrings when the font's lenIV == -1 but we are writing * the font with lenIV = 0. */ static int write_Private(stream *s, gs_font_type1 *pfont, gs_glyph *subset_glyphs, uint subset_size, gs_glyph notdef, int lenIV, int (*write_CharString)(stream *, const void *, uint), const param_printer_params_t *ppp) { const gs_type1_data *const pdata = &pfont->data; printer_param_list_t rlist; gs_param_list *const plist = (gs_param_list *)&rlist; int code = s_init_param_printer(&rlist, ppp, s); if (code < 0) return 0; stream_puts(s, "dup /Private 17 dict dup begin\n"); stream_puts(s, "/-|{string currentfile exch readstring pop}executeonly def\n"); stream_puts(s, "/|-{noaccess def}executeonly def\n"); stream_puts(s, "/|{noaccess put}executeonly def\n"); { static const gs_param_item_t private_items[] = { {"BlueFuzz", gs_param_type_int, offset_of(gs_type1_data, BlueFuzz)}, {"BlueScale", gs_param_type_float, offset_of(gs_type1_data, BlueScale)}, {"BlueShift", gs_param_type_float, offset_of(gs_type1_data, BlueShift)}, {"ExpansionFactor", gs_param_type_float, offset_of(gs_type1_data, ExpansionFactor)}, {"ForceBold", gs_param_type_bool, offset_of(gs_type1_data, ForceBold)}, {"LanguageGroup", gs_param_type_int, offset_of(gs_type1_data, LanguageGroup)}, {"RndStemUp", gs_param_type_bool, offset_of(gs_type1_data, RndStemUp)}, gs_param_item_end }; gs_type1_data defaults; defaults.BlueFuzz = 1; defaults.BlueScale = (float)0.039625; defaults.BlueShift = 7.0; defaults.ExpansionFactor = (float)0.06; defaults.ForceBold = false; defaults.LanguageGroup = 0; defaults.RndStemUp = true; code = gs_param_write_items(plist, pdata, &defaults, private_items); if (code < 0) return code; if (lenIV != 4) { code = param_write_int(plist, "lenIV", &lenIV); if (code < 0) return code; } write_float_array(plist, "BlueValues", pdata->BlueValues.values, pdata->BlueValues.count); write_float_array(plist, "OtherBlues", pdata->OtherBlues.values, pdata->OtherBlues.count); write_float_array(plist, "FamilyBlues", pdata->FamilyBlues.values, pdata->FamilyBlues.count); write_float_array(plist, "FamilyOtherBlues", pdata->FamilyOtherBlues.values, pdata->FamilyOtherBlues.count); write_float_array(plist, "StdHW", pdata->StdHW.values, pdata->StdHW.count); write_float_array(plist, "StdVW", pdata->StdVW.values, pdata->StdVW.count); write_float_array(plist, "StemSnapH", pdata->StemSnapH.values, pdata->StemSnapH.count); write_float_array(plist, "StemSnapV", pdata->StemSnapV.values, pdata->StemSnapV.count); } write_uid(s, &pfont->UID); stream_puts(s, "/MinFeature{16 16} def\n"); stream_puts(s, "/password 5839 def\n"); /* * Write the Subrs. We always write them all, even for subsets. * (We will fix this someday.) */ { int n, i; gs_glyph_data_t gdata; int code; gdata.memory = pfont->memory; for (n = 0; (code = pdata->procs.subr_data(pfont, n, false, &gdata)) != gs_error_rangecheck; ) { ++n; if (code >= 0) gs_glyph_data_free(&gdata, "write_Private(Subrs)"); } pprintd1(s, "/Subrs %d array\n", n); for (i = 0; i < n; ++i) if ((code = pdata->procs.subr_data(pfont, i, false, &gdata)) >= 0) { char buf[50]; if (gdata.bits.size) { sprintf(buf, "dup %d %u -| ", i, gdata.bits.size); stream_puts(s, buf); write_CharString(s, gdata.bits.data, gdata.bits.size); stream_puts(s, " |\n"); } gs_glyph_data_free(&gdata, "write_Private(Subrs)"); } stream_puts(s, "|-\n"); } /* We don't write OtherSubrs -- there had better not be any! */ /* Write the CharStrings. */ { int num_chars = 0; gs_glyph glyph; psf_glyph_enum_t genum; gs_glyph_data_t gdata; int code; gdata.memory = pfont->memory; psf_enumerate_glyphs_begin(&genum, (gs_font *)pfont, subset_glyphs, (subset_glyphs ? subset_size : 0), GLYPH_SPACE_NAME); for (glyph = gs_no_glyph; (code = psf_enumerate_glyphs_next(&genum, &glyph)) != 1; ) if (code == 0 && (code = pdata->procs.glyph_data(pfont, glyph, &gdata)) >= 0 ) { ++num_chars; gs_glyph_data_free(&gdata, "write_Private(CharStrings)"); } pprintd1(s, "2 index /CharStrings %d dict dup begin\n", num_chars); psf_enumerate_glyphs_reset(&genum); for (glyph = gs_no_glyph; (code = psf_enumerate_glyphs_next(&genum, &glyph)) != 1; ) if (code == 0 && (code = pdata->procs.glyph_data(pfont, glyph, &gdata)) >= 0 ) { gs_const_string gstr; int code; code = pfont->procs.glyph_name((gs_font *)pfont, glyph, &gstr); if (code < 0) return code; stream_puts(s, "/"); stream_write(s, gstr.data, gstr.size); pprintd1(s, " %d -| ", gdata.bits.size); write_CharString(s, gdata.bits.data, gdata.bits.size); stream_puts(s, " |-\n"); gs_glyph_data_free(&gdata, "write_Private(CharStrings)"); } } /* Wrap up. */ stream_puts(s, "end\nend\nreadonly put\nnoaccess put\n"); s_release_param_printer(&rlist); return 0; }
static bool look_for(parser_context *context, char *target) { return -1 != offset_of(context, target); }
// Note, this offset don't have to be wordSize aligned. static int base_offset_in_bytes() { return (int) (offset_of(Array<T>, _data)); };
static int holder_klass_offset() { return offset_of(compiledICHolderOopDesc, _holder_klass); }
instanceKlassHandle KlassFactory::create_from_stream(ClassFileStream* stream, Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, const InstanceKlass* host_klass, GrowableArray<Handle>* cp_patches, TRAPS) { assert(stream != NULL, "invariant"); assert(loader_data != NULL, "invariant"); assert(THREAD->is_Java_thread(), "must be a JavaThread"); ResourceMark rm; HandleMark hm; JvmtiCachedClassFileData* cached_class_file = NULL; ClassFileStream* old_stream = stream; // Skip this processing for VM anonymous classes if (host_klass == NULL) { stream = check_class_file_load_hook(stream, name, loader_data, protection_domain, &cached_class_file, CHECK_NULL); } ClassFileParser parser(stream, name, loader_data, protection_domain, host_klass, cp_patches, ClassFileParser::BROADCAST, // publicity level CHECK_NULL); instanceKlassHandle result = parser.create_instance_klass(old_stream != stream, CHECK_NULL); assert(result == parser.create_instance_klass(old_stream != stream, THREAD), "invariant"); if (result.is_null()) { return NULL; } if (cached_class_file != NULL) { // JVMTI: we have an InstanceKlass now, tell it about the cached bytes result->set_cached_class_file(cached_class_file); } if (InstanceKlass::should_store_fingerprint()) { result->store_fingerprint(!result->is_anonymous() ? stream->compute_fingerprint() : 0); } TRACE_KLASS_CREATION(result, parser, THREAD); #if INCLUDE_CDS && INCLUDE_JVMTI if (DumpSharedSpaces) { assert(cached_class_file == NULL, "Sanity"); // Archive the class stream data into the optional data section JvmtiCachedClassFileData *p; int len; const unsigned char *bytes; // event based tracing might set cached_class_file if ((bytes = result->get_cached_class_file_bytes()) != NULL) { len = result->get_cached_class_file_len(); } else { len = stream->length(); bytes = stream->buffer(); } p = (JvmtiCachedClassFileData*)MetaspaceShared::optional_data_space_alloc( offset_of(JvmtiCachedClassFileData, data) + len); p->length = len; memcpy(p->data, bytes, len); result->set_archived_class_data(p); } #endif return result; }
// Interpreter/Compiler offsets static int length_offset_in_bytes() { return offset_of(arrayOopDesc, _length); }
static CLEAR_MARKS_PROC(font_data_clear_marks) { ref_struct_clear_marks(cmem, vptr, offset_of(font_data, u.type42.mru_sfnts_index)/*size*/, pstype); }
static ENUM_PTRS_BEGIN_PROC(font_data_enum_ptrs) { return ref_struct_enum_ptrs(mem, vptr, offset_of(font_data, u.type42.mru_sfnts_index)/*size*/, index, pep, pstype, gcst); }
static inline fapi_ufst_server *IFS_to_I(IF_STATE *pIFS) { return (fapi_ufst_server *)((char *)pIFS - offset_of(fapi_ufst_server, IFS)); }
SpatialHash::Pts* SpatialHash::pts_at(Index idx) { return pts_at(offset_of(idx)); }