From a7e540a5e3c80df46a8a59a5484045c107169c71 Mon Sep 17 00:00:00 2001
From: Ian Douglas Scott <ian@iandouglasscott.com>
Date: Thu, 17 Aug 2017 19:36:34 -0700
Subject: [PATCH] perl: build POSIX

---
 recipes/perl/perl.patch | 110 ++++++++++++++++++++++++++++++++++++++++
 recipes/perl/recipe.sh  |   2 +-
 2 files changed, 111 insertions(+), 1 deletion(-)

diff --git a/recipes/perl/perl.patch b/recipes/perl/perl.patch
index 81b33b295..f3067191f 100644
--- a/recipes/perl/perl.patch
+++ b/recipes/perl/perl.patch
@@ -1,3 +1,113 @@
+diff -ru source/ext/POSIX/POSIX.xs source-new/ext/POSIX/POSIX.xs
+--- source/ext/POSIX/POSIX.xs	2017-06-30 14:03:22.000000000 -0700
++++ source-new/ext/POSIX/POSIX.xs	2017-08-17 19:21:59.498359355 -0700
+@@ -1302,6 +1302,7 @@
+ #endif
+ #include <fcntl.h>
+ 
++#if 0
+ #ifdef HAS_TZNAME
+ #  if !defined(WIN32) && !defined(__CYGWIN__) && !defined(NETWARE) && !defined(__UWIN__)
+ extern char *tzname[];
+@@ -1311,6 +1312,7 @@
+ char *tzname[] = { "" , "" };
+ #endif
+ #endif
++#endif
+ 
+ #if defined(__VMS) && !defined(__POSIX_SOURCE)
+ 
+@@ -1327,10 +1329,11 @@
+ #if defined (__CYGWIN__)
+ #    define tzname _tzname
+ #endif
+-#if defined (WIN32) || defined (NETWARE)
++#if 1
+ #  undef mkfifo
+ #  define mkfifo(a,b) not_here("mkfifo")
+ #  define ttyname(a) (char*)not_here("ttyname")
++#  define pause() not_here("pause")
+ #  define sigset_t long
+ #  define pid_t long
+ #  ifdef _MSC_VER
+@@ -1397,7 +1400,7 @@
+ typedef HV* POSIX__SigAction;
+ typedef int POSIX__SigNo;
+ typedef int POSIX__Fd;
+-#ifdef I_TERMIOS
++#if 0
+ typedef struct termios* POSIX__Termios;
+ #else /* Define termios types to int, and call not_here for the functions.*/
+ #define POSIX__Termios int
+@@ -1829,7 +1832,7 @@
+     const char *	packname
+     CODE:
+ 	{
+-#ifdef I_TERMIOS
++#if 0
+ 	    void *const p = allocate_struct(aTHX_ (ST(0) = sv_newmortal()),
+ 					    sizeof(struct termios), packname);
+ 	    /* The previous implementation stored a pointer to an uninitialised
+@@ -1896,7 +1899,7 @@
+ 	getcflag = 2
+ 	getlflag = 3
+     CODE:
+-#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
++#if 0 /* References a termios structure member so ifdef it out. */
+ 	switch(ix) {
+ 	case 0:
+ 	    RETVAL = termios_ref->c_iflag;
+@@ -1925,7 +1928,7 @@
+ 	POSIX::Termios	termios_ref
+ 	unsigned int	ccix
+     CODE:
+-#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
++#if 0 /* References a termios structure member so ifdef it out. */
+ 	if (ccix >= NCCS)
+ 	    croak("Bad getcc subscript");
+ 	RETVAL = termios_ref->c_cc[ccix];
+@@ -1957,7 +1960,7 @@
+ 	setcflag = 2
+ 	setlflag = 3
+     CODE:
+-#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
++#if 0 /* References a termios structure member so ifdef it out. */
+ 	switch(ix) {
+ 	case 0:
+ 	    termios_ref->c_iflag = flag;
+@@ -1982,7 +1985,7 @@
+ 	unsigned int	ccix
+ 	cc_t		cc
+     CODE:
+-#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
++#if 0 /* References a termios structure member so ifdef it out. */
+ 	if (ccix >= NCCS)
+ 	    croak("Bad setcc subscript");
+ 	termios_ref->c_cc[ccix] = cc;
+@@ -3540,15 +3543,15 @@
+ void
+ times()
+ 	PPCODE:
+-	struct tms tms;
+-	clock_t realtime;
+-	realtime = times( &tms );
++	//struct tms tms;
++	//clock_t realtime;
++	//realtime = times( &tms );
+ 	EXTEND(SP,5);
+-	PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
+-	PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
+-	PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
+-	PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
+-	PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
++	PUSHs( sv_2mortal( newSViv( (IV) 0 ) ) );
++	PUSHs( sv_2mortal( newSViv( (IV) 0 ) ) );
++	PUSHs( sv_2mortal( newSViv( (IV) 0 ) ) );
++	PUSHs( sv_2mortal( newSViv( (IV) 0 ) ) );
++	PUSHs( sv_2mortal( newSViv( (IV) 0 ) ) );
+ 
+ double
+ difftime(time1, time2)
 diff -ru source/mg.c source-new/mg.c
 --- source/mg.c	2017-06-30 14:03:22.000000000 -0700
 +++ source-new/mg.c	2017-08-17 14:40:37.669507085 -0700
diff --git a/recipes/perl/recipe.sh b/recipes/perl/recipe.sh
index 8403b17c4..465684369 100644
--- a/recipes/perl/recipe.sh
+++ b/recipes/perl/recipe.sh
@@ -18,7 +18,7 @@ function recipe_build {
     tar --strip-components=1 -xvf perl-cross-1.1.6.tar.gz
     wget -O cnf/config.sub http://git.savannah.gnu.org/cgit/config.git/plain/config.sub
     sysroot="$($HOST-gcc -print-sysroot)"
-    ./configure --target=${HOST} --prefix='/' --sysroot="$sysroot" --disable-mod=Sys-Syslog,POSIX,Time-HiRes --with-libs='m'
+    ./configure --target=${HOST} --prefix='/' --sysroot="$sysroot" --disable-mod=Sys-Syslog,Time-HiRes --with-libs='m'
     sed -i "s/^#define Netdb_name_t.*/#define Netdb_name_t const char*/" config.h # XXX
     sed -i 's/#define Strerror(e).*$/#define Strerror(e) strerror(e)/' config.h #
     echo "#define HAS_VPRINTF" >> config.h
-- 
GitLab