public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [basic-improvements] [RFD] VxWorks thread support, part two
@ 2002-11-04 22:04 Zack Weinberg
  2002-11-06 10:35 ` Richard Henderson
  2002-11-06 16:00 ` Mark Mitchell
  0 siblings, 2 replies; 3+ messages in thread
From: Zack Weinberg @ 2002-11-04 22:04 UTC (permalink / raw)
  To: gcc-patches

As I said in a previous message, the VxWorks threading support that I
just committed is not complete.  It relies on a set of hooks which
must be added to the VxWorks kernel.  Inserting this abstraction layer
insulates the code in libgcc from the exact version of the operating
system in use -- this was desired by Wind River (they'd like to
support just one GCC build for all their products).  As you can see
below, the hooks have to go digging around in the OS's internal data
structures; it is very likely that different versions of this file
will have to be written for newer versions of VxWorks.  In fact, the
*_dtor_context routines exist only because I know a future version of
VxWorks is going to need to do something in them.

In the near future these hooks are going to be included with VxWorks.
However, it also makes sense to distribute the code for them with GCC,
and describe how to use them in GCC's installation instructions.  I
would like some suggestions for where to put the code.  It doesn't
seem right to put it in gcc/config as it won't be built with the
compiler.  contrib?

For reference, the code as I've written it is appended to this message.

zw

/* Kernel-side additional module for the VxWorks threading support
   logic for GCC.  Written 2002 by Zack Weinberg.

   This file is distributed with GCC, but it is not part of GCC.
   The contents of this file are in the public domain.  */

/* If you are using the Tornado IDE, copy this file to
   $WIND_BASE/target/config/comps/src/gthread_supp.c.  Then create a
   file named 10comp_gthread_supp.cdf in target/config/comps/vxWorks
   with the following contents:

   Component INCLUDE_GCC_GTHREAD {
      NAME                GCC 3.x gthread support (required by C++)
      CONFIGLETTES        gthread_supp.c
      REQUIRES            INCLUDE_CPLUS
      INCLUDE_WHEN        INCLUDE_CPLUS
      _FOLDER             FOLDER_CPLUS
   }

   If you are using command line builds, instead copy this file to
   $WIND_BASE/target/src/config/gthread_supp.c, and add the following
   block to target/src/config/usrExtra.c:

   #ifdef INCLUDE_CPLUS
   #include "../../src/config/gthread_supp.c"
   #endif

   You should now be able to rebuild your application using GCC 3.x.  */

/* WARNING: This code is not 64-bit clean (it assumes that a pointer
   can be held in an 'int' without truncation).  As much of the rest
   of VxWorks also makes this assumption, we can't really avoid it.  */

#include <vxWorks.h>
#include <taskLib.h>

/* This file provides these routines:  */
extern void *__gthread_get_tsd_data (WIND_TCB *tcb);
extern void __gthread_set_tsd_data (WIND_TCB *tcb, void *data);

extern void __gthread_enter_tsd_dtor_context (WIND_TCB *tcb);
extern void __gthread_leave_tsd_dtor_context (WIND_TCB *tcb);

typedef void (*fet_callback_t) (WIND_TCB *, unsigned int);
extern void __gthread_for_all_tasks (fet_callback_t fun, unsigned int number);


/* Kernel private data structure that we go nosing through.  */
extern Q_HEAD activeQHead;

/* Set and retrieve the TSD data block for the task TCB.

   Possible choices for TSD_SLOT are:
     reserved1
     reserved2
     spare1
     spare2
     spare3
     spare4
   (these are all fields of the TCB structure; all have type 'int').

   If you find that the slot chosen by default is already used for
   something else, simply change the #define below and recompile this
   file.  No other file should reference TSD_SLOT directly.  */

#define TSD_SLOT reserved1

void *
__gthread_get_tsd_data (WIND_TCB *tcb)
{
  return (void *) (tcb->TSD_SLOT);
}

void
__gthread_set_tsd_data (WIND_TCB *tcb, void *data)
{
  tcb->TSD_SLOT = (int) data;
}

/* Enter and leave "TSD destructor context".  For VxWorks 5.x,
   nothing needs to be done.  */
#if __GNUC__ >= 2
#define UNUSED __attribute__((unused))
#else
#define UNUSED
#endif

void
__gthread_enter_tsd_dtor_context (WIND_TCB *tcb UNUSED)
{
}

void
__gthread_leave_tsd_dtor_context (WIND_TCB *tcb UNUSED)
{
}

/* Callback subroutine for __gthread_for_all_tasks.  */
struct fet_iter_args
{
  fet_callback_t fun;
  unsigned int number;
};


static BOOL
fet_iter (Q_NODE *node, int data)
{
  struct fet_iter_args *args = (struct fet_iter_args *) data;
  WIND_TCB *tcb = (WIND_TCB *) ((char *)node
				- offsetof (WIND_TCB, activeNode));

  args->fun (tcb, args->number);

  return TRUE;  /* keep going */
}

/* Called by __gthread_key_delete to iterate over all tasks.  */
void
__gthread_for_all_tasks (fet_callback_t fun, unsigned int number)
{
  struct fet_iter_args args;
  args.fun = fun;
  args.number = number;
  
  Q_EACH (&activeQHead, fet_iter, (int)&args);
}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [basic-improvements] [RFD] VxWorks thread support, part two
  2002-11-04 22:04 [basic-improvements] [RFD] VxWorks thread support, part two Zack Weinberg
@ 2002-11-06 10:35 ` Richard Henderson
  2002-11-06 16:00 ` Mark Mitchell
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2002-11-06 10:35 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: gcc-patches

On Mon, Nov 04, 2002 at 10:03:59PM -0800, Zack Weinberg wrote:
> It doesn't
> seem right to put it in gcc/config as it won't be built with the
> compiler.  contrib?

Seems reasonable.


r~

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [basic-improvements] [RFD] VxWorks thread support, part two
  2002-11-04 22:04 [basic-improvements] [RFD] VxWorks thread support, part two Zack Weinberg
  2002-11-06 10:35 ` Richard Henderson
@ 2002-11-06 16:00 ` Mark Mitchell
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Mitchell @ 2002-11-06 16:00 UTC (permalink / raw)
  To: Zack Weinberg, gcc-patches

> In the near future these hooks are going to be included with VxWorks.
> However, it also makes sense to distribute the code for them with GCC,
> and describe how to use them in GCC's installation instructions.  I
> would like some suggestions for where to put the code.  It doesn't
> seem right to put it in gcc/config as it won't be built with the
> compiler.  contrib?

Yes, that sounds right.

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-11-07  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-04 22:04 [basic-improvements] [RFD] VxWorks thread support, part two Zack Weinberg
2002-11-06 10:35 ` Richard Henderson
2002-11-06 16:00 ` Mark Mitchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).