Skip to content

Instantly share code, notes, and snippets.

@tcpiptan
Created May 25, 2010 09:43
Show Gist options
  • Save tcpiptan/412961 to your computer and use it in GitHub Desktop.
Save tcpiptan/412961 to your computer and use it in GitHub Desktop.
From 37c0cc0d511535fa92ba5c674f92f5298e0d2a8e Mon Sep 17 00:00:00 2001
From: tcpiptan <tcpipdoom@gmail.com>
Date: Tue, 25 May 2010 18:35:37 +0900
Subject: [PATCH 1/2] ppport.patch
---
xs/Console.xs | 1 +
xs/File.xs | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/xs/Console.xs b/xs/Console.xs
index 248ac34..f6bcdc4 100644
--- a/xs/Console.xs
+++ b/xs/Console.xs
@@ -3,6 +3,7 @@
#include "perl.h"
#include "XSUB.h"
+#define NEED_sv_2pv_flags_GLOBAL
#include "ppport.h"
#include <windows.h>
diff --git a/xs/File.xs b/xs/File.xs
index b2ffbf3..642d292 100644
--- a/xs/File.xs
+++ b/xs/File.xs
@@ -3,6 +3,7 @@
#include "perl.h"
#include "XSUB.h"
+#define NEED_newRV_noinc_GLOBAL
#include "ppport.h"
#include <windows.h>
--
1.7.1
From 3f234e41bd3f79812256e374b67fd2654ae184f2 Mon Sep 17 00:00:00 2001
From: tcpiptan <tcpipdoom@gmail.com>
Date: Tue, 25 May 2010 18:40:16 +0900
Subject: [PATCH 2/2] fix to make for ActivePerl + nmake
---
xs/File.xs | 8 ++++----
xs/Native.xs | 4 ++--
xs/Process.xs | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/xs/File.xs b/xs/File.xs
index 642d292..d385585 100644
--- a/xs/File.xs
+++ b/xs/File.xs
@@ -28,13 +28,13 @@ SV*
get_file_size(long handle)
CODE:
LARGE_INTEGER st;
+ SV* sv = newSV(0);
+ HV* hv = newHV();
if (GetFileSizeEx(handle, &st) == 0) {
XSRETURN_EMPTY;
}
- SV* sv = newSV(0);
- HV* hv = newHV();
sv_setsv(sv, sv_2mortal(newRV_noinc((SV*)hv)));
hv_store(hv, "high", strlen("high"), newSVnv(st.HighPart), 0);
hv_store(hv, "low", strlen("low"), newSVnv(st.LowPart), 0);
@@ -70,6 +70,8 @@ set_file_pointer(long handle, long lpos, long hpos, int whence)
CODE:
LARGE_INTEGER mv;
LARGE_INTEGER st;
+ SV* sv = newSV(0);
+ HV* hv = newHV();
mv.LowPart = lpos;
mv.HighPart = hpos;
@@ -78,8 +80,6 @@ set_file_pointer(long handle, long lpos, long hpos, int whence)
XSRETURN_EMPTY;
}
- SV* sv = newSV(0);
- HV* hv = newHV();
sv_setsv(sv, sv_2mortal(newRV_noinc((SV*)hv)));
hv_store(hv, "high", strlen("high"), newSVnv(st.HighPart), 0);
hv_store(hv, "low", strlen("low"), newSVnv(st.LowPart), 0);
diff --git a/xs/Native.xs b/xs/Native.xs
index f1eca00..66ec0fc 100644
--- a/xs/Native.xs
+++ b/xs/Native.xs
@@ -17,11 +17,11 @@ parse_argv()
CODE:
int argc;
int i;
+ SV* sv = newSV(0);
+ AV* av = newAV();
LPWSTR* args = CommandLineToArgvW(GetCommandLineW(), &argc);
- SV* sv = newSV(0);
- AV* av = newAV();
sv_setsv(sv, sv_2mortal(newRV_noinc((SV*)av)));
for (i = 0; i < argc; i++) {
av_push(av, newSVpv(args[i], wcslen(args[i]) * 2));
diff --git a/xs/Process.xs b/xs/Process.xs
index d85e081..55be5bd 100644
--- a/xs/Process.xs
+++ b/xs/Process.xs
@@ -33,6 +33,8 @@ create_process(SV* shell, SV* cmd)
WCHAR* ccmd = SvPV(cmd, len);
STARTUPINFOW si;
PROCESS_INFORMATION pi;
+ SV* sv = newSV(0);
+ HV* hv = newHV();
ZeroMemory(&si,sizeof(si));
si.cb=sizeof(si);
@@ -52,8 +54,6 @@ create_process(SV* shell, SV* cmd)
XSRETURN_EMPTY;
}
- SV* sv = newSV(0);
- HV* hv = newHV();
sv_setsv(sv, sv_2mortal(newRV_noinc((SV*)hv)));
hv_store(hv, "thread_handle", strlen("thread_handle"), newSViv(pi.hThread), 0);
hv_store(hv, "process_handle", strlen("process_handle"), newSViv(pi.hProcess), 0);
--
1.7.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment