Let me try reposting the patch, which gives me the opportunity to bit twiddle a bit more:
* Removed the mmap nonsense which was sent by accident * Renamed config.c to config_string.c to make it less generic * Moved a couple externs from a core parrot library into the main executable, where they sit better Thanks for considering this patch, Nick On 10/17/05, Joshua Hoblitt via RT <[EMAIL PROTECTED]> wrote: > I'm guessing that this change in src/embed.c wasn't intended to be included > in the patch: > > - mmap(0, program_size, PROT_READ, MAP_SHARED, fd, (off_t)0); > + mmap(0, program_size, PROT_READ, MAP_PRIVATE, fd, (off_t)0);
Index: build_tools/parrot_config_c.pl =================================================================== --- build_tools/parrot_config_c.pl (revision 9496) +++ build_tools/parrot_config_c.pl (working copy) @@ -7,7 +7,7 @@ =head1 NAME -build_tools/parrot_config_c.pl - Create src/parrot_config.c +build_tools/parrot_config_c.pl - Create src/parrot_config.c and variants =head1 SYNOPSIS @@ -41,46 +41,46 @@ * */ +EOF + +if ($mini_parrot) { + + print << "EOF"; #include "parrot/parrot.h" +const char* parrot_config_ptr = NULL; +unsigned int parrot_config_size = 0; +EOF +} +else +{ + print << "EOF"; static const char parrot_config[] = { EOF -if ($mini_parrot) { - print " 0\n"; -} -else { my $image_file = $install_parrot ? - 'install_config.fpmc' : 'runtime/parrot/include/config.fpmc'; + 'install_config.fpmc' : 'runtime/parrot/include/config.fpmc'; open F, $image_file or die "Can't read '$image_file': $!"; my $image; local $/; - binmode F; + binmode F; $_ = <F>; close F; my @c = split ''; printf ' '; my $i; for (@c) { - printf "0x%02x", ord($_); - ++$i; - print ', ', if ($i < scalar(@c)); - print "\n " unless $i % 8; + printf "0x%02x", ord($_); + ++$i; + print ', ', if ($i < scalar(@c)); + print "\n " unless $i % 8; } print "\n"; -} print << "EOF"; }; /* parrot_config */ -STRING* -parrot_get_config_string(Interp* interpreter) -{ - if (sizeof(parrot_config) <= 1) - return NULL; - return string_from_const_cstring(interpreter, - parrot_config, sizeof(parrot_config)); +const char* parrot_config_ptr = parrot_config; +unsigned int parrot_config_size = sizeof(parrot_config); +EOF } -EOF - - Index: src/config_string.c =================================================================== --- src/config_string.c (revision 0) +++ src/config_string.c (revision 0) @@ -0,0 +1,63 @@ +/* + Copyright: 2005 The Perl Foundation. All Rights Reserved. + $Id$ + +=head1 NAME + +src/config_string.c - Register configuration bundle with parrot runtime + +=head1 DESCRIPTION + +The routines in this file can be used to set and retrieve the embedded +configuration data for the parrot runtime. + +There are currently three runtimes: + +=over 4 + +=item * a dummy stub used in minparrot during and other utilities. No +explicit set is required for this + +=item * the default config used during the build + +=item * a config profile suitable once parrot has been installed system-wide + +=back + +=cut + +*/ + +#include "parrot/parrot.h" + +static const char *parrot_config_private_ptr = NULL; +static unsigned int parrot_config_private_size = 0; + +void +Parrot_set_config_string(const char* new_parrot_config_ptr, + unsigned int new_parrot_config_size) +{ + parrot_config_private_ptr = new_parrot_config_ptr; + parrot_config_private_size = new_parrot_config_size; +} + +STRING* +parrot_get_config_string(Interp* interpreter) +{ + if (!parrot_config_private_ptr) + return NULL; + + return string_from_const_cstring(interpreter, + parrot_config_private_ptr, + parrot_config_private_size); +} + +/* + * Local variables: + * c-indentation-style: bsd + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * + * vim: expandtab shiftwidth=4: + */ Index: MANIFEST =================================================================== --- MANIFEST (revision 9496) +++ MANIFEST (working copy) @@ -1728,6 +1728,7 @@ src/exec_save.c [] src/exec_start.c [] src/exit.c [] +src/config_string.c [] src/extend.c [] src/gc_gms.c [] src/gc_ims.c [] Index: imcc/main.c =================================================================== --- imcc/main.c (revision 9496) +++ imcc/main.c (working copy) @@ -26,6 +26,9 @@ static char optimizer_opt[20]; extern FILE *yyin; +extern const char* parrot_config_ptr; +extern unsigned int parrot_config_size; + static void usage(FILE* fp) { @@ -455,6 +458,8 @@ char *sourcefile; char *output; + Parrot_set_config_string(parrot_config_ptr,parrot_config_size); + Interp *interp = Parrot_new(NULL); Parrot_init(interp); Index: include/parrot/library.h =================================================================== --- include/parrot/library.h (revision 9496) +++ include/parrot/library.h (working copy) @@ -28,6 +28,9 @@ enum_runtime_ft); void Parrot_autoload_class(Interp *, STRING *class); + +void Parrot_set_config_string(const char* new_parrot_config_ptr, + unsigned int new_parrot_config_size); STRING * parrot_get_config_string(Interp* ); const char* Parrot_get_runtime_prefix(Interp *, STRING **prefix); Index: config/gen/makefiles/libparrot_def.in =================================================================== --- config/gen/makefiles/libparrot_def.in (revision 9496) +++ config/gen/makefiles/libparrot_def.in (working copy) @@ -10,4 +10,5 @@ Parrot_destroy Parrot_debug Parrot_disassemble + Parrot_set_config_string Parrot_DynOp_core_${MAJOR}_${MINOR}_${PATCH} Index: config/gen/makefiles/root.in =================================================================== --- config/gen/makefiles/root.in (revision 9496) +++ config/gen/makefiles/root.in (working copy) @@ -426,6 +426,7 @@ $(SRC_DIR)/mmd$(O) \ $(SRC_DIR)/builtin$(O) \ $(SRC_DIR)/extend$(O) \ + $(SRC_DIR)/config_string$(O) \ $(SRC_DIR)/revision$(O) \ $(PF_DIR)/pf_items$(O) \ $(OPS_DIR)/core_ops$(O) \ @@ -764,7 +765,6 @@ $(PDB) : $(SRC_DIR)/pdb$(O) $(LIBPARROT) $(LINK) ${ld_out}$(PDB) \ $(SRC_DIR)/pdb$(O) \ - $(SRC_DIR)/null_config$(O) \ $(LINKFLAGS) $(ALL_PARROT_LIBS) # @@ -776,7 +776,6 @@ $(DIS) : $(SRC_DIR)/disassemble$(O) $(LIBPARROT) $(LINK) ${ld_out}$(DIS) \ $(SRC_DIR)/disassemble$(O) \ - $(SRC_DIR)/null_config$(O) \ $(LINKFLAGS) $(ALL_PARROT_LIBS) # @@ -786,7 +785,6 @@ $(PDUMP) : $(SRC_DIR)/pdump$(O) $(SRC_DIR)/packdump$(O) $(LIBPARROT) $(LINK) ${ld_out}$(PDUMP) \ $(SRC_DIR)/pdump$(O) \ - $(SRC_DIR)/null_config$(O) \ $(SRC_DIR)/packdump$(O) $(LINKFLAGS) $(ALL_PARROT_LIBS) @@ -794,7 +792,6 @@ $(PINFO) : $(SRC_DIR)/pbc_info$(O) $(LIBPARROT) $(LINK) ${ld_out}$(PINFO) \ $(SRC_DIR)/pbc_info$(O) \ - $(SRC_DIR)/null_config$(O) \ $(LINKFLAGS) $(ALL_PARROT_LIBS) # @@ -805,7 +802,6 @@ $(PBCMERGE) : $(SRC_DIR)/pbc_merge$(O) $(LIBPARROT) $(LINK) ${ld_out}$(PBCMERGE) \ $(SRC_DIR)/pbc_merge$(O) \ - $(SRC_DIR)/null_config$(O) \ $(LINKFLAGS) $(ALL_PARROT_LIBS) @@ -946,6 +942,8 @@ $(SRC_DIR)/thread$(O) : $(GENERAL_H_FILES) +$(SRC_DIR)/config_string$(O) : $(GENERAL_H_FILES) + $(SRC_DIR)/extend$(O) : $(GENERAL_H_FILES) $(INC_DIR)/extend.h $(SRC_DIR)/interpreter$(O) : $(SRC_DIR)/interpreter.c $(GENERAL_H_FILES) \