PROTOTYPES: DISABLE
+BOOT:
+ INIT_SPECIALSV_LIST;
+
#define B_main_cv() main_cv
#define B_main_root() main_root
#define B_main_start() main_start
void
threadsv_names()
PPCODE:
+#ifdef USE_THREADS
int i;
STRLEN len = strlen(threadsv_names);
EXTEND(sp, len);
for (i = 0; i < len; i++)
PUSHs(sv_2mortal(newSVpv(&threadsv_names[i], 1)));
+#endif
#define OP_next(o) o->op_next
sub prepare_assemble {
my $newfh = IO::File->new_tmpfile;
select($newfh);
+ binmode $newfh;
return $newfh;
}
my @options = @_;
my ($option, $opt, $arg);
open(OUT, ">&STDOUT");
+ binmode OUT;
select(OUT);
OPTION:
while ($option = shift @options) {
} elsif ($opt eq "o") {
$arg ||= shift @options;
open(OUT, ">$arg") or return "$arg: $!\n";
+ binmode OUT;
} elsif ($opt eq "D") {
$arg ||= shift @options;
foreach $arg (split(//, $arg)) {
perl_construct( my_perl );
}
+#ifdef CSH
if (!cshlen)
cshlen = strlen(cshname);
+#endif
#ifdef ALLOW_PERL_OPTIONS
#define EXTRA_OPTIONS 2
use ExtUtils::MakeMaker;
use Config;
+my $e = $Config{'exe_ext'};
+my $o = $Config{'obj_ext'};
+my $exeout_flag = '-o ';
+if ($^O eq 'MSWin32') {
+ if ($Config{'cc'} =~ /^cl/i) {
+ $exeout_flag = '-Fe';
+ }
+ elsif ($Config{'cc'} =~ /^bcc/i) {
+ $exeout_flag = '-e';
+ }
+}
+
WriteMakefile(
NAME => "B",
VERSION => "a5",
- OBJECT => "B.o byterun.o",
+ OBJECT => "B$o byterun$o",
depend => {
- "B.o" => "B.c bytecode.h byterun.h",
+ "B$o" => "B.c bytecode.h byterun.h",
},
clean => {
- FILES => "perl byteperl btest btest.c *.o B.c *~"
+ FILES => "perl byteperl$e btest$e btest.c *$o B.c *~"
}
);
sub MY::top_targets {
my $self = shift;
my $targets = $self->MM::top_targets();
- $targets =~ s/^(all ::.*)$/$1 byteperl/m;
- return <<'EOT' . $targets;
+ $targets =~ s/^(all ::.*)$/$1 byteperl$e/m;
+ return <<"EOT" . $targets;
#
# byterun.h, byterun.c and Asmdata.pm are auto-generated. If any of the
# files are missing or if you change bytecode.pl (which is what generates
# them all) then you can "make regen_headers" to regenerate them.
#
regen_headers:
- $(PERL) bytecode.pl
- $(MV) Asmdata.pm B
+ \$(PERL) bytecode.pl
+ \$(MV) Asmdata.pm B
#
# byteperl is *not* a standard perl+XSUB executable. It's a special
# program for running standalone bytecode executables. It isn't an XSUB
# at the moment because a standlone Perl program needs to set up curpad
# which is overwritten on exit from an XSUB.
#
-byteperl: byteperl.o B.o byterun.o
- $(CC) -o byteperl byteperl.o B.o byterun.o $(LDFLAGS) -L$(PERL_ARCHLIB)/CORE -lperl $(LIBS)
+byteperl$e : byteperl$o B$o byterun$o
+ \$(CC) ${exeout_flag}byteperl$e byteperl$o B$o byterun$o \$(LDFLAGS) \$(PERL_ARCHLIB)/CORE/$Config{libperl} \$(LIBS)
EOT
}
use B::Assembler qw(assemble_fh);
use FileHandle;
-my ($filename, $fh);
+my ($filename, $fh, $out);
if ($ARGV[0] eq "-d") {
B::Assembler::debug(1);
shift;
}
+$out = \*STDOUT;
+
if (@ARGV == 0) {
$fh = \*STDIN;
$filename = "-";
} elsif (@ARGV == 1) {
$filename = $ARGV[0];
$fh = new FileHandle "<$filename";
+} elsif (@ARGV == 2) {
+ $filename = $ARGV[0];
+ $fh = new FileHandle "<$filename";
+ $out = new FileHandle ">$ARGV[1]";
} else {
- die "Usage: assemble [filename]\n";
+ die "Usage: assemble [filename] [outfilename]\n";
}
+binmode $out;
$SIG{__WARN__} = sub { warn "$filename:@_" };
$SIG{__DIE__} = sub { die "$filename: @_" };
-assemble_fh($fh, sub { print @_ });
+assemble_fh($fh, sub { print $out @_ });
*/
#define BSET_op_type(o, arg) do { \
o->op_type = arg; \
- o->op_ppaddr = (arg != OP_MAPSTART) ? ppaddr[arg] : pp_grepstart; \
+ if (arg == OP_MAPSTART) \
+ arg = OP_GREPSTART; \
+ o->op_ppaddr = ppaddr[arg]; \
} while (0)
#define BSET_op_ppaddr(o, arg) croak("op_ppaddr not yet implemented")
#define BSET_curpad(pad, arg) pad = AvARRAY(arg)
EOT
printf BYTERUN_H <<'EOT', scalar(@specialsv);
-EXT SV * specialsv_list[%d]
-#ifdef DOINIT
+EXT SV * specialsv_list[%d];
+#define INIT_SPECIALSV_LIST STMT_START { \
EOT
-print BYTERUN_H "= { ", join(", ", @specialsv), " }\n";
+for ($i = 0; $i < @specialsv; $i++) {
+ print BYTERUN_H "specialsv_list[$i] = $specialsv[$i]; \\\n";
+}
print BYTERUN_H <<'EOT';
-#endif /* DOINIT */
-;
+} STMT_END
EOT
#
struct bytestream bs;
#endif /* INDIRECT_BGET_MACROS */
+ INIT_SPECIALSV_LIST;
PERL_SYS_INIT(&argc,&argv);
#if PATCHLEVEL > 3 || (PATCHLEVEL == 3 && SUBVERSION >= 1)
perl_construct( my_perl );
}
+#ifdef CSH
if (!cshlen)
cshlen = strlen(cshname);
+#endif
if (argc < 2)
fp = stdin;
else {
+#ifdef WIN32
+ fp = fopen(argv[1], "rb");
+#else
fp = fopen(argv[1], "r");
+#endif
if (!fp) {
perror(argv[1]);
exit(1);
#endif /* DOINIT */
;
-EXT SV * specialsv_list[4]
-#ifdef DOINIT
-= { Nullsv, &sv_undef, &sv_yes, &sv_no }
-#endif /* DOINIT */
-;
+EXT SV * specialsv_list[4];
+#define INIT_SPECIALSV_LIST STMT_START { \
+specialsv_list[0] = Nullsv; \
+specialsv_list[1] = &sv_undef; \
+specialsv_list[2] = &sv_yes; \
+specialsv_list[3] = &sv_no; \
+} STMT_END
$libdir = $ENV{PERL_SRC} || "$Config{installarchlib}/CORE";
if (!grep(/^-[cS]$/, @ARGV)) {
- $linkargs = sprintf("%s -L$libdir -lperl %s", @Config{qw(ldflags libs)});
+ $linkargs = sprintf("%s $libdir/$Config{libperl} %s",
+ @Config{qw(ldflags libs)});
}
$cccmd = "$Config{cc} $Config{ccflags} -I$libdir @ARGV $linkargs";