Author: petdance
Date: Fri Jun 15 07:59:57 2007
New Revision: 19021
Modified:
trunk/config/gen/makefiles/root.in
trunk/include/parrot/events.h
trunk/src/embed.c
trunk/src/events.c
trunk/src/inter_cb.c
trunk/src/inter_create.c
trunk/src/interpreter.c
Log:
headerized events.c and embed.c, except that embed.h will take some magic to
make work right, so it is not actually getting headerized
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in (original)
+++ trunk/config/gen/makefiles/root.in Fri Jun 15 07:59:57 2007
@@ -1838,6 +1838,7 @@
src/debug.o \
src/dynext.o \
src/encoding.o \
+ src/events.o \
src/exceptions.o \
src/exit.o \
src/fingerprint.o \
Modified: trunk/include/parrot/events.h
==============================================================================
--- trunk/include/parrot/events.h (original)
+++ trunk/include/parrot/events.h Fri Jun 15 07:59:57 2007
@@ -1,5 +1,5 @@
/* events.h
- * Copyright (C) 2001-2003, The Perl Foundation.
+ * Copyright (C) 2001-2007, The Perl Foundation.
* SVN Info
* $Id$
* Overview:
@@ -74,32 +74,60 @@
} parrot_event;
struct QUEUE_ENTRY;
-PARROT_API void Parrot_schedule_event(Parrot_Interp, parrot_event*);
-PARROT_API void Parrot_schedule_interp_event(Parrot_Interp, parrot_event*);
-PARROT_API void Parrot_schedule_interp_qentry(Parrot_Interp, struct
QUEUE_ENTRY* entry);
#define CHECK_EVENTS(i, n) (opcode_t *)Parrot_do_check_events(i, n)
#define HANDLE_EVENTS(i, n) (opcode_t *)Parrot_do_handle_events(i, 1, n)
-PARROT_API void Parrot_init_signals(void);
-PARROT_API void Parrot_init_events(Parrot_Interp);
-PARROT_API opcode_t * Parrot_do_check_events(Parrot_Interp, opcode_t *);
-PARROT_API opcode_t * Parrot_do_handle_events(Parrot_Interp, int, opcode_t *);
-
-PARROT_API void Parrot_new_timer_event(Parrot_Interp, PMC*, FLOATVAL,
- FLOATVAL, int, PMC*, parrot_event_type_enum);
-PARROT_API void Parrot_del_timer_event(Parrot_Interp, PMC* timer);
-PARROT_API void Parrot_new_terminate_event(Parrot_Interp);
-PARROT_API void Parrot_new_suspend_for_gc_event(Parrot_Interp);
-PARROT_API void disable_event_checking(Parrot_Interp);
-PARROT_API void enable_event_checking(Parrot_Interp);
-
-PARROT_API void Parrot_new_cb_event(Parrot_Interp, PMC* cbi, char *ext);
-PARROT_API void Parrot_run_callback(Parrot_Interp, PMC* cbi, char *ext);
-
-PARROT_API void Parrot_kill_event_loop(void);
-PARROT_API opcode_t * Parrot_sleep_on_event(Parrot_Interp, FLOATVAL t,
- opcode_t *next);
+/* HEADERIZER BEGIN: src/events.c */
+
+PARROT_API void Parrot_del_timer_event( Interp *interp, PMC *timer );
+PARROT_API opcode_t * Parrot_do_check_events( Interp *interp, opcode_t *next );
+PARROT_API opcode_t * Parrot_do_handle_events( Interp *interp /*NN*/,
+ int restore,
+ opcode_t *next )
+ __attribute__nonnull__(1);
+
+PARROT_API void Parrot_event_add_io_event( Interp *interp,
+ PMC *pio,
+ PMC *sub,
+ PMC *data,
+ INTVAL which );
+
+PARROT_API void Parrot_init_events( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1);
+
+PARROT_API void Parrot_init_signals( void );
+PARROT_API void Parrot_kill_event_loop( void );
+PARROT_API void Parrot_new_cb_event( Interp *interp /*NN*/,
+ PMC *cbi,
+ char *ext )
+ __attribute__nonnull__(1);
+
+PARROT_API void Parrot_new_terminate_event( Interp *interp );
+PARROT_API void Parrot_new_timer_event( Interp *interp,
+ PMC *timer,
+ FLOATVAL diff,
+ FLOATVAL interval,
+ int repeat,
+ PMC *sub,
+ parrot_event_type_enum typ );
+
+PARROT_API void Parrot_schedule_event( Interp *interp,
+ parrot_event* ev /*NN*/ )
+ __attribute__nonnull__(2);
+
+PARROT_API void Parrot_schedule_interp_qentry( Interp *interp /*NN*/,
+ struct QUEUE_ENTRY *entry /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_API opcode_t * Parrot_sleep_on_event( Interp *interp /*NN*/,
+ FLOATVAL t,
+ opcode_t *next )
+ __attribute__nonnull__(1);
+
+void Parrot_schedule_broadcast_qentry( struct QUEUE_ENTRY *entry );
+/* HEADERIZER END: src/events.c */
/* &gen_from_enum(io_thr_msg.pasm) */
typedef enum {
@@ -109,9 +137,6 @@
} io_thread_msg_type;
/* &end_gen */
-PARROT_API void Parrot_event_add_io_event(Interp*,
- PMC* pio, PMC* sub, PMC* data, INTVAL which);
-
#endif /* PARROT_EVENTS_H_GUARD */
/*
Modified: trunk/src/embed.c
==============================================================================
--- trunk/src/embed.c (original)
+++ trunk/src/embed.c Fri Jun 15 07:59:57 2007
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2006, The Perl Foundation.
+Copyright (C) 2001-2007, The Perl Foundation.
$Id$
=head1 NAME
@@ -12,27 +12,23 @@
=head2 Functions
-=over 4
-
-=cut
-
*/
#include "parrot/parrot.h"
#include "parrot/embed.h"
#include "parrot/oplib/ops.h"
+/* HEADER: include/parrot/embed.h */
+
/*
-=item C<Parrot_Interp Parrot_new(Parrot_Interp parent)>
+FUNCDOC: Parrot_new
Returns a new Parrot interpreter.
The first created interpreter (C<parent> is C<NULL>) is the last one
to get destroyed.
-=cut
-
*/
#ifdef JIT_CAPABLE
@@ -41,6 +37,8 @@
# endif /* EXEC_CAPABLE */
# include "jit.h"
#endif
+
+PARROT_API
Parrot_Interp
Parrot_new(Parrot_Interp parent)
{
@@ -48,11 +46,11 @@
return make_interpreter(parent, PARROT_NO_FLAGS);
}
-extern void Parrot_initialize_core_pmcs(Interp *interp);
+extern void Parrot_initialize_core_pmcs(Parrot_Interp interp);
/*
-=item C<void Parrot_init(Interp *interp)>
+FUNCDOC: Parrot_init
Initializes the new interpreter. This function only has effect the first
time it is called. Therefore Parrot_init() doesn't have to be called
@@ -61,7 +59,7 @@
Use this function when you intend to enter the run loop,
which automatically sets the top of stack pointer.
-=item C<void Parrot_init_stacktop(Interp *interp, void *stack_top)>
+FUNCDOC: Parrot_init_stacktop
Like above. Additionally sets the stack top, so that Parrot objects created
in inner stack frames will be visible during DODs stack walking code.
@@ -71,12 +69,12 @@
Use this function when you call into Parrot before entering a run loop.
-=cut
-
*/
+/* XXX Parrot_init() should be removed, no longer required for embedders */
+PARROT_API
void
-Parrot_init(Interp *interp)
+Parrot_init(Parrot_Interp interp /*NN*/)
{
if (!interp->world_inited) {
/* global_setup.c:init_world sets up some vtable stuff.
@@ -88,8 +86,9 @@
}
}
+PARROT_API
void
-Parrot_init_stacktop(Interp *interp, void *stack_top)
+Parrot_init_stacktop(Parrot_Interp interp /*NN*/, void *stack_top)
{
interp->lo_var_ptr = stack_top;
Parrot_init(interp);
@@ -97,7 +96,7 @@
/*
-=item C<void Parrot_set_flag(Interp *interp, INTVAL flag)>
+FUNCDOC: Parrot_set_flag
Sets a flag in the interpreter specified by C<flag>, any of
C<PARROT_BOUNDS_FLAG>, or C<PARROT_PROFILE_FLAG> to enable profiling, and
@@ -106,20 +105,19 @@
disable variable sharing but enable thread communication, or to enable variable
sharing.
-=item C<void Parrot_set_debug(Interp *interp, UINTVAL flag)>
+FUNCDOC: Parrot_set_debug
Set a debug flag: C<PARROT_DEBUG_FLAG>.
-=item C<void Parrot_set_trace(Interp *interp, UINTVAL flag)>
+FUNCDOC: Parrot_set_trace
Set a trace flag: C<PARROT_TRACE_FLAG>
-=cut
-
*/
+PARROT_API
void
-Parrot_set_flag(Interp *interp, INTVAL flag)
+Parrot_set_flag(Parrot_Interp interp /*NN*/, INTVAL flag)
{
/* These two macros (from interpreter.h) do exactly what they look like. */
@@ -134,117 +132,121 @@
}
}
+PARROT_API
void
-Parrot_set_debug(Interp *interp, UINTVAL flag)
+Parrot_set_debug(Parrot_Interp interp /*NN*/, UINTVAL flag)
{
interp->debug_flags |= flag;
}
+PARROT_API
void
-Parrot_set_trace(Interp *interp, UINTVAL flag)
+Parrot_set_trace(Parrot_Interp interp /*NN*/, UINTVAL flag)
{
-
CONTEXT(interp->ctx)->trace_flags |= flag;
Interp_core_SET(interp, PARROT_SLOW_CORE);
}
/*
-=item C<void Parrot_clear_flag(Interp *, INTVAL flag)>
+FUNCDOC: Parrot_clear_flag
-=item C<void Parrot_clear_debug(Interp *, UINTVAL flag)>
+Clears a flag in the interpreter.
-=item C<void Parrot_clear_trace(Interp *, UINTVAL flag)>
+FUNCDOC: Parrot_clear_debug
Clears a flag in the interpreter.
-=cut
+FUNCDOC: Parrot_clear_trace
+
+Clears a flag in the interpreter.
*/
+PARROT_API
void
Parrot_clear_flag(Parrot_Interp interp, INTVAL flag)
{
Interp_flags_CLEAR(interp, flag);
}
+PARROT_API
void
-Parrot_clear_debug(Interp *interp, UINTVAL flag)
+Parrot_clear_debug(Parrot_Interp interp /*NN*/, UINTVAL flag)
{
interp->debug_flags &= ~flag;
}
+PARROT_API
void
-Parrot_clear_trace(Interp *interp, UINTVAL flag)
+Parrot_clear_trace(Parrot_Interp interp /*NN*/, UINTVAL flag)
{
CONTEXT(interp->ctx)->trace_flags &= ~flag;
}
/*
-=item C<Parrot_Int
-Parrot_test_flag(Interp*, INTVAL flag)>
+FUNCDOC: Parrot_test_flag
-=item C<UINTVAL
-Parrot_test_debug(Interp*, UINTVAL flag)>
+Test the interpreter flags specified in C<flag>.
-=item C<UINTVAL
-Parrot_test_trace(Interp*, UINTVAL flag)>
+FUNCDOC: Parrot_test_debug
Test the interpreter flags specified in C<flag>.
-=cut
+FUNCDOC: Parrot_test_trace
+
+Test the interpreter flags specified in C<flag>.
*/
+PARROT_API
Parrot_Int
-Parrot_test_flag(Interp* interp, INTVAL flag)
+Parrot_test_flag(Interp* interp /*NN*/, INTVAL flag)
{
return Interp_flags_TEST(interp, flag);
}
+PARROT_API
UINTVAL
-Parrot_test_debug(Interp *interp, UINTVAL flag)
+Parrot_test_debug(Parrot_Interp interp /*NN*/, UINTVAL flag)
{
return interp->debug_flags & flag;
}
+PARROT_API
UINTVAL
-Parrot_test_trace(Interp *interp, UINTVAL flag)
+Parrot_test_trace(Parrot_Interp interp /*NN*/, UINTVAL flag)
{
return CONTEXT(interp->ctx)->trace_flags & flag;
}
/*
-=item C<void
-Parrot_set_run_core(Interp *interp, Parrot_Run_core_t core)>
+FUNCDOC: Parrot_set_run_core
Sets the specified run core.
-=cut
-
*/
+PARROT_API
void
-Parrot_set_run_core(Interp *interp, Parrot_Run_core_t core)
+Parrot_set_run_core(Parrot_Interp interp /*NN*/, Parrot_Run_core_t core)
{
Interp_core_SET(interp, core);
}
/*
-=item C<void
-Parrot_setwarnings(Interp *interp, Parrot_warnclass wc)>
+FUNCDOC: Parrot_setwarnings
Activates the given warnings.
-=cut
-
*/
+PARROT_API
void
-Parrot_setwarnings(Interp *interp, Parrot_warnclass wc)
+Parrot_setwarnings(Parrot_Interp interp /*NN*/, Parrot_warnclass wc)
{
/* Activates the given warnings. (Macro from warnings.h.) */
PARROT_WARNINGS_on(interp, wc);
@@ -252,17 +254,15 @@
/*
-=item C<PackFile *
-Parrot_readbc(Interp *interp, const char *filename)>
+FUNCDOC: Parrot_readbc
Read in a bytecode, unpack it into a C<PackFile> structure, and do fixups.
-=cut
-
*/
+PARROT_API
PackFile *
-Parrot_readbc(Interp *interp, const char *fullname /*NULLOK*/)
+Parrot_readbc(Parrot_Interp interp, const char *fullname /*NULLOK*/)
{
INTVAL program_size, wanted;
char *program_code;
@@ -420,17 +420,15 @@
/*
-=item C<void
-Parrot_loadbc(Interp *interp, PackFile *pf)>
+FUNCDOC: Parrot_loadbc
Loads the C<PackFile> returned by C<Parrot_readbc()>.
-=cut
-
*/
+PARROT_API
void
-Parrot_loadbc(Interp *interp, PackFile *pf)
+Parrot_loadbc(Parrot_Interp interp /*NN*/, PackFile *pf /*NULLOK*/)
{
if (pf == NULL) {
PIO_eprintf(interp, "Invalid packfile\n");
@@ -442,17 +440,14 @@
/*
-=item C<static PMC*
-setup_argv(Interp *interp, int argc, char ** argv)>
+FUNCDOC: setup_argv
Creates and returns C<ARGS> array PMC.
-=cut
-
*/
static PMC*
-setup_argv(Interp *interp, int argc, char ** argv)
+setup_argv(Parrot_Interp interp, int argc, char ** argv)
{
INTVAL i;
PMC *userargv;
@@ -486,17 +481,14 @@
/*
-=item C<static int
-prof_sort_f(const void *a, const void *b)>
+FUNCDOC: prof_sort_f
Sort function for profile data. Sorts by time.
-=cut
-
*/
static int
-prof_sort_f(const void *a, const void *b)
+prof_sort_f(const void *a /*NN*/, const void *b /*NN*/)
{
const ProfData *pa = (const ProfData *) a;
const ProfData *pb = (const ProfData *) b;
@@ -509,17 +501,14 @@
/*
-=item C<static const char *
-op_name(Parrot_Interp interp, int k)>
+FUNCDOC: op_name
Returns the name of the opcode.
-=cut
-
*/
static const char *
-op_name(Parrot_Interp interp, int k)
+op_name(Parrot_Interp interp /*NN*/, int k)
{
switch (k) {
case PARROT_PROF_DOD_p1:
@@ -542,18 +531,15 @@
/*
-=item C<static FLOATVAL
-calibrate(Parrot_Interp interp)>
+FUNCDOC: calibrate
With this calibration, reported times of C<parrot -p> almost match those
measured with time C<parrot -b>.
-=cut
-
*/
static FLOATVAL
-calibrate(Parrot_Interp interp)
+calibrate(Parrot_Interp interp /*NN*/)
{
size_t n = interp->op_count;
size_t i;
@@ -572,32 +558,31 @@
/*
-=item C<static void print_profile(Interp*, int status, void *p)>
+FUNCDOC: print_profile
Prints out a profile listing.
-=cut
-
*/
static void
-print_profile(Interp *interp, int status, void *p)
+print_profile(Parrot_Interp interp /*NN*/, int status, void *p)
{
- if (interp->profile != NULL) {
+ RunProfile * const profile = interp->profile;
+
+ if (profile) {
UINTVAL j;
int k;
int jit;
UINTVAL op_count = 0;
UINTVAL call_count = 0;
FLOATVAL sum_time = 0.0;
- RunProfile *profile = interp->profile;
FLOATVAL empty = calibrate(interp);
PIO_printf(interp,
" Code J Name "
"Calls Total/s Avg/ms\n");
for (j = 0; j < interp->op_count + PARROT_PROF_EXTRA; j++) {
- UINTVAL n = profile->data[j].numcalls;
+ const UINTVAL n = profile->data[j].numcalls;
profile->data[j].op = j;
if (j >= PARROT_PROF_EXTRA) {
profile->data[j].time -= empty * n;
@@ -609,9 +594,11 @@
PARROT_PROF_EXTRA,
sizeof (ProfData), prof_sort_f);
for (j = 0; j < interp->op_count + PARROT_PROF_EXTRA; j++) {
- UINTVAL n = profile->data[j].numcalls;
- FLOATVAL t = profile->data[j].time;
+ const UINTVAL n = profile->data[j].numcalls;
+
if (n > 0) {
+ const FLOATVAL t = profile->data[j].time;
+
op_count++;
call_count += n;
sum_time += t;
@@ -644,16 +631,14 @@
/*
-=item C<static void print_debug(Interp*, int status, void *p)>
+FUNCDOC: print_debug
Prints GC info.
-=cut
-
*/
static void
-print_debug(Interp *interp, int status, void *p)
+print_debug(Parrot_Interp interp /*NN*/, int status, void *p)
{
if (Interp_debug_TEST(interp, PARROT_MEM_STAT_DEBUG_FLAG)) {
/* Give the souls brave enough to activate debugging an earful
@@ -665,25 +650,23 @@
}
static PMC*
-set_current_sub(Interp *interp)
+set_current_sub(Parrot_Interp interp /*NN*/)
{
opcode_t i, ci;
- PackFile_ByteCode *cur_cs;
- PackFile_FixupTable *ft;
- PackFile_ConstTable *ct;
Parrot_sub *sub;
PMC *sub_pmc;
opcode_t *code_start;
size_t offs;
+ PackFile_ByteCode * const cur_cs = interp->code;
+ PackFile_FixupTable * const ft = cur_cs->fixups;
+ PackFile_ConstTable * const ct = cur_cs->const_table;
+
/*
* Walk the fixup table. The first Sub-like entry should be our
* entry point with the address at our resume_offset.
*/
- cur_cs = interp->code;
- ft = cur_cs->fixups;
- ct = cur_cs->const_table;
for (i = 0; i < ft->fixup_count; i++) {
switch (ft->fixups[i]->type) {
case enum_fixup_sub:
@@ -713,24 +696,22 @@
/*
-=item C<void
-Parrot_runcode(Interp *interp, int argc, char *argv[])>
+FUNCDOC: Parrot_runcode
Sets up C<ARGV> and runs the ops.
-=cut
-
*/
+PARROT_API
void
-Parrot_runcode(Interp *interp, int argc, char *argv[])
+Parrot_runcode(Parrot_Interp interp /*NN*/, int argc, char *argv[])
{
PMC *userargv, *main_sub;
- if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
- PIO_eprintf(interp,
- "*** Parrot VM: Setting stack top. ***\n");
- }
+ if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
+ PIO_eprintf(interp,
+ "*** Parrot VM: Setting stack top. ***\n");
+ }
/* Debugging mode nonsense. */
if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
if (Interp_flags_TEST(interp, PARROT_BOUNDS_FLAG)) {
@@ -806,23 +787,20 @@
/*
-=item C<void
-Parrot_debug(Interp *interp, int argc, char **argv)>
+FUNCDOC: Parrot_debug
Runs the interpreter's bytecode in debugging mode.
-=cut
-
*/
+PARROT_API
opcode_t *
-Parrot_debug(Interp *debugger, opcode_t * pc)
+Parrot_debug(Parrot_Interp debugger /*NN*/, opcode_t * pc)
{
- PDB_t *pdb;
const char *command;
- Interp *interp;
+ Parrot_Interp interp;
- pdb = debugger->pdb;
+ PDB_t * const pdb = debugger->pdb;
pdb->cur_opcode = pc;
@@ -844,19 +822,17 @@
/*
-=item C<void
-Parrot_disassemble(Interp *interp)>
+FUNCDOC: Parrot_disassemble
Disassembles and prints out the interpreter's bytecode.
This is used by the Parrot disassembler.
-=cut
-
*/
+PARROT_API
void
-Parrot_disassemble(Interp *interp)
+Parrot_disassemble(Parrot_Interp interp /*NN*/)
{
char *c;
PDB_t *pdb = mem_allocate_zeroed_typed(PDB_t);
@@ -926,8 +902,7 @@
/*
-=item C<void
-Parrot_run_native(Parrot_Interp interp, native_func_t func)>
+FUNCDOC: Parrot_run_native
Run the C function C<func> through the program C<[enternative, end]>.
This ensures that the function is run with the same setup as in other
@@ -936,12 +911,11 @@
This function is used in some of the source tests in F<t/src> which use
the interpreter outside a runloop.
-=cut
-
*/
+PARROT_API
void
-Parrot_run_native(Parrot_Interp interp, native_func_t func)
+Parrot_run_native(Parrot_Interp interp /*NN*/, native_func_t func)
{
static opcode_t program_code[2];
PackFile * pf;
@@ -964,8 +938,6 @@
/*
-=back
-
=head1 SEE ALSO
F<include/parrot/embed.h> and F<docs/embed.pod>.
@@ -974,8 +946,6 @@
Initial version by Brent Dax on 2002.1.28.
-=cut
-
*/
Modified: trunk/src/events.c
==============================================================================
--- trunk/src/events.c (original)
+++ trunk/src/events.c Fri Jun 15 07:59:57 2007
@@ -15,13 +15,14 @@
IO events and signals are caught in the io_thread, which again
dispatches these to one or all interpreters.
-=cut
-
*/
#include "parrot/parrot.h"
+#include "parrot/events.h"
#include <assert.h>
+/* HEADER: include/parrot/events.h */
+
/*
* event debugging stuff - turn it off before running tests
*/
@@ -118,16 +119,12 @@
=head2 Signal Handling
-=over 4
-
-=item C<static void sig_handler(int signum)>
+FUNCDOC: sig_handler
Handle signal C<signum>.
TODO - Only C<SIGHUP> is handled at the moment for testing
-=cut
-
*/
static void
@@ -146,15 +143,12 @@
#if PARROT_HAS_SIGACTION
/*
-=item C<static void
-Parrot_sigaction(int sig, void (*handler)(int))>
+FUNCDOC: Parrot_sigaction
Signal handlers are common to all threads, signal block masks are
specific, so we install one handler then block that signal and unblock
it in the thread, that will receive that signal.
-=cut
-
*/
static void
@@ -200,6 +194,7 @@
}
#endif
+PARROT_API
void
Parrot_init_signals(void)
{
@@ -213,22 +208,16 @@
/*
-=back
-
=head2 Initialization
-=over 4
-
-=item C<static void init_events_first(Parrot_Interp interp)>
+FUNCDOC: init_events_first
Init event system for first interpreter.
-=cut
-
*/
static void
-init_events_first(Parrot_Interp interp)
+init_events_first(Interp *interp)
{
Parrot_thread ev_handle;
#ifndef WIN32
@@ -278,16 +267,14 @@
/*
-=item C<static void init_events_all(Parrot_Interp interp)>
+FUNCDOC: init_events_all
Init events for all interpreters.
-=cut
-
*/
static void
-init_events_all(Parrot_Interp interp)
+init_events_all(Interp *interp)
{
/*
* create per interpreter task queue
@@ -297,16 +284,15 @@
/*
-=item C<void Parrot_init_events(Parrot_Interp interp)>
+FUNCDOC: Parrot_init_events
Initialize the event system.
-=cut
-
*/
+PARROT_API
void
-Parrot_init_events(Parrot_Interp interp)
+Parrot_init_events(Interp *interp /*NN*/)
{
if (!interp->parent_interpreter) {
/* add the very first interpreter to the list of interps. */
@@ -318,22 +304,17 @@
/*
-=back
-
=head2 Event Handler Functions
-=over 4
-
-=item C<code>
+FUNCDOC: Parrot_schedule_event
Create queue entry and insert event into task queue.
-=cut
-
*/
+PARROT_API
void
-Parrot_schedule_event(Parrot_Interp interp, parrot_event* ev)
+Parrot_schedule_event(Interp *interp, parrot_event* ev /*NN*/)
{
QUEUE_ENTRY* const entry = mem_allocate_typed(QUEUE_ENTRY);
entry->next = NULL;
@@ -380,19 +361,16 @@
/*
-=item C<void
-Parrot_new_timer_event(Parrot_Interp interp, PMC *timer, FLOATVAL diff,
- FLOATVAL interval, int repeat, PMC *sub, parrot_event_type_enum typ)>
+FUNCDOC: Parrot_new_timer_event
Create a new timer event due at C<diff> from now, repeated at C<interval>
and running the passed C<sub>.
-=cut
-
*/
+PARROT_API
void
-Parrot_new_timer_event(Parrot_Interp interp, PMC *timer, FLOATVAL diff,
+Parrot_new_timer_event(Interp *interp, PMC *timer, FLOATVAL diff,
FLOATVAL interval, int repeat, PMC *sub, parrot_event_type_enum typ)
{
parrot_event* const ev = mem_allocate_typed(parrot_event);
@@ -410,17 +388,15 @@
/*
-=item C<void
-Parrot_new_cb_event(Parrot_Interp, PMC *cbi, char *ext)>
+FUNCDOC: Parrot_new_cb_event
Prepare and schedule a callback event.
-=cut
-
*/
+PARROT_API
void
-Parrot_new_cb_event(Parrot_Interp interp, PMC *cbi, char *ext)
+Parrot_new_cb_event(Interp *interp /*NN*/, PMC *cbi, char *ext)
{
parrot_event* const ev = mem_allocate_typed(parrot_event);
QUEUE_ENTRY* const entry = mem_allocate_typed(QUEUE_ENTRY);
@@ -436,17 +412,15 @@
/*
-=item C<void
-Parrot_del_timer_event(Parrot_Interp interp, PMC *timer)>
+FUNCDOC: Parrot_del_timer_event
Deactivate the timer identified by C<timer>.
-=cut
-
*/
+PARROT_API
void
-Parrot_del_timer_event(Parrot_Interp interp, PMC *timer)
+Parrot_del_timer_event(Interp *interp, PMC *timer)
{
QUEUE_ENTRY *entry;
@@ -470,17 +444,16 @@
/*
-=item C<void Parrot_new_terminate_event(Parrot_Interp interp)>
+FUNCDOC: Parrot_new_terminate_event
Create a terminate event, interpreter will leave the run-loop when this
event arrives.
-=cut
-
*/
+PARROT_API
void
-Parrot_new_terminate_event(Parrot_Interp interp)
+Parrot_new_terminate_event(Interp *interp)
{
parrot_event* const ev = mem_allocate_typed(parrot_event);
ev->type = EVENT_TYPE_TERMINATE;
@@ -489,17 +462,16 @@
/*
-=item C<void Parrot_new_suspend_for_gc_event(Parrot_Interp interp)>
+FUNCDOC: Parrot_new_suspend_for_gc_event
Create a suspend-for-GC event, interpreter will wait on a condition
variable for GC to finish when the event arrives.
-=cut
-
*/
+PARROT_API
void
-Parrot_new_suspend_for_gc_event(Parrot_Interp interp) {
+Parrot_new_suspend_for_gc_event(Interp *interp /*NN*/) {
QUEUE_ENTRY *qe;
parrot_event* const ev = mem_allocate_typed(parrot_event);
ev->type = EVENT_TYPE_SUSPEND_FOR_GC;
@@ -515,14 +487,13 @@
/*
-=item C<void Parrot_kill_event_loop(void)>
+FUNCDOC: Parrot_kill_event_loop
Schedule event-loop terminate event. This shuts down the event thread.
-=cut
-
*/
+PARROT_API
void
Parrot_kill_event_loop(void)
{
@@ -533,18 +504,16 @@
/*
-=item C<void
-Parrot_schedule_interp_qentry(Parrot_Interp interp, QUEUE_ENTRY* entry)>
+FUNCDOC: Parrot_schedule_interp_qentry
Put a queue entry into the interpreters task queue and enable event
checking for the interpreter.
-=cut
-
*/
+PARROT_API
void
-Parrot_schedule_interp_qentry(Parrot_Interp interp, QUEUE_ENTRY *entry)
+Parrot_schedule_interp_qentry(Interp *interp /*NN*/, struct QUEUE_ENTRY *entry
/*NN*/)
{
parrot_event * const event = (parrot_event *)entry->data;
/*
@@ -573,19 +542,16 @@
/*
-=item C<void
-Parrot_schedule_broadcast_qentry(QUEUE_ENTRY *entry)>
+FUNCDOC: Parrot_schedule_broadcast_qentry
Broadcast an event.
-=cut
-
*/
void
-Parrot_schedule_broadcast_qentry(QUEUE_ENTRY *entry)
+Parrot_schedule_broadcast_qentry(struct QUEUE_ENTRY *entry)
{
- Parrot_Interp interp;
+ Interp *interp;
parrot_event * const event = (parrot_event *)entry->data;
switch (event->type) {
@@ -638,22 +604,15 @@
/*
-=back
-
=head2 IO Thread Handling
-=over 4
-
-=item C<static void*
-io_thread(void *data)>
+FUNCDOC: io_thread
The IO thread uses select/poll to handle IO events and signals.
It waits on input from the message pipe to insert file descriptors in
the wait sets.
-=cut
-
*/
#ifndef WIN32
@@ -818,13 +777,10 @@
/*
-=item C<static void
-stop_io_thread(void)>
+FUNCDOC: stop_io_thread
Tell the IO thread to stop.
-=cut
-
*/
static void
@@ -841,6 +797,7 @@
#endif
}
+PARROT_API
void
Parrot_event_add_io_event(Interp *interp,
PMC *pio, PMC *sub, PMC *data, INTVAL which)
@@ -870,19 +827,12 @@
/*
-=back
-
=head2 Event Handler Thread Functions
-=over 4
-
-=item C<static QUEUE_ENTRY*
-dup_entry(QUEUE_ENTRY *entry)>
+FUNCDOC: dup_entry
Duplicate queue entry.
-=cut
-
*/
static QUEUE_ENTRY*
@@ -900,13 +850,10 @@
/*
-=item C<static QUEUE_ENTRY*
-dup_entry_interval(QUEUE_ENTRY *entry, FLOATVAL now)>
+FUNCDOC: dup_entry_interval
Duplicate timed entry and add interval to C<abs_time>.
-=cut
-
*/
static QUEUE_ENTRY*
@@ -922,13 +869,11 @@
/*
-=item C<static int process_events(QUEUE *event_q)>
+FUNCDOC: process_events
Do something, when an event arrived caller has locked the mutex returns
0 if event thread terminates.
-=cut
-
*/
static int
@@ -1004,13 +949,11 @@
/*
-=item C<static void* event_thread(void *data)>
+FUNCDOC: event_thread
The event thread is started by the first interpreter. It handles all
events for all interpreters.
-=cut
-
*/
static void*
@@ -1069,24 +1012,17 @@
/*
-=back
-
=head2 Sleep Handling
-=over 4
-
-=item C<static opcode_t *
-wait_for_wakeup(Parrot_Interp interp, opcode_t *next)>
+FUNCDOC: wait_for_wakeup
Sleep on the event queue condition. If an event arrives, the event
is processed. Terminate the loop if sleeping is finished.
-=cut
-
*/
static opcode_t *
-wait_for_wakeup(Parrot_Interp interp, opcode_t *next)
+wait_for_wakeup(Interp *interp, opcode_t *next)
{
QUEUE_ENTRY *entry;
parrot_event *event;
@@ -1122,17 +1058,15 @@
/*
-=item C<opcode_t *
-Parrot_sleep_on_event(Parrot_Interp interp, FLOATVAL t, opcode_t *next)>
+FUNCDOC: Parrot_sleep_on_event
Go to sleep. This is called from the C<sleep> opcode.
-=cut
-
*/
+PARROT_API
opcode_t *
-Parrot_sleep_on_event(Parrot_Interp interp, FLOATVAL t, opcode_t *next)
+Parrot_sleep_on_event(Interp *interp /*NN*/, FLOATVAL t, opcode_t *next)
{
#if PARROT_HAS_THREADS
@@ -1156,23 +1090,17 @@
/*
-=back
-
=head2 Event Handling for Run-Loops
-=over 4
-
-=item C<void*
-Parrot_do_check_events(Parrot_Interp interp, opcode_t *next)>
+FUNCDOC: Parrot_do_check_events
Explicitly C<sync> called by the check_event opcode from run loops.
-=cut
-
*/
+PARROT_API
opcode_t *
-Parrot_do_check_events(Parrot_Interp interp, opcode_t *next)
+Parrot_do_check_events(Interp *interp, opcode_t *next)
{
if (peek_entry(interp->task_queue))
return Parrot_do_handle_events(interp, 0, next);
@@ -1182,17 +1110,14 @@
/*
-=item C<static void
-event_to_exception(Parrot_Interp interp, parrot_event* event)>
+FUNCDOC: event_to_exception
Convert event to exception and throw it.
-=cut
-
*/
static void
-event_to_exception(Parrot_Interp interp, parrot_event* event)
+event_to_exception(Interp *interp, parrot_event* event)
{
const int exit_code = -event->u.signal;
@@ -1213,17 +1138,14 @@
/*
-=item C<static opcode_t *
-do_event(Parrot_Interp interp, parrot_event* event, opcode_t *next)>
+FUNCDOC: do_event
Run user code or such.
-=cut
-
*/
static opcode_t *
-do_event(Parrot_Interp interp, parrot_event* event, opcode_t *next)
+do_event(Interp *interp, parrot_event* event, opcode_t *next)
{
edebug((stderr, "do_event %s\n", et(event)));
switch (event->type) {
@@ -1271,22 +1193,18 @@
/*
-=item C<opcode_t *
-Parrot_do_handle_events(Parrot_Interp interp, int restore, opcode_t *next)>
+FUNCDOC: Parrot_do_handle_events
Called by the C<check_event__> opcode from run loops or from above. When
called from the C<check_events__> opcode, we have to restore the
C<op_func_table>.
-=cut
-
*/
+PARROT_API
opcode_t *
-Parrot_do_handle_events(Parrot_Interp interp, int restore, opcode_t *next)
+Parrot_do_handle_events(Interp *interp /*NN*/, int restore, opcode_t *next)
{
- QUEUE_ENTRY *entry;
- parrot_event *event;
QUEUE * const tq = interp->task_queue;
if (restore)
@@ -1296,8 +1214,9 @@
return next;
while (peek_entry(tq)) {
- entry = pop_entry(tq);
- event = (parrot_event*)entry->data;
+ QUEUE_ENTRY * const entry = pop_entry(tq);
+ parrot_event * const event = (parrot_event*)entry->data;
+
mem_sys_free(entry);
next = do_event(interp, event, next);
}
@@ -1307,14 +1226,10 @@
/*
-=back
-
=head1 SEE ALSO
F<include/parrot/events.h> and F<docs/dev/events.pod>.
-=cut
-
*/
Modified: trunk/src/inter_cb.c
==============================================================================
--- trunk/src/inter_cb.c (original)
+++ trunk/src/inter_cb.c Fri Jun 15 07:59:57 2007
@@ -244,20 +244,17 @@
/*
-=item C<void
-Parrot_run_callback(Parrot_Interp interp,
- PMC* user_data, void* external_data)>
+FUNCDOC: Parrot_run_callback
Run a callback function. The PMC* user_data holds all
necessary items in its properties.
-=cut
-
*/
+PARROT_API
void
-Parrot_run_callback(Parrot_Interp interp,
- PMC* user_data, char* external_data)
+Parrot_run_callback(Interp *interp /*NN*/,
+ PMC* user_data, char* external_data)
{
PMC * signature;
PMC * sub;
Modified: trunk/src/inter_create.c
==============================================================================
--- trunk/src/inter_create.c (original)
+++ trunk/src/inter_create.c Fri Jun 15 07:59:57 2007
@@ -77,19 +77,16 @@
/*
-=item C<Parrot_Interp
-make_interpreter(Parrot_Interp parent, INTVAL flags)>
+FUNCDOC: make_interpreter
Create the Parrot interpreter. Allocate memory and clear the registers.
-=cut
-
*/
void Parrot_really_destroy(Interp *, int exit_code, void *);
Parrot_Interp
-make_interpreter(Parrot_Interp parent, INTVAL flags)
+make_interpreter(Interp *parent /*NULLOK*/, INTVAL flags)
{
Interp *interp;
#if EXEC_CAPABLE
@@ -259,18 +256,16 @@
/*
-=item C<void
-Parrot_destroy(Interp *interp)>
+FUNCDOC: Parrot_destroy
Does nothing if C<ATEXIT_DESTROY> is defined. Otherwise calls
C<Parrot_really_destroy()> with exit code 0.
This function is not currently used.
-=cut
-
*/
+PARROT_API
void
Parrot_destroy(Interp *interp)
{
Modified: trunk/src/interpreter.c
==============================================================================
--- trunk/src/interpreter.c (original)
+++ trunk/src/interpreter.c Fri Jun 15 07:59:57 2007
@@ -1126,19 +1126,17 @@
/*
-=item C<void
-disable_event_checking(Parrot_Interp interp)>
+FUNCDOC: disable_event_checking
Restore old function table.
XXX This is only implemented for the function core at present.
-=cut
-
*/
+PARROT_API
void
-disable_event_checking(Parrot_Interp interp)
+disable_event_checking(Interp *interp /*NN*/)
{
/*
* restore func table
@@ -1149,8 +1147,7 @@
/*
-=item C<void
-enable_event_checking(Parrot_Interp interp)>
+FUNCDOC: enable_event_checking
Replace func table with one that does event checking for all opcodes.
@@ -1159,12 +1156,11 @@
XXX This is only implemented for the function core at present.
-=cut
-
*/
+PARROT_API
void
-enable_event_checking(Parrot_Interp interp)
+enable_event_checking(Interp *interp /*NN*/)
{
/*
* put table in place