On Fri, Sep 2, 2016 at 5:35 PM, Benoit Canet <[email protected]
> wrote:

> Go use this on linux to lookup time. We need a shared
> libary that we will expose to the go runtime by passing
> it's pointer in order for go to resolve this kinds of
> symbols.
>

If you can use the main kernel object instead of a separate shared library
(as I suggested in my review of the next patch), then these _vdso_*
functions can even be aliases of the normal functions - instead of new
functions calling them - so they will be slightly faster (one less function
call).


>
> This so will be reworked after next patch.
>
> Signed-off-by: Benoît Canet <[email protected]>
> ---
>  Makefile                |  8 +++++++-
>  libc/vdso.c             | 18 ++++++++++++++++++
>  usr.manifest.skel       |  1 +
>  usr_nozfs.manifest.skel |  1 +
>  4 files changed, 27 insertions(+), 1 deletion(-)
>  create mode 100644 libc/vdso.c
>
> diff --git a/Makefile b/Makefile
> index e294a03..1e33533 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1832,10 +1832,16 @@ $(out)/bsd/%.o: COMMON += -DSMP
> -D'__FBSDID(__str__)=extern int __bogus__'
>  environ_sources = $(addprefix libc/, $(environ_libc))
>  environ_sources += $(addprefix musl/src/, $(environ_musl))
>
> +vdso_sources = libc/vdso.c
> +
>  $(out)/libenviron.so: $(environ_sources)
>         $(makedir)
>          $(call quiet, $(CC) $(CFLAGS) -shared -o $(out)/libenviron.so
> $(environ_sources), CC libenviron.so)
>
> +$(out)/libvdso.so: $(vdso_sources)
> +       $(makedir)
> +        $(call quiet, $(CC) $(CFLAGS) -shared -o $(out)/libvdso.so
> $(vdso_sources), CC libvdso.so)
> +
>  bootfs_manifest ?= bootfs.manifest.skel
>
>  # If parameter "bootfs_manifest" has been changed since the last make,
> @@ -1848,7 +1854,7 @@ $(bootfs_manifest_dep): phony
>         fi
>
>  $(out)/bootfs.bin: scripts/mkbootfs.py $(bootfs_manifest)
> $(bootfs_manifest_dep) $(tools:%=$(out)/%) \
> -               $(out)/zpool.so $(out)/zfs.so $(out)/libenviron.so
> +               $(out)/zpool.so $(out)/zfs.so $(out)/libenviron.so
> $(out)/libvdso.so
>         $(call quiet, olddir=`pwd`; cd $(out);
> $$olddir/scripts/mkbootfs.py -o bootfs.bin -d bootfs.bin.d -m
> $$olddir/$(bootfs_manifest) \
>                 -D jdkbase=$(jdkbase) -D gccbase=$(gccbase) -D \
>                 glibcbase=$(glibcbase) -D miscbase=$(miscbase), MKBOOTFS
> $@)
> diff --git a/libc/vdso.c b/libc/vdso.c
> new file mode 100644
> index 0000000..eb0bf49
> --- /dev/null
> +++ b/libc/vdso.c
> @@ -0,0 +1,18 @@
> +#include <time.h>
> +#include <sys/time.h>
> +
> +time_t __vdso_time(time_t *tloc)
> +{
> +    return time(tloc);
> +}
> +
> +int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
> +{
> +    return gettimeofday(tv, tz);
> +}
> +
> +int __vdso_clock_gettime(clockid_t clk_id, struct timespec *tp)
> +{
> +    return clock_gettime(clk_id, tp);
> +}
> +
> diff --git a/usr.manifest.skel b/usr.manifest.skel
> index 583bdfe..159b73d 100644
> --- a/usr.manifest.skel
> +++ b/usr.manifest.skel
> @@ -1,5 +1,6 @@
>  [manifest]
>  /libenviron.so: libenviron.so
> +/libvdso.so: libvdso.so
>  /zpool.so: zpool.so
>  /libzfs.so: libzfs.so
>  /libuutil.so: libuutil.so
> diff --git a/usr_nozfs.manifest.skel b/usr_nozfs.manifest.skel
> index a7d4731..ce051af 100644
> --- a/usr_nozfs.manifest.skel
> +++ b/usr_nozfs.manifest.skel
> @@ -1,5 +1,6 @@
>  [manifest]
>  /libenviron.so: libenviron.so
> +/libvdso.so: libvdso.so
>  /tools/mount-nfs.so: tools/mount/mount-nfs.so
>  /tools/umount.so: tools/mount/umount.so
>  /usr/lib/libgcc_s.so.1: %(gccbase)s/lib64/libgcc_s.so.1
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to