summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2015-03-29 04:50:56 -0500
committerWaldemar Brodkorb <wbx@openadk.org>2015-03-29 04:50:56 -0500
commitcd5f92704e1e17bbc0c15d197f3bc236c7dc9bf2 (patch)
tree1400302b543e4528aedea5d72731983559cfcf36 /libc/sysdeps/linux/common
parentad2bffbf1926051ef333f9899344f6bddf2c03cf (diff)
parent24946289317ea23bb0d1814cca0a499a905f7d6f (diff)
merge uClibc git master
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r--libc/sysdeps/linux/common/Makefile.in1
-rw-r--r--libc/sysdeps/linux/common/bits/kernel-features.h5
-rw-r--r--libc/sysdeps/linux/common/bits/mathcalls.h23
-rw-r--r--libc/sysdeps/linux/common/bits/utmp.h4
-rw-r--r--libc/sysdeps/linux/common/bits/utmpx.h2
-rw-r--r--libc/sysdeps/linux/common/getrandom.c14
-rw-r--r--libc/sysdeps/linux/common/getrusage.c1
-rw-r--r--libc/sysdeps/linux/common/makedev.c42
-rw-r--r--libc/sysdeps/linux/common/stubs.c4
-rw-r--r--libc/sysdeps/linux/common/sys/random.h33
10 files changed, 126 insertions, 3 deletions
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index 8ee956b6b..82525984a 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -27,6 +27,7 @@ CSRC-$(UCLIBC_LINUX_SPECIFIC) += \
eventfd.c \
eventfd_read.c \
eventfd_write.c \
+ getrandom.c \
inotify.c \
ioperm.c \
iopl.c \
diff --git a/libc/sysdeps/linux/common/bits/kernel-features.h b/libc/sysdeps/linux/common/bits/kernel-features.h
index 6184c2b9d..708bb4906 100644
--- a/libc/sysdeps/linux/common/bits/kernel-features.h
+++ b/libc/sysdeps/linux/common/bits/kernel-features.h
@@ -507,3 +507,8 @@
#if defined __x86_64__ && __LINUX_KERNEL_VERSION >= 0x030100
# define __ASSUME_GETCPU_SYSCALL 1
#endif
+
+/* getrandom syscall (widely) appeared around 4.0.0 */
+#if __LINUX_KERNEL_VERSION >= 0x040000
+# define __ASSUME_GETRANDOM_SYSCALL 1
+#endif
diff --git a/libc/sysdeps/linux/common/bits/mathcalls.h b/libc/sysdeps/linux/common/bits/mathcalls.h
index 427027355..3d7e34fa2 100644
--- a/libc/sysdeps/linux/common/bits/mathcalls.h
+++ b/libc/sysdeps/linux/common/bits/mathcalls.h
@@ -74,8 +74,22 @@ __MATHCALLI (atan2,, (_Mdouble_ __y, _Mdouble_ __x))
/* Cosine of X. */
__MATHCALLI (cos,, (_Mdouble_ __x))
+# if defined _LIBC && defined _Mlong_double_
+libm_hidden_proto(cosl)
+# endif
+# if defined _LIBC && defined _Mfloat_
+libm_hidden_proto(cosf)
+# endif
+
/* Sine of X. */
__MATHCALLI (sin,, (_Mdouble_ __x))
+# if defined _LIBC && defined _Mlong_double_
+libm_hidden_proto(sinl)
+# endif
+# if defined _LIBC && defined _Mfloat_
+libm_hidden_proto(sinf)
+# endif
+
/* Tangent of X. */
__MATHCALLI (tan,, (_Mdouble_ __x))
@@ -111,6 +125,9 @@ __END_NAMESPACE_C99
_Mdouble_BEGIN_NAMESPACE
/* Exponential function of X. */
__MATHCALLI (exp,, (_Mdouble_ __x))
+# if defined _LIBC && defined _Mlong_double_
+libm_hidden_proto(expl)
+# endif
/* Break VALUE into a normalized fraction and an integral power of 2. */
__MATHCALLI (frexp,, (_Mdouble_ __x, int *__exponent))
@@ -173,6 +190,9 @@ _Mdouble_END_NAMESPACE
__BEGIN_NAMESPACE_C99
/* Return `sqrt(X*X + Y*Y)'. */
__MATHCALLI (hypot,, (_Mdouble_ __x, _Mdouble_ __y))
+# if defined _LIBC && defined _Mlong_double_
+libm_hidden_proto(hypotl)
+# endif
__END_NAMESPACE_C99
#endif
@@ -300,6 +320,9 @@ __MATHCALLI (rint,, (_Mdouble_ __x))
/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__))
+# if defined _LIBC && defined _Mlong_double_
+libm_hidden_proto(nextafterl)
+# endif
# if defined __USE_ISOC99 && !defined __LDBL_COMPAT
# ifndef _Mdouble_is_float_
__MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__))
diff --git a/libc/sysdeps/linux/common/bits/utmp.h b/libc/sysdeps/linux/common/bits/utmp.h
index c13380ab8..6ece31e34 100644
--- a/libc/sysdeps/linux/common/bits/utmp.h
+++ b/libc/sysdeps/linux/common/bits/utmp.h
@@ -36,7 +36,7 @@
previous logins. */
struct lastlog
{
-#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
+#ifdef __WORDSIZE_TIME64_COMPAT32
int32_t ll_time;
#else
__time_t ll_time;
@@ -69,7 +69,7 @@ struct utmp
/* The ut_session and ut_tv fields must be the same size when compiled
32- and 64-bit. This allows data files and shared memory to be
shared between 32- and 64-bit applications. */
-#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
+#ifdef __WORDSIZE_TIME64_COMPAT32
int32_t ut_session; /* Session ID, used for windowing. */
struct
{
diff --git a/libc/sysdeps/linux/common/bits/utmpx.h b/libc/sysdeps/linux/common/bits/utmpx.h
index 87626f085..815fc90b8 100644
--- a/libc/sysdeps/linux/common/bits/utmpx.h
+++ b/libc/sysdeps/linux/common/bits/utmpx.h
@@ -66,7 +66,7 @@ struct utmpx
/* The fields ut_session and ut_tv must be the same size when compiled
32- and 64-bit. This allows files and shared memory to be shared
between 32- and 64-bit applications. */
-#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
+#ifdef __WORDSIZE_TIME64_COMPAT32
__int32_t ut_session; /* Session ID, used for windowing. */
struct
{
diff --git a/libc/sysdeps/linux/common/getrandom.c b/libc/sysdeps/linux/common/getrandom.c
new file mode 100644
index 000000000..d33d5224a
--- /dev/null
+++ b/libc/sysdeps/linux/common/getrandom.c
@@ -0,0 +1,14 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * getrandom() for uClibc
+ *
+ * Copyright (C) 2015 Bernhard Reutner-Fischer
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/random.h>
+#ifdef __NR_getrandom
+_syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags)
+#endif
diff --git a/libc/sysdeps/linux/common/getrusage.c b/libc/sysdeps/linux/common/getrusage.c
index 3e719f294..fb7614be8 100644
--- a/libc/sysdeps/linux/common/getrusage.c
+++ b/libc/sysdeps/linux/common/getrusage.c
@@ -10,4 +10,5 @@
#include <sys/syscall.h>
#include <unistd.h>
#include <wait.h>
+#include <sys/resource.h>
_syscall2(int, getrusage, __rusage_who_t, who, struct rusage *, usage)
diff --git a/libc/sysdeps/linux/common/makedev.c b/libc/sysdeps/linux/common/makedev.c
new file mode 100644
index 000000000..d7761671b
--- /dev/null
+++ b/libc/sysdeps/linux/common/makedev.c
@@ -0,0 +1,42 @@
+/* Definitions of functions to access `dev_t' values.
+ Copyright (C) 2003-2015 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 <endian.h>
+#include <sys/sysmacros.h>
+
+unsigned int
+gnu_dev_major (unsigned long long int dev)
+{
+ return ((dev >> 8) & 0xfff) | ((unsigned int) (dev >> 32) & ~0xfff);
+}
+libc_hidden_def(gnu_dev_major)
+
+unsigned int
+gnu_dev_minor (unsigned long long int dev)
+{
+ return (dev & 0xff) | ((unsigned int) (dev >> 12) & ~0xff);
+}
+libc_hidden_def(gnu_dev_minor)
+
+unsigned long long int
+gnu_dev_makedev (unsigned int major, unsigned int minor)
+{
+ return ((minor & 0xff) | ((major & 0xfff) << 8)
+ | (((unsigned long long int) (minor & ~0xff)) << 12)
+ | (((unsigned long long int) (major & ~0xfff)) << 32));
+}
diff --git a/libc/sysdeps/linux/common/stubs.c b/libc/sysdeps/linux/common/stubs.c
index 2c50307aa..19a33714a 100644
--- a/libc/sysdeps/linux/common/stubs.c
+++ b/libc/sysdeps/linux/common/stubs.c
@@ -157,6 +157,10 @@ make_stub(getpeername)
make_stub(getpgrp)
#endif
+#if !defined __NR_getrandom && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(getrandom)
+#endif
+
#if !defined __NR_getsockname && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
make_stub(getsockname)
#endif
diff --git a/libc/sysdeps/linux/common/sys/random.h b/libc/sysdeps/linux/common/sys/random.h
new file mode 100644
index 000000000..42f802576
--- /dev/null
+++ b/libc/sysdeps/linux/common/sys/random.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 2015 Bernhard Reutner-Fischer
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+*/
+
+#ifndef _SYS_RANDOM_H
+#define _SYS_RANDOM_H 1
+#include <features.h>
+
+__BEGIN_DECLS
+
+#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
+# if 0 /*def __ASSUME_GETRANDOM_SYSCALL */
+# include <linux/random.h>
+# else
+# undef GRND_NONBLOCK
+# undef GRND_RANDOM
+/*
+ * Flags for getrandom(2)
+ *
+ * GRND_NONBLOCK Don't block and return EAGAIN instead
+ * GRND_RANDOM Use the /dev/random pool instead of /dev/urandom
+ */
+# define GRND_NONBLOCK 0x0001
+# define GRND_RANDOM 0x0002
+# endif
+/* FIXME: aren't there a couple of __restrict and const missing ? */
+extern int getrandom(void *__buf, size_t count, unsigned int flags)
+ __nonnull ((1)) __wur;
+#endif
+
+__END_DECLS
+
+#endif /* sys/random.h */