msgdomain_list_ty * msgdomain_read_csharp (const char *resource_name, const char *locale_name, const char *directory) { char *culture_name; const char *args[4]; const char *gettextexedir; const char *gettextlibdir; char *assembly_path; const char *libdirs[1]; struct locals locals; /* Assign a default value to the resource name. */ if (resource_name == NULL) resource_name = "Messages"; /* Convert the locale name to a .NET specific culture name. */ culture_name = xstrdup (locale_name); { char *p; for (p = culture_name; *p != '\0'; p++) if (*p == '_') *p = '-'; } /* Prepare arguments. */ args[0] = directory; args[1] = resource_name; args[2] = culture_name; args[3] = NULL; /* Make it possible to override the .exe location. This is necessary for running the testsuite before "make install". */ gettextexedir = getenv ("GETTEXTCSHARPEXEDIR"); if (gettextexedir == NULL || gettextexedir[0] == '\0') gettextexedir = relocate (LIBDIR "/gettext"); /* Make it possible to override the .dll location. This is necessary for running the testsuite before "make install". */ gettextlibdir = getenv ("GETTEXTCSHARPLIBDIR"); if (gettextlibdir == NULL || gettextlibdir[0] == '\0') gettextlibdir = relocate (LIBDIR); /* Dump the resource and retrieve the resulting output. */ assembly_path = concatenated_pathname (gettextexedir, "msgunfmt.net", ".exe"); libdirs[0] = gettextlibdir; if (execute_csharp_program (assembly_path, libdirs, 1, args, verbose, false, execute_and_read_po_output, &locals)) /* An error message should already have been provided. */ exit (EXIT_FAILURE); free (assembly_path); free (culture_name); return locals.mdlp; }
msgdomain_list_ty * msgdomain_read_java (const char *resource_name, const char *locale_name) { const char *class_name = "gnu.gettext.DumpResource"; const char *gettextjexedir; const char *gettextjar; const char *args[3]; struct locals locals; #if USEJEXE /* Make it possible to override the executable's location. This is necessary for running the testsuite before "make install". */ gettextjexedir = getenv ("GETTEXTJEXEDIR"); if (gettextjexedir == NULL || gettextjexedir[0] == '\0') gettextjexedir = relocate (GETTEXTJEXEDIR); #else gettextjexedir = NULL; #endif /* Make it possible to override the gettext.jar location. This is necessary for running the testsuite before "make install". */ gettextjar = getenv ("GETTEXTJAR"); if (gettextjar == NULL || gettextjar[0] == '\0') gettextjar = relocate (GETTEXTJAR); /* Assign a default value to the resource name. */ if (resource_name == NULL) resource_name = "Messages"; /* Prepare arguments. */ args[0] = resource_name; if (locale_name != NULL) { args[1] = locale_name; args[2] = NULL; } else args[1] = NULL; /* Dump the resource and retrieve the resulting output. Here we use the user's CLASSPATH, not a minimal one, so that the resource can be found. */ if (execute_java_class (class_name, &gettextjar, 1, false, gettextjexedir, args, verbose, false, execute_and_read_po_output, &locals)) /* An error message should already have been provided. */ exit (EXIT_FAILURE); return locals.mdlp; }
void read_resources_file (message_list_ty *mlp, const char *filename) { const char *args[2]; const char *gettextexedir; const char *gettextlibdir; char *assembly_path; const char *libdirs[1]; struct locals locals; /* Prepare arguments. */ args[0] = filename; args[1] = NULL; /* Make it possible to override the .exe location. This is necessary for running the testsuite before "make install". */ gettextexedir = getenv ("GETTEXTCSHARPEXEDIR"); if (gettextexedir == NULL || gettextexedir[0] == '\0') gettextexedir = relocate (LIBDIR "/gettext"); /* Make it possible to override the .dll location. This is necessary for running the testsuite before "make install". */ gettextlibdir = getenv ("GETTEXTCSHARPLIBDIR"); if (gettextlibdir == NULL || gettextlibdir[0] == '\0') gettextlibdir = relocate (LIBDIR); /* Dump the resource and retrieve the resulting output. */ assembly_path = xconcatenated_filename (gettextexedir, "msgunfmt.net", ".exe"); libdirs[0] = gettextlibdir; if (execute_csharp_program (assembly_path, libdirs, 1, args, verbose, false, execute_and_read_po_output, &locals)) /* An error message should already have been provided. */ exit (EXIT_FAILURE); /* Add the output to mlp. */ { message_list_ty *read_mlp = locals.mdlp->item[0]->messages; size_t j; for (j = 0; j < read_mlp->nitems; j++) message_list_append (mlp, read_mlp->item[j]); } free (assembly_path); }
inline void MacroAssembler::load_const(Register t, const AddressLiteral& a) { assert(t != Z_R0, "R0 not allowed"); // First relocate (we don't change the offset in the RelocationHolder, // just pass a.rspec()), then delegate to load_const(Register, long). relocate(a.rspec()); load_const(t, (long)a.value()); }
void ArrayCopyStub::emit_code(LIR_Assembler* ce) { // Slow case: call to native. __ bind(_entry); __ lgr_if_needed(Z_ARG1, src()->as_register()); __ lgr_if_needed(Z_ARG2, src_pos()->as_register()); __ lgr_if_needed(Z_ARG3, dst()->as_register()); __ lgr_if_needed(Z_ARG4, dst_pos()->as_register()); __ lgr_if_needed(Z_ARG5, length()->as_register()); // Must align calls sites, otherwise they can't be updated atomically on MP hardware. ce->align_call(lir_static_call); assert((__ offset() + NativeCall::call_far_pcrelative_displacement_offset) % NativeCall::call_far_pcrelative_displacement_alignment == 0, "must be aligned"); ce->emit_static_call_stub(); // Prepend each BRASL with a nop. __ relocate(relocInfo::static_call_type); __ z_nop(); __ z_brasl(Z_R14, SharedRuntime::get_resolve_static_call_stub()); ce->add_call_info_here(info()); ce->verify_oop_map(info()); #ifndef PRODUCT __ load_const_optimized(Z_R1_scratch, (address)&Runtime1::_arraycopy_slowcase_cnt); __ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch); #endif __ branch_optimized(Assembler::bcondAlways, _continuation); }
void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) { #ifdef COMPILER2 // Stub is fixed up when the corresponding call is converted from calling // compiled code to calling interpreted code. // set (empty), G5 // jmp -1 address mark = cbuf.insts_mark(); // Get mark within main instrs section. MacroAssembler _masm(&cbuf); address base = __ start_a_stub(to_interp_stub_size()*2); if (base == NULL) return; // CodeBuffer::expand failed. // Static stub relocation stores the instruction address of the call. __ relocate(static_stub_Relocation::spec(mark)); __ set_metadata(NULL, as_Register(Matcher::inline_cache_reg_encode())); __ set_inst_mark(); AddressLiteral addrlit(-1); __ JUMP(addrlit, G3, 0); __ delayed()->nop(); // Update current stubs pointer and restore code_end. __ end_a_stub(); #else ShouldNotReachHere(); #endif }
void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) { // Stub is fixed up when the corresponding call is converted from // calling compiled code to calling interpreted code. // mov rmethod, 0 // jmp -4 # to self address mark = cbuf.insts_mark(); // Get mark within main instrs section. // Note that the code buffer's insts_mark is always relative to insts. // That's why we must use the macroassembler to generate a stub. MacroAssembler _masm(&cbuf); address base = __ start_a_stub(to_interp_stub_size()*2); int offset = __ offset(); if (base == NULL) return; // CodeBuffer::expand failed // static stub relocation stores the instruction address of the call __ relocate(static_stub_Relocation::spec(mark)); // static stub relocation also tags the Method* in the code-stream. __ mov_metadata(rmethod, (Metadata*)NULL); __ movptr(rscratch1, 0); __ br(rscratch1); assert((__ offset() - offset) <= (int)to_interp_stub_size(), "stub too big"); __ end_a_stub(); }
/* Returns the pathname, relocated according to the current installation directory. This function sets *ALLOCATEDP to the allocated memory, or to NULL if no memory allocation occurs. So that, after you're done with the return value, to reclaim allocated memory, you can do: free (*ALLOCATEDP). */ const char * relocate2 (const char *pathname, char **allocatedp) { const char *result = relocate (pathname); *allocatedp = (result != pathname ? (char *) result : NULL); return result; }
/* fix_data -- fix up global refs in the data segment */ void fix_data(uchar *base, int bss) { int i, u, v; /* Shift BSS symbols by offset bss */ for (i = 0; i < ndict; i++) { symbol s = dict[i]; if (s->s_seg == BSS) s->s_value += bss; } /* Fix up each symbol */ for (i = 0; i < ndict; i++) { symbol s = dict[i]; int val; if (s->s_uchain == -1) continue; if (dflag > 0) printf("Fixing %s\n", s->s_name); val = sym_value(s); /* Run along the use chain, inserting the value */ for (u = s->s_uchain; u != -1; u = v) { v = *((int *) &base[u]); put4(&base[u], val); relocate(u, (s->s_seg == ABS ? R_WORD : R_DATA)); } } }
int snake_move(t_map map, t_snake *snake, char vdir, char hdir) { relocate(snake->h); if (vdir == 'U') { if (snake->h->y == 0) return (screen_game_over()); snake->h->y--; } if (vdir == 'D') { if (snake->h->y == map.h) return (screen_game_over()); snake->h->y++; } if (hdir == 'L') { if (snake->h->x == 0) return (screen_game_over()); snake->h->x--; } if (hdir == 'R') { if (snake->h->x == map.w) return (screen_game_over()); snake->h->x++; } return (1); }
static void s390_elf_corehdr_create(char **elfcorebuf, size_t *elfcorebuf_sz) { Elf64_Phdr *phdr_notes, *phdr_loads; int mem_chunk_cnt; void *ptr, *hdr; u32 alloc_size; u64 hdr_off; mem_chunk_cnt = get_mem_chunk_cnt(); alloc_size = 0x1000 + get_cpu_cnt() * 0x300 + mem_chunk_cnt * sizeof(Elf64_Phdr); hdr = kzalloc_panic(alloc_size); /* */ ptr = ehdr_init(hdr, mem_chunk_cnt); /* */ phdr_notes = ptr; ptr = PTR_ADD(ptr, sizeof(Elf64_Phdr)); phdr_loads = ptr; ptr = PTR_ADD(ptr, sizeof(Elf64_Phdr) * mem_chunk_cnt); /* */ hdr_off = PTR_DIFF(ptr, hdr); ptr = notes_init(phdr_notes, ptr, ((unsigned long) hdr) + hdr_off); /* */ hdr_off = PTR_DIFF(ptr, hdr); loads_init(phdr_loads, ((unsigned long) hdr) + hdr_off); *elfcorebuf_sz = hdr_off; *elfcorebuf = (void *) relocate((unsigned long) hdr); BUG_ON(*elfcorebuf_sz > alloc_size); }
static COMMAND_FUNC( do_relocate ) { Data_Obj *dp; long x,y,t; const char *obj_name; dp=pick_obj("subimage"); x=(long) how_many("x offset"); y=(long) how_many("y offset"); t=(long) how_many("t offset"); if( dp==NULL ) return; obj_name = OBJ_NAME(dp); INSIST_NONNEGATIVE(x,"x offset","relocate"); INSIST_NONNEGATIVE(y,"y offset","relocate"); INSIST_NONNEGATIVE(t,"t offset","relocate"); if( OBJ_PARENT(dp) == NULL ){ sprintf(ERROR_STRING, "relocate: object \"%s\" is not a subimage", OBJ_NAME(dp)); warn(ERROR_STRING); return; } relocate(dp,(index_t)x,(index_t)y,(index_t)t); }
address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) { // Stub is fixed up when the corresponding call is converted from calling // compiled code to calling interpreted code. // set (empty), G5 // jmp -1 if (mark == NULL) { mark = cbuf.insts_mark(); // Get mark within main instrs section. } MacroAssembler _masm(&cbuf); address base = __ start_a_stub(to_interp_stub_size()); if (base == NULL) { return NULL; // CodeBuffer::expand failed. } // Static stub relocation stores the instruction address of the call. __ relocate(static_stub_Relocation::spec(mark)); __ set_metadata(NULL, as_Register(Matcher::inline_cache_reg_encode())); __ set_inst_mark(); AddressLiteral addrlit(-1); __ JUMP(addrlit, G3, 0); __ delayed()->nop(); assert(__ pc() - base <= to_interp_stub_size(), "wrong stub size"); // Update current stubs pointer and restore code_end. __ end_a_stub(); return base; }
void rdr_xlat::XlatArray() { int az, rng; unsigned char *p = src_array; float km_n, km_e; if (!dest_array) return; if (ApplyTestPattern) { if (rdr_xlat_testpatterntoggle) for (az = 0; az < src_ydim; az++) for (rng = 0; rng < src_xdim; rng++) { if (*p == 0) *p = (rng / 10) % 7; p++; } else for (az = 0; az < src_ydim; az++) for (rng = 0; rng < src_xdim; rng++) { if (*p == 0) *p = (az / 10) % 7; p++; } rdr_xlat_testpatterntoggle = !rdr_xlat_testpatterntoggle; } LatLongKmDiff(StnRec[dest_stnid].Lat(), StnRec[dest_stnid].Lng(), StnRec[source_stnid].Lat(), StnRec[source_stnid].Lng(), &km_n, &km_e); relocate(src_array, dest_array, src_ydim, src_xdim, dest_xdim, SrcScan->rng_res / 1000.0, SrcScan->start_rng / 1000.0, 0, km_n, km_e); }
/* Assign a default value to style_file_name if necessary. */ void style_file_prepare () { if (style_file_name == NULL) { const char *user_preference = getenv ("PO_STYLE"); if (user_preference != NULL && user_preference[0] != '\0') style_file_name = style_file_lookup (xstrdup (user_preference)); else { const char *gettextdatadir; /* Make it possible to override the po-default.css location. This is necessary for running the testsuite before "make install". */ gettextdatadir = getenv ("GETTEXTDATADIR"); if (gettextdatadir == NULL || gettextdatadir[0] == '\0') gettextdatadir = relocate (GETTEXTDATADIR); style_file_name = xconcatenated_filename (gettextdatadir, "styles/po-default.css", NULL); } } else style_file_name = style_file_lookup (style_file_name); }
address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) { // Stub is fixed up when the corresponding call is converted from // calling compiled code to calling interpreted code. // movq rbx, 0 // jmp -5 # to self address mark = cbuf.insts_mark(); // Get mark within main instrs section. // Note that the code buffer's insts_mark is always relative to insts. // That's why we must use the macroassembler to generate a stub. MacroAssembler _masm(&cbuf); address base = __ start_a_stub(to_interp_stub_size()); if (base == NULL) { return NULL; // CodeBuffer::expand failed. } // Static stub relocation stores the instruction address of the call. __ relocate(static_stub_Relocation::spec(mark), Assembler::imm_operand); // Static stub relocation also tags the Method* in the code-stream. __ mov_metadata(rbx, (Metadata*) NULL); // Method is zapped till fixup time. // This is recognized as unresolved by relocs/nativeinst/ic code. __ jump(RuntimeAddress(__ pc())); // Update current stubs pointer and restore insts_end. __ end_a_stub(); return base; }
/* Lookup the location of the style file. */ static const char * style_file_lookup (const char *file_name) { if (!IS_PATH_WITH_DIR (file_name)) { /* It's a file name without a directory specification. If it does not exist in the current directory... */ struct stat statbuf; if (stat (file_name, &statbuf) < 0) { /* ... but it exists in the styles installation location... */ const char *gettextstylesdir = relocate (GETTEXTDATADIR "/styles"); char *possible_file_name = xconcatenated_filename (gettextstylesdir, file_name, NULL); if (stat (possible_file_name, &statbuf) >= 0) { /* ... then use the file in the styles installation directory. */ return possible_file_name; } free (possible_file_name); } /* Let the CSS library show a warning. */ } return file_name; }
void gc(void) { static int grew = 0; unsigned char *temp; u_int32_t i; curheap = tospace; lim = curheap+heapsize-sizeof(cons_t); for (i=0; i < SP; i++) Stack[i] = relocate(Stack[i]); trace_globals(symtab); #ifdef VERBOSEGC printf("gc found %d/%d live conses\n", (curheap-tospace)/8, heapsize/8); #endif temp = tospace; tospace = fromspace; fromspace = temp; // if we're using > 80% of the space, resize tospace so we have // more space to fill next time. if we grew tospace last time, // grow the other half of the heap this time to catch up. if (grew || ((lim-curheap) < (int)(heapsize/5))) { temp = realloc(tospace, grew ? heapsize : heapsize*2); if (temp == NULL) lerror("out of memory\n"); tospace = temp; if (!grew) heapsize*=2; grew = !grew; } if (curheap > lim) // all data was live gc(); }
void View::setLocation(int inBaseX, int inBaseY) { if ((windowImpl) && (flags & WINDOW_IMPL_OWNER)) windowImpl->setLocation(inBaseX, inBaseY); else relocate(inBaseX, inBaseY); }
struct dsc *loader_arch_load_dsc(const char *name) { char *loadaddr; struct dsc_hdr *dschdr; int length; /* get length of file */ length = get_file_length(name); if (length==0) return NULL; /* allocate memory */ loadaddr = malloc(length); if (loadaddr==NULL) return NULL; /* load the file */ load_file(name, loadaddr); dschdr = (struct dsc_hdr *)loadaddr; /* relocate it */ relocate(dschdr->relocatedata, loadaddr); return &dschdr->dscdata; }
unsigned char loader_arch_load(const char *name, char *arg) { char *loadaddr; struct prg_hdr *prghdr; int length; /* get length of file */ length = get_file_length(name); if (length==0) return LOADER_ERR_OPEN; /* allocate memory */ loadaddr = malloc(length); if (loadaddr==NULL) return LOADER_ERR_MEM; /* load the file */ load_file(name,loadaddr); prghdr = (struct prg_hdr *)loadaddr; /* relocate it */ relocate(prghdr->relocatedata,loadaddr); ((void (*)(char *))prghdr->initfunc)(arg); return LOADER_OK; }
/* mDeltaY : Distance to shrink from standing. */ void glStaticMovesRobot::squat( float mAngle ) { // (start simple - ie flat floor. Later expand to hills) lift_left_leg ( mAngle ); lift_right_leg( mAngle ); float new_height = m_torso.height/2. + m_left_leg.get_vertical_height(); relocate(m_x, new_height, m_z); }
/* Relocate the list of directories that contain the libraries. */ static void relocate_libdirs () { size_t i; for (i = 0; i < sizeof (libdirs) / sizeof (libdirs[0]) - 1; i++) libdirs[i] = relocate (libdirs[i]); }
static void trace_globals(symbol_t *root) { while (root != NULL) { root->binding = relocate(root->binding); trace_globals(root->left); root = root->right; } }
static value_t relocate(value_t v) { value_t a, d, nc; if (!iscons(v)) return v; if (car_(v) == UNBOUND) return cdr_(v); nc = mk_cons(); a = car_(v); d = cdr_(v); car_(v) = UNBOUND; cdr_(v) = nc; car_(nc) = relocate(a); cdr_(nc) = relocate(d); return nc; }
void StaticCallStub::emit_code(LIR_Assembler* ce) { __ relocate(static_stub_Relocation::spec(_call_pc)); __ set_oop(NULL, G5); // must be set to -1 at code generation time Address a(G3, (address)-1); __ jump_to(a, 0); __ delayed()->nop(); }
void *cc_producer(void *bin, const char *name) { struct elf_hdr *ehdr; struct elf_shdr *shdr_table; struct elf_sec *sec_table = NULL; struct elf_obj elfobj; unsigned char *image = NULL; void *kernel_entry; isfailed = 0; image = bin; ehdr = (struct elf_hdr *)image; /* First of all, some simple consistency checks */ if (!elf_check_ident(ehdr)) { HSA_DEBUG_LOG("Check ident failed.\n"); goto failed; } if (!elf_check_ehdr(ehdr)) { HSA_DEBUG_LOG("Check ehdr failed.\n"); goto failed; } memset(&elfobj, 0, sizeof(struct elf_obj)); shdr_table = (struct elf_shdr *)(image + ehdr->e_shoff); sec_table = load_sectiontable(image, shdr_table); if (!sec_table) { HSA_DEBUG_LOG("fetch sec_table failed.\n"); goto failed; } elfobj.ehdrp = ehdr; elfobj.shdr_tablep = shdr_table; elfobj.sec_tablep = sec_table; relocate(&elfobj, find_sym, NULL); if (isfailed) goto failed; kernel_entry = loaderGetSymAddr(&elfobj, name); if (sec_table) free(sec_table); if (elfobj.SHNCommonData) free(elfobj.SHNCommonData); return kernel_entry; failed: if (sec_table) free(sec_table); if (elfobj.SHNCommonData) free(elfobj.SHNCommonData); return NULL; }
inline void MacroAssembler::ldf(FloatRegisterImpl::Width w, const Address& a, FloatRegister d, int offset) { relocate(a.rspec(offset)); if (a.has_index()) { assert(offset == 0, ""); ldf(w, a.base(), a.index(), d); } else { ldf(w, a.base(), a.disp() + offset, d); } }
void glStaticMovesRobot::squat_distance( float mDeltaY ) { // THE HEIGHT, will be: distance (ankle to Knee) + (knee to hip) + (ankle height) // Horizontal distance absorbed by legs. float new_height = m_torso.height/2. + m_left_leg.get_length() - mDeltaY; relocate(m_x, new_height, m_z); lift_leg_from_standing( mDeltaY, true ); lift_leg_from_standing( mDeltaY, false); }
int relocate(t_snakepoint *s) { if (s->n) { relocate(s->n); s->n->y = s->y; s->n->x = s->x; } return (1); }