|
From: <sv...@va...> - 2005-05-29 16:05:46
|
Author: njn
Date: 2005-05-29 17:05:37 +0100 (Sun, 29 May 2005)
New Revision: 3806
Modified:
trunk/coregrind/linux/core_os.h
trunk/coregrind/linux/sema.c
Log:
Removed the unused futex-based semaphore implementation. It can be
added back in later if necessary.
Modified: trunk/coregrind/linux/core_os.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/linux/core_os.h 2005-05-25 21:30:05 UTC (rev 3805)
+++ trunk/coregrind/linux/core_os.h 2005-05-29 16:05:37 UTC (rev 3806)
@@ -32,61 +32,8 @@
#ifndef __LINUX_CORE_OS_H
#define __LINUX_CORE_OS_H
=20
-#define FUTEX_SEMA 0
-
-#if FUTEX_SEMA
-/* ---------------------------------------------------------------------
- Definition for a semaphore. Defined in terms of futex.
-
- Futex semaphore operations taken from futex-2.2/usersem.h
- ------------------------------------------------------------------ */
+/* Not really a semaphore, but use a pipe for a token-passing scheme */
typedef struct {
- int count;
-} vg_sema_t;
-
-extern Int __futex_down_slow(vg_sema_t *, int, struct vki_timespec *);
-extern Int __futex_up_slow(vg_sema_t *);
-
-void VGO_(sema_init)(vg_sema_t *);
-static inline void VGO_(sema_deinit)(vg_sema_t *)=20
-{
-}
-
-static inline void VGO_(sema_down)(vg_sema_t *futx)
-{
- Int val, woken =3D 0;
-
- /* Returns new value */
- while ((val =3D __futex_down(&futx->count)) !=3D 0) {
- Int ret =3D __futex_down_slow(futx, val, NULL);
- if (ret < 0)=20
- return; /* error */
- else if (ret =3D=3D 1)
- return; /* passed */
- else if (ret =3D=3D 0)
- woken =3D 1; /* slept */
- else
- /* loop */;
- }
- /* If we were woken, someone else might be sleeping too: set to -1 */
- if (woken) {
- futx->count =3D -1;
- }
- return;
-}
-
-/* If __futex_up increments count from 0 -> 1, noone was waiting.
- Otherwise, set to 1 and tell kernel to wake them up. */
-static inline void VGO_(sema_up)(vg_sema_t *futx)
-{
- if (!__futex_up(&futx->count))
- __futex_up_slow(futx);
-}
-#else /* !FUTEX_SEMA */
-/*=20
- Not really a semaphore, but use a pipe for a token-passing scheme
- */
-typedef struct {
Int pipe[2];
Int owner_thread; /* who currently has it */
} vg_sema_t;
@@ -96,8 +43,6 @@
void VGO_(sema_down)(vg_sema_t *sema);
void VGO_(sema_up)(vg_sema_t *sema);
=20
-#endif /* FUTEX_SEMA */
-
/* OS-specific thread state */
typedef struct {
/* who we are */
Modified: trunk/coregrind/linux/sema.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/linux/sema.c 2005-05-25 21:30:05 UTC (rev 3805)
+++ trunk/coregrind/linux/sema.c 2005-05-29 16:05:37 UTC (rev 3806)
@@ -31,58 +31,9 @@
=20
#include "core.h"
=20
-#if FUTEX_SEMA
/*=20
- Futex-based semaphore operations.
-
- Taken from futex-2.2/usersem.c
- Based on work by Matthew Kirkwood <ma...@ha...>.=20
-*/
-
-#define FUTEX_PASSED (-(1024 * 1024 * 1024))
-
-static inline Int sys_futex(Int *futex, Int op, Int val, struct vki_time=
spec *rel)
-{
- return VG_(do_syscall)(__NR_futex, futex, op, val, rel);
-}
-
-/* Returns -1 on fail, 0 on wakeup, 1 on pass, 2 on didn't sleep */
-int __futex_down_slow(vg_sema_t *futx, int val, struct vki_timespec *rel=
)
-{
- Int ret;
-
- ret =3D sys_futex(&futx->count, VKI_FUTEX_WAIT, val, rel);
- if (ret =3D=3D 0) {
- /* <=3D in case someone else decremented it */
- if (futx->count <=3D FUTEX_PASSED) {
- futx->count =3D -1;
- return 1;
- }
- return 0;
- }
- /* EWOULDBLOCK just means value changed before we slept: loop */
- if (ret =3D=3D -VKI_EWOULDBLOCK)
- return 2;
- return -1;
-}
-
-int __futex_up_slow(vg_sema_t *futx)
-{
- futx->count =3D 1;
- __futex_commit();
- return sys_futex(&futx->count, VKI_FUTEX_WAKE, 1, NULL);
-}
-
-void VGO_(sema_init)(vg_sema_t *sema)
-{
- sema->count =3D 1;
- __futex_commit();
-}
-
-#else /* !FUTEX_SEMA */
-
-/*=20
- Slower but more portable pipe-based token passing scheme.
+ Slower (than the removed futex-based sema scheme) but more portable
+ pipe-based token passing scheme.
*/
=20
void VGO_(sema_init)(vg_sema_t *sema)
@@ -139,8 +90,6 @@
vg_assert(ret =3D=3D 1);
}
=20
-#endif /* FUTEX_SEMA */
-
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
|