806dd0472f
2019-11-12 Corentin Gay <gay@adacore.com> Jerome Lambourg <lambourg@adacore.com> Olivier Hainque <hainque@adacore.com> libgcc/ * config/t-gthr-vxworks: New file, add all the gthr-vxworks sources to LIB2ADDEH. * config/t-vxworks: Remove adjustments to LIB2ADDEH. * config/t-vxworks7: Likewise. * config.host: Append a block at the end of the file to add the t-gthr files to the tmake_file list for VxWorks after everything else. * config/vxlib.c: Rename as gthr-vxworks.c. * config/vxlib-tls.c: Rename as gthr-vxworks-tls.c. * config/gthr-vxworks.h: Simplify a few comments. Expose a TAS API and a basic error checking API, both internal. Simplify the __gthread_once_t type definition and initializers. Add sections for condition variables support and for the C++0x thread support, conditioned against Vx653 for the latter. * config/gthr-vxworks.c (__gthread_once): Simplify comments and implementation, leveraging the TAS internal API. * config/gthr-vxworks-tls.c: Introduce an internal TLS data access API, leveraging the general availability of TLS services in VxWorks7 post SR6xxx. (__gthread_setspecific, __gthread_setspecific): Use it. (tls_delete_hook): Likewise, and simplify the enter/leave dtor logic. * config/gthr-vxworks-cond.c: New file. GTHREAD_COND variable support based on VxWorks primitives. * config/gthr-vxworks-thread.c: New file. GTHREAD_CXX0X support based on VxWorks primitives. Co-Authored-By: Jerome Lambourg <lambourg@adacore.com> Co-Authored-By: Olivier Hainque <hainque@adacore.com> From-SVN: r278249
84 lines
2.1 KiB
C
84 lines
2.1 KiB
C
/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
|
|
|
|
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 3, 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.
|
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
/* Threads compatibility routines for libgcc2 for VxWorks.
|
|
|
|
This file implements the GTHREAD_HAS_COND part of the interface
|
|
exposed by gthr-vxworks.h. */
|
|
|
|
#include "gthr.h"
|
|
#include <taskLib.h>
|
|
|
|
/* --------------------------- Condition Variables ------------------------ */
|
|
|
|
void
|
|
__gthread_cond_init (__gthread_cond_t *cond)
|
|
{
|
|
if (!cond)
|
|
return;
|
|
*cond = semBCreate (SEM_Q_FIFO, SEM_EMPTY);
|
|
}
|
|
|
|
int
|
|
__gthread_cond_destroy (__gthread_cond_t *cond)
|
|
{
|
|
if (!cond)
|
|
return ERROR;
|
|
return __CHECK_RESULT (semDelete (*cond));
|
|
}
|
|
|
|
int
|
|
__gthread_cond_broadcast (__gthread_cond_t *cond)
|
|
{
|
|
if (!cond)
|
|
return ERROR;
|
|
|
|
return __CHECK_RESULT (semFlush (*cond));
|
|
}
|
|
|
|
int
|
|
__gthread_cond_wait (__gthread_cond_t *cond,
|
|
__gthread_mutex_t *mutex)
|
|
{
|
|
if (!cond)
|
|
return ERROR;
|
|
|
|
if (!mutex)
|
|
return ERROR;
|
|
|
|
__RETURN_ERRNO_IF_NOT_OK (semGive (*mutex));
|
|
|
|
__RETURN_ERRNO_IF_NOT_OK (semTake (*cond, WAIT_FOREVER));
|
|
|
|
__RETURN_ERRNO_IF_NOT_OK (semTake (*mutex, WAIT_FOREVER));
|
|
|
|
return OK;
|
|
}
|
|
|
|
int
|
|
__gthread_cond_wait_recursive (__gthread_cond_t *cond,
|
|
__gthread_recursive_mutex_t *mutex)
|
|
{
|
|
return __gthread_cond_wait (cond, mutex);
|
|
}
|