[gst-devel] Re: Forte Solaris patch
Brian Cameron
Brian.Cameron at sun.com
Mon Jan 20 08:17:02 CET 2003
Crud. I found a bug in my patch. Fixed it and sending again. Sorry
for being such a bother.
Brian
> Okay, I updated the patch again. This patch takes into account David
> Schleef's comments. I added "__GNUC__" ifdef's to the various __asm__
> code for all compiler types, since you don't want to use gcc+'s inline
> assembly extensions if not using gcc.
>
> Forte does support inline, it just doesn't work well with
> __gst_debug_register_funcptr. This is because the Forte compiler only
> supports inline static functions. Since __gst_debug_register_funcptr is
> non-static, it needs to be defined as non-inline for Forte. I updated
> the patch to use the Forte #ifndef __sun rather than #ifdef __GNUC__,
> so this is cleaner. Since this is just a debug function, it probably
> isn't worth making this a static inline function in all functions that
> require GST_DEBUG_FUNCPTR.
>
> David also pointed out that the non-gcc version of CURRENT_STACK_FRAME
> should be the preferred method of getting the stack frame anyway. I
> didn't go ahead and make this change, since I felt that decision would
> be better left to someone that is more intimate with that part of the
> code. My patch for now is just to make the code compile on Forte.
>
> David pointed out that he thought that the entire gstarch.h
> could be surrounded by an #ifdef __GNUC__. However, note that Forte
> is falling into the "USE_MAKECONTEXT" #elif case, so not the *entire*
> file could be included with an #ifdef __GNUC__. :) Again I'll leave
> this change to someone more intimate with the code, if this is
> desired.
>
> This patch also addresses the compile issue that Christian
> Frederik pointed out, so it should work better for everyone. :)
>
> I'm using the #ifndef __sun rather than #ifdef __GNUC__, since this is
> a Forte specific issue.
>
> Brian
>
>
> > Updated patch. I found out that the previous patch I sent had a problem
> > which caused it to fail on patching configure.ac. I've heard that this
> > patch works better. :)
> >
> > Brian
> >
> >
> > > The attached patch makes gstreamer build fine with Forte! Finally got
> > > all the issues sorted. Could this patch be applied to gstreamer head?
> > >
> > > Brian
> > >
> > >
> > > Note: things still aren't working 100% with Forte. Running "make check"
> > > fails as follows.
> > >
> > > --make check output start--
> > >
> > > make[5]: Entering directory
> > > `/export/home/build/gnome/future/gstreamer/libs/ext/cothreads/tests'
> > > 0: calling the pthread function directly
> > > 0: spawning a new cothread
> > >
> > > (process:3848): Cothreads-CRITICAL **: mmap failed, captain
> > >
> > > Cothreads-ERROR **: could not allocate a new cothread stack
> > > aborting...
> > > FAIL: cothreads
> > > 0: spawning a new cothread (iteration 1)
> > > FAIL: dynamic
> > > ===================
> > > 2 of 2 tests failed
> > > ===================
> > >
> > > --make check output end--
> > >
> > > Brian
> >
> >
> > Brian
>
>
> Brian
Brian
-------------- next part --------------
Index: gstreamer/configure.ac
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/configure.ac,v
retrieving revision 1.203
diff -u -p -r1.203 configure.ac
--- gstreamer/configure.ac 11 Jan 2003 00:27:29 -0000 1.203
+++ gstreamer/configure.ac 20 Jan 2003 16:11:55 -0000
@@ -174,6 +174,8 @@ int main ()
ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/])
])
+AC_CHECK_HEADER(ucontext.h, AC_DEFINE(HAVE_UCONTEXT_H))
+
dnl Check for atomic.h
dnl Note: use AC_CHECK_HEADER not AC_CHECK_HEADERS, because the latter
dnl defines the wrong default symbol as well (HAVE_ASM_ATOMIC_H)
Index: gstreamer/gst/cothreads.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/cothreads.c,v
retrieving revision 1.105
diff -u -p -r1.105 cothreads.c
--- gstreamer/gst/cothreads.c 1 Jan 2003 04:28:32 -0000 1.105
+++ gstreamer/gst/cothreads.c 20 Jan 2003 16:11:55 -0000
@@ -36,6 +36,11 @@
#include "gstarch.h"
#include "gstlog.h"
#include "gstutils.h"
+#ifdef HAVE_MAKECONTEXT
+#ifdef HAVE_UCONTEXT_H
+ #include <ucontext.h>
+#endif
+#endif
/* older glibc's have MAP_ANON instead of MAP_ANONYMOUS */
#ifndef MAP_ANONYMOUS
@@ -101,8 +106,14 @@ cothread_get_current_context (void)
cothread_context *
cothread_context_init (void)
{
+#ifndef __GNUC__
+ char __csf;
+ void *sp = &__csf;
+#else
+ void *sp = CURRENT_STACK_FRAME;
+#endif
+
cothread_context *ctx;
- void *sp;
/* if there already is a cotread context for this thread,
* just return it */
@@ -136,7 +147,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
@@ -158,7 +168,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 *) sp;
GST_INFO (GST_CAT_COTHREADS, "0th cothread is %p at sp:%p",
ctx->cothreads[0], ctx->cothreads[0]->sp);
@@ -443,6 +453,13 @@ cothread_current (void)
static void
cothread_stub (void)
{
+#ifndef __GNUC__
+ char __csf;
+ char *sp = &__csf;
+#else
+ char *sp = CURRENT_STACK_FRAME;
+#endif
+
cothread_context *ctx = cothread_get_current_context();
cothread_state *cothread = ctx->cothreads[ctx->current];
@@ -457,7 +474,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", sp);
GST_DEBUG (GST_CAT_COTHREADS, "ctx=%p current=%p", ctx,cothread_get_current_context());
g_assert (ctx == cothread_get_current_context());
Index: gstreamer/gst/gst.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gst.c,v
retrieving revision 1.89
diff -u -p -r1.89 gst.c
--- gstreamer/gst/gst.c 16 Jan 2003 21:22:06 -0000 1.89
+++ gstreamer/gst/gst.c 20 Jan 2003 16:11:55 -0000
@@ -190,18 +190,54 @@ gst_init_with_popt_table (int *argc, cha
gint nextopt, i, j, nstrip;
gchar **temp;
const struct poptOption *options;
- /* this is probably hacky, no? */
- const struct poptOption options_with[] = {
- {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL},
- {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) gst_init_get_popt_table(), 0, "GStreamer options:", NULL},
- {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) popt_options, 0, "Application options:", NULL},
- POPT_TABLEEND
+ struct poptOption options_with[] = {
+ POPT_TABLEEND,
+ POPT_TABLEEND,
+ POPT_TABLEEND,
+ POPT_TABLEEND
};
- const struct poptOption options_without[] = {
- {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL},
- {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) gst_init_get_popt_table(), 0, "GStreamer options:", NULL},
- POPT_TABLEEND
+ struct poptOption options_without[] = {
+ POPT_TABLEEND,
+ POPT_TABLEEND,
+ POPT_TABLEEND
};
+
+ options_with[0].longName = NULL;
+ options_with[0].shortName = NUL;
+ options_with[0].argInfo = POPT_ARG_INCLUDE_TABLE;
+ options_with[0].arg = poptHelpOptions;
+ options_with[0].val = 0;
+ options_with[0].descrip = "Help options:";
+ options_with[0].argDescrip = NULL;
+ options_with[1].longName = NULL;
+ options_with[1].shortName = NUL;
+ options_with[1].argInfo = POPT_ARG_INCLUDE_TABLE;
+ options_with[1].arg = (struct poptOption *) gst_init_get_popt_table();
+ options_with[1].val = 0;
+ options_with[1].descrip = "GStreamer options:";
+ options_with[1].argDescrip = NULL;
+ options_with[2].longName = NULL;
+ options_with[2].shortName = NUL;
+ options_with[2].argInfo = POPT_ARG_INCLUDE_TABLE;
+ options_with[2].arg = (struct poptOption *) popt_options;
+ options_with[2].val = 0;
+ options_with[2].descrip = "Application options:";
+ options_with[2].argDescrip = NULL;
+
+ options_without[0].longName = NULL;
+ options_without[0].shortName = NUL;
+ options_without[0].argInfo = POPT_ARG_INCLUDE_TABLE;
+ options_without[0].arg = poptHelpOptions;
+ options_without[0].val = 0;
+ options_without[0].descrip = "Help options:";
+ options_without[0].argDescrip = NULL;
+ options_without[1].longName = NULL;
+ options_without[1].shortName = NUL;
+ options_without[1].argInfo = POPT_ARG_INCLUDE_TABLE;
+ options_without[1].arg = (struct poptOption *) gst_init_get_popt_table();
+ options_without[1].val = 0;
+ options_without[1].descrip = "GStreamer options:";
+ options_without[1].argDescrip = NULL;
if (gst_initialized)
{
Index: gstreamer/gst/gstarch.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstarch.h,v
retrieving revision 1.18
diff -u -p -r1.18 gstarch.h
--- gstreamer/gst/gstarch.h 11 Dec 2002 21:33:07 -0000 1.18
+++ gstreamer/gst/gstarch.h 20 Jan 2003 16:11:55 -0000
@@ -30,7 +30,7 @@
/***** Intel x86 *****/
-#if defined(HAVE_CPU_I386)
+#if defined(HAVE_CPU_I386) && defined(__GNUC__)
#define GST_ARCH_SET_SP(stackpointer) \
__asm__( "movl %0, %%esp\n" : : "r"(stackpointer) );
@@ -43,7 +43,7 @@
/***** PowerPC *****/
-#elif defined (HAVE_CPU_PPC)
+#elif defined (HAVE_CPU_PPC) && defined(__GNUC__)
/* should bring this in line with others and use an "r" */
#define GST_ARCH_SET_SP(stackpointer) \
@@ -68,7 +68,7 @@ struct minimal_ppc_stackframe {
/***** DEC[/Compaq/HP?/Intel?] Alpha *****/
-#elif defined(HAVE_CPU_ALPHA)
+#elif defined(HAVE_CPU_ALPHA) && defined(__GNUC__)
#define GST_ARCH_SET_SP(stackpointer) \
__asm__("bis $31,%0,$30" : : "r"(stackpointer));
@@ -94,7 +94,7 @@ struct minimal_stackframe {
/***** ARM *****/
-#elif defined(HAVE_CPU_ARM)
+#elif defined(HAVE_CPU_ARM) && defined(__GNUC__)
#define GST_ARCH_SET_SP(stackpointer) \
__asm__( "mov sp, %0" : : "r"(stackpointer));
@@ -110,7 +110,7 @@ struct minimal_stackframe {
/***** Sun SPARC *****/
-#elif defined(HAVE_CPU_SPARC)
+#elif defined(HAVE_CPU_SPARC) && defined(__GNUC__)
#define GST_ARCH_SET_SP(stackpointer) \
__asm__( "ta 3\n\t" \
@@ -131,7 +131,7 @@ struct minimal_stackframe {
/***** MIPS *****/
-#elif defined(HAVE_CPU_MIPS)
+#elif defined(HAVE_CPU_MIPS) && defined(__GNUC__)
#define GST_ARCH_SET_SP(stackpointer) \
__asm__("lw $sp,0(%0)\n\t" : : "r"(stackpointer));
@@ -146,7 +146,7 @@ struct minimal_stackframe {
/***** HP-PA *****/
-#elif defined(HAVE_CPU_HPPA)
+#elif defined(HAVE_CPU_HPPA) && defined(__GNUC__)
#define GST_ARCH_SET_SP(stackpointer) \
__asm__("copy %0,%%sp\n\t" : : "r"(stackpointer));
@@ -160,7 +160,7 @@ struct minimal_stackframe {
#define GST_ARCH_SETUP_STACK(sp) sp -= 4
/***** S/390 *****/
-#elif defined(HAVE_CPU_S390)
+#elif defined(HAVE_CPU_S390) && defined(__GNUC__)
#define GST_ARCH_SET_SP(stackpointer) \
__asm__("lr 15,%0" : : "r"(stackpointer))
Index: gstreamer/gst/gstatomic_impl.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstatomic_impl.h,v
retrieving revision 1.1
diff -u -p -r1.1 gstatomic_impl.h
--- gstreamer/gst/gstatomic_impl.h 31 Dec 2002 03:21:07 -0000 1.1
+++ gstreamer/gst/gstatomic_impl.h 20 Jan 2003 16:11:55 -0000
@@ -33,7 +33,7 @@ G_BEGIN_DECLS
#if defined (GST_CAN_INLINE) || defined (__GST_ATOMIC_C__)
/***** Intel x86 *****/
-#if defined (HAVE_CPU_I386)
+#if defined (HAVE_CPU_I386) && defined(__GNUC__)
#ifdef GST_CONFIG_NO_SMP
#define SMP_LOCK ""
@@ -78,7 +78,7 @@ gst_atomic_int_dec_and_test (GstAtomicIn
}
/***** PowerPC *****/
-#elif defined (HAVE_CPU_PPC)
+#elif defined (HAVE_CPU_PPC) && defined(__GNUC__)
#ifdef GST_CONFIG_NO_SMP
#define SMP_SYNC ""
@@ -154,7 +154,7 @@ gst_atomic_int_dec_and_test (GstAtomicIn
}
/***** DEC[/Compaq/HP?/Intel?] Alpha *****/
-#elif defined(HAVE_CPU_ALPHA)
+#elif defined(HAVE_CPU_ALPHA) && defined(__GNUC__)
GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
@@ -206,7 +206,7 @@ gst_atomic_int_dec_and_test (GstAtomicIn
}
/***** Sun SPARC *****/
-#elif defined(HAVE_CPU_SPARC)
+#elif defined(HAVE_CPU_SPARC) && defined(__GNUC__)
GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
@@ -285,7 +285,7 @@ gst_atomic_int_dec_and_test (GstAtomicIn
}
/***** MIPS *****/
-#elif defined(HAVE_CPU_MIPS)
+#elif defined(HAVE_CPU_MIPS) && defined(__GNUC__)
GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
@@ -336,7 +336,7 @@ gst_atomic_int_dec_and_test (GstAtomicIn
}
/***** S/390 *****/
-#elif defined(HAVE_CPU_S390)
+#elif defined(HAVE_CPU_S390) && defined(__GNUC__)
GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
Index: gstreamer/gst/gstinfo.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstinfo.c,v
retrieving revision 1.51
diff -u -p -r1.51 gstinfo.c
--- gstreamer/gst/gstinfo.c 13 Dec 2002 15:33:39 -0000 1.51
+++ gstreamer/gst/gstinfo.c 20 Jan 2003 16:11:55 -0000
@@ -564,7 +564,12 @@ gst_debug_print_stack_trace (void)
#endif /* GST_ENABLE_FUNC_INTSTRUMENTATION */
+/* Forte does not work with non-static inline functions */
+#ifndef __sun
inline void *
+#else
+void *
+#endif
_gst_debug_register_funcptr (void *ptr, gchar *ptrname)
{
if (!__gst_function_pointers)
Index: gstreamer/gst/gstinfo.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstinfo.h,v
retrieving revision 1.39
diff -u -p -r1.39 gstinfo.h
--- gstreamer/gst/gstinfo.h 15 Jan 2003 21:42:30 -0000 1.39
+++ gstreamer/gst/gstinfo.h 20 Jan 2003 16:11:55 -0000
@@ -352,7 +352,12 @@ void gst_default_info_handler (gint cate
gint line,const gchar *debug_string,
void *element,gchar *string);
+/* Forte does not work with non-static inline functions */
+#ifdef __sun
+void * _gst_debug_register_funcptr (void *ptr, gchar *ptrname);
+#else
inline void * _gst_debug_register_funcptr (void *ptr, gchar *ptrname);
+#endif
extern GstInfoHandler _gst_info_handler;
extern guint32 _gst_info_categories;
Index: gstreamer/gst/elements/gstmd5sink.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/elements/gstmd5sink.c,v
retrieving revision 1.7
diff -u -p -r1.7 gstmd5sink.c
--- gstreamer/gst/elements/gstmd5sink.c 29 Sep 2002 17:52:31 -0000 1.7
+++ gstreamer/gst/elements/gstmd5sink.c 20 Jan 2003 16:11:55 -0000
@@ -151,7 +151,11 @@ md5_process_bytes (const void *buffer, s
size_t add = 128 - left_over > len ? len : 128 - left_over;
/* Only put full words in the buffer. */
+#ifdef __GNUC__
add -= add % __alignof__ (guint32);
+#else
+ add -= add % 4;
+#endif
memcpy (&ctx->buffer[left_over], buffer, add);
ctx->buflen += add;
Index: gstreamer/libs/ext/cothreads/cothreads/cothreads.c
===================================================================
RCS file: /cvsroot/gstreamer/cothreads/cothreads/cothreads.c,v
retrieving revision 1.21
diff -u -p -r1.21 cothreads.c
--- gstreamer/libs/ext/cothreads/cothreads/cothreads.c 12 Sep 2002 19:28:28 -0000 1.21
+++ gstreamer/libs/ext/cothreads/cothreads/cothreads.c 20 Jan 2003 16:11:55 -0000
@@ -238,7 +238,14 @@ cothreads_get_chunk (void)
cothread*
cothread_create (cothread_func func, int argc, void **argv, cothread *main)
{
- char *low, *high, *dest;
+#ifndef __GNUC__
+ char __csf;
+ char *low;
+#else
+ char *low;
+#endif
+
+ char *high, *dest;
cothread_private priv;
cothread *ret = NULL;
cothread_chunk *chunk;
@@ -250,9 +257,15 @@ cothread_create (cothread_func func, int
priv.chunk = chunk;
if (!func) {
+
+#ifndef __GNUC__
+ low = &__csf;
+#else
+ low = CURRENT_STACK_FRAME;
+#endif
+
/* we are being asked to save the current thread into a new cothread. this
* only happens for the first cothread in a thread. */
- low = CURRENT_STACK_FRAME;
#if PTH_STACK_GROWTH > 0
dest = (char*) ((gulong)low | (chunk->size / chunk->nblocks - 1))
+ 1 - getpagesize() * 2;
@@ -302,7 +315,12 @@ cothread_create (cothread_func func, int
cothread*
cothread_self (void)
{
+#ifndef __GNUC__
+ char __csf;
+ char *sp = &__csf;
+#else
char *sp = CURRENT_STACK_FRAME;
+#endif
return (cothread*)cothread_private_get (cothreads_get_chunk(), sp, NULL, sizeof (cothread_private));
}
@@ -542,8 +560,13 @@ static cothread_chunk*
cothread_chunk_new (glong size, gint nblocks)
{
cothread_chunk *ret;
+#ifndef __GNUC__
+ char __csf;
+ char *sp = &__csf;
+#else
char *sp = CURRENT_STACK_FRAME;
-
+#endif
+
ret = g_new0 (cothread_chunk, 1);
ret->nblocks = nblocks;
ret->block_states = g_new0 (cothread_block_state, ret->nblocks);
More information about the gstreamer-devel
mailing list