config.gcc (*-*-vxworks*): Update tm_file, add extra_options, remove use_collect2.

2005-08-22  Phil Edwards  <phil@codesourcery.com>

	* config.gcc (*-*-vxworks*):  Update tm_file, add extra_options,
	remove use_collect2.
	(powerpc-wrs-vxworks):  Update, split out *-*-vxworksae target.

	* target-def.h (TARGET_HAVE_CTORS_DTORS):  Allow target
	configuration files to override the default value.

	* config/t-vxworks:  Remove INSTALL_ASSERT_H.  Define STMP_FIXPROTO,
	EXTRA_HEADERS, and EXTRA_MULTILIB_PARTS.
	* config/vx-common.h:  New file, split out from...
	* config/vxworks.h:  here.  Update for VxWorks 6.x and RTP mode.
	* config/vxworksae.h:  New file, for VxWorks AE.
	* config/vxworks.opt:  New file.
	* config/vxlib.c:  Update for VxWorks 6.

	* config/rs6000/t-vxworks (MULTILIB_OPTIONS):  New list.  Adjust
	other MULTILIB_* variables appropriately.
	(LIB2FUNCS_EXTRA, EXTRA_MULTILIB_PARTS):  Correct from t-ppccomm.
	* config/rs6000/t-vxworksae:  New file, adjust multilibs for AE.
	* config/rs6000/vxworks.h:  Update for VxWorks 6.
	* config/rs6000/vxworksae.h:  New file, mostly placeholder for now.

From-SVN: r103432
This commit is contained in:
Phil Edwards 2005-08-24 07:13:10 +00:00 committed by Phil Edwards
parent 7307936052
commit 2eab15c974
13 changed files with 628 additions and 189 deletions

View File

@ -1,3 +1,27 @@
2005-08-23 Phil Edwards <phil@codesourcery.com>
* config.gcc (*-*-vxworks*): Update tm_file, add extra_options,
remove use_collect2.
(powerpc-wrs-vxworks): Update, split out *-*-vxworksae target.
* target-def.h (TARGET_HAVE_CTORS_DTORS): Allow target
configuration files to override the default value.
* config/t-vxworks: Remove INSTALL_ASSERT_H. Define STMP_FIXPROTO,
EXTRA_HEADERS, and EXTRA_MULTILIB_PARTS.
* config/vx-common.h: New file, split out from...
* config/vxworks.h: here. Update for VxWorks 6.x and RTP mode.
* config/vxworksae.h: New file, for VxWorks AE.
* config/vxworks.opt: New file.
* config/vxlib.c: Update for VxWorks 6.
* config/rs6000/t-vxworks (MULTILIB_OPTIONS): New list. Adjust
other MULTILIB_* variables appropriately.
(LIB2FUNCS_EXTRA, EXTRA_MULTILIB_PARTS): Correct from t-ppccomm.
* config/rs6000/t-vxworksae: New file, adjust multilibs for AE.
* config/rs6000/vxworks.h: Update for VxWorks 6.
* config/rs6000/vxworksae.h: New file, mostly placeholder for now.
2005-08-23 Andrew Pinski <pinskia@physics.uc.edu>
PR target/20799

View File

@ -533,14 +533,14 @@ case ${target} in
;;
*-*-vxworks*)
tmake_file=t-vxworks
tm_file="${tm_file} elfos.h svr4.h vxworks.h"
tm_file="${tm_file} elfos.h svr4.h"
xm_defines=POSIX
extra_options="${extra_options} vxworks.opt"
case ${enable_threads} in
no) ;;
"" | yes | vxworks) thread_file='vxworks' ;;
*) echo 'Unknown thread configuration for VxWorks'; exit 1 ;;
esac
use_collect2=yes
xm_defines=POSIX
;;
esac
@ -1722,22 +1722,30 @@ powerpc-*-gnu*)
thread_file='posix'
fi
;;
powerpc-wrs-vxworks*)
powerpc-wrs-vxworks|powerpc-wrs-vxworksae)
# We want vxworks.h after rs6000/sysv4.h, which unfortunately
# means we have to redo the tm_file list from scratch.
tm_file="rs6000/rs6000.h elfos.h svr4.h freebsd-spec.h rs6000/sysv4.h"
tm_file="${tm_file} vxworks.h rs6000/vxworks.h"
tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-ppccomm rs6000/t-vxworks"
extra_options="${extra_options} rs6000/sysv4.opt"
extra_headers=ppc-asm.h
case ${target} in
*-vxworksae*)
tm_file="${tm_file} vx-common.h vxworksae.h rs6000/vxworks.h rs6000/vxworksae.h"
tmake_file="${tmake_file} rs6000/t-vxworksae"
;;
*-vxworks*)
tm_file="${tm_file} vx-common.h vxworks.h rs6000/vxworks.h"
;;
esac
;;
powerpc-wrs-windiss*) # Instruction-level simulator for VxWorks.
powerpc-wrs-windiss*) # Instruction-level simulator for VxWorks.
tm_file="${tm_file} elfos.h svr4.h freebsd-spec.h rs6000/sysv4.h rs6000/windiss.h"
tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
extra_options="${extra_options} rs6000/sysv4.opt"
thread_file=""
thread_file=""
use_fixproto=yes
;;
;;
powerpc-*-lynxos*)
xm_defines=POSIX
tm_file="${tm_file} dbxelf.h elfos.h rs6000/sysv4.h rs6000/lynx.h lynx.h"

View File

@ -1,10 +1,11 @@
# Multilibs for VxWorks.
MULTILIB_OPTIONS = t403/t405/t440/t603/t604/t860
MULTILIB_DIRNAMES = PPC403gnu PPC405gnu PPC440gnu \
PPC603gnu PPC604gnu PPC860gnu
# The base multilib is -mhard-float.
MULTILIB_OPTIONS = mrtp fPIC msoft-float
MULTILIB_DIRNAMES =
MULTILIB_MATCHES = fPIC=fpic
MULTILIB_EXCEPTIONS = fPIC*
MULTILIB_MATCHES = t604=
# Put vxlib.c back in LIB2FUNCS_EXTRA (t-ppccomm clobbers it).
LIB2FUNCS_EXTRA += $(srcdir)/config/vxlib.c
# Restore some variables from t-vxworks clobbered by t-ppccomm.
EXTRA_MULTILIB_PARTS =
LIB2FUNCS_EXTRA = $(srcdir)/config/vxlib.c

View File

@ -0,0 +1,5 @@
# Multilibs for VxWorks AE.
MULTILIB_OPTIONS = mvthreads msoft-float
MULTILIB_MATCHES =
MULTILIB_EXCEPTIONS =

View File

@ -1,32 +1,66 @@
/* Definitions of target machine for GNU compiler. Vxworks PowerPC version.
Copyright (C) 1996, 2000, 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 1996, 2000, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Contributed by CodeSourcery, LLC.
This file is part of GCC.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your
option) any later version.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC 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 General Public
License for more details.
GCC 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 General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
#undef TARGET_OS_CPP_BUILTINS
/* Note to future editors: VxWorks is mostly an EABI target. We do
not use rs6000/eabi.h because we would have to override most of
it anyway. However, if you change that file, consider making
analogous changes here too. */
#undef TARGET_VERSION
#define TARGET_VERSION fprintf (stderr, " (PowerPC VxWorks)");
/* CPP predefined macros. */
#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS() \
do \
{ \
builtin_define ("__ppc"); \
builtin_define ("__EABI__"); \
builtin_define ("__ELF__"); \
builtin_define ("__vxworks"); \
builtin_define ("__vxworks__"); \
builtin_define ("__VXWORKS__"); \
if (!TARGET_SOFT_FLOAT) \
builtin_define ("__hardfp"); \
if (flag_pic == 2) \
{ \
builtin_define ("__PIC__=2"); \
builtin_define ("__pic__=2"); \
} \
else if (flag_pic == 1) \
{ \
builtin_define ("__PIC__=1"); \
builtin_define ("__pic__=1"); \
} \
\
/* C89 namespace violation! */ \
builtin_define ("CPU_FAMILY=PPC"); \
} \
while (0)
/* Only big endian PPC is supported by VxWorks. */
#undef BYTES_BIG_ENDIAN
#define BYTES_BIG_ENDIAN 1
/* We have to kill off the entire specs set created by rs6000/sysv4.h
and substitute our own set. The top level vxworks.h has done some
of this for us. */
@ -38,45 +72,92 @@
#define SUBTARGET_EXTRA_SPECS /* none needed */
/* FIXME: The only reason we allow no -mcpu switch at all is because
config-ml.in insists on a "." multilib. */
#define CPP_SPEC \
"-DCPU_FAMILY=PPC -D__ppc -D__EABI__ \
%{t403: -DCPU=PPC403 -D_SOFT_FLOAT ; \
t405: -DCPU=PPC405 -D_SOFT_FLOAT ; \
t440: -DCPU=PPC440 -D_SOFT_FLOAT ; \
t603: -DCPU=PPC603 ; \
t604: -DCPU=PPC604 ; \
t860: -DCPU=PPC860 -D_SOFT_FLOAT ; \
: -DCPU=PPC604} \
%{!msoft-float:-D__hardfp} \
%{fpic|fpie: -D__PIC__=1 -D__pic__=1 ; \
fPIC|fPIE: -D__PIC__=2 -D__pic__=2 } \
%(cpp_cpu)"
"%{!DCPU=*: \
%{mcpu=403 : -DCPU=PPC403 ; \
mcpu=405 : -DCPU=PPC405 ; \
mcpu=440 : -DCPU=PPC440 ; \
mcpu=603 : -DCPU=PPC603 ; \
mcpu=604 : -DCPU=PPC604 ; \
mcpu=860 : -DCPU=PPC860 ; \
mcpu=8540: -DCPU=PPC85XX ; \
: -DCPU=PPC604 }}" \
VXWORKS_ADDITIONAL_CPP_SPEC
#define CC1_SPEC \
"%{t403: -mcpu=403 -mstrict-align ; \
t405: -mcpu=405 -mstrict-align ; \
t440: -mcpu=440 -mstrict-align ; \
t603: -mcpu=603 -mstrict-align ; \
t604: -mcpu=604 -mstrict-align ; \
t860: -mcpu=860 ; \
: -mcpu=604 -mstrict-align } \
%{G*} %{mno-sdata:-msdata=none} %{msdata:-msdata=default} \
#define CC1_SPEC \
"%{G*} %{mno-sdata:-msdata=none} %{msdata:-msdata=default} \
%{mlittle|mlittle-endian:-mstrict-align} \
%{profile: -p} \
%{profile: -p} \
%{fvec:-maltivec} %{fvec-eabi:-maltivec -mabi=altivec}"
#define ASM_SPEC "%(asm_cpu) \
%{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \
%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
%{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} -mbig"
#undef MULTILIB_DEFAULTS
#define MULTILIB_DEFAULTS { "t604" }
#define ASM_SPEC \
"%(asm_cpu) \
%{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \
%{v:-v} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
%{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} -mbig"
/* We can't use .ctors/.dtors sections. */
#undef TARGET_ASM_OUTPUT_CONSTRUCTOR
#undef TARGET_ASM_OUTPUT_DESTRUCTOR
#undef LIB_SPEC
#define LIB_SPEC VXWORKS_LIB_SPEC
#undef LINK_SPEC
#define LINK_SPEC VXWORKS_LINK_SPEC
#undef STARTFILE_SPEC
#define STARTFILE_SPEC VXWORKS_STARTFILE_SPEC
#undef ENDFILE_SPEC
#define ENDFILE_SPEC VXWORKS_ENDFILE_SPEC
/* Nor sdata. */
#undef SDATA_DEFAULT_SIZE
#define SDATA_DEFAULT_SIZE 0
/* There is no default multilib. */
#undef MULTILIB_DEFAULTS
#undef TARGET_DEFAULT
#define TARGET_DEFAULT \
(MASK_POWERPC | MASK_NEW_MNEMONICS | MASK_EABI | MASK_STRICT_ALIGN)
#undef PROCESSOR_DEFAULT
#define PROCESSOR_DEFAULT PROCESSOR_PPC604
/* Nor sdata, for kernel mode. We use this in
SUBSUBTARGET_INITIALIZE_OPTIONS, after rs6000_rtp has been initialized. */
#undef SDATA_DEFAULT_SIZE
#define SDATA_DEFAULT_SIZE (TARGET_VXWORKS_RTP ? 8 : 0)
#undef STACK_BOUNDARY
#define STACK_BOUNDARY (16*BITS_PER_UNIT)
/* Override sysv4.h, reset to the default. */
#undef PREFERRED_STACK_BOUNDARY
/* Enable SPE */
#undef TARGET_SPE_ABI
#undef TARGET_SPE
#undef TARGET_E500
#undef TARGET_ISEL
#undef TARGET_FPRS
#define TARGET_SPE_ABI rs6000_spe_abi
#define TARGET_SPE rs6000_spe
#define TARGET_E500 (rs6000_cpu == PROCESSOR_PPC8540)
#define TARGET_ISEL rs6000_isel
#define TARGET_FPRS (!rs6000_float_gprs)
/* Make -mcpu=8540 imply SPE. ISEL is automatically enabled, the
others must be done by hand. Handle -mrtp. Disable -fPIC
for -mrtp - the VxWorks PIC model is not compatible with it. */
#undef SUBSUBTARGET_OVERRIDE_OPTIONS
#define SUBSUBTARGET_OVERRIDE_OPTIONS \
do { \
if (TARGET_E500) \
{ \
rs6000_spe = 1; \
rs6000_spe_abi = 1; \
rs6000_float_gprs = 1; \
} \
\
if (!g_switch_set) \
g_switch_value = SDATA_DEFAULT_SIZE; \
VXWORKS_OVERRIDE_OPTIONS; \
} while (0)
/* No _mcount profiling on VxWorks. */
#undef FUNCTION_PROFILER
#define FUNCTION_PROFILER(FILE,LABELNO) VXWORKS_FUNCTION_PROFILER(FILE,LABELNO)

View File

@ -0,0 +1,24 @@
/* PowerPC VxWorks AE target definitions for GNU compiler.
Copyright (C) 2005 Free Software Foundation, Inc.
Contributed by CodeSourcery, LLC.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC 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 General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
#undef TARGET_VERSION
#define TARGET_VERSION fprintf (stderr, " (PowerPC VxWorks AE)");

View File

@ -1,8 +1,7 @@
# Since we have a functional assert.h, use it.
INSTALL_ASSERT_H =
# Don't run fixproto.
STMP_FIXPROTO =
# Build libgcc using the multilib mechanism
LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
@ -15,8 +14,14 @@ LIBGCC2_DEBUG_CFLAGS =
# Extra libgcc2 module used by gthr-vxworks.h functions
LIB2FUNCS_EXTRA = $(srcdir)/config/vxlib.c
# Some runtime modules need these. Can't set extra_headers in config.gcc
# because the paths are always made absolute to the cpu config dir.
EXTRA_HEADERS += $(srcdir)/gthr-vxworks.h gthr-default.h
# This ensures that the correct target headers are used; some
# VxWorks system headers have names that collide with GCC's
# internal (host) headers, e.g. regs.h.
# FIXME: May not be necessary anymore.
LIBGCC2_INCLUDES="-I$(SYSTEM_HEADER_DIR)"
EXTRA_MULTILIB_PARTS =

99
gcc/config/vx-common.h Normal file
View File

@ -0,0 +1,99 @@
/* Target-independent configuration for VxWorks and VxWorks AE.
Copyright (C) 2005 Free Software Foundation, Inc.
Contributed by by CodeSourcery, LLC.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC 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 General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* VxWorks headers are C++-aware. */
#undef NO_IMPLICIT_EXTERN_C
#define NO_IMPLICIT_EXTERN_C
/* Most of these will probably be overridden by subsequent headers. We
undefine them here just in case, and define VXWORKS_ versions of each,
to be used in port-specific vxworks.h. */
#undef LIB_SPEC
#undef LINK_SPEC
#undef LIBGCC_SPEC
#define LIBGCC_SPEC VXWORKS_LIBGCC_SPEC
#undef STARTFILE_SPEC
#undef ENDFILE_SPEC
/* Most of these macros are overridden in "config/vxworks.h" or
"config/vxworksae.h" and are here merely for documentation
purposes. */
#define VXWORKS_ADDITIONAL_CPP_SPEC ""
#define VXWORKS_LIB_SPEC ""
#define VXWORKS_LINK_SPEC ""
#define VXWORKS_LIBGCC_SPEC ""
#define VXWORKS_STARTFILE_SPEC ""
#define VXWORKS_ENDFILE_SPEC ""
/* VxWorks cannot have dots in constructor labels, because it uses a
mutant variation of collect2 that generates C code instead of
assembly. Thus each constructor label must be a legitimate C
symbol. FIXME: Have VxWorks use real collect2 instead. */
#undef NO_DOLLAR_IN_LABEL
#define NO_DOT_IN_LABEL
/* VxWorks uses wchar_t == unsigned short (UCS2) on all architectures. */
#undef WCHAR_TYPE
#define WCHAR_TYPE "short unsigned int"
#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE 16
/* Dwarf2 unwind info is not supported. */
#define DWARF2_UNWIND_INFO 0
/* VxWorks uses DWARF2. */
#define DWARF2_DEBUGGING_INFO 1
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
/* None of these other formats is supported. */
#undef DWARF_DEBUGGING_INFO
#undef DBX_DEBUGGING_INFO
#undef SDB_DEBUGGING_INFO
#undef XCOFF_DEBUGGING_INFO
#undef VMS_DEBUGGING_INFO
/* Kernel mode doesn't have ctors/dtors, but RTP mode does. */
#define TARGET_HAVE_CTORS_DTORS false
#define VXWORKS_OVERRIDE_OPTIONS /* empty */
/* No math library needed. */
#define MATH_LIBRARY ""
/* No profiling. */
#define VXWORKS_FUNCTION_PROFILER(FILE, LABELNO) do \
{ \
sorry ("profiler support for VxWorks"); \
} while (0)
/* This section either contains dynamic relocations, or contains
PC-rel indirections to stubs in the data section which contain dynamic
relocations. General dynamic relocations are not processed
for shared libraries' text segments, and PC-relative displacements
from the text segment to the data segment don't work. So force
it to .gcc_except_section, which the linker will place in .data. */
void vxworks_exception_section (void);
#undef TARGET_ASM_EXCEPTION_SECTION
#define TARGET_ASM_EXCEPTION_SECTION default_exception_section
/* We occasionally need to distinguish between the VxWorks variants. */
#define VXWORKS_KIND_NORMAL 1
#define VXWORKS_KIND_AE 2

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2002 Free Software Foundation, Inc.
/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Zack Weinberg <zack@codesourcery.com>
This file is part of GCC.
@ -18,9 +18,6 @@ along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* Threads compatibility routines for libgcc2 for VxWorks.
These are out-of-line routines called from gthr-vxworks.h. */
/* As a special exception, if you link this library with other files,
some of which are compiled with GCC, to produce an executable,
this library does not by itself cause the resulting executable
@ -28,14 +25,24 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
/* Threads compatibility routines for libgcc2 for VxWorks.
These are out-of-line routines called from gthr-vxworks.h. */
#include "tconfig.h"
#include "tsystem.h"
#include "gthr.h"
#if defined(__GTHREADS)
#include <vxWorks.h>
#ifndef __RTP__
#include <vxLib.h>
#endif
#include <taskLib.h>
#ifndef __RTP__
#include <taskHookLib.h>
#else
# include <errno.h>
#endif
/* Init-once operation.
@ -57,8 +64,12 @@ __gthread_once (__gthread_once_t *guard, void (*func)(void))
if (guard->done)
return 0;
#ifdef __RTP__
__gthread_lock_library ();
#else
while (!vxTas ((void *)&guard->busy))
taskDelay (1);
#endif
/* Only one thread at a time gets here. Check ->done again, then
go ahead and call func() if no one has done it yet. */
@ -68,29 +79,37 @@ __gthread_once (__gthread_once_t *guard, void (*func)(void))
guard->done = 1;
}
#ifdef __RTP__
__gthread_unlock_library ();
#else
guard->busy = 0;
#endif
return 0;
}
/* Thread-specific data.
/* Thread-local storage.
We reserve a field in the TCB to point to a dynamically allocated
array which is used to store TSD values. A TSD key is simply an
array which is used to store TLS values. A TLS key is simply an
offset in this array. The exact location of the TCB field is not
known to this code nor to vxlib.c -- all access to it indirects
through the routines __gthread_get_tsd_data and
__gthread_set_tsd_data, which are provided by the VxWorks kernel.
through the routines __gthread_get_tls_data and
__gthread_set_tls_data, which are provided by the VxWorks kernel.
There is also a global array which records which keys are valid and
which have destructors.
A task delete hook is installed to execute key destructors. The
routines __gthread_enter_tsd_dtor_context and
__gthread_leave_tsd_dtor_context, which are also provided by the
routines __gthread_enter_tls_dtor_context and
__gthread_leave_tls_dtor_context, which are also provided by the
kernel, ensure that it is safe to call free() on memory allocated
by the task being deleted. (This is a no-op on VxWorks 5, but
a major undertaking on AE.)
The task delete hook is only installed when at least one thread
has TLS data. This is a necessary precaution, to allow this module
to be unloaded - a module with a hook can not be removed.
Since this interface is used to allocate only a small number of
keys, the table size is small and static, which simplifies the
code quite a bit. Revisit this if and when it becomes necessary. */
@ -98,23 +117,29 @@ __gthread_once (__gthread_once_t *guard, void (*func)(void))
#define MAX_KEYS 4
/* This is the structure pointed to by the pointer returned
by __gthread_get_tsd_data. */
struct tsd_data
by __gthread_get_tls_data. */
struct tls_data
{
int *owner;
void *values[MAX_KEYS];
unsigned int generation[MAX_KEYS];
};
/* To make sure we only delete TLS data associated with this object,
include a pointer to a local variable in the TLS data object. */
static int self_owner;
/* The number of threads for this module which have active TLS data.
This is protected by tls_lock. */
static int active_tls_threads;
/* kernel provided routines */
extern void *__gthread_get_tsd_data (WIND_TCB *tcb);
extern void __gthread_set_tsd_data (WIND_TCB *tcb, void *data);
extern void *__gthread_get_tls_data (void);
extern void __gthread_set_tls_data (void *data);
extern void __gthread_enter_tsd_dtor_context (WIND_TCB *tcb);
extern void __gthread_leave_tsd_dtor_context (WIND_TCB *tcb);
extern void __gthread_enter_tls_dtor_context (void);
extern void __gthread_leave_tls_dtor_context (void);
typedef void (*fet_callback_t) (WIND_TCB *, unsigned int);
extern void __gthread_for_all_tasks (fet_callback_t fun, unsigned int number);
/* This is a global structure which records all of the active keys.
@ -128,89 +153,118 @@ extern void __gthread_for_all_tasks (fet_callback_t fun, unsigned int number);
stored in this structure is equal to the generation count stored in
T's specific-value structure. */
typedef void (*tsd_dtor) (void *);
typedef void (*tls_dtor) (void *);
struct tsd_keys
struct tls_keys
{
tsd_dtor dtor[MAX_KEYS];
tls_dtor dtor[MAX_KEYS];
unsigned int generation[MAX_KEYS];
};
#define KEY_VALID_P(key) !(tsd_keys.generation[key] & 1)
#define KEY_VALID_P(key) !(tls_keys.generation[key] & 1)
/* Note: if MAX_KEYS is increased, this initializer must be updated
to match. All the generation counts begin at 1, which means no
key is valid. */
static struct tsd_keys tsd_keys =
static struct tls_keys tls_keys =
{
{ 0, 0, 0, 0 },
{ 1, 1, 1, 1 }
};
/* This lock protects the tsd_keys structure. */
static __gthread_mutex_t tsd_lock;
/* This lock protects the tls_keys structure. */
static __gthread_mutex_t tls_lock;
static __gthread_once_t tsd_init_guard = __GTHREAD_ONCE_INIT;
static __gthread_once_t tls_init_guard = __GTHREAD_ONCE_INIT;
/* Internal routines. */
/* The task TCB has just been deleted. Call the destructor
function for each TSD key that has both a destructor and
function for each TLS key that has both a destructor and
a non-NULL specific value in this thread.
This routine does not need to take tsd_lock; the generation
This routine does not need to take tls_lock; the generation
count protects us from calling a stale destructor. It does
need to read tsd_keys.dtor[key] atomically. */
need to read tls_keys.dtor[key] atomically. */
static void
tsd_delete_hook (WIND_TCB *tcb)
tls_delete_hook (void *tcb ATTRIBUTE_UNUSED)
{
struct tsd_data *data = __gthread_get_tsd_data (tcb);
struct tls_data *data = __gthread_get_tls_data ();
__gthread_key_t key;
if (data)
if (data && data->owner == &self_owner)
{
__gthread_enter_tsd_dtor_context (tcb);
__gthread_enter_tls_dtor_context ();
for (key = 0; key < MAX_KEYS; key++)
{
if (data->generation[key] == tsd_keys.generation[key])
if (data->generation[key] == tls_keys.generation[key])
{
tsd_dtor dtor = tsd_keys.dtor[key];
tls_dtor dtor = tls_keys.dtor[key];
if (dtor)
dtor (data->values[key]);
}
}
free (data);
__gthread_set_tsd_data (tcb, 0);
__gthread_leave_tsd_dtor_context (tcb);
/* We can't handle an error here, so just leave the thread
marked as loaded if one occurs. */
if (__gthread_mutex_lock (&tls_lock) != ERROR)
{
active_tls_threads--;
if (active_tls_threads == 0)
taskDeleteHookDelete ((FUNCPTR)tls_delete_hook);
__gthread_mutex_unlock (&tls_lock);
}
__gthread_set_tls_data (0);
__gthread_leave_tls_dtor_context ();
}
}
/* Initialize global data used by the TSD system. */
/* Initialize global data used by the TLS system. */
static void
tsd_init (void)
tls_init (void)
{
taskDeleteHookAdd ((FUNCPTR)tsd_delete_hook);
__GTHREAD_MUTEX_INIT_FUNCTION (&tsd_lock);
__GTHREAD_MUTEX_INIT_FUNCTION (&tls_lock);
}
static void tls_destructor (void) __attribute__ ((destructor));
static void
tls_destructor (void)
{
#ifdef __RTP__
/* All threads but this one should have exited by now. */
tls_delete_hook (NULL);
#else
/* Unregister the hook forcibly. The counter of active threads may
be incorrect, because constructors (like the C++ library's) and
destructors (like this one) run in the context of the shell rather
than in a task spawned from this module. */
taskDeleteHookDelete ((FUNCPTR)tls_delete_hook);
#endif
if (tls_init_guard.done && __gthread_mutex_lock (&tls_lock) != ERROR)
semDelete (tls_lock);
}
/* External interface */
/* Store in KEYP a value which can be passed to __gthread_setspecific/
__gthread_getspecific to store and retrieve a value which is
__gthread_getspecific to store and retrive a value which is
specific to each calling thread. If DTOR is not NULL, it will be
called when a thread terminates with a non-NULL specific value for
this key, with the value as its sole argument. */
int
__gthread_key_create (__gthread_key_t *keyp, tsd_dtor dtor)
__gthread_key_create (__gthread_key_t *keyp, tls_dtor dtor)
{
__gthread_key_t key;
__gthread_once (&tsd_init_guard, tsd_init);
__gthread_once (&tls_init_guard, tls_init);
if (__gthread_mutex_lock (&tsd_lock) == ERROR)
if (__gthread_mutex_lock (&tls_lock) == ERROR)
return errno;
for (key = 0; key < MAX_KEYS; key++)
@ -218,14 +272,14 @@ __gthread_key_create (__gthread_key_t *keyp, tsd_dtor dtor)
goto found_slot;
/* no room */
__gthread_mutex_unlock (&tsd_lock);
__gthread_mutex_unlock (&tls_lock);
return EAGAIN;
found_slot:
tsd_keys.generation[key]++; /* making it even */
tsd_keys.dtor[key] = dtor;
tls_keys.generation[key]++; /* making it even */
tls_keys.dtor[key] = dtor;
*keyp = key;
__gthread_mutex_unlock (&tsd_lock);
__gthread_mutex_unlock (&tls_lock);
return 0;
}
@ -238,21 +292,21 @@ __gthread_key_delete (__gthread_key_t key)
if (key >= MAX_KEYS)
return EINVAL;
__gthread_once (&tsd_init_guard, tsd_init);
__gthread_once (&tls_init_guard, tls_init);
if (__gthread_mutex_lock (&tsd_lock) == ERROR)
if (__gthread_mutex_lock (&tls_lock) == ERROR)
return errno;
if (!KEY_VALID_P (key))
{
__gthread_mutex_unlock (&tsd_lock);
__gthread_mutex_unlock (&tls_lock);
return EINVAL;
}
tsd_keys.generation[key]++; /* making it odd */
tsd_keys.dtor[key] = 0;
tls_keys.generation[key]++; /* making it odd */
tls_keys.dtor[key] = 0;
__gthread_mutex_unlock (&tsd_lock);
__gthread_mutex_unlock (&tls_lock);
return 0;
}
@ -266,17 +320,17 @@ __gthread_key_delete (__gthread_key_t key)
void *
__gthread_getspecific (__gthread_key_t key)
{
struct tsd_data *data;
struct tls_data *data;
if (key >= MAX_KEYS)
return 0;
data = __gthread_get_tsd_data (taskTcb (taskIdSelf ()));
data = __gthread_get_tls_data ();
if (!data)
return 0;
if (data->generation[key] != tsd_keys.generation[key])
if (data->generation[key] != tls_keys.generation[key])
return 0;
return data->values[key];
@ -289,31 +343,37 @@ __gthread_getspecific (__gthread_key_t key)
key_create/key_delete; the worst thing that can happen is that a
value is successfully stored into a dead generation (and then
immediately becomes invalid). However, we do have to make sure
to read tsd_keys.generation[key] atomically. */
to read tls_keys.generation[key] atomically. */
int
__gthread_setspecific (__gthread_key_t key, void *value)
{
struct tsd_data *data;
WIND_TCB *tcb;
struct tls_data *data;
unsigned int generation;
if (key >= MAX_KEYS)
return EINVAL;
tcb = taskTcb (taskIdSelf ());
data = __gthread_get_tsd_data (tcb);
data = __gthread_get_tls_data ();
if (!data)
{
data = malloc (sizeof (struct tsd_data));
if (__gthread_mutex_lock (&tls_lock) == ERROR)
return ENOMEM;
if (active_tls_threads == 0)
taskDeleteHookAdd ((FUNCPTR)tls_delete_hook);
active_tls_threads++;
__gthread_mutex_unlock (&tls_lock);
data = malloc (sizeof (struct tls_data));
if (!data)
return ENOMEM;
memset (data, 0, sizeof (struct tsd_data));
__gthread_set_tsd_data (tcb, data);
memset (data, 0, sizeof (struct tls_data));
data->owner = &self_owner;
__gthread_set_tls_data (data);
}
generation = tsd_keys.generation[key];
generation = tls_keys.generation[key];
if (generation & 1)
return EINVAL;
@ -323,3 +383,4 @@ __gthread_setspecific (__gthread_key_t key, void *value)
return 0;
}
#endif /* __GTHREADS */

View File

@ -1,64 +1,103 @@
/* Common VxWorks target definitions for GCC.
Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
/* Common VxWorks target definitions for GNU compiler.
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Contributed by Wind River Systems.
Rewritten by CodeSourcery, LLC.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC 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 General Public License for more details.
GCC 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 General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* Specify what to link with. */
/* VxWorks does all the library stuff itself. */
#undef LIB_SPEC
#define LIB_SPEC ""
/* In kernel mode, VxWorks provides all the libraries itself, as well as
the functionality of startup files, etc. In RTP mode, it behaves more
like a traditional Unix, with more external files. Most of our specs
must be aware of the difference. */
#undef LINK_SPEC
#define LINK_SPEC "-r"
/* The directory containing the VxWorks target headers. */
#define VXWORKS_TARGET_DIR "/home/tornado/base6/target"
/* VxWorks provides the functionality of crt0.o and friends itself. */
#undef STARTFILE_SPEC
#define STARTFILE_SPEC ""
/* Since we provide a default -isystem, expand -isystem on the command
line early. */
#undef VXWORKS_ADDITIONAL_CPP_SPEC
#define VXWORKS_ADDITIONAL_CPP_SPEC " \
%{!nostdinc:%{isystem*}} \
%{mrtp: -D__RTP__=1 \
%{!nostdinc:-isystem " VXWORKS_TARGET_DIR "/usr/h}} \
%{!mrtp:-D_WRS_KERNEL=1 \
%{!nostdinc:-isystem " VXWORKS_TARGET_DIR "/h}}"
#undef ENDFILE_SPEC
#define ENDFILE_SPEC ""
/* The references to __init and __fini will be satisified by
libc_internal.a. */
#undef VXWORKS_LIB_SPEC
#define VXWORKS_LIB_SPEC \
"%{mrtp:%{shared:-u " USER_LABEL_PREFIX "__init -u " USER_LABEL_PREFIX "__fini} \
%{!shared:%{non-static:-u " USER_LABEL_PREFIX "_STI__6__rtld -ldl} \
--start-group -lc -lgcc -lc_internal -lnet -ldsi \
--end-group}}"
/* VxWorks cannot have dots in constructor labels, because it uses a
mutant variation of collect2 that generates C code instead of
assembly. Thus each constructor label must be a legitimate C
symbol. FIXME: Have VxWorks use real collect2 instead. */
/* The no-op spec for "-shared" below is present because otherwise GCC
will treat it as an unrecognized option. */
#undef VXWORKS_LINK_SPEC
#define VXWORKS_LINK_SPEC \
"%{!mrtp:-r} \
%{!shared: \
%{mrtp:-q %{h*} \
%{R*} %{!Wl,-T*: %{!T*: %(link_start) }} \
%(link_target) %(link_os)}} \
%{v:-V} \
%{shared:-shared} \
%{Bstatic:-Bstatic} \
%{Bdynamic:-Bdynamic} \
%{!Xbind-lazy:-z now} \
%{Xbind-now:%{Xbind-lazy: \
%e-Xbind-now and -Xbind-lazy are incompatible}} \
%{mrtp:%{!shared:%{!non-static:-static} \
%{non-static:--force-dynamic --export-dynamic}}}"
#undef NO_DOLLAR_IN_LABEL
#define NO_DOT_IN_LABEL
/* For VxWorks, the system provides libc_internal.a. This is a superset
of libgcc.a; we want to use it. Make sure not to dynamically export
any of its symbols, though. Always look for libgcc.a first so that
we get the latest versions of the GNU intrinsics during our builds. */
#undef VXWORKS_LIBGCC_SPEC
#define VXWORKS_LIBGCC_SPEC \
"-lgcc %{mrtp:--exclude-libs=libc_internal,libgcc -lc_internal}"
/* We want #pragma pack(n) enabled and expect to inherit the proper
definition of HANDLE_SYSV_PRAGMA from elfos.h for that purpose. */
#undef VXWORKS_STARTFILE_SPEC
#define VXWORKS_STARTFILE_SPEC "%{mrtp:%{!shared:crt0.o%s}}"
#define VXWORKS_ENDFILE_SPEC ""
/* No underscore is prepended to any C symbol name. */
#undef USER_LABEL_PREFIX
#define USER_LABEL_PREFIX ""
/* We can use .ctors/.dtors sections only in RTP mode.
Unfortunately this must be an integer constant expression;
fix up in override_options. */
#undef VXWORKS_OVERRIDE_OPTIONS
#define VXWORKS_OVERRIDE_OPTIONS do { \
targetm.have_ctors_dtors = TARGET_VXWORKS_RTP; \
} while (0)
/* VxWorks uses wchar_t == unsigned short (UCS2) on all architectures. */
#undef WCHAR_TYPE
#define WCHAR_TYPE "short unsigned int"
#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE 16
/* The VxWorks runtime uses a clever trick to get the sentinel entry
(-1) inserted at the beginning of the .ctors segment. This trick
will not work if we ever generate any entries in plain .ctors
sections; we must always use .ctors.PRIORITY. */
#define ALWAYS_NUMBER_CTORS_SECTIONS 1
/* Dwarf2 unwind info is not supported. */
#define DWARF2_UNWIND_INFO 0
/* Weak symbols and link-once sections are not enabled by default. */
#define DEFAULT_USE_WEAK 0
/* The name of the symbol for the table of GOTs in a particular
RTP. */
#define VXWORKS_GOTT_BASE "__GOTT_BASE__"
/* The name of the symbol for the index into the table of GOTs for the
GOT associated with the current shared library. */
#define VXWORKS_GOTT_INDEX "__GOTT_INDEX__"
/* Only supported debug format is Dwarf2. */
#undef DBX_DEBUGGING_INFO
#define VXWORKS_KIND VXWORKS_KIND_NORMAL

32
gcc/config/vxworks.opt Normal file
View File

@ -0,0 +1,32 @@
; Processor-independent options for VxWorks.
;
; Copyright (C) 2005 Free Software Foundation, Inc.
; Contributed by CodeSourcery, LLC.
;
; This file is part of GCC.
;
; GCC is free software; you can redistribute it and/or modify it under
; the terms of the GNU General Public License as published by the Free
; Software Foundation; either version 2, or (at your option) any later
; version.
;
; GCC 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 General Public License
; for more details.
;
; You should have received a copy of the GNU General Public License
; along with GCC; see the file COPYING. If not, write to the Free
; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
; 02110-1301, USA.
mrtp
Target Report RejectNegative Mask(VXWORKS_RTP) Condition(VXWORKS_KIND == VXWORKS_KIND_NORMAL)
Assume the VxWorks RTP environment
; VxWorks AE has two modes: kernel mode and vThreads mode. In
; general, back ends do not actually need to know which mode they're
; in, so we do not have to set any flags.
mvthreads
Target RejectNegative Condition(VXWORKS_KIND == VXWORKS_KIND_AE)
Assume the VxWorks vThreads environment

58
gcc/config/vxworksae.h Normal file
View File

@ -0,0 +1,58 @@
/* Common VxWorks AE target definitions for GNU compiler.
Copyright (C) 2004, 2005 Free Software Foundation, Inc.
Contributed by CodeSourcery, LLC.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC 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 General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* This header should be included after including vx-common.h. */
/* Most of the definitions below this point are versions of the
vxworks.h definitions, without the -mrtp bits. */
/* The directory containing the VxWorks AE target headers. */
#define VXWORKSAE_TARGET_DIR \
"/home/tornado/vxworks-ae/latest/target"
/* Include target/vThreads/h or target/h (depending on the compilation
mode), and then target/val/h (in either mode). The macros defined
are in the user's namespace, but the VxWorks headers require
them. */
#undef VXWORKS_ADDITIONAL_CPP_SPEC
#define VXWORKS_ADDITIONAL_CPP_SPEC " \
%{!nostdinc:%{isystem*}} \
%{mvthreads:-DVTHREADS=1 \
%{!nostdinc:-isystem " VXWORKSAE_TARGET_DIR "/vThreads/h}} \
%{!mvthreads:-DAE653_BUILD=1 \
%{!nostdinc:-isystem " VXWORKSAE_TARGET_DIR "/h}} \
%{!nostdinc:-isystem " VXWORKSAE_TARGET_DIR "/val/h}"
#undef VXWORKS_LIB_SPEC
#define VXWORKS_LIB_SPEC ""
#undef VXWORKS_LINK_SPEC
#define VXWORKS_LINK_SPEC \
"-r %{v:-V}"
#undef VXWORKS_LIBGCC_SPEC
#define VXWORKS_LIBGCC_SPEC \
"-lgcc"
#undef VXWORKS_STARTFILE_SPEC
#define VXWORKS_STARTFILE_SPEC ""
#define VXWORKS_KIND VXWORKS_KIND_AE

View File

@ -126,12 +126,14 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define TARGET_ASM_OUTPUT_MI_THUNK NULL
#define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_tree_hwi_hwi_tree_false
#if defined(TARGET_ASM_CONSTRUCTOR) && defined(TARGET_ASM_DESTRUCTOR)
#define TARGET_HAVE_CTORS_DTORS true
#else
#define TARGET_HAVE_CTORS_DTORS false
#define TARGET_ASM_CONSTRUCTOR NULL
#define TARGET_ASM_DESTRUCTOR NULL
#if !defined(TARGET_HAVE_CTORS_DTORS)
# if defined(TARGET_ASM_CONSTRUCTOR) && defined(TARGET_ASM_DESTRUCTOR)
# define TARGET_HAVE_CTORS_DTORS true
# else
# define TARGET_HAVE_CTORS_DTORS false
# define TARGET_ASM_CONSTRUCTOR NULL
# define TARGET_ASM_DESTRUCTOR NULL
# endif
#endif
#ifdef TARGET_ASM_NAMED_SECTION