From: Ingo Weinhold Date: Wed, 29 Oct 2008 02:25:44 +0000 (+0100) Subject: Haiku Port X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=df00ff3beeb297b9622f8acbed9c80d320c87580;p=p5sagit%2Fp5-mst-13.2.git Haiku Port Message-Id: <20081029022544.413.1@knochen-vm.localdomain> p4raw-id: //depot/perl@34630 --- diff --git a/Configure b/Configure index dc27345..aa005d5 100755 --- a/Configure +++ b/Configure @@ -25,7 +25,7 @@ # $Id: Head.U 6 2006-08-25 22:21:46Z rmanfredi $ # -# Generated on Tue Oct 28 18:51:20 CET 2008 [metaconfig 3.5 PL0] +# Generated on Wed Oct 29 09:08:09 CET 2008 [metaconfig 3.5 PL0] # (with additional metaconfig patches by perlbug@perl.org) cat >c1$$ < with your respective version of Perl. + +=head1 KNOWN PROBLEMS + +The following problems are encountered with Haiku revision 28311: + +=over 4 + +=item * + +Perl cannot be compiled with threading support ATM. + +=item * + +The C test fails. More precisely: the subtests +using datagram sockets fail. Unix datagram sockets aren't implemented in +Haiku yet. + +=item * + +A subtest of the C test fails. This is due to Haiku +not implementing C support yet. + +=item * + +The tests C and C +fail. This is due to bugs in Haiku's network stack implementation. + +=back + +=head1 CONTACT + +For Haiku specific problems contact the HaikuPorts developers: +http://ports.haiku-files.org/ + +The initial Haiku port was done by Ingo Weinhold . + +Last update: 2008-10-29 diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL index 6f20c5e..802e638 100644 --- a/ext/Errno/Errno_pm.PL +++ b/ext/Errno/Errno_pm.PL @@ -155,7 +155,7 @@ sub get_files { # 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; diff --git a/ext/Time/HiRes/t/HiRes.t b/ext/Time/HiRes/t/HiRes.t index fbb0d6d..d967348 100644 --- a/ext/Time/HiRes/t/HiRes.t +++ b/ext/Time/HiRes/t/HiRes.t @@ -337,7 +337,8 @@ unless ( defined &Time::HiRes::setitimer && 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"; } diff --git a/haiku/Haiku/Haiku.pm b/haiku/Haiku/Haiku.pm new file mode 100644 index 0000000..2577bec --- /dev/null +++ b/haiku/Haiku/Haiku.pm @@ -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 diff --git a/haiku/Haiku/Haiku.xs b/haiku/Haiku/Haiku.xs new file mode 100644 index 0000000..c5a121d --- /dev/null +++ b/haiku/Haiku/Haiku.xs @@ -0,0 +1,137 @@ +#define PERL_NO_GET_CONTEXT +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include + +#include + +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; + + 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; +} diff --git a/haiku/Haiku/Makefile.PL b/haiku/Haiku/Makefile.PL new file mode 100644 index 0000000..dacf230 --- /dev/null +++ b/haiku/Haiku/Makefile.PL @@ -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 ', + ABSTRACT_FROM => 'Haiku.pm', +); diff --git a/haiku/haikuish.h b/haiku/haikuish.h new file mode 100644 index 0000000..55869b4 --- /dev/null +++ b/haiku/haikuish.h @@ -0,0 +1,11 @@ +#ifndef PERL_HAIKU_HAIKUISH_H +#define PERL_HAIKU_HAIKUISH_H + +#include "../unixish.h" + +/* We need or else the W* macros aren't defined in perl.h. */ + +#include + +#endif + diff --git a/lib/CPANPLUS/Internals/Constants/Report.pm b/lib/CPANPLUS/Internals/Constants/Report.pm index 027da44..adde170 100644 --- a/lib/CPANPLUS/Internals/Constants/Report.pm +++ b/lib/CPANPLUS/Internals/Constants/Report.pm @@ -29,6 +29,7 @@ my %OS = ( Cygwin => 'cygwin', Darwin => 'darwin', EBCDIC => 'os390|os400|posix-bc|vmesa', + Haiku => 'haiku', HPUX => 'hpux', Linux => 'linux', MSDOS => 'dos|os2|MSWin32|cygwin', diff --git a/lib/ExtUtils/CBuilder.pm b/lib/ExtUtils/CBuilder.pm index 099761c..851fdaf 100644 --- a/lib/ExtUtils/CBuilder.pm +++ b/lib/ExtUtils/CBuilder.pm @@ -38,6 +38,7 @@ my %OSTYPES = qw( os2 Unix gnu Unix gnukfreebsd Unix + haiku Unix dos Windows MSWin32 Windows diff --git a/lib/ExtUtils/MM.pm b/lib/ExtUtils/MM.pm index 04195ee..fc7aac5 100644 --- a/lib/ExtUtils/MM.pm +++ b/lib/ExtUtils/MM.pm @@ -68,6 +68,7 @@ $Is{VOS} = $^O eq 'vos'; $Is{QNX} = $^O eq 'qnx'; $Is{AIX} = $^O eq 'aix'; $Is{Darwin} = $^O eq 'darwin'; +$Is{Haiku} = $^O eq 'haiku'; $Is{Unix} = !grep { $_ } values %Is; diff --git a/lib/Module/Build.pm b/lib/Module/Build.pm index e435c8a..b0430b6 100644 --- a/lib/Module/Build.pm +++ b/lib/Module/Build.pm @@ -30,6 +30,7 @@ my %OSTYPES = qw( dynixptx Unix freebsd Unix linux Unix + haiku Unix hpux Unix irix Unix darwin Unix diff --git a/perl.h b/perl.h index 39414e7..a3272bc 100644 --- a/perl.h +++ b/perl.h @@ -1539,15 +1539,15 @@ EXTERN_C char *crypt(const char *, const char *); # define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH) #endif -/* BeOS 5.0 seems to define S_IREAD and S_IWRITE in +/* BeOS 5.0 and Haiku R1 seem to define S_IREAD and S_IWRITE in * which would get included through , but that is 3000 * lines in the future. --jhi */ -#if !defined(S_IREAD) && !defined(__BEOS__) +#if !defined(S_IREAD) && !(defined(__BEOS__) || defined(__HAIKU__)) # define S_IREAD S_IRUSR #endif -#if !defined(S_IWRITE) && !defined(__BEOS__) +#if !defined(S_IWRITE) && !(defined(__BEOS__) || defined(__HAIKU__)) # define S_IWRITE S_IWUSR #endif @@ -2571,7 +2571,10 @@ typedef struct clone_params CLONE_PARAMS; # 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 @@ -5690,9 +5693,10 @@ int flock(int fd, int op); #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 diff --git a/pod/perlport.pod b/pod/perlport.pod index f8fb1fe..35635a0 100644 --- a/pod/perlport.pod +++ b/pod/perlport.pod @@ -815,6 +815,7 @@ are a few of the more popular Unix flavors: dgux dgux AViiON-dgux DYNIX/ptx dynixptx i386-dynixptx FreeBSD freebsd freebsd-i386 + Haiku haiku BePC-haiku Linux linux arm-linux Linux linux i386-linux Linux linux i586-linux diff --git a/t/io/fs.t b/t/io/fs.t index cd8bd55..8c45c8d 100755 --- a/t/io/fs.t +++ b/t/io/fs.t @@ -281,7 +281,7 @@ sub check_utime_result { is( $atime, 500000001, 'atime' ); is( $mtime, 500000000 + $delta, 'mtime' ); } - elsif ($^O eq 'beos') { + elsif ($^O eq 'beos' || $^O eq 'haiku') { SKIP: { skip "atime not updated", 1; }