aboutsummaryrefslogtreecommitdiff
path: root/libgcc/config
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-11-10 07:26:18 -0800
committerIan Lance Taylor <iant@golang.org>2020-11-10 07:26:18 -0800
commit8d703821c69062c0cd255787d793e44f1a95d463 (patch)
tree6b1df9cdc36cc47b6164db69a14bc86a63dc77c6 /libgcc/config
parent9cd320ea6572c577cdf17ce1f9ea5230b166af6d (diff)
parentcf392dbdf17e38026f8e3c0e9af7f5b87f63be56 (diff)
downloadgcc-8d703821c69062c0cd255787d793e44f1a95d463.zip
gcc-8d703821c69062c0cd255787d793e44f1a95d463.tar.gz
gcc-8d703821c69062c0cd255787d793e44f1a95d463.tar.bz2
Merge from trunk revision cf392dbdf17e38026f8e3c0e9af7f5b87f63be56.
Diffstat (limited to 'libgcc/config')
-rw-r--r--libgcc/config/gthr-vxworks-cond.c11
-rw-r--r--libgcc/config/gthr-vxworks-thread.c58
-rw-r--r--libgcc/config/gthr-vxworks-tls.c22
-rw-r--r--libgcc/config/gthr-vxworks.c1
-rw-r--r--libgcc/config/gthr-vxworks.h14
-rw-r--r--libgcc/config/libbid/ChangeLog5
-rw-r--r--libgcc/config/libbid/bid_functions.h2
-rw-r--r--libgcc/config/t-vxcrtstuff12
-rw-r--r--libgcc/config/t-vxworks1
-rw-r--r--libgcc/config/t-vxworks71
10 files changed, 98 insertions, 29 deletions
diff --git a/libgcc/config/gthr-vxworks-cond.c b/libgcc/config/gthr-vxworks-cond.c
index d65d07a..e307bea 100644
--- a/libgcc/config/gthr-vxworks-cond.c
+++ b/libgcc/config/gthr-vxworks-cond.c
@@ -27,6 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
exposed by gthr-vxworks.h. */
#include "gthr.h"
+
+#if __GTHREAD_HAS_COND
+
#include <taskLib.h>
/* --------------------------- Condition Variables ------------------------ */
@@ -66,13 +69,11 @@ __gthread_cond_wait (__gthread_cond_t *cond,
if (!mutex)
return ERROR;
- __RETURN_ERRNO_IF_NOT_OK (semGive (*mutex));
-
- __RETURN_ERRNO_IF_NOT_OK (semTake (*cond, WAIT_FOREVER));
+ int ret = __CHECK_RESULT (semExchange (*mutex, *cond, WAIT_FOREVER));
__RETURN_ERRNO_IF_NOT_OK (semTake (*mutex, WAIT_FOREVER));
- return OK;
+ return ret;
}
int
@@ -81,3 +82,5 @@ __gthread_cond_wait_recursive (__gthread_cond_t *cond,
{
return __gthread_cond_wait (cond, mutex);
}
+
+#endif
diff --git a/libgcc/config/gthr-vxworks-thread.c b/libgcc/config/gthr-vxworks-thread.c
index 8544b03..c8fe65f 100644
--- a/libgcc/config/gthr-vxworks-thread.c
+++ b/libgcc/config/gthr-vxworks-thread.c
@@ -28,7 +28,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
VxWorks kernels. */
#include "gthr.h"
+
+#if __GTHREADS_CXX0X
+
#include <taskLib.h>
+#include <stdlib.h>
#define __TIMESPEC_TO_NSEC(timespec) \
((long long)timespec.tv_sec * 1000000000 + (long long)timespec.tv_nsec)
@@ -38,7 +42,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/ 1000000000)
#ifdef __RTP__
- void tls_delete_hook ();
+ void tls_delete_hook (void);
#define __CALL_DELETE_HOOK(tcb) tls_delete_hook()
#else
/* In kernel mode, we need to pass the TCB to task_delete_hook. The TCB is
@@ -47,17 +51,55 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define __CALL_DELETE_HOOK(tcb) tls_delete_hook((WIND_TCB *) ((tcb)->task_id))
#endif
-/* -------------------- Timed Condition Variables --------------------- */
-
int
__gthread_cond_signal (__gthread_cond_t *cond)
{
if (!cond)
return ERROR;
- return __CHECK_RESULT (semGive (*cond));
+ /* If nobody is waiting, skip the semGive altogether: no one can get
+ in line while we hold the mutex associated with *COND. We could
+ skip this test altogether, but it's presumed cheaper than going
+ through the give and take below, and that a signal without a
+ waiter occurs often enough for the test to be worth it. */
+ SEM_INFO info;
+ memset (&info, 0, sizeof (info));
+ __RETURN_ERRNO_IF_NOT_OK (semInfoGet (*cond, &info));
+ if (info.numTasks == 0)
+ return OK;
+
+ int ret = __CHECK_RESULT (semGive (*cond));
+
+ /* It might be the case, however, that when we called semInfo, there
+ was a waiter just about to timeout, and by the time we called
+ semGive, it had already timed out, so our semGive would leave the
+ *cond semaphore full, so the next caller of wait would pass
+ through. We don't want that. So, make sure we leave the
+ semaphore empty. Despite the window in which the semaphore will
+ be full, this works because:
+
+ - we're holding the mutex, so nobody else can semGive, and any
+ pending semTakes are actually within semExchange. there might
+ be others blocked to acquire the mutex, but those are not
+ relevant for the analysis.
+
+ - if there was another non-timed out waiter, semGive will wake it
+ up immediately instead of leaving the semaphore full, so the
+ semTake below will time out, and the semantics are as expected
+
+ - otherwise, if all waiters timed out before the semGive (or if
+ there weren't any to begin with), our semGive completed leaving
+ the semaphore full, and our semTake below will consume it
+ before any other waiter has a change to reach the semExchange,
+ because we're holding the mutex. */
+ if (ret == OK)
+ semTake (*cond, NO_WAIT);
+
+ return ret;
}
+/* -------------------- Timed Condition Variables --------------------- */
+
int
__gthread_cond_timedwait (__gthread_cond_t *cond,
__gthread_mutex_t *mutex,
@@ -93,13 +135,11 @@ __gthread_cond_timedwait (__gthread_cond_t *cond,
if (waiting_ticks > INT_MAX)
waiting_ticks = INT_MAX;
- __RETURN_ERRNO_IF_NOT_OK (semGive (*mutex));
-
- __RETURN_ERRNO_IF_NOT_OK (semTake (*cond, waiting_ticks));
+ int ret = __CHECK_RESULT (semExchange (*mutex, *cond, waiting_ticks));
__RETURN_ERRNO_IF_NOT_OK (semTake (*mutex, WAIT_FOREVER));
- return OK;
+ return ret;
}
/* --------------------------- Timed Mutexes ------------------------------ */
@@ -347,3 +387,5 @@ __gthread_detach (__gthread_t __threadid)
return OK;
}
+
+#endif
diff --git a/libgcc/config/gthr-vxworks-tls.c b/libgcc/config/gthr-vxworks-tls.c
index fac25e3..1d5c4fb 100644
--- a/libgcc/config/gthr-vxworks-tls.c
+++ b/libgcc/config/gthr-vxworks-tls.c
@@ -94,7 +94,9 @@ static int self_owner;
static volatile int delete_hook_installed;
/* TLS data access internal API. A straight __thread variable starting with
- VxWorks 7, a pointer returned by kernel provided routines otherwise. */
+ VxWorks 7, a pointer returned by kernel provided routines otherwise. And
+ on VxWorks 6, the kernel expects us to notify entry/exit of regions
+ handling such variables by calls to kernel provided __gthread routines. */
#if _VXWORKS_MAJOR_GE(7)
@@ -103,23 +105,29 @@ static __thread struct tls_data *__gthread_tls_data;
#define VX_GET_TLS_DATA() __gthread_tls_data
#define VX_SET_TLS_DATA(x) __gthread_tls_data = (x)
-#define VX_ENTER_TLS_DTOR()
-#define VX_LEAVE_TLS_DTOR()
-
#else
extern void *__gthread_get_tls_data (void);
extern void __gthread_set_tls_data (void *data);
-extern void __gthread_enter_tls_dtor_context (void);
-extern void __gthread_leave_tls_dtor_context (void);
-
#define VX_GET_TLS_DATA() __gthread_get_tls_data()
#define VX_SET_TLS_DATA(x) __gthread_set_tls_data(x)
+#endif
+
+#if _VXWORKS_MAJOR_EQ(6)
+
+extern void __gthread_enter_tls_dtor_context (void);
+extern void __gthread_leave_tls_dtor_context (void);
+
#define VX_ENTER_TLS_DTOR() __gthread_enter_tls_dtor_context ()
#define VX_LEAVE_TLS_DTOR() __gthread_leave_tls_dtor_context ()
+#else
+
+#define VX_ENTER_TLS_DTOR()
+#define VX_LEAVE_TLS_DTOR()
+
#endif
/* This is a global structure which records all of the active keys.
diff --git a/libgcc/config/gthr-vxworks.c b/libgcc/config/gthr-vxworks.c
index 9b47ec8..4e73108 100644
--- a/libgcc/config/gthr-vxworks.c
+++ b/libgcc/config/gthr-vxworks.c
@@ -33,6 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined(__GTHREADS)
#include <vxWorks.h>
+#include <taskLib.h>
#ifndef __RTP__
# include <vxLib.h>
diff --git a/libgcc/config/gthr-vxworks.h b/libgcc/config/gthr-vxworks.h
index 8b55fc5..beedf5e 100644
--- a/libgcc/config/gthr-vxworks.h
+++ b/libgcc/config/gthr-vxworks.h
@@ -234,6 +234,12 @@ extern int __gthread_setspecific (__gthread_key_t __key, void *__ptr);
/* ------------------ Base condition variables support ------------------- */
+/* VxWorks prio to 6 misses a few services key to a correct
+ implementation of condition variables with reasonable complexity.
+ semExchange in particular. */
+
+#if _VXWORKS_MAJOR_GE(6)
+
#define __GTHREAD_HAS_COND 1
typedef SEM_ID __gthread_cond_t;
@@ -254,12 +260,14 @@ extern int __gthread_cond_wait (__gthread_cond_t *cond,
extern int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
__gthread_recursive_mutex_t *mutex);
+#endif
+
/* ----------------------- C++0x thread support ------------------------- */
/* We do not support C++0x threads on that VxWorks 653, which we can
recognize by VTHREADS being defined. */
-#ifndef VTHREADS
+#if _VXWORKS_MAJOR_GE(6) && !defined(VTHREADS)
#define __GTHREADS_CXX0X 1
@@ -286,7 +294,7 @@ typedef struct
typedef __gthread_tcb *__gthread_t;
/* Typedefs specific to different vxworks versions. */
-#if _VXW_PRE_69
+#if _VXWORKS_PRE(6,9)
typedef int _Vx_usr_arg_t;
#define TASK_ID_NULL ((TASK_ID)NULL)
#define SEM_ID_NULL ((SEM_ID)NULL)
@@ -322,7 +330,7 @@ extern int __gthread_detach (__gthread_t thread);
extern __gthread_t __gthread_self (void);
-#endif
+#endif /* _VXWORKS_MAJOR_GE(6) && !defined(VTHREADS) */
#ifdef __cplusplus
}
diff --git a/libgcc/config/libbid/ChangeLog b/libgcc/config/libbid/ChangeLog
index a1a9f46..ce4b57e 100644
--- a/libgcc/config/libbid/ChangeLog
+++ b/libgcc/config/libbid/ChangeLog
@@ -1,3 +1,8 @@
+2020-10-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/97164
+ * bid_functions.h (UINT192): Decrease alignment to 8 bytes.
+
2020-05-05 Martin Liska <mliska@suse.cz>
PR libgcc/92565
diff --git a/libgcc/config/libbid/bid_functions.h b/libgcc/config/libbid/bid_functions.h
index 05f9566..d0f0cb2 100644
--- a/libgcc/config/libbid/bid_functions.h
+++ b/libgcc/config/libbid/bid_functions.h
@@ -81,7 +81,7 @@ ALIGN (16)
#define SQRT80 sqrtw
#endif
- typedef ALIGN (16)
+ typedef ALIGN (8)
struct {
UINT64 w[3];
} UINT192;
diff --git a/libgcc/config/t-vxcrtstuff b/libgcc/config/t-vxcrtstuff
index 96b7285..ef64951 100644
--- a/libgcc/config/t-vxcrtstuff
+++ b/libgcc/config/t-vxcrtstuff
@@ -1,12 +1,12 @@
-# crtbegin/crtend for VxWorks (DKM or RTP)
+# crtbegin/crtend for VxWorks
-vx_crtbegin-kernel.o: $(srcdir)/config/vxcrtstuff.c
+vx_crtbegin.o: $(srcdir)/config/vxcrtstuff.c
$(crt_compile) $(CRTSTUFF_T_CFLAGS) -DCRT_BEGIN -c $<
-vx_crtbegin-rtp.o: $(srcdir)/config/vxcrtstuff.c
- $(crt_compile) $(CRTSTUFF_T_CFLAGS) -DCRT_BEGIN -c $< -mrtp
-
vx_crtend.o: $(srcdir)/config/vxcrtstuff.c
$(crt_compile) $(CRTSTUFF_T_CFLAGS) -DCRT_END -c $<
-EXTRA_PARTS += vx_crtbegin-kernel.o vx_crtbegin-rtp.o vx_crtend.o
+# We do pretty different things for kernel vs rtp modes, all
+# controlled thanks to __RTP__ and (optional) multilibs.
+
+EXTRA_PARTS += vx_crtbegin.o vx_crtend.o
diff --git a/libgcc/config/t-vxworks b/libgcc/config/t-vxworks
index 757cead..02e2efa 100644
--- a/libgcc/config/t-vxworks
+++ b/libgcc/config/t-vxworks
@@ -12,6 +12,7 @@ LIB2ADD += $(srcdir)/config/vxcache.c
# prevail (e.g. unwind.h), and that gcc provided header files intended
# to be user visible eventually are visible as well.
LIBGCC2_INCLUDES = -nostdinc -I. \
+ -I$(MULTIBUILDTOP)../../gcc/include-fixed$(MULTISUBDIR) \
-I$(MULTIBUILDTOP)../../gcc/include \
`case "/$(MULTIDIR)" in \
*/mrtp*) echo -I$(WIND_USR)/h -I$(WIND_USR)/h/wrn/coreip ;; \
diff --git a/libgcc/config/t-vxworks7 b/libgcc/config/t-vxworks7
index f2cc904..20c72f4 100644
--- a/libgcc/config/t-vxworks7
+++ b/libgcc/config/t-vxworks7
@@ -12,6 +12,7 @@ LIB2ADD += $(srcdir)/config/vxcache.c
# prevail (e.g. unwind.h), and that gcc provided header files intended
# to be user visible eventually are visible as well.
LIBGCC2_INCLUDES = -nostdinc -I. \
+ -I$(MULTIBUILDTOP)../../gcc/include-fixed$(MULTISUBDIR) \
-I$(VSB_DIR)/h -I$(VSB_DIR)/share/h \
-I$(MULTIBUILDTOP)../../gcc/include \
`case "/$(MULTIDIR)" in \