Permalink
Browse files

[src] Various Cygwin tweaks:

* jit.pm, exec.h: enabled EXEC_CAPABLE with EXEC_COFF on cygwin
* added config/auto/jit/test_exec_cygwin.in

* dynext get_path(): replace leading "lib" with "cyg".

* dynext pirs: added special cygwin dll name tweaks for SDL, ncurses, Pg
(no optional versioning yet)

* fixed and enabled tests for t/native_pbc/header.t, t/src/compiler.t,
t/stm/basic_mt.t, t/stm/llqueue.t

* added a README_cygwin.pod

(Reini Urban, RT #51328).

git-svn-id: https://svn.parrot.org/parrot/trunk@26398 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 875e237 commit f52e604217c4a5fdedf13863d940cb2a60ef981f @chromatic chromatic committed Mar 15, 2008
View
@@ -24,6 +24,7 @@ NEWS [devel]doc
PBC_COMPAT [devel]doc
PLATFORMS [devel]doc
README [devel]doc
+README_cygwin.pod []
README_win32.pod []
RESPONSIBLE_PARTIES [main]doc
TODO [main]doc
@@ -260,6 +261,7 @@ config/auto/isreg.pm []
config/auto/isreg/test_c.in []
config/auto/jit.pm []
config/auto/jit/test_c.in []
+config/auto/jit/test_exec_cygwin.in []
config/auto/jit/test_exec_linux.in []
config/auto/jit/test_exec_openbsd.in []
config/auto/m4.pm []
View
@@ -0,0 +1,78 @@
+This file is best viewed with "perldoc README.cygwin".
+
+=head1 NAME
+
+README.cygwin - Parrot under cygwin
+
+=head1 SYNOPSIS
+
+parrot builds out of the box under cygwin.
+Some tweaks are needed for different names of dynamic loading of some dll's.
+
+=head1 ICU
+
+This is no official cygwin package yet.
+However, icu4c-3_8 builds out of the box on cygwin.
+ http://download.icu-project.org/files/icu4c/3.8/icu4c-3_8-src.tgz
+
+Note that ICU is now optional, you can build Parrot without it,
+by not installing it or asking Parrot to ignore it (C<--without-icu>).
+
+=head1 INSTALL
+
+ perl Configure.pl
+ make
+ make test
+ make reallyinstall
+
+=head1 TODO
+
+=over
+
+=item Makefile tuning
+
+rename libparrot.dll to cygparrot.dll, create an interim libparrot.dll.a
+
+for make test:
+blib/lib must be added to the PATH, or link blib/lib/libparrot.dll to the parrot root.
+ ln blib/lib/libparrot.dll libparrot.dll
+
+=item DLL versioning
+
+cyg*-1.1.dll instead of lib*.so.1.1
+
+Thanks to the L<Windows DLL Hell / http://> and the impossibility of file
+hardlinks, windows dll names are versioned, so the loadlib function or the various
+pir's needs more logic.
+
+Either add the version to each loadlib call, and stem the version from
+POSIX versions within get_path(), or add an optional version argument to
+loadlib for win32. Or just fix all the pir's.
+
+=item Configure
+
+nmake detection probably wrong. replace by make.
+
+=item Features
+
+Threads, Events, and Signals are missing.
+
+=back
+
+=head1 AUTHORS
+
+=over
+
+=item Reini Urban E<lt>rurban@cpan.orgE<gt>
+
+=back
+
+=head1 SEE ALSO
+
+ L<parrot>
+
+=head1 HISTORY
+
+Last updated: 2 March 2008
+
+=cut
View
@@ -123,6 +123,7 @@ sub runstep {
|| ( $osname eq 'netbsd' )
|| ( $osname eq 'linux' )
|| ( $osname eq 'darwin' )
+ || ( $osname eq 'cygwin' )
|| ( $osname eq 'MSWin32' ) )
{
$execcapable = 0;
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <limits.h>
+#include <errno.h>
+#include <malloc.h>
+#include <unistd.h>
+#ifndef PAGE_SIZE
+# define PAGE_SIZE getpagesize()
+#endif
+#
+/* test for exec privs */
+
+/*
+ * c equiv:
+ int t() {
+ return 1;
+}
+*/
+
+char code[] = {
+ 0xB8,0x01,0,0,0, /* movl $1, %eax */
+ 0xC3 /* ret */
+};
+
+typedef int (*pf)(void);
+
+int main(int argc, char *argv[])
+{
+ pf t;
+ char *p;
+ int rc;
+ int prot = PROT_READ;
+
+ if (argc != 2) {
+ fprintf(stderr, "usage: test 0 | 1\n");
+ exit(1);
+ }
+
+ if (atoi(argv[1]))
+ prot |= PROT_EXEC;
+
+ p = memalign(PAGE_SIZE, sizeof(code));
+ memcpy(p, code, sizeof(code));
+
+ t = (pf) p;
+ rc = mprotect(p, PAGE_SIZE, prot);
+
+ if (rc) {
+ fprintf(stderr, "p = %p PAGE_SIZE = %d (0x%x)\n", p,
+ PAGE_SIZE, PAGE_SIZE);
+ perror("failure");
+ }
+
+ if (t() == 1)
+ puts("ok");
+
+ else
+ return 1;
+
+ return 0;
+}
View
@@ -33,7 +33,7 @@
# if defined(PARROT_EXEC_OS_FREEBSD) || defined(PARROT_EXEC_OS_NETBSD) || defined(PARROT_EXEC_OS_LINUX)
# define EXEC_ELF
# endif
-# ifdef PARROT_EXEC_OS_MSWIN32
+# if defined(PARROT_EXEC_OS_MSWIN32) || defined(PARROT_EXEC_OS_CYGWIN)
# define EXEC_COFF
# endif
@@ -100,6 +100,11 @@ In fact, don't count on it sticking around. It may not. Then again, it might.
$I0 = typeof libsdl
if $I0 != .Undef goto OK_HINT2
+ # cygwin
+ loadlib libsdl, 'cygSDL-1-2-0'
+ $I0 = typeof libsdl
+ if $I0 != .Undef goto OK
+
# failed to load libSDL
$P0 = new 'Exception'
$P0["_message"] = "libSDL not found!"
@@ -186,6 +191,10 @@ SDL::Image library anyway, which calls this for you.
$I0 = typeof image_lib
if $I0 != .Undef goto OK_HINT2
+ loadlib image_lib, 'cygSDL_image-1-2-0'
+ $I0 = typeof image_lib
+ if $I0 != .Undef goto OK
+
# failed to load libSDL
$P0 = new 'Exception'
$P0["_message"] = "libSDL_image not found!"
@@ -214,6 +223,8 @@ SDL::Font library anyway, which calls this for you.
.sub _init_ttf
.local pmc ttf_lib
loadlib ttf_lib, 'libSDL_ttf'
+ if ttf_lib goto initialize
+ loadlib ttf_lib, 'cygSDL_ttf-2-0-0'
unless ttf_lib goto error
initialize:
@@ -3,6 +3,8 @@
loadlib $P1, 'libpq'
if $P1 goto has_lib
+loadlib $P1, 'pq'
+if $P1 goto has_lib
$P2 = new 'Exception'
$P2[0] = 'error loading libpg - loadlib failed'
throw $P2
View
@@ -268,6 +268,22 @@ get_path(PARROT_INTERP, ARGMOD(STRING *lib), ARGOUT(void **handle),
}
}
#endif
+
+ /* And on cygwin replace a leading "lib" by "cyg". */
+#ifdef __CYGWIN__
+ if (!STRING_IS_EMPTY(lib) && memcmp(lib->strstart, "lib", 3) == 0) {
+ strcpy(path->strstart, lib->strstart);
+
+ path->strstart[0] = 'c';
+ path->strstart[1] = 'y';
+ path->strstart[2] = 'g';
+
+ *handle = Parrot_dlopen(path->strstart);
+
+ if (*handle)
+ return path;
+ }
+#endif
err = Parrot_dlerror();
Parrot_warn(interp, PARROT_WARNINGS_DYNEXT_FLAG,
"Couldn't load '%Ss': %s\n",
View
@@ -35,7 +35,10 @@ table, which should be created by your sysadmin.
# TODO: fix when exception handling works again
loadlib $P0, 'libpq'
+ if $P0 goto have_lib
+ loadlib $P0, 'pq'
unless $P0 goto no_pg
+ have_lib:
load_bytecode 'postgres.pir'
pop_eh
test.'ok'(1, 'load_bytecode')
View
@@ -50,14 +50,14 @@ my @fields = qw(
my %h;
@h{@fields} = unpack "a8CCCCCCa10a8", $pbc;
-is( $h{magic}, "\xfe\x50\x42\x43\x0d\x0a\x1a\x0a", "magic string" );
+is( $h{magic}, "\xfe\x50\x42\x43\x0a\x1a\x0a\cD", "magic string" );
ok( $h{wordsize} < 2, "wordsize" );
ok( $h{byteorder} < 2, "byteorder" );
is( $h{major}, $PConfig{MAJOR}, "major version" );
is( $h{minor}, $PConfig{MINOR}, "minor version" );
-ok( $h{intval} == 4 || $h{intval} == 8, "intval" );
-ok( $h{floattype} < 2, "floattype" );
-is( $h{padding}, pack "x8", "NULL padding" );
+ok( $h{intval} == 3 || $h{intval} == 4 || $h{intval} == 8, "intval" );
+ok( $h{floattype} < 4, "floattype" );
+is( $h{padding}, pack("x7")."\cA", "NULL padding" );
# Local Variables:
# mode: cperl
View
@@ -8,8 +8,8 @@ use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Test;
-plan $^O =~ m/MSWin32|cygwin/
- ? ( skip_all => 'broken on win32 && cygwin' )
+plan $^O =~ m/MSWin32/
+ ? ( skip_all => 'broken on win32' )
: ( tests => 6 );
=head1 NAME

0 comments on commit f52e604

Please sign in to comment.