[svn:parrot] r39790 - in branches/io_cleanups: include/parrot src/interp src/io
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Fri Jun 26 01:36:49 UTC 2009
Author: whiteknight
Date: Fri Jun 26 01:36:48 2009
New Revision: 39790
URL: https://trac.parrot.org/parrot/changeset/39790
Log:
[io_cleanups] move the functions from src/io/core.c into src/io/api.c, since they really were API functions. Separate Parrot_io_init into two separate functions because it was performing two completely separate actions at different times
Modified:
branches/io_cleanups/include/parrot/io.h
branches/io_cleanups/src/interp/inter_create.c
branches/io_cleanups/src/io/api.c
branches/io_cleanups/src/io/core.c
Modified: branches/io_cleanups/include/parrot/io.h
==============================================================================
--- branches/io_cleanups/include/parrot/io.h Fri Jun 26 01:19:42 2009 (r39789)
+++ branches/io_cleanups/include/parrot/io.h Fri Jun 26 01:36:48 2009 (r39790)
@@ -180,6 +180,10 @@
__attribute__nonnull__(4);
PARROT_EXPORT
+void Parrot_io_finish(PARROT_INTERP)
+ __attribute__nonnull__(1);
+
+PARROT_EXPORT
void Parrot_io_flush(PARROT_INTERP, ARGMOD(PMC *pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
@@ -205,6 +209,14 @@
FUNC_MODIFIES(*pmc);
PARROT_EXPORT
+void Parrot_io_init_handles(PARROT_INTERP)
+ __attribute__nonnull__(1);
+
+PARROT_EXPORT
+void Parrot_io_init_table(PARROT_INTERP)
+ __attribute__nonnull__(1);
+
+PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
INTVAL Parrot_io_is_closed(PARROT_INTERP, ARGMOD(PMC *pmc))
__attribute__nonnull__(1)
@@ -342,6 +354,11 @@
__attribute__nonnull__(3)
FUNC_MODIFIES(*pmc);
+PARROT_EXPORT
+void Parrot_IOData_mark(PARROT_INTERP, ARGIN(ParrotIOData *piodata))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
PARROT_WARN_UNUSED_RESULT
PIOOFF_T Parrot_io_make_offset32(INTVAL hi, INTVAL lo);
@@ -364,6 +381,8 @@
#define ASSERT_ARGS_Parrot_io_fdopen __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(sflags)
+#define ASSERT_ARGS_Parrot_io_finish __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_io_flush __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc)
@@ -374,6 +393,10 @@
#define ASSERT_ARGS_Parrot_io_getfd __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc)
+#define ASSERT_ARGS_Parrot_io_init_handles __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_io_init_table __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_io_is_closed __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc)
@@ -423,6 +446,9 @@
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc) \
|| PARROT_ASSERT_ARG(buffer)
+#define ASSERT_ARGS_Parrot_IOData_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(piodata)
#define ASSERT_ARGS_Parrot_io_make_offset32 __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
#define ASSERT_ARGS_Parrot_io_make_offset_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
@@ -618,7 +644,8 @@
__attribute__nonnull__(2);
PARROT_EXPORT
-PIOHANDLE Parrot_io_get_os_handle(SHIM_INTERP, ARGIN(PMC *filehandle))
+PIOHANDLE Parrot_io_get_os_handle(PARROT_INTERP, ARGIN(PMC *filehandle))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_EXPORT
@@ -656,9 +683,10 @@
__attribute__nonnull__(2);
PARROT_EXPORT
-void Parrot_io_set_os_handle(SHIM_INTERP,
+void Parrot_io_set_os_handle(PARROT_INTERP,
ARGIN(PMC *filehandle),
PIOHANDLE file_descriptor)
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_CAN_RETURN_NULL
@@ -666,7 +694,8 @@
__attribute__nonnull__(2);
PARROT_CAN_RETURN_NULL
-INTVAL Parrot_io_get_buffer_flags(SHIM_INTERP, ARGIN(PMC *filehandle))
+INTVAL Parrot_io_get_buffer_flags(PARROT_INTERP, ARGIN(PMC *filehandle))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_CAN_RETURN_NULL
@@ -687,9 +716,10 @@
ARGIN_NULLOK(unsigned char *new_end))
__attribute__nonnull__(2);
-void Parrot_io_set_buffer_flags(SHIM_INTERP,
+void Parrot_io_set_buffer_flags(PARROT_INTERP,
ARGIN(PMC *filehandle),
INTVAL new_flags)
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
void Parrot_io_set_buffer_next(SHIM_INTERP,
@@ -727,7 +757,8 @@
__attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_get_os_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(filehandle)
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_is_closed_filehandle \
__attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
@@ -744,11 +775,13 @@
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_set_os_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(filehandle)
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_clear_buffer __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_get_buffer_flags __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(filehandle)
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_get_buffer_size __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_make_string __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -757,7 +790,8 @@
#define ASSERT_ARGS_Parrot_io_set_buffer_end __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_set_buffer_flags __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(filehandle)
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_set_buffer_next __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_set_buffer_size __attribute__unused__ int _ASSERT_ARGS_CHECK = \
Modified: branches/io_cleanups/src/interp/inter_create.c
==============================================================================
--- branches/io_cleanups/src/interp/inter_create.c Fri Jun 26 01:19:42 2009 (r39789)
+++ branches/io_cleanups/src/interp/inter_create.c Fri Jun 26 01:36:48 2009 (r39790)
@@ -157,7 +157,7 @@
/* PANIC will fail until this is done */
interp->piodata = NULL;
- Parrot_io_init(interp);
+ Parrot_io_init_table(interp);
if (is_env_var_set("PARROT_GC_DEBUG")) {
#if ! DISABLE_GC_DEBUG
@@ -243,7 +243,7 @@
setup_default_compreg(interp);
/* setup stdio PMCs */
- Parrot_io_init(interp);
+ Parrot_io_init_handles(interp);
/* init IMCC compiler */
imcc_init(interp);
Modified: branches/io_cleanups/src/io/api.c
==============================================================================
--- branches/io_cleanups/src/io/api.c Fri Jun 26 01:19:42 2009 (r39789)
+++ branches/io_cleanups/src/io/api.c Fri Jun 26 01:36:48 2009 (r39790)
@@ -38,6 +38,8 @@
/* HEADERIZER HFILE: include/parrot/io.h */
+PIOOFF_T piooffsetzero;
+
/*
=head2 Generic I/O interface
@@ -72,6 +74,122 @@
return result;
}
+
+/*
+
+=item C<void Parrot_io_init_handles(PARROT_INTERP)>
+
+Sets up the interpreter's I/O storage and creates the C<STD*> handles.
+
+Called when creating an interpreter.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_io_init_handles(PARROT_INTERP)
+{
+ ASSERT_ARGS(Parrot_io_init_handles)
+ /* Has interp been initialized already? */
+ if (interp->piodata) {
+ /* memsub system is up and running: */
+ /* Init IO stacks and handles for interp instance. */
+ PIO_INIT(interp);
+
+ if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG))
+ Parrot_io_eprintf(NULL, "I/O system initialized.\n");
+ }
+ else
+ /* This should never happen, but still good to check */
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
+ "PIO alloc piodata failure.");
+}
+
+/*
+
+=item C<void Parrot_io_init_table(PARROT_INTERP)>
+
+Sets up the Parrot IO table to hold the standard handles
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_io_init_table(PARROT_INTERP)
+{
+ ASSERT_ARGS(Parrot_io_init_table)
+ interp->piodata = mem_allocate_typed(ParrotIOData);
+ if (interp->piodata == NULL)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
+ "PIO alloc piodata failure.");
+ interp->piodata->table =
+ (PMC **)mem_sys_allocate_zeroed(PIO_NR_OPEN * sizeof (PMC *));
+
+ if (!interp->piodata->table)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
+ "PIO alloc table failure.");
+}
+
+/*
+
+=item C<void Parrot_io_finish(PARROT_INTERP)>
+
+Closes the interpreter's IO resourses. Called during its interpreter
+destruction.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_io_finish(PARROT_INTERP)
+{
+ ASSERT_ARGS(Parrot_io_finish)
+ /*
+ * TODO free IO of std-handles
+ */
+ mem_sys_free(interp->piodata->table);
+ interp->piodata->table = NULL;
+ mem_sys_free(interp->piodata);
+ interp->piodata = NULL;
+
+}
+
+
+/*
+
+=item C<void Parrot_IOData_mark(PARROT_INTERP, ParrotIOData *piodata)>
+
+Called from C<Parrot_gc_trace_root()> to mark the IO data live.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_IOData_mark(PARROT_INTERP, ARGIN(ParrotIOData *piodata))
+{
+ ASSERT_ARGS(Parrot_IOData_mark)
+ INTVAL i;
+ ParrotIOTable table = piodata->table;
+
+ /* this was i < PIO_NR_OPEN, but only standard handles 0..2 need
+ * to be kept alive AFAIK -leo
+ */
+ for (i = 0; i < 3; i++) {
+ if (table[i]) {
+ Parrot_gc_mark_PObj_alive(interp, (PObj *)table[i]);
+ }
+ }
+}
+
+
/*
=item C<PMC * Parrot_io_new_pmc(PARROT_INTERP, INTVAL flags)>
Modified: branches/io_cleanups/src/io/core.c
==============================================================================
--- branches/io_cleanups/src/io/core.c Fri Jun 26 01:19:42 2009 (r39789)
+++ branches/io_cleanups/src/io/core.c Fri Jun 26 01:36:48 2009 (r39790)
@@ -19,119 +19,6 @@
*/
-#include "parrot/parrot.h"
-#include "io_private.h"
-
-/* HEADERIZER HFILE: include/parrot/io.h */
-
-/*
- The standard streams are:
-
- interp->piodata->table[PIO_STD*_FILENO].
-*/
-
-PIOOFF_T piooffsetzero;
-
-/*
-
-=item C<void Parrot_io_init(PARROT_INTERP)>
-
-Sets up the interpreter's I/O storage and creates the C<STD*> handles.
-
-Called when creating an interpreter.
-
-=cut
-
-*/
-
-PARROT_EXPORT
-void
-Parrot_io_init(PARROT_INTERP)
-{
- ASSERT_ARGS(Parrot_io_init)
- /* Has interp been initialized already? */
- if (interp->piodata) {
- /* memsub system is up and running: */
- /* Init IO stacks and handles for interp instance. */
- PIO_INIT(interp);
-
-
- if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
- Parrot_io_eprintf(NULL, "I/O system initialized.\n");
- }
-
- return;
- }
-
-
- interp->piodata = mem_allocate_typed(ParrotIOData);
- if (interp->piodata == NULL)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
- "PIO alloc piodata failure.");
- interp->piodata->table =
- (PMC **)mem_sys_allocate_zeroed(PIO_NR_OPEN * sizeof (PMC *));
-
- if (!interp->piodata->table)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
- "PIO alloc table failure.");
-}
-
-/*
-
-=item C<void Parrot_io_finish(PARROT_INTERP)>
-
-Closes the interpreter's IO resourses. Called during its interpreter
-destruction.
-
-=cut
-
-*/
-
-PARROT_EXPORT
-void
-Parrot_io_finish(PARROT_INTERP)
-{
- ASSERT_ARGS(Parrot_io_finish)
- /*
- * TODO free IO of std-handles
- */
- mem_sys_free(interp->piodata->table);
- interp->piodata->table = NULL;
- mem_sys_free(interp->piodata);
- interp->piodata = NULL;
-
-}
-
-
-/*
-
-=item C<void Parrot_IOData_mark(PARROT_INTERP, ParrotIOData *piodata)>
-
-Called from C<Parrot_gc_trace_root()> to mark the IO data live.
-
-=cut
-
-*/
-
-PARROT_EXPORT
-void
-Parrot_IOData_mark(PARROT_INTERP, ARGIN(ParrotIOData *piodata))
-{
- ASSERT_ARGS(Parrot_IOData_mark)
- INTVAL i;
- ParrotIOTable table = piodata->table;
-
- /* this was i < PIO_NR_OPEN, but only standard handles 0..2 need
- * to be kept alive AFAIK -leo
- */
- for (i = 0; i < 3; i++) {
- if (table[i]) {
- Parrot_gc_mark_PObj_alive(interp, (PObj *)table[i]);
- }
- }
-}
-
-
/*
=back
More information about the parrot-commits
mailing list