From fb871eec23f320944e21b8f071bdcaef76c92376 Mon Sep 17 00:00:00 2001 From: Erik Walthinsen Date: Thu, 18 Jan 2001 08:54:25 +0000 Subject: [PATCH] Updates to cothreads code, including non-working alpha. Changed things a bit, including PPC. Not having a PPC machi... Original commit message from CVS: Updates to cothreads code, including non-working alpha. Changed things a bit, including PPC. Not having a PPC machine, I need someone to test these changes and report back whether they worked or not. --- gst/Makefile.am | 1 + gst/cothreads.c | 13 +++++++------ gst/gstalpha.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ gst/gstarch.h | 4 ++++ gst/gsti386.h | 8 ++++---- gst/gstppc.h | 6 ++++-- 6 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 gst/gstalpha.h diff --git a/gst/Makefile.am b/gst/Makefile.am index d945eb6917..94aadcec7a 100644 --- a/gst/Makefile.am +++ b/gst/Makefile.am @@ -101,6 +101,7 @@ noinst_HEADERS = \ gstarch.h \ gsti386.h \ gstppc.h \ + gstalpha.h \ gstpropsprivate.h CFLAGS = $(LIBGST_CFLAGS) diff --git a/gst/cothreads.c b/gst/cothreads.c index a40d6c8e8a..def70b9b88 100644 --- a/gst/cothreads.c +++ b/gst/cothreads.c @@ -29,7 +29,7 @@ #include /* we make too much noise for normal debugging... */ -#define GST_DEBUG_FORCE_DISABLE +//#define GST_DEBUG_FORCE_DISABLE #include "gst_private.h" #include "cothreads.h" @@ -180,7 +180,7 @@ cothread_stub (void) thread->pc = 0; thread->sp = thread->top_sp; GST_DEBUG_LEAVE(""); -// printf("uh, yeah, we shouldn't be here, but we should deal anyway\n"); + fprintf(stderr,"uh, yeah, we shouldn't be here, but we should deal anyway\n"); } /** @@ -258,11 +258,12 @@ cothread_switch (cothread_state *thread) if (current == thread) goto selfswitch; // find the number of the thread to switch to + GST_INFO (GST_CAT_COTHREAD_SWITCH,"switching from cothread %d to to cothread #%d\n", + ctx->current,thread->threadnum); ctx->current = thread->threadnum; - GST_INFO (GST_CAT_COTHREAD_SWITCH,"switching to thread #%d",ctx->current); /* save the current stack pointer, frame pointer, and pc */ - GET_SP(current->sp); +// GET_SP(current->sp); enter = setjmp(current->jmp); if (enter != 0) { GST_DEBUG (0,"enter thread #%d %d %p<->%p (%d)\n",current->threadnum, enter, @@ -277,14 +278,14 @@ cothread_switch (cothread_state *thread) /* restore stack pointer and other stuff of new cothread */ if (thread->flags & COTHREAD_STARTED) { GST_DEBUG (0,"in thread \n"); - SET_SP(thread->sp); +// SET_SP(thread->sp); // switch to it longjmp(thread->jmp,1); } else { SETUP_STACK(thread->sp); SET_SP(thread->sp); // start it - cothread_stub(); + CALL(cothread_stub); GST_DEBUG (0,"exit thread \n"); ctx->current = 0; } diff --git a/gst/gstalpha.h b/gst/gstalpha.h new file mode 100644 index 0000000000..27eb612da1 --- /dev/null +++ b/gst/gstalpha.h @@ -0,0 +1,49 @@ +/* GStreamer + * Copyright (C) 1999,2000 Erik Walthinsen + * 2000 Wim Taymans + * + * gstppc.h: Header for PPC-specific architecture issues + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef GST_HGUARD_GSTALPHA_H +#define GST_HGUARD_GSTALPHA_H + +#warning in gstalpha.h + +#define GET_SP(target) \ + __asm__("stq $30,%0" : "=m"(target) : : "30"); + +#define SET_SP(stackpointer) \ + __asm__("bis $31,%0,$30" : : "r"(stackpointer)); + +#define CALL(target) \ + __asm__( "bis $31,%0,$27\n\t" \ + "jsr $26,($27),0" : : "r"(target) ); + +struct minimal_ppc_stackframe { + unsigned long back_chain; + unsigned long LR_save; + unsigned long unused1; + unsigned long unused2; +}; + +#define SETUP_STACK(sp) \ + sp = ((unsigned long *)(sp)) - 4; \ + ((struct minimal_ppc_stackframe *)sp)->back_chain = 0; + +#endif /* GST_HGUARD_GSTALPHA_H */ diff --git a/gst/gstarch.h b/gst/gstarch.h index 1ae9083781..3d09d5972d 100644 --- a/gst/gstarch.h +++ b/gst/gstarch.h @@ -33,8 +33,12 @@ #ifdef HAVE_CPU_PPC #include "gstppc.h" #else +#ifdef HAVE_CPU_ALPHA +#include "gstalpha.h" +#else #error Need to know about this architecture, or have a generic implementation #endif #endif +#endif #endif /* __GST_GSTARCH_H__ */ diff --git a/gst/gsti386.h b/gst/gsti386.h index 6283744718..568ad67ba1 100644 --- a/gst/gsti386.h +++ b/gst/gsti386.h @@ -24,13 +24,13 @@ #define GST_HGUARD_GSTI386_H #define GET_SP(target) \ - __asm__("movl %%esp, %0" : "=m"(target) : : "esp", "ebp"); + __asm__( "movl %%esp, %0" : "=r"(target) : : "esp", "ebp" ); #define SET_SP(source) \ - __asm__("movl %0, %%esp\n" : "=m"(thread->sp)); + __asm__( "movl %0, %%esp\n" : : "r"(source) ); -#define JUMP(target) \ - __asm__("jmp " SYMBOL_NAME_STR(cothread_stub)) +#define CALL(target) \ + __asm__("call *%0" : : "r"(target) ); #define SETUP_STACK(sp) do ; while(0) diff --git a/gst/gstppc.h b/gst/gstppc.h index c23b7c77b3..fe530eaa6f 100644 --- a/gst/gstppc.h +++ b/gst/gstppc.h @@ -31,8 +31,10 @@ #define SET_SP(source) \ __asm__("lwz 1,%0" : "=m"(source)) -#define JUMP(target) \ - __asm__("b " SYMBOL_NAME_STR(cothread_stub)) +#define CALL(target) \ + __asm__( "mr 0,%0\n\t" \ + "mtlr 0\n\t" \ + "blrl" : : "r"(target) ); struct minimal_ppc_stackframe { unsigned long back_chain;