* [PATCH] tile: add vDSO support for gettimeofday()
@ 2012-10-26 13:23 Chris Metcalf
2012-10-26 13:27 ` Chris Metcalf
0 siblings, 1 reply; 3+ messages in thread
From: Chris Metcalf @ 2012-10-26 13:23 UTC (permalink / raw)
To: libc-ports
---
ports/sysdeps/unix/sysv/linux/tile/Makefile | 4 +++
.../sysdeps/unix/sysv/linux/tile/bits/libc-vdso.h | 30 ++++++++++++++++
ports/sysdeps/unix/sysv/linux/tile/gettimeofday.c | 38 ++++++++++++++++++++
ports/sysdeps/unix/sysv/linux/tile/init-first.c | 34 ++++++++++++++++++
4 files changed, 106 insertions(+)
create mode 100644 ports/sysdeps/unix/sysv/linux/tile/bits/libc-vdso.h
create mode 100644 ports/sysdeps/unix/sysv/linux/tile/gettimeofday.c
create mode 100644 ports/sysdeps/unix/sysv/linux/tile/init-first.c
diff --git a/ports/sysdeps/unix/sysv/linux/tile/Makefile b/ports/sysdeps/unix/sysv/linux/tile/Makefile
index 0cbfdd0..1c0c968 100644
--- a/ports/sysdeps/unix/sysv/linux/tile/Makefile
+++ b/ports/sysdeps/unix/sysv/linux/tile/Makefile
@@ -13,3 +13,7 @@ sysdep_headers += sys/dataplane.h
sysdep_routines += set_dataplane
endif
+
+ifeq ($(subdir),elf)
+sysdep_routines += dl-vdso
+endif
diff --git a/ports/sysdeps/unix/sysv/linux/tile/bits/libc-vdso.h b/ports/sysdeps/unix/sysv/linux/tile/bits/libc-vdso.h
new file mode 100644
index 0000000..b972720
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/tile/bits/libc-vdso.h
@@ -0,0 +1,30 @@
+/* Resolve function pointers to VDSO functions.
+ Copyright (C) 2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+
+#ifndef _LIBC_VDSO_H
+#define _LIBC_VDSO_H
+
+#ifdef SHARED
+
+extern long int (*__vdso_gettimeofday) (struct timeval *, void *)
+ attribute_hidden;
+
+#endif
+
+#endif /* _LIBC_VDSO_H */
diff --git a/ports/sysdeps/unix/sysv/linux/tile/gettimeofday.c b/ports/sysdeps/unix/sysv/linux/tile/gettimeofday.c
new file mode 100644
index 0000000..95a9d34
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/tile/gettimeofday.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <stddef.h>
+#include <sys/time.h>
+#include <time.h>
+
+#undef __gettimeofday
+#include <bits/libc-vdso.h>
+
+int
+__gettimeofday (struct timeval *tv, struct timezone *tz)
+{
+#if SHARED
+ /* If the vDSO is available we use it. */
+ if (__vdso_gettimeofday != NULL)
+ return __vdso_gettimeofday (tv, tz);
+#endif
+ return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
+}
+
+strong_alias (__gettimeofday, __gettimeofday_internal)
+weak_alias (__gettimeofday, gettimeofday)
diff --git a/ports/sysdeps/unix/sysv/linux/tile/init-first.c b/ports/sysdeps/unix/sysv/linux/tile/init-first.c
new file mode 100644
index 0000000..58b6533
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/tile/init-first.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef SHARED
+#include <dl-vdso.h>
+#include <bits/libc-vdso.h>
+
+long int (*__vdso_gettimeofday) (struct timeval *, void *) attribute_hidden;
+
+static inline void
+_libc_vdso_platform_setup (void)
+{
+ PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
+ __vdso_gettimeofday = _dl_vdso_vsym ("__vdso_gettimeofday", &linux26);
+}
+
+#define VDSO_SETUP _libc_vdso_platform_setup
+#endif
+
+#include "../init-first.c"
--
1.7.10.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tile: add vDSO support for gettimeofday()
2012-10-26 13:23 [PATCH] tile: add vDSO support for gettimeofday() Chris Metcalf
@ 2012-10-26 13:27 ` Chris Metcalf
2012-10-26 16:55 ` Roland McGrath
0 siblings, 1 reply; 3+ messages in thread
From: Chris Metcalf @ 2012-10-26 13:27 UTC (permalink / raw)
To: libc-ports
Oops, forgot to include the Changelog.tile entry:
2012-10-26 Chris Metcalf <cmetcalf@tilera.com>
* sysdeps/unix/sysv/linux/tile/Makefile (sysdep_routines):
Include dl-vdso.
* sysdeps/unix/sysv/linux/tile/bits/libc-vdso.h: New file.
* sysdeps/unix/sysv/linux/tile/gettimeofday.c: New file.
* sysdeps/unix/sysv/linux/tile/init-first.c: New file.
On 10/26/2012 9:21 AM, Chris Metcalf wrote:
> ---
> ports/sysdeps/unix/sysv/linux/tile/Makefile | 4 +++
> .../sysdeps/unix/sysv/linux/tile/bits/libc-vdso.h | 30 ++++++++++++++++
> ports/sysdeps/unix/sysv/linux/tile/gettimeofday.c | 38 ++++++++++++++++++++
> ports/sysdeps/unix/sysv/linux/tile/init-first.c | 34 ++++++++++++++++++
> 4 files changed, 106 insertions(+)
> create mode 100644 ports/sysdeps/unix/sysv/linux/tile/bits/libc-vdso.h
> create mode 100644 ports/sysdeps/unix/sysv/linux/tile/gettimeofday.c
> create mode 100644 ports/sysdeps/unix/sysv/linux/tile/init-first.c
>
> diff --git a/ports/sysdeps/unix/sysv/linux/tile/Makefile b/ports/sysdeps/unix/sysv/linux/tile/Makefile
> index 0cbfdd0..1c0c968 100644
> --- a/ports/sysdeps/unix/sysv/linux/tile/Makefile
> +++ b/ports/sysdeps/unix/sysv/linux/tile/Makefile
> @@ -13,3 +13,7 @@ sysdep_headers += sys/dataplane.h
> sysdep_routines += set_dataplane
>
> endif
> +
> +ifeq ($(subdir),elf)
> +sysdep_routines += dl-vdso
> +endif
> diff --git a/ports/sysdeps/unix/sysv/linux/tile/bits/libc-vdso.h b/ports/sysdeps/unix/sysv/linux/tile/bits/libc-vdso.h
> new file mode 100644
> index 0000000..b972720
> --- /dev/null
> +++ b/ports/sysdeps/unix/sysv/linux/tile/bits/libc-vdso.h
> @@ -0,0 +1,30 @@
> +/* Resolve function pointers to VDSO functions.
> + Copyright (C) 2012 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library 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
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library. If not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +
> +#ifndef _LIBC_VDSO_H
> +#define _LIBC_VDSO_H
> +
> +#ifdef SHARED
> +
> +extern long int (*__vdso_gettimeofday) (struct timeval *, void *)
> + attribute_hidden;
> +
> +#endif
> +
> +#endif /* _LIBC_VDSO_H */
> diff --git a/ports/sysdeps/unix/sysv/linux/tile/gettimeofday.c b/ports/sysdeps/unix/sysv/linux/tile/gettimeofday.c
> new file mode 100644
> index 0000000..95a9d34
> --- /dev/null
> +++ b/ports/sysdeps/unix/sysv/linux/tile/gettimeofday.c
> @@ -0,0 +1,38 @@
> +/* Copyright (C) 2012 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library 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
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library. If not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +#include <sysdep.h>
> +#include <stddef.h>
> +#include <sys/time.h>
> +#include <time.h>
> +
> +#undef __gettimeofday
> +#include <bits/libc-vdso.h>
> +
> +int
> +__gettimeofday (struct timeval *tv, struct timezone *tz)
> +{
> +#if SHARED
> + /* If the vDSO is available we use it. */
> + if (__vdso_gettimeofday != NULL)
> + return __vdso_gettimeofday (tv, tz);
> +#endif
> + return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
> +}
> +
> +strong_alias (__gettimeofday, __gettimeofday_internal)
> +weak_alias (__gettimeofday, gettimeofday)
> diff --git a/ports/sysdeps/unix/sysv/linux/tile/init-first.c b/ports/sysdeps/unix/sysv/linux/tile/init-first.c
> new file mode 100644
> index 0000000..58b6533
> --- /dev/null
> +++ b/ports/sysdeps/unix/sysv/linux/tile/init-first.c
> @@ -0,0 +1,34 @@
> +/* Copyright (C) 2012 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library 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
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library. If not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +#ifdef SHARED
> +#include <dl-vdso.h>
> +#include <bits/libc-vdso.h>
> +
> +long int (*__vdso_gettimeofday) (struct timeval *, void *) attribute_hidden;
> +
> +static inline void
> +_libc_vdso_platform_setup (void)
> +{
> + PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
> + __vdso_gettimeofday = _dl_vdso_vsym ("__vdso_gettimeofday", &linux26);
> +}
> +
> +#define VDSO_SETUP _libc_vdso_platform_setup
> +#endif
> +
> +#include "../init-first.c"
--
Chris Metcalf, Tilera Corp.
http://www.tilera.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tile: add vDSO support for gettimeofday()
2012-10-26 13:27 ` Chris Metcalf
@ 2012-10-26 16:55 ` Roland McGrath
0 siblings, 0 replies; 3+ messages in thread
From: Roland McGrath @ 2012-10-26 16:55 UTC (permalink / raw)
To: Chris Metcalf; +Cc: libc-ports
> > +int
> > +__gettimeofday (struct timeval *tv, struct timezone *tz)
> > +{
> > +#if SHARED
#ifdef
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-26 16:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-26 13:23 [PATCH] tile: add vDSO support for gettimeofday() Chris Metcalf
2012-10-26 13:27 ` Chris Metcalf
2012-10-26 16:55 ` Roland McGrath
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).