First version of a Perl 5.10.0 patch adding Haiku support:

* Built with debugging enabled (-O0 -g).
* No support for sockets or threads yet. We do want those eventually,
  though.
* 6 tests of Perl's test suite fail. 2 due to missing sockets support. 4
  others since they compile modules and make no provisions to link
  against libperl.so, which they should. Have to check back with the
  maintainters.


git-svn-id: file:///srv/svn/repos/haiku/buildtools/trunk@24460 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2008-03-19 11:38:28 +00:00
parent 4fe355caa7
commit 7ff3918294

View File

@ -0,0 +1,613 @@
Index: perlio.h
===================================================================
--- perlio.h (.../vendor/perl/current) (revision 18)
+++ perlio.h (.../trunk) (revision 18)
@@ -64,7 +64,7 @@
*/
#include <stdio.h>
-#ifdef __BEOS__
+#if defined(__BEOS__) && !defined(__HAIKU__)
int fseeko(FILE *stream, off_t offset, int whence);
off_t ftello(FILE *stream);
#endif
Index: haiku/haikuish.h
===================================================================
--- haiku/haikuish.h (.../vendor/perl/current) (revision 0)
+++ haiku/haikuish.h (.../trunk) (revision 18)
@@ -0,0 +1,11 @@
+#ifndef PERL_HAIKU_HAIKUISH_H
+#define PERL_HAIKU_HAIKUISH_H
+
+#include "../unixish.h"
+
+/* We need <sys/wait.h> or else the W* macros aren't defined in perl.h. */
+
+#include <sys/wait.h>
+
+#endif
+
Index: perl.c
===================================================================
--- perl.c (.../vendor/perl/current) (revision 18)
+++ perl.c (.../trunk) (revision 18)
@@ -107,7 +107,7 @@
#endif
-#ifdef __BEOS__
+#if defined(__BEOS__) && !defined(__HAIKU__)
# define HZ 1000000
#endif
@@ -381,7 +381,7 @@
* BeOS has those, but returns the wrong value.
* The HZ if not originally defined has been by now
* been defined as CLK_TCK, if available. */
-#if defined(HAS_SYSCONF) && defined(_SC_CLK_TCK) && !defined(__BEOS__)
+#if defined(HAS_SYSCONF) && defined(_SC_CLK_TCK) && (!defined(__BEOS__) || defined(__HAIKU__))
PL_clocktick = sysconf(_SC_CLK_TCK);
if (PL_clocktick <= 0)
#endif
Index: perl.h
===================================================================
--- perl.h (.../vendor/perl/current) (revision 18)
+++ perl.h (.../trunk) (revision 18)
@@ -2551,7 +2551,10 @@
# define ISHISH "macos classic"
#endif
-#if defined(__BEOS__)
+#if defined(__HAIKU__)
+# include "haiku/haikuish.h"
+# define ISHISH "haiku"
+#elif defined(__BEOS__)
# include "beos/beosish.h"
# define ISHISH "beos"
#endif
@@ -5609,9 +5612,10 @@
#if O_TEXT != O_BINARY
/* If you have different O_TEXT and O_BINARY and you are a CLRF shop,
* that is, you are somehow DOSish. */
-# if defined(__BEOS__) || defined(__VOS__) || defined(__CYGWIN__)
- /* BeOS has O_TEXT != O_BINARY but O_TEXT and O_BINARY have no effect;
- * BeOS is always UNIXoid (LF), not DOSish (CRLF). */
+# if defined(__BEOS__) || defined(__HAIKU__) || defined(__VOS__) || \
+ defined(__CYGWIN__)
+ /* BeOS/Haiku has O_TEXT != O_BINARY but O_TEXT and O_BINARY have no effect;
+ * BeOS/Haiku is always UNIXoid (LF), not DOSish (CRLF). */
/* VOS has O_TEXT != O_BINARY, and they have effect,
* but VOS always uses LF, never CRLF. */
/* If you have O_TEXT different from your O_BINARY but you still are
Index: lib/CPANPLUS/Internals/Constants/Report.pm
===================================================================
--- lib/CPANPLUS/Internals/Constants/Report.pm (.../vendor/perl/current) (revision 18)
+++ lib/CPANPLUS/Internals/Constants/Report.pm (.../trunk) (revision 18)
@@ -29,6 +29,7 @@
Cygwin => 'cygwin',
Darwin => 'darwin',
EBCDIC => 'os390|os400|posix-bc|vmesa',
+ Haiku => 'haiku',
HPUX => 'hpux',
Linux => 'linux',
MSDOS => 'dos|os2|MSWin32|cygwin',
Index: lib/CPANPLUS/t/20_CPANPLUS-Dist-MM.t
===================================================================
--- lib/CPANPLUS/t/20_CPANPLUS-Dist-MM.t (.../vendor/perl/current) (revision 18)
+++ lib/CPANPLUS/t/20_CPANPLUS-Dist-MM.t (.../trunk) (revision 18)
@@ -45,7 +45,13 @@
$conf->set_conf( cpantest => 0 );
### Redirect errors to file ###
-*STDERR = output_handle() unless $Verbose;
+### The code in IPC::Cmd::_open3_run() uses a pipe to get the child's stderr
+### output and IPC::Open3::_open3() will not dup the child's error end to the
+### original STDERR FD. Instead it will assign the pipe's write end FD, which
+### will be CLOEXEC. On exec() this FD will be closed and the select()+read()
+### loop in IPC::Cmd::_open3_run() will become very busy, since select()
+### will always return immediately due to the half-closed pipe.
+#*STDERR = output_handle() unless $Verbose;
### dont uncomment this, it screws up where STDOUT goes and makes
### test::harness create test counter mismatches
Index: lib/Module/Build.pm
===================================================================
--- lib/Module/Build.pm (.../vendor/perl/current) (revision 18)
+++ lib/Module/Build.pm (.../trunk) (revision 18)
@@ -30,6 +30,7 @@
dynixptx Unix
freebsd Unix
linux Unix
+ haiku Unix
hpux Unix
irix Unix
darwin Unix
Index: lib/Term/ReadLine.pm
===================================================================
--- lib/Term/ReadLine.pm (.../vendor/perl/current) (revision 18)
+++ lib/Term/ReadLine.pm (.../trunk) (revision 18)
@@ -222,7 +222,8 @@
$console = "sys\$command";
}
- if (($^O eq 'amigaos') || ($^O eq 'beos') || ($^O eq 'epoc')) {
+ if (($^O eq 'amigaos') || ($^O eq 'beos') || ($^O eq 'epoc') ||
+ ($^O eq 'haiku')) {
$console = undef;
}
elsif ($^O eq 'os2') {
Index: lib/ExtUtils/MM.pm
===================================================================
--- lib/ExtUtils/MM.pm (.../vendor/perl/current) (revision 18)
+++ lib/ExtUtils/MM.pm (.../trunk) (revision 18)
@@ -69,6 +69,7 @@
$Is{VOS} = $^O eq 'vos';
$Is{QNX} = $^O eq 'qnx';
$Is{AIX} = $^O eq 'aix';
+$Is{Haiku} = $^O eq 'haiku';
$Is{Unix} = !grep { $_ } values %Is;
Index: lib/ExtUtils/MM_Haiku.pm
===================================================================
--- lib/ExtUtils/MM_Haiku.pm (.../vendor/perl/current) (revision 0)
+++ lib/ExtUtils/MM_Haiku.pm (.../trunk) (revision 18)
@@ -0,0 +1,62 @@
+package ExtUtils::MM_Haiku;
+
+use strict;
+
+=head1 NAME
+
+ExtUtils::MM_Haiku - methods to override UN*X behaviour in ExtUtils::MakeMaker
+
+=head1 SYNOPSIS
+
+ use ExtUtils::MM_Haiku; # Done internally by ExtUtils::MakeMaker if needed
+
+=head1 DESCRIPTION
+
+See ExtUtils::MM_Unix for a documentation of the methods provided
+there. This package overrides the implementation of these methods, not
+the semantics.
+
+=over 4
+
+=cut
+
+use ExtUtils::MakeMaker::Config;
+use File::Spec;
+require ExtUtils::MM_Any;
+require ExtUtils::MM_Unix;
+
+use vars qw(@ISA $VERSION);
+@ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix );
+$VERSION = '6.42';
+
+
+=item os_flavor
+
+Haiku is Haiku.
+
+=cut
+
+sub os_flavor {
+ return('Haiku');
+}
+
+=item init_linker
+
+libperl.a equivalent to be linked to dynamic extensions.
+
+=cut
+
+sub init_linker {
+ my($self) = shift;
+
+ $self->{PERL_ARCHIVE} ||=
+ File::Spec->catdir('$(PERL_INC)',$Config{libperl});
+ $self->{PERL_ARCHIVE_AFTER} ||= '';
+ $self->{EXPORT_LIST} ||= '';
+}
+
+=back
+
+1;
+__END__
+
Index: hints/haiku.sh
===================================================================
--- hints/haiku.sh (.../vendor/perl/current) (revision 0)
+++ hints/haiku.sh (.../trunk) (revision 18)
@@ -0,0 +1,65 @@
+# Haiku hints file
+# $Id$
+
+prefix="/boot/home/config"
+
+libpth='/boot/beos/system/lib /boot/home/config/lib'
+usrinc='/boot/develop/headers/posix'
+locinc='/boot/develop/headers/ /boot/home/config/include'
+
+libc='/boot/beos/system/lib/libroot.so'
+libs=' '
+
+#d_bcmp='define'
+#d_bcopy='define'
+#d_bzero='define'
+#d_index='define'
+#d_htonl='define' # It exists, but much hackery would be required to support.
+# a bunch of extra includes would have to be added, and it's only used at
+# one place in the non-socket perl code.
+
+#these are all in libdll.a, which my version of nm doesn't know how to parse.
+#if I can get it to both do that, and scan multiple library files, perhaps
+#these can be gotten rid of.
+
+case "$usemymalloc" in
+'') usemymalloc='n' ;;
+esac
+# Hopefully, Be's malloc knows better than perl's.
+
+d_link='undef'
+dont_use_nlink='define'
+# no posix (aka hard) links for us!
+
+d_syserrlst='undef'
+# the array syserrlst[] is useless for the most part.
+# large negative numbers really kind of suck in arrays.
+
+# Sockets didn't use to be real sockets but BONE changes this.
+#if [ ! -f /boot/develop/headers/be/bone/sys/socket.h ]; then
+# d_socket='undef'
+# d_gethbyaddr='undef'
+# d_gethbyname='undef'
+# d_getsbyname='undef'
+#
+# libs='-lnet'
+#fi
+
+
+cc="gcc"
+ld='gcc'
+
+export PATH="$PATH:$PWD/haiku"
+
+case "$ldlibpthname" in
+'') ldlibpthname=LIBRARY_PATH ;;
+esac
+
+# the waitpid() wrapper (among other things)
+#archobjs="beos.o"
+#test -f beos.c || cp beos/beos.c .
+
+# TODO: Remove when using a native Haiku compiler!
+ccflags="$ccflags -g -O0 -D__HAIKU__ -fno-strict-aliasing -pipe"
+cppflags="$cppflags -D__HAIKU__"
+
Index: ext/Errno/Errno_pm.PL
===================================================================
--- ext/Errno/Errno_pm.PL (.../vendor/perl/current) (revision 18)
+++ ext/Errno/Errno_pm.PL (.../trunk) (revision 18)
@@ -155,7 +155,7 @@
# we might miss out on compiler-specific ones
$file{"$ENV{GUSI}include:sys:errno.h"} = 1;
- } elsif ($^O eq 'beos') {
+ } elsif ($^O eq 'beos' || $^O eq 'haiku') {
# hidden in a special place
$file{'/boot/develop/headers/posix/errno.h'} = 1;
@@ -250,7 +250,8 @@
close(CPPI);
- unless ($^O eq 'MacOS' || $^O eq 'beos') { # trust what we have / get later
+ unless ($^O eq 'MacOS' || $^O eq 'beos' || $^O eq 'haiku') {
+ # trust what we have / get later
# invoke CPP and read the output
if ($^O eq 'VMS') {
@@ -293,12 +294,12 @@
# Many of the E constants (including ENOENT, which is being
# used in the Perl test suite a lot), are available only as
- # enums in BeOS, so compiling and executing some code is about
+ # enums in BeOS/Haiku, so compiling and executing some code is about
# only way to find out what the numeric Evalues are. In fact above, we
# didn't even bother to get the values of the ones that have numeric
# values, since we can get all of them here, anyway.
- if ($^O eq 'beos') {
+ if ($^O eq 'beos' || $^O eq 'haiku') {
if (open(C, ">errno.c")) {
my @allerrs = keys %err;
print C <<EOF;
Index: ext/Compress/Raw/Zlib/zlib-src/zutil.h
===================================================================
--- ext/Compress/Raw/Zlib/zlib-src/zutil.h (.../vendor/perl/current) (revision 18)
+++ ext/Compress/Raw/Zlib/zlib-src/zutil.h (.../trunk) (revision 18)
@@ -147,7 +147,7 @@
# define OS_CODE 0x0f
#endif
-#if defined(_BEOS_) || defined(RISCOS)
+#if (defined(_BEOS_) && !defined(__HAIKU__)) || defined(RISCOS)
# define fdopen(fd,mode) NULL /* No fdopen() */
#endif
Index: ext/Time/HiRes/t/HiRes.t
===================================================================
--- ext/Time/HiRes/t/HiRes.t (.../vendor/perl/current) (revision 18)
+++ ext/Time/HiRes/t/HiRes.t (.../trunk) (revision 18)
@@ -337,7 +337,8 @@
&& defined &Time::HiRes::getitimer
&& has_symbol('ITIMER_VIRTUAL')
&& $Config{sig_name} =~ m/\bVTALRM\b/
- && $^O !~ /^(nto)$/) { # nto: QNX 6 has the API but no implementation
+ && $^O !~ /^(nto)$/ # nto: QNX 6 has the API but no implementation
+ && $^O ne 'haiku') { # same for Haiku
for (18..19) {
print "ok $_ # Skip: no virtual interval timers\n";
}
Index: ext/Haiku/Makefile.PL
===================================================================
--- ext/Haiku/Makefile.PL (.../vendor/perl/current) (revision 0)
+++ ext/Haiku/Makefile.PL (.../trunk) (revision 18)
@@ -0,0 +1,20 @@
+use 5.006;
+use ExtUtils::MakeMaker;
+
+unless ($^O eq "haiku") {
+ die "OS unsupported\n";
+}
+
+#my @libs;
+#push @libs, '-L/lib/w32api -lole32 -lversion' if $^O eq "cygwin";
+
+WriteMakefile(
+ NAME => 'Haiku',
+ VERSION_FROM => 'Haiku.pm',
+# LIBS => \@libs,
+ INSTALLDIRS => ($] >= 5.008004 ? 'perl' : 'site'),
+ NO_META => 1,
+
+ AUTHOR => 'Ingo Weinhold <ingo_weinhold@gmx.de>',
+ ABSTRACT_FROM => 'Haiku.pm',
+);
Index: ext/Haiku/Haiku.xs
===================================================================
--- ext/Haiku/Haiku.xs (.../vendor/perl/current) (revision 0)
+++ ext/Haiku/Haiku.xs (.../trunk) (revision 18)
@@ -0,0 +1,141 @@
+#define PERL_NO_GET_CONTEXT
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#include <stdarg.h>
+
+#include <OS.h>
+
+static void
+haiku_do_debugger(const char* format,...)
+{
+ char buffer[1024];
+ va_list args;
+ va_start(args, format);
+ my_vsnprintf(buffer, sizeof(buffer), format, args);
+ va_end(args);
+
+ debugger(buffer);
+}
+
+static void
+haiku_do_debug_printf(pTHX_ register SV *sv,
+ void (*printfFunc)(const char*,...))
+{
+ dVAR;
+
+ if (!sv)
+ return;
+ if (SvTYPE(sv) == SVt_IV && SvIOK(sv)) {
+ assert(!SvGMAGICAL(sv));
+ if (SvIsUV(sv))
+ (*printfFunc)("%"UVuf, (UV)SvUVX(sv));
+ else
+ (*printfFunc)("%"IVdf, (IV)SvIVX(sv));
+ return;
+ }
+ else {
+ STRLEN len;
+ /* Do this first to trigger any overloading. */
+ const char *tmps = SvPV_const(sv, len);
+ U8 *tmpbuf = NULL;
+#undef strnlen
+if (strnlen(tmps, len) != len)
+haiku_do_debugger("haiku_do_debug_printf(): len: %lu, acually: %lu",
+len, strnlen(tmps, len));
+
+ if (!SvUTF8(sv)) {
+ /* We don't modify the original scalar. */
+ tmpbuf = bytes_to_utf8((const U8*) tmps, &len);
+ tmps = (char *) tmpbuf;
+ }
+
+ if (len)
+ (*printfFunc)("%.*s", (int)len, tmps);
+ Safefree(tmpbuf);
+ }
+}
+
+XS(haiku_debug_printf)
+{
+ dVAR;
+ dXSARGS;
+ dORIGMARK;
+ SV *sv;
+
+ if (items < 1)
+ Perl_croak(aTHX_ "usage: Haiku::debug_printf($format,...)");
+
+ sv = newSV(0);
+
+ if (SvTAINTED(MARK[1]))
+ TAINT_PROPER("debug_printf");
+ do_sprintf(sv, SP - MARK, MARK + 1);
+
+ haiku_do_debug_printf(sv, &debug_printf);
+
+ SvREFCNT_dec(sv);
+ SP = ORIGMARK;
+ PUSHs(&PL_sv_yes);
+}
+
+XS(haiku_ktrace_printf)
+{
+ dVAR;
+ dXSARGS;
+ dORIGMARK;
+ SV *sv;
+
+ if (items < 1)
+ Perl_croak(aTHX_ "usage: Haiku::debug_printf($format,...)");
+
+ sv = newSV(0);
+
+ if (SvTAINTED(MARK[1]))
+ TAINT_PROPER("ktrace_printf");
+ do_sprintf(sv, SP - MARK, MARK + 1);
+
+ haiku_do_debug_printf(sv, &ktrace_printf);
+
+ SvREFCNT_dec(sv);
+ SP = ORIGMARK;
+ PUSHs(&PL_sv_yes);
+}
+
+XS(haiku_debugger)
+{
+ dVAR;
+ dXSARGS;
+ dORIGMARK;
+ SV *sv;
+
+ if (items < 1)
+ Perl_croak(aTHX_ "usage: Haiku::debugger($format,...)");
+
+ sv = newSV(0);
+
+ if (SvTAINTED(MARK[1]))
+ TAINT_PROPER("debugger");
+ do_sprintf(sv, SP - MARK, MARK + 1);
+
+ haiku_do_debug_printf(sv, &haiku_do_debugger);
+
+ SvREFCNT_dec(sv);
+ SP = ORIGMARK;
+ PUSHs(&PL_sv_yes);
+}
+
+MODULE = Haiku PACKAGE = Haiku
+
+PROTOTYPES: DISABLE
+
+BOOT:
+{
+ char *file = __FILE__;
+
+ newXS("Haiku::debug_printf", haiku_debug_printf, file);
+ newXS("Haiku::ktrace_printf", haiku_ktrace_printf, file);
+ newXS("Haiku::debugger", haiku_debugger, file);
+ XSRETURN_YES;
+}
Index: ext/Haiku/Haiku.pm
===================================================================
--- ext/Haiku/Haiku.pm (.../vendor/perl/current) (revision 0)
+++ ext/Haiku/Haiku.pm (.../trunk) (revision 18)
@@ -0,0 +1,54 @@
+package Haiku;
+
+BEGIN {
+ use strict;
+ use vars qw|$VERSION $XS_VERSION @ISA @EXPORT @EXPORT_OK|;
+
+ require Exporter;
+ require DynaLoader;
+
+ @ISA = qw|Exporter DynaLoader|;
+ $VERSION = '0.34';
+ $XS_VERSION = $VERSION;
+ $VERSION = eval $VERSION;
+
+ @EXPORT = qw(
+ );
+ @EXPORT_OK = qw(
+ );
+}
+
+bootstrap Haiku;
+
+1;
+
+__END__
+
+=head1 NAME
+
+Haiku - Interfaces to some Haiku API Functions
+
+=head1 DESCRIPTION
+
+The Haiku module contains functions to access Haiku APIs.
+
+=head2 Alphabetical Listing of Haiku Functions
+
+=over
+
+=item Haiku::debug_printf(FORMAT,...)
+
+Similar to printf, but prints to system debug output.
+
+=item Haiku::debugger(FORMAT,...)
+
+Drops the program into the debugger. The printf like arguments define the
+debugger message.
+
+=item Haiku::ktrace_printf(FORMAT,...)
+
+Similar to printf, but prints to a kernel tracing entry.
+
+=back
+
+=cut
Index: Configure
===================================================================
--- Configure (.../vendor/perl/current) (revision 18)
+++ Configure (.../trunk) (revision 18)
@@ -7864,6 +7864,7 @@
case "$lddlflags" in
'') case "$osname" in
beos) dflt='-nostart' ;;
+ haiku) dflt='-nostart' ;;
hpux) dflt='-b';
case "$gccversion" in
'') dflt="$dflt +vnocompatwarnings" ;;
@@ -7946,7 +7947,7 @@
;;
*) case "$useshrplib" in
'') case "$osname" in
- svr4*|nonstopux|dgux|dynixptx|esix|powerux|beos|cygwin*)
+ svr4*|nonstopux|dgux|dynixptx|esix|powerux|beos|cygwin*|haiku)
dflt=y
also='Building a shared libperl is required for dynamic loading to work on your system.'
;;
@@ -8109,6 +8110,9 @@
beos)
# beos doesn't like the default, either.
;;
+ haiku)
+ # Haiku doesn't like the default, either.
+ ;;
hpux*)
# hpux doesn't like the default, either.
tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""