Joshua Hoblitt wrote:
# New Ticket Created by Joshua Hoblitt
# Please include the string: [perl #37303]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37303 >
----- Forwarded message from Nick Glencross <[EMAIL PROTECTED]> -----
From: Nick Glencross <[EMAIL PROTECTED]>
Guys,
I've been wanting to relax the dependency that parrot's core has on
parrot_config.
I'm not sure that the patch made it into RT. Here it is again, with a
small tweak to a Makefile dependency.
src/config.c will need to be 'svn add'ed when applying the patch, and
Configure rerun to recreate the top-level Makefile.
Cheers,
Nick
Index: build_tools/parrot_config_c.pl
===================================================================
--- build_tools/parrot_config_c.pl (revision 9273)
+++ 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,44 @@
*
*/
-#include "parrot/parrot.h"
-
-static const char parrot_config[] = {
EOF
if ($mini_parrot) {
- print " 0\n";
+
+ print << "EOF";
+const char* parrot_config_ptr = 0;
+unsigned int parrot_config_size = 0;
+EOF
}
-else {
+else
+{
+ print << "EOF";
+static const char parrot_config[] = {
+EOF
+
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
-
-
+}
Index: src/config.c
===================================================================
--- src/config.c (revision 0)
+++ src/config.c (revision 0)
@@ -0,0 +1,63 @@
+/*
+ Copyright: 2005 The Perl Foundation. All Rights Reserved.
+ $Id$
+
+=head1 NAME
+
+src/config.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: src/pmc_freeze.c
===================================================================
--- src/pmc_freeze.c (revision 9273)
+++ src/pmc_freeze.c (working copy)
@@ -712,7 +712,7 @@
else {
if (string_length(interpreter, s) < PACKFILE_HEADER_BYTES) {
real_exception(interpreter, NULL, E_IOError,
- "bad string too thaw");
+ "bad string to thaw");
}
mem_sys_memcopy(pf->header, s->strstart, PACKFILE_HEADER_BYTES);
PackFile_assign_transforms(pf);
Index: MANIFEST
===================================================================
--- MANIFEST (revision 9273)
+++ MANIFEST (working copy)
@@ -1721,6 +1721,7 @@
src/exec_save.c []
src/exec_start.c []
src/exit.c []
+src/config.c []
src/extend.c []
src/gc_gms.c []
src/gc_ims.c []
Index: imcc/main.c
===================================================================
--- imcc/main.c (revision 9273)
+++ imcc/main.c (working copy)
@@ -459,6 +459,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 9273)
+++ include/parrot/library.h (working copy)
@@ -28,6 +28,12 @@
enum_runtime_ft);
void Parrot_autoload_class(Interp *, STRING *class);
+
+const char* parrot_config_ptr;
+unsigned int parrot_config_size;
+
+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/root.in
===================================================================
--- config/gen/makefiles/root.in (revision 9273)
+++ config/gen/makefiles/root.in (working copy)
@@ -428,6 +428,7 @@
$(SRC_DIR)/mmd$(O) \
$(SRC_DIR)/builtin$(O) \
$(SRC_DIR)/extend$(O) \
+ $(SRC_DIR)/config$(O) \
$(SRC_DIR)/revision$(O) \
$(PF_DIR)/pf_items$(O) \
$(OPS_DIR)/core_ops$(O) \
@@ -761,7 +762,6 @@
$(PDB) : $(SRC_DIR)/pdb$(O) $(LIBPARROT)
$(LINK) ${ld_out}$(PDB) \
$(SRC_DIR)/pdb$(O) \
- $(SRC_DIR)/null_config$(O) \
$(LINKFLAGS) $(ALL_PARROT_LIBS)
#
@@ -773,7 +773,6 @@
$(DIS) : $(SRC_DIR)/disassemble$(O) $(LIBPARROT)
$(LINK) ${ld_out}$(DIS) \
$(SRC_DIR)/disassemble$(O) \
- $(SRC_DIR)/null_config$(O) \
$(LINKFLAGS) $(ALL_PARROT_LIBS)
#
@@ -783,7 +782,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)
@@ -791,7 +789,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)
#
@@ -802,7 +799,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)
@@ -943,6 +939,8 @@
$(SRC_DIR)/thread$(O) : $(GENERAL_H_FILES)
+$(SRC_DIR)/config$(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) \