From fb27bbee3701b24ec450a09e00b543126547091d Mon Sep 17 00:00:00 2001 From: David Schleef Date: Tue, 21 Jan 2003 22:01:37 +0000 Subject: [PATCH] Remove GCC-ism used to find current stack pointer, and use this opportunity to clean up the code slightly. Based on ... Original commit message from CVS: Remove GCC-ism used to find current stack pointer, and use this opportunity to clean up the code slightly. Based on patch from Brian Cameron. --- gst/cothreads.c | 15 ++++++++++----- gst/cothreads.h | 5 ----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gst/cothreads.c b/gst/cothreads.c index dbe9a8f14c..e68a612f87 100644 --- a/gst/cothreads.c +++ b/gst/cothreads.c @@ -29,6 +29,9 @@ #include #include #include +#ifdef HAVE_UCONTEXT_H +#include +#endif #include "gst_private.h" @@ -101,8 +104,9 @@ cothread_get_current_context (void) cothread_context * cothread_context_init (void) { + char __csf; + void *current_stack_frame = &__csf; /* Get pointer inside current stack frame */ cothread_context *ctx; - void *sp; /* if there already is a cotread context for this thread, * just return it */ @@ -136,7 +140,6 @@ cothread_context_init (void) /* clear the cothread data */ memset (ctx->cothreads, 0, sizeof (ctx->cothreads)); - sp = CURRENT_STACK_FRAME; /* FIXME this may not be 64bit clean * could use casts to uintptr_t from inttypes.h * if only all platforms had inttypes.h @@ -144,7 +147,7 @@ cothread_context_init (void) /* stack_top is the address of the first byte past our stack segment. */ /* FIXME: an assumption is made that the stack segment is STACK_SIZE * aligned. */ - ctx->stack_top = ((gulong) sp | (STACK_SIZE - 1)) + 1; + ctx->stack_top = ((gulong) current_stack_frame | (STACK_SIZE - 1)) + 1; GST_DEBUG (GST_CAT_COTHREADS, "stack top is 0x%08lx", ctx->stack_top); /* @@ -158,7 +161,7 @@ cothread_context_init (void) ctx->cothreads[0]->argv = NULL; ctx->cothreads[0]->priv = NULL; ctx->cothreads[0]->flags = COTHREAD_STARTED; - ctx->cothreads[0]->sp = (void *) CURRENT_STACK_FRAME; + ctx->cothreads[0]->sp = (void *) current_stack_frame; GST_INFO (GST_CAT_COTHREADS, "0th cothread is %p at sp:%p", ctx->cothreads[0], ctx->cothreads[0]->sp); @@ -445,6 +448,8 @@ cothread_stub (void) { cothread_context *ctx = cothread_get_current_context(); cothread_state *cothread = ctx->cothreads[ctx->current]; + char __csf; + void *current_stack_frame = &__csf; GST_DEBUG_ENTER (""); @@ -457,7 +462,7 @@ cothread_stub (void) GST_DEBUG (GST_CAT_COTHREADS, "cothread[%d] thread->func exited", ctx->current); - GST_DEBUG (GST_CAT_COTHREADS, "sp=%p", CURRENT_STACK_FRAME); + GST_DEBUG (GST_CAT_COTHREADS, "sp=%p", current_stack_frame); GST_DEBUG (GST_CAT_COTHREADS, "ctx=%p current=%p", ctx,cothread_get_current_context()); g_assert (ctx == cothread_get_current_context()); diff --git a/gst/cothreads.h b/gst/cothreads.h index bdcb0a9ecf..da4fc02415 100644 --- a/gst/cothreads.h +++ b/gst/cothreads.h @@ -26,11 +26,6 @@ #include #include -/* this bit is lifted out of glibc */ -#ifndef CURRENT_STACK_FRAME -#define CURRENT_STACK_FRAME ({ char __csf; &__csf; }) -#endif /* CURRENT_STACK_FRAME */ - typedef struct _cothread_state cothread_state; typedef struct _cothread_context cothread_context;