[svn:parrot] r39267 - in branches/io_rewiring: include/parrot src/io

Infinoid at svn.parrot.org Infinoid at svn.parrot.org
Sat May 30 12:59:17 UTC 2009


Author: Infinoid
Date: Sat May 30 12:59:17 2009
New Revision: 39267
URL: https://trac.parrot.org/parrot/changeset/39267

Log:
[io] Implement Parrot_io_close_piohandle() and PIO_PIPE() on win32, too.

Modified:
   branches/io_rewiring/include/parrot/io_win32.h
   branches/io_rewiring/src/io/win32.c

Modified: branches/io_rewiring/include/parrot/io_win32.h
==============================================================================
--- branches/io_rewiring/include/parrot/io_win32.h	Sat May 30 12:59:13 2009	(r39266)
+++ branches/io_rewiring/include/parrot/io_win32.h	Sat May 30 12:59:17 2009	(r39267)
@@ -21,6 +21,9 @@
 /* HEADERIZER BEGIN: src/io/win32.c */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
+INTVAL Parrot_io_close_piohandle_win32(PARROT_INTERP, PIOHANDLE handle)
+        __attribute__nonnull__(1);
+
 INTVAL Parrot_io_close_win32(PARROT_INTERP, ARGMOD(PMC *filehandle))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -74,6 +77,16 @@
     SHIM(STRING **buf))
         __attribute__nonnull__(1);
 
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+INTVAL Parrot_io_pipe_win32(SHIM_INTERP,
+    ARGMOD(PIOHANDLE *reader),
+    ARGMOD(PIOHANDLE *writer))
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*reader)
+        FUNC_MODIFIES(*writer);
+
 size_t Parrot_io_read_win32(PARROT_INTERP,
     ARGMOD(PMC *filehandle),
     ARGOUT(STRING **buf))
@@ -102,6 +115,9 @@
         __attribute__nonnull__(2)
         __attribute__nonnull__(3);
 
+#define ASSERT_ARGS_Parrot_io_close_piohandle_win32 \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_Parrot_io_close_win32 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(filehandle)
@@ -126,6 +142,9 @@
     || PARROT_ASSERT_ARG(path)
 #define ASSERT_ARGS_Parrot_io_peek_win32 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_io_pipe_win32 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(reader) \
+    || PARROT_ASSERT_ARG(writer)
 #define ASSERT_ARGS_Parrot_io_read_win32 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(filehandle) \

Modified: branches/io_rewiring/src/io/win32.c
==============================================================================
--- branches/io_rewiring/src/io/win32.c	Sat May 30 12:59:13 2009	(r39266)
+++ branches/io_rewiring/src/io/win32.c	Sat May 30 12:59:17 2009	(r39267)
@@ -295,6 +295,28 @@
 
 /*
 
+=item C<INTVAL Parrot_io_close_piohandle_win32(PARROT_INTERP, PIOHANDLE handle)>
+
+Calls C<CloseHandle()> to close the given file descriptor.  Returns 0 on
+success, -1 on error.
+
+=cut
+
+*/
+
+INTVAL
+Parrot_io_close_piohandle_win32(PARROT_INTERP, PIOHANDLE handle)
+{
+    ASSERT_ARGS(Parrot_io_close_piohandle_win32)
+
+    if (handle == INVALID_HANDLE_VALUE)
+        return -1;
+
+    return CloseHandle(handle) ? 0 : -1;
+}
+
+/*
+
 =item C<INTVAL Parrot_io_close_win32(PARROT_INTERP, PMC *filehandle)>
 
 Calls C<CloseHandle()> to close C<*io>'s file descriptor.
@@ -704,6 +726,27 @@
         "pipe open error");
 }
 
+/*
+
+=item C<INTVAL Parrot_io_pipe_win32(PARROT_INTERP, PIOHANDLE *reader, PIOHANDLE
+*writer)>
+
+Uses CreatePipe() to create a matched pair of pipe handles.  Returns 0 on
+success, -1 on failure.
+
+=cut
+
+*/
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+INTVAL
+Parrot_io_pipe_win32(SHIM_INTERP, ARGMOD(PIOHANDLE *reader), ARGMOD(PIOHANDLE *writer))
+{
+    ASSERT_ARGS(Parrot_io_pipe_win32)
+    return CreatePipe(reader, writer, NULL, 0) ? 0 : -1;
+}
+
 #endif /* PIO_OS_WIN32 */
 
 /*


More information about the parrot-commits mailing list