Enhanced debugging by making DEBUG() print out the cothread ID as well as the process ID. cothread_getcurrent return...

Original commit message from CVS:
Enhanced debugging by making DEBUG() print out the cothread ID as well as
the process ID.  cothread_getcurrent returns the current cothread ID, or
-1 if cothreads aren't set up in this process context.
This commit is contained in:
Erik Walthinsen 2000-12-03 00:17:52 +00:00
parent 16834308e7
commit 34811a366d
3 changed files with 17 additions and 3 deletions

View file

@ -155,7 +155,7 @@ cothread_init (void)
cothread_state* cothread_state*
cothread_main(cothread_context *ctx) cothread_main(cothread_context *ctx)
{ {
DEBUG(stderr,"returning %p, the 0th cothread\n",ctx->threads[0]); DEBUG("returning %p, the 0th cothread\n",ctx->threads[0]);
return ctx->threads[0]; return ctx->threads[0];
} }
@ -173,7 +173,18 @@ cothread_stub (void)
thread->pc = 0; thread->pc = 0;
thread->sp = thread->top_sp; thread->sp = thread->top_sp;
DEBUG("cothread: cothread_stub() exit\n"); DEBUG("cothread: cothread_stub() exit\n");
//printf("uh, yeah, we shouldn't be here, but we should deal anyway\n"); // printf("uh, yeah, we shouldn't be here, but we should deal anyway\n");
}
/**
* cothread_getcurrent:
*
* Returns: the current cothread id
*/
int cothread_getcurrent(void) {
cothread_context *ctx = pthread_getspecific(_cothread_key);
if (!ctx) return -1;
return ctx->current;
} }
/** /**

View file

@ -65,6 +65,7 @@ cothread_context* cothread_init();
cothread_state* cothread_create (cothread_context *ctx); cothread_state* cothread_create (cothread_context *ctx);
void cothread_setfunc (cothread_state *thread, cothread_func func, void cothread_setfunc (cothread_state *thread, cothread_func func,
int argc, char **argv); int argc, char **argv);
int cothread_getcurrent (void);
void cothread_switch (cothread_state *thread); void cothread_switch (cothread_state *thread);
void cothread_set_data (cothread_state *thread, gchar *key, gpointer data); void cothread_set_data (cothread_state *thread, gchar *key, gpointer data);
gpointer cothread_get_data (cothread_state *thread, gchar *key); gpointer cothread_get_data (cothread_state *thread, gchar *key);

View file

@ -48,6 +48,8 @@
#include <gst/gsttee.h> #include <gst/gsttee.h>
#include <gst/cothreads.h>
/* initialize GST */ /* initialize GST */
void gst_init(int *argc,char **argv[]); void gst_init(int *argc,char **argv[]);
@ -57,7 +59,7 @@ void gst_main_quit (void);
/* debugging */ /* debugging */
#ifndef DEBUG #ifndef DEBUG
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
#define DEBUG(format, args...) g_print("DEBUG:(%d) " format, getpid() , ##args) #define DEBUG(format, args...) g_print("DEBUG:(%d:%d) " format, getpid() , cothread_getcurrent() , ##args)
#else #else
#define DEBUG(format, args...) #define DEBUG(format, args...)
#endif #endif