ec311ec42787a0a2d11cfa0132bb0a08a156167a
[platform/upstream/glibc.git] / ports / sysdeps / unix / sysv / linux / m68k / init-first.c
1 /* Copyright (C) 2010 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library.  If not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 /* Note: linking in vDSO to a static binary requires changes to
20    the main GLIBC proper.  Not yet implemented.  */
21 #ifdef SHARED
22
23 #include <dl-vdso.h>
24 #include <bits/m68k-vdso.h>
25
26 static inline void
27 _libc_vdso_platform_setup (void)
28 {
29   void *p;
30
31   PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
32
33   /* It may happen that rtld didn't initialize the vDSO, so fallback
34      to the syscall implementations if _dl_vdso_vsym returns NULL.
35      This may happen when a static executable dlopen's a dynamic library.
36      This really is nothing more than a workaround for rtld/csu
37      deficiency.  Ideally, init code would setup the vDSO for static
38      binaries too.  */
39
40   p = _dl_vdso_vsym ("__kernel_read_tp", &linux26);
41   if (p != NULL)
42     {
43       __vdso_read_tp = p;
44       __rtld___vdso_read_tp = p;
45     }
46   else
47     assert (__vdso_read_tp == (void *) __vdso_read_tp_stub);
48
49   p = _dl_vdso_vsym ("__kernel_atomic_cmpxchg_32", &linux26);
50   if (p != NULL)
51     {
52       __vdso_atomic_cmpxchg_32 = p;
53       __rtld___vdso_atomic_cmpxchg_32 = p;
54     }
55   else
56     assert (__vdso_atomic_cmpxchg_32
57             == (void *) __vdso_atomic_cmpxchg_32_stub);
58
59   p = _dl_vdso_vsym ("__kernel_atomic_barrier", &linux26);
60   if (p != NULL)
61     {
62       __vdso_atomic_barrier = p;
63       __rtld___vdso_atomic_barrier = p;
64     }
65   else
66     assert (__vdso_atomic_barrier == (void *) __vdso_atomic_barrier_stub);
67 }
68
69 #define VDSO_SETUP _libc_vdso_platform_setup
70
71 #endif /* SHARED */
72
73 #include <sysdeps/unix/sysv/linux/init-first.c>