From 21cbb6fe887a30f0777521ec10f0d0d9c2a7da7e Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Fri, 13 Mar 2015 21:03:10 +0100 Subject: unistd.h: put getppid under XOPEN2K8 Add __LEAF to all __THROW, introduce non-leaf __THROWNL Adjust affected spots accordingly. Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/common/getrusage.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libc/sysdeps') 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 #include #include +#include _syscall2(int, getrusage, __rusage_who_t, who, struct rusage *, usage) -- cgit v1.2.3 From 75d9bf2dc57f89532a25ab9942b8bea468585199 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Tue, 17 Mar 2015 20:54:58 +0100 Subject: include: silence __leaf warning Signed-off-by: Bernhard Reutner-Fischer --- include/sys/sysmacros.h | 29 +++++++++++++------------ libc/sysdeps/linux/common/makedev.c | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 libc/sysdeps/linux/common/makedev.c (limited to 'libc/sysdeps') diff --git a/include/sys/sysmacros.h b/include/sys/sysmacros.h index 7a5635edd..3addb7500 100644 --- a/include/sys/sysmacros.h +++ b/include/sys/sysmacros.h @@ -21,35 +21,39 @@ #include +__BEGIN_DECLS + /* If the compiler does not know long long it is out of luck. We are not going to hack weird hacks to support the dev_t representation they need. */ -#if 1 /*def __GLIBC_HAVE_LONG_LONG uClibc note: always enable */ + __extension__ -static __inline unsigned int gnu_dev_major (unsigned long long int __dev) - __THROW; +extern unsigned int gnu_dev_major (unsigned long long int __dev) + __THROW __attribute__ ((__const__)); +libc_hidden_proto(gnu_dev_major) __extension__ -static __inline unsigned int gnu_dev_minor (unsigned long long int __dev) - __THROW; +extern unsigned int gnu_dev_minor (unsigned long long int __dev) + __THROW __attribute__ ((__const__)); +libc_hidden_proto(gnu_dev_minor) __extension__ -static __inline unsigned long long int gnu_dev_makedev (unsigned int __major, +extern unsigned long long int gnu_dev_makedev (unsigned int __major, unsigned int __minor) - __THROW; + __THROW __attribute__ ((__const__)); -# if defined __GNUC__ && __GNUC__ >= 2 -__extension__ static __inline unsigned int +# ifdef __USE_EXTERN_INLINES +__extension__ __extern_inline __attribute__ ((__const__)) unsigned int __NTH (gnu_dev_major (unsigned long long int __dev)) { return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff); } -__extension__ static __inline unsigned int +__extension__ __extern_inline __attribute__ ((__const__)) unsigned int __NTH (gnu_dev_minor (unsigned long long int __dev)) { return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff); } -__extension__ static __inline unsigned long long int +__extension__ __extern_inline __attribute__ ((__const__)) unsigned long long int __NTH (gnu_dev_makedev (unsigned int __major, unsigned int __minor)) { return ((__minor & 0xff) | ((__major & 0xfff) << 8) @@ -57,12 +61,11 @@ __NTH (gnu_dev_makedev (unsigned int __major, unsigned int __minor)) | (((unsigned long long int) (__major & ~0xfff)) << 32)); } # endif - +__END_DECLS /* Access the functions with their traditional names. */ # define major(dev) gnu_dev_major (dev) # define minor(dev) gnu_dev_minor (dev) # define makedev(maj, min) gnu_dev_makedev (maj, min) -#endif #endif /* sys/sysmacros.h */ 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 + . */ + +#include +#include + +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)); +} -- cgit v1.2.3 From 6c4538905e65ceb203f59aaa9a61728e81c6bc0a Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Wed, 18 Mar 2015 22:32:22 +0100 Subject: libm: Add missing C99 float/ld wrappers Signed-off-by: Bernhard Reutner-Fischer --- TODO | 1 + include/complex.h | 2 + include/math.h | 2 + libc/sysdeps/linux/common/bits/mathcalls.h | 23 +++++++++++ libm/Makefile.in | 41 +++++++++++++++++--- libm/float_wrappers.c | 62 ++++++++++++++++++++---------- libm/ldouble_wrappers.c | 58 ++++++++++++++++++++++++++-- libm/s_fdim.c | 17 ++++++-- libm/s_fmax.c | 6 +-- libm/s_fmin.c | 6 +-- libm/s_nextafter.c | 4 +- test/math/compile_test.c | 20 +++++----- test/math/libm-test.inc | 56 ++++++++++++--------------- 13 files changed, 216 insertions(+), 82 deletions(-) (limited to 'libc/sysdeps') diff --git a/TODO b/TODO index c6ad7bfb5..5f897b74f 100644 --- a/TODO +++ b/TODO @@ -93,6 +93,7 @@ TODO list for the uClibc 1.0.0 release: ugetrlimit, it seems, else use the modern variant) *) simplify exec*() in the light of execvpe (perhaps single internal impl); USE_GNU for execvpe (and other GNU extensions, see psm). + *) Remove unused math complex hidden protos throughout TODO list for AFTER the uClibc 1.0.0 release: diff --git a/include/complex.h b/include/complex.h index 91efc0d2b..ed7e502b7 100644 --- a/include/complex.h +++ b/include/complex.h @@ -79,6 +79,7 @@ __BEGIN_DECLS #endif #include #undef _Mdouble_ +#undef _Mfloat_ #undef __MATH_PRECNAME /* And the long double versions. It is non-critical to define them @@ -97,6 +98,7 @@ __BEGIN_DECLS # include #endif #undef _Mdouble_ +#undef _Mlong_double_ #undef __MATH_PRECNAME #undef __MATHDECL_1 #undef __MATHDECL diff --git a/include/math.h b/include/math.h index ecb9aa6f6..1b54c9ee9 100644 --- a/include/math.h +++ b/include/math.h @@ -129,6 +129,7 @@ __BEGIN_DECLS # undef _Mdouble_ # undef _Mdouble_BEGIN_NAMESPACE # undef _Mdouble_END_NAMESPACE +# undef _Mfloat_ # undef __MATH_PRECNAME # undef __MATH_maybe_libm_hidden_proto @@ -176,6 +177,7 @@ extern long double __REDIRECT_NTH (nexttowardl, (long double __x, long double __ # undef _Mdouble_ # undef _Mdouble_BEGIN_NAMESPACE # undef _Mdouble_END_NAMESPACE +# undef _Mlong_double_ # undef __MATH_PRECNAME # undef __MATH_maybe_libm_hidden_proto diff --git a/libc/sysdeps/linux/common/bits/mathcalls.h b/libc/sysdeps/linux/common/bits/mathcalls.h index 84b793c96..9bebb5190 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 @@ -298,6 +318,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 __MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__)) # endif diff --git a/libm/Makefile.in b/libm/Makefile.in index 751170678..d886cdbc5 100644 --- a/libm/Makefile.in +++ b/libm/Makefile.in @@ -75,9 +75,6 @@ libm_CSRC := \ s_remquo.c w_exp2.c \ cexp.c sincos.c -# Not implemented [yet?], see comment in float_wrappers.c: -# fdimf.o fmaf.o fmaxf.o fminf.o -# nearbyintf.o remquof.o scalblnf.o tgammaf.o FL_MOBJ := \ acosf.o \ acoshf.o \ @@ -98,7 +95,11 @@ FL_MOBJ := \ expf.o \ expm1f.o \ fabsf.o \ + fdimf.o \ floorf.o \ + fmaf.o \ + fmaxf.o \ + fminf.o \ fmodf.o \ frexpf.o \ gammaf.o \ @@ -116,11 +117,14 @@ FL_MOBJ := \ lrintf.o \ lroundf.o \ modff.o \ + nearbyintf.o \ + nexttowardf.o \ powf.o \ remainderf.o \ + remquof.o \ rintf.o \ roundf.o \ - scalbf.o \ + scalblnf.o \ scalbnf.o \ significandf.o \ sinf.o \ @@ -128,9 +132,24 @@ FL_MOBJ := \ sqrtf.o \ tanf.o \ tanhf.o \ + tgammaf.o \ truncf.o \ -# Not implemented [yet?]: nexttowardl.o +ifeq ($(UCLIBC_SUSV3_LEGACY),y) +FL_MOBJ += scalbf.o +endif + +# Do not (yet?) implement the float variants of bessel functions +ifeq (not-yet-implemented-$(DO_XSI_MATH),y) +FL_MOBJ += \ + j0f.o \ + j1f.o \ + jnf.o \ + y0f.o \ + y1f.o \ + ynf.o +endif + LD_MOBJ := \ __finitel.o \ __fpclassifyl.o \ @@ -180,6 +199,7 @@ LD_MOBJ := \ modfl.o \ nearbyintl.o \ nextafterl.o \ + nexttowardl.o \ powl.o \ remainderl.o \ remquol.o \ @@ -196,6 +216,17 @@ LD_MOBJ := \ tgammal.o \ truncl.o \ +# Do not (yet?) implement the long double variants of bessel functions +ifeq (not-yet-implemented-$(DO_XSI_MATH),y) +LD_MOBJ += \ + j0l.o \ + j1l.o \ + jnl.o \ + y0l.o \ + y1l.o \ + ynl.o +endif + else # This list of math functions was taken from POSIX/IEEE 1003.1b-1993 diff --git a/libm/float_wrappers.c b/libm/float_wrappers.c index 82b7963e1..105486e46 100644 --- a/libm/float_wrappers.c +++ b/libm/float_wrappers.c @@ -38,19 +38,14 @@ long long func##f (float x) \ return func((double)x); \ } - -/* For the time being, do _NOT_ implement these functions - * that are defined by SuSv3 [because we don't need them - * and nobody asked to include them] */ -#undef L_fdimf /*float fdimf(float, float);*/ -#undef L_fmaf /*float fmaf(float, float, float);*/ -#undef L_fmaxf /*float fmaxf(float, float);*/ -#undef L_fminf /*float fminf(float, float);*/ -#undef L_nearbyintf /*float nearbyintf(float);*/ -#undef L_nexttowardf /*float nexttowardf(float, long double);*/ -#undef L_remquof /*float remquof(float, float, int *);*/ -#undef L_scalblnf /*float scalblnf(float, long);*/ -#undef L_tgammaf /*float tgammaf(float);*/ +#ifndef __DO_XSI_MATH__ +# undef L_j0f /* float j0f(float x); */ +# undef L_j1f /* float j1f(float x); */ +# undef L_jnf /* float jnf(int n, float x); */ +# undef L_y0f /* float y0f(float x); */ +# undef L_y1f /* float y1f(float x); */ +# undef L_ynf /* float ynf(int n, float x); */ +#endif /* Implement the following, as defined by SuSv3 */ #if 0 @@ -155,6 +150,7 @@ float copysignf (float x, float y) #ifdef L_cosf WRAPPER1(cos) +libm_hidden_def(cosf) #endif #ifdef L_coshf @@ -242,6 +238,21 @@ float hypotf (float x, float y) int_WRAPPER1(ilogb) #endif +#ifdef L_j0f +WRAPPER1(j0) +#endif + +#ifdef L_j1f +WRAPPER1(j1) +#endif + +#ifdef L_jnf +float jnf(int n, float x) +{ + return (float) jn(n, (double)x); +} +#endif + #ifdef L_ldexpf float ldexpf (float x, int _exp) { @@ -306,7 +317,7 @@ WRAPPER1(nearbyint) #ifdef L_nexttowardf float nexttowardf (float x, long double y) { - return (float) nexttoward( (double)x, (double)y ); + return (float) nexttoward( (double)x, (long double)y ); } #endif @@ -355,6 +366,7 @@ float scalbnf (float x, int _exp) #ifdef L_sinf WRAPPER1(sin) +libm_hidden_def(sinf) #endif #ifdef L_sinhf @@ -381,13 +393,6 @@ WRAPPER1(tgamma) WRAPPER1(trunc) #endif -#ifdef L_fmaf -float fmaf (float x, float y, float z) -{ - return (float) fma( (double)x, (double)y, (double)z ); -} -#endif - #if defined L_scalbf && defined __UCLIBC_SUSV3_LEGACY__ float scalbf (float x, float y) { @@ -402,3 +407,18 @@ WRAPPER1(gamma) #ifdef L_significandf WRAPPER1(significand) #endif + +#ifdef L_y0f +WRAPPER1(y0) +#endif + +#ifdef L_y1f +WRAPPER1(y1) +#endif + +#ifdef L_ynf +float ynf(int n, float x) +{ + return (float) yn(n, (double)x); +} +#endif diff --git a/libm/ldouble_wrappers.c b/libm/ldouble_wrappers.c index 118a78f64..b4215cbf3 100644 --- a/libm/ldouble_wrappers.c +++ b/libm/ldouble_wrappers.c @@ -42,6 +42,15 @@ long long func##l(long double x) \ return func((double) x); \ } +#ifndef __DO_XSI_MATH__ +# undef L_j0l /* long double j0l(long double x); */ +# undef L_j1l /* long double j1l(long double x); */ +# undef L_jnl /* long double jnl(int n, long double x); */ +# undef L_y0l /* long double y0l(long double x); */ +# undef L_y1l /* long double y1l(long double x); */ +# undef L_ynl /* long double ynl(int n, long double x); */ +#endif + /* Implement the following, as defined by SuSv3 */ #if 0 long double acoshl(long double); @@ -156,6 +165,7 @@ WRAPPER1(cosh) #ifdef L_cosl WRAPPER1(cos) +libm_hidden_def(cosl) #endif #ifdef L_erfcl @@ -172,6 +182,7 @@ WRAPPER1(exp2) #ifdef L_expl WRAPPER1(exp) +libm_hidden_def(expl) #endif #ifdef L_expm1l @@ -222,12 +233,28 @@ WRAPPER1(gamma) #ifdef L_hypotl WRAPPER2(hypot) +libm_hidden_def(hypotl) #endif #ifdef L_ilogbl int_WRAPPER1(ilogb) #endif +#ifdef L_j0l + WRAPPER1(j0) +#endif + +#ifdef L_j1l + WRAPPER1(j1) +#endif + +#ifdef L_jnl +long double jnl(int n, long double x) +{ + return (long double) jn(n, (double)x); +} +#endif + #ifdef L_ldexpl long double ldexpl (long double x, int ex) { @@ -291,12 +318,18 @@ WRAPPER1(nearbyint) #ifdef L_nextafterl WRAPPER2(nextafter) +libm_hidden_def(nextafterl) #endif -/* Disabled in Makefile.in */ -#if 0 /* def L_nexttowardl */ -WRAPPER2(nexttoward) -libm_hidden_def(nexttowardl) +#ifdef L_nexttowardl +# if 0 /* TODO */ +strong_alias(nextafterl, nexttowardl) +# else +long double nexttowardl(long double x, long double y) +{ + return nextafterl(x, y); +} +#endif #endif #ifdef L_powl @@ -344,6 +377,7 @@ WRAPPER1(sinh) #ifdef L_sinl WRAPPER1(sin) +libm_hidden_def(sinl) #endif #ifdef L_sqrtl @@ -370,6 +404,22 @@ WRAPPER1(trunc) WRAPPER1(significand) #endif +#ifdef L_y0l +WRAPPER1(y0) +#endif + +#ifdef L_y1l +WRAPPER1(y1) +#endif + +#ifdef L_ynl +long double ynl(int n, long double x) +{ + return (long double) yn(n, (double)x); +} +#endif + + #if defined __DO_C99_MATH__ && !defined __NO_LONG_DOUBLE_MATH # ifdef L___fpclassifyl diff --git a/libm/s_fdim.c b/libm/s_fdim.c index 6249219c8..6ed695c3d 100644 --- a/libm/s_fdim.c +++ b/libm/s_fdim.c @@ -6,13 +6,22 @@ #include "math.h" #include "math_private.h" +#include double fdim(double x, double y) { - int c = __fpclassify(x); - if (c == FP_NAN || c == FP_INFINITE) - return HUGE_VAL; + int cx = __fpclassify(x); /* need both NAN and INF */ + int cy = __fpclassify(y); /* need both NAN and INF */ + if (cx == FP_NAN || cy == NAN) + return x - y; - return x > y ? x - y : 0.0; + if (x <= y) + return .0; + + double z = x - y; + if (isinf(z) && cx != FP_INFINITE && cy != FP_INFINITE) + __set_errno(ERANGE); + + return z; } libm_hidden_def(fdim) diff --git a/libm/s_fmax.c b/libm/s_fmax.c index 21dfaa981..5f29ad8e3 100644 --- a/libm/s_fmax.c +++ b/libm/s_fmax.c @@ -9,10 +9,10 @@ double fmax(double x, double y) { - if (__fpclassify(x) == FP_NAN) - return x; - if (__fpclassify(y) == FP_NAN) + if (isnan(x)) return y; + if (isnan(y)) + return x; return x > y ? x : y; } diff --git a/libm/s_fmin.c b/libm/s_fmin.c index 674d9a56b..a549678ee 100644 --- a/libm/s_fmin.c +++ b/libm/s_fmin.c @@ -9,10 +9,10 @@ double fmin(double x, double y) { - if (__fpclassify(x) == FP_NAN) - return x; - if (__fpclassify(y) == FP_NAN) + if (isnan(x)) return y; + if (isnan(y)) + return x; return x < y ? x : y; } diff --git a/libm/s_nextafter.c b/libm/s_nextafter.c index ee4621cc7..73a8ab2be 100644 --- a/libm/s_nextafter.c +++ b/libm/s_nextafter.c @@ -32,7 +32,7 @@ double nextafter(double x, double y) if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || /* x is nan */ ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) /* y is nan */ return x+y; - if(x==y) return x; /* x=y, return x */ + if(x==y) return y; /* x=y, return y */ if((ix|lx)==0) { /* x == 0 */ INSERT_WORDS(x,hy&0x80000000,1); /* return +-minsubnormal */ y = x*x; @@ -68,3 +68,5 @@ double nextafter(double x, double y) return x; } libm_hidden_def(nextafter) +strong_alias_untyped(nextafter, nexttoward) +libm_hidden_def(nexttoward) diff --git a/test/math/compile_test.c b/test/math/compile_test.c index ab8c40c48..aedfde601 100644 --- a/test/math/compile_test.c +++ b/test/math/compile_test.c @@ -22,11 +22,11 @@ r += exp2f(float_x); r += expf(float_x); r += expm1f(float_x); r += fabsf(float_x); -/*r += fdimf(float_x, float_x); - uclibc does not have it (yet?) */ +r += fdimf(float_x, float_x); r += floorf(float_x); -/*r += fmaf(float_x, float_x, float_x); - uclibc does not have it (yet?) */ -/*r += fmaxf(float_x, float_x); - uclibc does not have it (yet?) */ -/*r += fminf(float_x, float_x); - uclibc does not have it (yet?) */ +r += fmaf(float_x, float_x, float_x); +r += fmaxf(float_x, float_x); +r += fminf(float_x, float_x); r += fmodf(float_x, float_x); r += frexpf(float_x, &int_x); r += gammaf(float_x); @@ -44,17 +44,17 @@ r += logf(float_x); r += lrintf(float_x); r += lroundf(float_x); r += modff(float_x, &float_x); -/*r += nearbyintf(float_x); - uclibc does not have it (yet?) */ -/*r += nexttowardf(float_x, long_double_x); - uclibc does not have it (yet?) */ +r += nearbyintf(float_x); +r += nexttowardf(float_x, long_double_x); r += powf(float_x, float_x); r += remainderf(float_x, float_x); -/*r += remquof(float_x, float_x, &int_x); - uclibc does not have it (yet?) */ +r += remquof(float_x, float_x, &int_x); r += rintf(float_x); r += roundf(float_x); #ifdef __UCLIBC_SUSV3_LEGACY__ r += scalbf(float_x, float_x); #endif -/*r += scalblnf(float_x, long_x); - uclibc does not have it (yet?) */ +r += scalblnf(float_x, long_x); r += scalbnf(float_x, int_x); r += significandf(float_x); r += sinf(float_x); @@ -62,7 +62,7 @@ r += sinhf(float_x); r += sqrtf(float_x); r += tanf(float_x); r += tanhf(float_x); -/*r += tgammaf(float_x); - uclibc does not have it (yet?) */ +r += tgammaf(float_x); r += truncf(float_x); return r; } @@ -116,7 +116,7 @@ r += lroundl(long_double_x); r += modfl(long_double_x, &long_double_x); r += nearbyintl(long_double_x); r += nextafterl(long_double_x, long_double_x); -/* r += nexttowardl(long_double_x, long_double_x); - uclibc doesn't provide this [yet?] */ +r += nexttowardl(long_double_x, long_double_x); r += powl(long_double_x, long_double_x); r += remainderl(long_double_x, long_double_x); r += remquol(long_double_x, long_double_x, &int_x); diff --git a/test/math/libm-test.inc b/test/math/libm-test.inc index d0f0a0c30..8f0db3c88 100644 --- a/test/math/libm-test.inc +++ b/test/math/libm-test.inc @@ -115,6 +115,9 @@ # define _GNU_SOURCE #endif +#undef __CHK_COMPLEX_STUFF +#define __CHK_COMPLEX_STUFF 0 + #include "libm-test-ulps.h" #include #include @@ -1120,8 +1123,10 @@ cacosh_test (void) END (cacosh, complex); } +#endif +#if __CHK_COMPLEX_STUFF static void carg_test (void) { @@ -1188,7 +1193,9 @@ carg_test (void) END (carg); } +#endif /* __CHK_COMPLEX_STUFF */ +#if 0 static void casin_test (void) { @@ -1683,7 +1690,7 @@ ceil_test (void) } -#if 0 +#if __CHK_COMPLEX_STUFF static void cexp_test (void) { @@ -1746,8 +1753,9 @@ cexp_test (void) END (cexp, complex); } +#endif /* __CHK_COMPLEX_STUFF */ - +#if 0 static void cimag_test (void) { @@ -2588,7 +2596,6 @@ fabs_test (void) } -#if 0 static void fdim_test (void) { @@ -2624,7 +2631,6 @@ fdim_test (void) END (fdim); } -#endif static void @@ -2694,7 +2700,6 @@ floor_test (void) } -#if 0 static void fma_test (void) { @@ -2797,7 +2802,6 @@ fmin_test (void) END (fmin); } -#endif static void @@ -3002,7 +3006,7 @@ isnormal_test (void) END (isnormal); } -#if defined __DO_XSI_MATH__ +#if defined __DO_XSI_MATH__ && !(defined TEST_LDOUBLE || defined TEST_FLOAT) static void j0_test (void) { @@ -3629,7 +3633,6 @@ modf_test (void) } -#if 0 static void nearbyint_test (void) { @@ -3710,7 +3713,6 @@ nexttoward_test (void) END (nexttoward); } -#endif static void @@ -3950,7 +3952,6 @@ remainder_test (void) END (remainder); } -#if 0 static void remquo_test (void) { @@ -3981,7 +3982,6 @@ remquo_test (void) END (remquo); } -#endif static void rint_test (void) @@ -4229,12 +4229,12 @@ round_test (void) #endif +#ifdef __UCLIBC_SUSV3_LEGACY__ static void scalb_test (void) { START (scalb); #ifndef TEST_LDOUBLE /* uclibc doesn't have scalbl */ -#ifdef __UCLIBC_SUSV3_LEGACY__ /* scalbf is susv3 legacy */ TEST_ff_f (scalb, 2.0, 0.5, nan_value, INVALID_EXCEPTION); TEST_ff_f (scalb, 3.0, -2.5, nan_value, INVALID_EXCEPTION); @@ -4285,11 +4285,10 @@ scalb_test (void) TEST_ff_f (scalb, 0.8L, 4, 12.8L); TEST_ff_f (scalb, -0.854375L, 5, -27.34L); -#endif /* __UCLIBC_SUSV3_LEGACY__ */ #endif /* TEST_LDOUBLE */ END (scalb); } - +#endif static void scalbn_test (void) @@ -4313,7 +4312,6 @@ scalbn_test (void) } -#if 0 static void scalbln_test (void) { @@ -4334,7 +4332,6 @@ scalbln_test (void) END (scalbn); } -#endif static void @@ -4539,7 +4536,6 @@ tanh_test (void) END (tanh); } -#if 0 static void tgamma_test (void) { @@ -4571,7 +4567,6 @@ tgamma_test (void) END (tgamma); } -#endif #if 0 @@ -4651,7 +4646,7 @@ trunc_test (void) } #endif -#if defined __DO_XSI_MATH__ +#if defined __DO_XSI_MATH__ && !(defined TEST_LDOUBLE || defined TEST_FLOAT) static void y0_test (void) { @@ -4979,11 +4974,11 @@ main (int argc, char **argv) logb_test (); modf_test (); ilogb_test (); +#ifdef __UCLIBC_SUSV3_LEGACY__ scalb_test (); +#endif scalbn_test (); -#if 0 scalbln_test (); -#endif significand_test (); /* Power and absolute value functions: */ @@ -4998,16 +4993,12 @@ main (int argc, char **argv) erfc_test (); gamma_test (); lgamma_test (); -#if 0 tgamma_test (); -#endif /* Nearest integer functions: */ ceil_test (); floor_test (); -#if 0 nearbyint_test (); -#endif rint_test (); #if 0 rint_test_tonearest (); @@ -5025,13 +5016,10 @@ main (int argc, char **argv) /* Remainder functions: */ fmod_test (); remainder_test (); -#if 0 remquo_test (); -#endif /* Manipulation functions: */ copysign_test (); -#if 0 nextafter_test (); nexttoward_test (); @@ -5043,24 +5031,29 @@ main (int argc, char **argv) /* Multiply and add: */ fma_test (); + /* Complex functions: */ cabs_test (); +#if __CHK_COMPLEX_STUFF +#if 0 cacos_test (); cacosh_test (); +#endif carg_test (); +#if 0 casin_test (); casinh_test (); catan_test (); catanh_test (); ccos_test (); ccosh_test (); +#endif cexp_test (); +#if 0 cimag_test (); clog10_test (); clog_test (); -#if 0 conj_test (); -#endif cpow_test (); cproj_test (); creal_test (); @@ -5070,9 +5063,10 @@ main (int argc, char **argv) ctan_test (); ctanh_test (); #endif +#endif /* __CHK_COMPLEX_STUFF */ /* Bessel functions: */ -#if defined __DO_XSI_MATH__ +#if defined __DO_XSI_MATH__ && !(defined TEST_LDOUBLE || defined TEST_FLOAT) j0_test (); j1_test (); jn_test (); -- cgit v1.2.3 From bfb988452cc66ddf93f69a199c50ea1c14e9ccb7 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sat, 23 Jun 2012 14:21:17 -0700 Subject: nptl/arm: Move aeabi_read_tp to uclibc_nonshared.a Otherwise it creates wrong references from shared libs Signed-off-by: Khem Raj Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/arm/Makefile.arch | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libc/sysdeps') diff --git a/libc/sysdeps/linux/arm/Makefile.arch b/libc/sysdeps/linux/arm/Makefile.arch index 3054273df..cda3db206 100644 --- a/libc/sysdeps/linux/arm/Makefile.arch +++ b/libc/sysdeps/linux/arm/Makefile.arch @@ -13,7 +13,9 @@ SSRC-y := \ vfork.S clone.S SSRC-$(UCLIBC_HAS_LFS) += mmap64.S -SSRC-$(UCLIBC_HAS_THREADS_NATIVE) += libc-aeabi_read_tp.S libc-thumb_atomics.S +SSRC-$(UCLIBC_HAS_THREADS_NATIVE) += libc-thumb_atomics.S +libc-nonshared-$(UCLIBC_HAS_THREADS_NATIVE) += $(ARCH_OUT)/libc-aeabi_read_tp.os +libc-static-$(UCLIBC_HAS_THREADS_NATIVE) += $(ARCH_OUT)/libc-aeabi_read_tp.o CSRC-$(UCLIBC_HAS_CONTEXT_FUNCS) += makecontext.c SSRC-$(UCLIBC_HAS_CONTEXT_FUNCS) += getcontext.S setcontext.S swapcontext.S -- cgit v1.2.3 From 09ff424905d5de0b2a21a3960d9756a90b07ba26 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Sun, 22 Mar 2015 14:47:29 +0100 Subject: libc: add getrandom(2) Introduce a for it. /* 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; Signed-off-by: Bernhard Reutner-Fischer --- Makefile.in | 1 + extra/Configs/Config.in | 2 +- libc/sysdeps/linux/common/Makefile.in | 1 + libc/sysdeps/linux/common/bits/kernel-features.h | 5 ++++ libc/sysdeps/linux/common/getrandom.c | 14 ++++++++++ libc/sysdeps/linux/common/stubs.c | 4 +++ libc/sysdeps/linux/common/sys/random.h | 33 ++++++++++++++++++++++++ 7 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 libc/sysdeps/linux/common/getrandom.c create mode 100644 libc/sysdeps/linux/common/sys/random.h (limited to 'libc/sysdeps') diff --git a/Makefile.in b/Makefile.in index 5d60ddaba..a64fec956 100644 --- a/Makefile.in +++ b/Makefile.in @@ -310,6 +310,7 @@ HEADERS_RM-$(UCLIBC_LINUX_SPECIFIC) += \ sys/perm.h \ sys/personality.h \ sys/prctl.h \ + sys/random.h \ sys/reboot.h \ sys/sendfile.h \ bits/signalfd.h \ diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index f5210cdf9..35c1cee9a 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -1025,7 +1025,7 @@ config UCLIBC_LINUX_SPECIFIC help accept4(), bdflush(), capget(), capset(), eventfd(), fallocate(), - fstatfs(), inotify_*(), ioperm(), iopl(), + fstatfs(), getrandom(), inotify_*(), ioperm(), iopl(), madvise(), modify_ldt(), pipe2(), personality(), prctl()/arch_prctl(), pivot_root(), modify_ldt(), ppoll(), readahead(), reboot(), remap_file_pages(), 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/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 +#include +#ifdef __NR_getrandom +_syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags) +#endif 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 + +__BEGIN_DECLS + +#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU +# if 0 /*def __ASSUME_GETRANDOM_SYSCALL */ +# include +# 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 */ -- cgit v1.2.3 From eee76e42f32f90af4e64a254810fcb767297fecf Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Tue, 24 Mar 2015 00:11:15 +0100 Subject: libc: TIME64_COMPAT32 for sparc, mips Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/common/bits/utmp.h | 4 ++-- libc/sysdeps/linux/common/bits/utmpx.h | 2 +- libc/sysdeps/linux/mips/bits/wordsize.h | 3 +++ libc/sysdeps/linux/powerpc/bits/wordsize.h | 2 +- libc/sysdeps/linux/sparc/bits/wordsize.h | 1 + libc/sysdeps/linux/x86_64/bits/wordsize.h | 9 ++++++--- libutil/logout.c | 2 +- libutil/logwtmp.c | 2 +- 8 files changed, 16 insertions(+), 9 deletions(-) (limited to 'libc/sysdeps') 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/mips/bits/wordsize.h b/libc/sysdeps/linux/mips/bits/wordsize.h index 39e15062c..fe130806c 100644 --- a/libc/sysdeps/linux/mips/bits/wordsize.h +++ b/libc/sysdeps/linux/mips/bits/wordsize.h @@ -16,3 +16,6 @@ . */ #define __WORDSIZE _MIPS_SZPTR +#if _MIPS_SIM == _ABI64 +# define __WORDSIZE_TIME64_COMPAT32 1 +#endif diff --git a/libc/sysdeps/linux/powerpc/bits/wordsize.h b/libc/sysdeps/linux/powerpc/bits/wordsize.h index cf934234f..3e8a1e0a1 100644 --- a/libc/sysdeps/linux/powerpc/bits/wordsize.h +++ b/libc/sysdeps/linux/powerpc/bits/wordsize.h @@ -2,7 +2,7 @@ #if defined __powerpc64__ # define __WORDSIZE 64 -# define __WORDSIZE_COMPAT32 1 +# define __WORDSIZE_TIME64_COMPAT32 1 #else # define __WORDSIZE 32 #endif diff --git a/libc/sysdeps/linux/sparc/bits/wordsize.h b/libc/sysdeps/linux/sparc/bits/wordsize.h index c0e600ed5..aa15dbc7a 100644 --- a/libc/sysdeps/linux/sparc/bits/wordsize.h +++ b/libc/sysdeps/linux/sparc/bits/wordsize.h @@ -2,6 +2,7 @@ #if defined __arch64__ || defined __sparcv9 # define __WORDSIZE 64 +# define __WORDSIZE_TIME64_COMPAT32 1 #else # define __WORDSIZE 32 #endif diff --git a/libc/sysdeps/linux/x86_64/bits/wordsize.h b/libc/sysdeps/linux/x86_64/bits/wordsize.h index e55524100..9db982c90 100644 --- a/libc/sysdeps/linux/x86_64/bits/wordsize.h +++ b/libc/sysdeps/linux/x86_64/bits/wordsize.h @@ -1,9 +1,12 @@ /* Determine the wordsize from the preprocessor defines. */ -#if defined __x86_64__ +#if defined __x86_64__ && !defined __ILP32__ # define __WORDSIZE 64 -/* This makes /var/run/utmp compatible with 32-bit environment: */ -# define __WORDSIZE_COMPAT32 1 #else # define __WORDSIZE 32 #endif + +#ifdef __x86_64__ +/* This makes /var/run/utmp compatible with 32-bit environment: */ +# define __WORDSIZE_TIME64_COMPAT32 1 +#endif diff --git a/libutil/logout.c b/libutil/logout.c index 9c7440b19..45804552d 100644 --- a/libutil/logout.c +++ b/libutil/logout.c @@ -50,7 +50,7 @@ logout (const char *line) memset (ut->ut_host, 0, sizeof ut->ut_host); #endif #if _HAVE_UT_TV - 0 -# if !defined __WORDSIZE_COMPAT32 || __WORDSIZE_COMPAT32 == 0 +# if !defined __WORDSIZE_TIME64_COMPAT32 gettimeofday (&ut->ut_tv, NULL); # else { diff --git a/libutil/logwtmp.c b/libutil/logwtmp.c index 2a6f28a48..6a53b5ff1 100644 --- a/libutil/logwtmp.c +++ b/libutil/logwtmp.c @@ -23,7 +23,7 @@ void logwtmp(const char *line, const char *name, const char *host) strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1); strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1); strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1); -#if !defined __WORDSIZE_COMPAT32 || __WORDSIZE_COMPAT32 == 0 +#if !defined __WORDSIZE_TIME64_COMPAT32 gettimeofday(&lutmp.ut_tv, NULL); #else { -- cgit v1.2.3 From 40effcf4c1e9a2fb9169d9189bdc9b1c888f9345 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Tue, 24 Mar 2015 00:11:49 +0100 Subject: mips: switch float_t to float Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/mips/bits/mathdef.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libc/sysdeps') diff --git a/libc/sysdeps/linux/mips/bits/mathdef.h b/libc/sysdeps/linux/mips/bits/mathdef.h index 1c636a199..6afe20d8a 100644 --- a/libc/sysdeps/linux/mips/bits/mathdef.h +++ b/libc/sysdeps/linux/mips/bits/mathdef.h @@ -25,10 +25,9 @@ #if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF # define _MATH_H_MATHDEF 1 -/* Normally, there is no long double type and the `float' and `double' - expressions are evaluated as `double'. */ -typedef double float_t; /* `float' expressions are evaluated as - `double'. */ +/* MIPS has both `float' and `double' arithmetic. */ +typedef float float_t; /* `float' expressions are evaluated as + `float'. */ typedef double double_t; /* `double' expressions are evaluated as `double'. */ -- cgit v1.2.3 From 6ff9c31abc14f207265ab214370982ecb3bfe428 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Wed, 25 Mar 2015 23:59:45 +0100 Subject: utmp: favour POSIX utmpx over SVID utmp Note: _PATH_UTMPX == _PATH_UTMP and the utmp struct is identical to the utmpx struct so this only changes the external API entrypoints and NOT the underlying data source. This saves about 500b (~1300b from previously ~1950) while at it. Signed-off-by: Bernhard Reutner-Fischer --- extra/Configs/Config.in | 24 +++---- include/internal/utmp.h | 92 +++++++++++++++++++++++++++ include/pty.h | 1 + include/utmp.h | 10 +-- libc/misc/utmp/Makefile.in | 4 +- libc/misc/utmp/utent.c | 121 +++++++++++++++++++++--------------- libc/misc/utmp/utxent.c | 108 -------------------------------- libc/misc/utmp/wtent.c | 50 --------------- libc/sysdeps/linux/sh/bits/atomic.h | 12 +++- libutil/forkpty.c | 3 - libutil/login.c | 6 +- libutil/login_tty.c | 1 - libutil/logout.c | 6 +- libutil/logwtmp.c | 21 +------ libutil/openpty.c | 1 - test/misc/Makefile.in | 4 ++ 16 files changed, 200 insertions(+), 264 deletions(-) create mode 100644 include/internal/utmp.h delete mode 100644 libc/misc/utmp/utxent.c delete mode 100644 libc/misc/utmp/wtent.c (limited to 'libc/sysdeps') diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index 7546e96ea..1ef13667f 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -701,23 +701,23 @@ config COMPAT_ATEXIT else you will be missing atexit() until you rebuild all apps. config UCLIBC_HAS_UTMPX - bool "utmpx based support for tracking login/logouts to/from the system" - depends on UCLIBC_HAS_UTMP # TODO, remove this, it's backward - help - Answer y to enable support for accessing user accounting database. - It can be used to track all login/logout to the system. + bool "utmpx based support for tracking login/logouts to/from the system" + help + Answer y to enable support for accessing user accounting database. + It can be used to track all login/logout to the system. config UCLIBC_HAS_UTMP - bool "utmp support (XPG2, SVr4 compat)" - help - Answer y to enable legacy SVID support for accessing - user accounting database: + bool "utmp support (XPG2 compat, SVr4 compat)" + #depends on UCLIBC_HAS_UTMPX # for educational purposes.. + help + Answer y to enable legacy SVID support for accessing + user accounting database: getutent(), getutid(), getutline(), pututline(), setutent(), endutent(), utmpname() in utmp.h - It can be used to track all login/logout to the system. + It can be used to track all login/logout to the system. - If unsure, just answer N and use utmpx.h and corresponding - POSIX functions. + If unsure, answer N and use corresponding POSIX functions + from utmpx.h config UCLIBC_SUSV2_LEGACY bool "Enable SuSv2 LEGACY functions" diff --git a/include/internal/utmp.h b/include/internal/utmp.h new file mode 100644 index 000000000..49f96b4d8 --- /dev/null +++ b/include/internal/utmp.h @@ -0,0 +1,92 @@ +/* vi: set sw=4 ts=4: */ +/* + * internal helper for utmp and utmpx handling + * + * Copyright (C) 2015 by Bernhard Reutner-Fischer + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ +#ifndef __INTERNAL_UTMP_H +#define __INTERNAL_UTMP_H + +#include +#include + +/* Note: _PATH_UTMPX == _PATH_UTMP */ + +#if (defined __UCLIBC_HAS_UTMPX__ && defined __UCLIBC_HAS_UTMP__) \ + || !defined __UCLIBC_HAS_UTMP__ +/* implement the X and alias the non-X */ +# define __set_unlocked __setutxent_unlocked +# define set setutxent +# define __get_unlocked __getutxent_unlocked +# define get getutxent +# define end endutxent +# define __getid_unlocked __getutxid_unlocked +# define getid getutxid +# define getline getutxline +# define putline pututxline +# define name utmpxname +# define updw updwtmpx +# define UT utmpx +# ifndef __DEFAULT_PATH_UTMP +# define __DEFAULT_PATH_UTMP _PATH_UTMPX +# endif +# if defined __UCLIBC_HAS_UTMP__ +# define other(n,a) strong_alias_untyped(n,a) +# else +# define other(n,a) /* nothing */ +# endif +#elif defined __UCLIBC_HAS_UTMP__ +# define __set_unlocked __setutent_unlocked +# define set setutent +# define __get_unlocked __getutent_unlocked +# define get getutent +# define end endutent +# define __getid_unlocked __getutid_unlocked +# define getid getutid +# define getline getutline +# define putline pututline +# define name utmpname +# define updw updwtmp +# define UT utmp +# ifndef __DEFAULT_PATH_UTMP +# define __DEFAULT_PATH_UTMP _PATH_UTMP +# endif +# define other(n,a) /* nothing */ +#else +#error You are supposed to either have UTMP or UTMPX or both here +#endif + +/* not used in libc_hidden_proto(setutxent) */ +/* not used in libc_hidden_proto(endutxent) */ +/* not used in libc_hidden_proto(getutxent) */ +/* not used in libc_hidden_proto(getutxid) */ +/* not used in libc_hidden_proto(getutxline) */ +/* not used in libc_hidden_proto(pututxline) */ +/* not used in libc_hidden_proto(utmpxname) */ +/* not used in libc_hidden_proto(updwtmpx) */ + +/* not used in libc_hidden_proto(setutent) */ +/* not used in libc_hidden_proto(endutent) */ +/* not used in libc_hidden_proto(getutent) */ +/* not used in libc_hidden_proto(getutid) */ +/* not used in libc_hidden_proto(getutline) */ +/* not used in libc_hidden_proto(pututline) */ +/* not used in libc_hidden_proto(utmpname) */ +/* not used in libc_hidden_proto(updwtmp) */ + +#ifdef IS_IN_libutil +# if (defined __UCLIBC_HAS_UTMPX__ && defined __UCLIBC_HAS_UTMP__) \ + || !defined __UCLIBC_HAS_UTMP__ + /* monkey-patch to use the POSIX interface */ +# define setutent setutxent +# define getutline getutxline +# define pututline pututxline +# define endutent endutxent +# define updwtmp updwtmpx +# endif +#endif /* IS_IN_libutil */ + +#endif /* __INTERNAL_UTMP_H */ + diff --git a/include/pty.h b/include/pty.h index 26c3011c6..f23a260ae 100644 --- a/include/pty.h +++ b/include/pty.h @@ -32,6 +32,7 @@ __BEGIN_DECLS ends in AMASTER and ASLAVE. */ extern int openpty (int *__amaster, int *__aslave, char *__name, struct termios *__termp, struct winsize *__winp) __THROW; +libutil_hidden_proto(openpty) /* Create child process and establish the slave pseudo terminal as the child's controlling terminal. */ diff --git a/include/utmp.h b/include/utmp.h index 754f76781..8ecbb54e7 100644 --- a/include/utmp.h +++ b/include/utmp.h @@ -40,7 +40,7 @@ __BEGIN_DECLS /* Make FD be the controlling terminal, stdin, stdout, and stderr; then close FD. Returns 0 on success, nonzero on error. */ extern int login_tty (int __fd) __THROW; - +libutil_hidden_proto(login_tty) /* Write the given entry into utmp and wtmp. */ extern void login (const struct utmp *__entry) __THROW; @@ -56,37 +56,29 @@ extern void logwtmp (const char *__ut_line, const char *__ut_name, /* Append entry UTMP to the wtmp-like file WTMP_FILE. */ extern void updwtmp (const char *__wtmp_file, const struct utmp *__utmp) __THROW; -libc_hidden_proto(updwtmp) /* Change name of the utmp file to be examined. */ extern int utmpname (const char *__file) __THROW; -libc_hidden_proto(utmpname) /* Read next entry from a utmp-like file. */ extern struct utmp *getutent (void) __THROW; -libc_hidden_proto(getutent) /* Reset the input stream to the beginning of the file. */ extern void setutent (void) __THROW; -libc_hidden_proto(setutent) /* Close the current open file. */ extern void endutent (void) __THROW; -libc_hidden_proto(endutent) /* Search forward from the current point in the utmp file until the next entry with a ut_type matching ID->ut_type. */ extern struct utmp *getutid (const struct utmp *__id) __THROW; -libc_hidden_proto(getutid) /* Search forward from the current point in the utmp file until the next entry with a ut_line matching LINE->ut_line. */ extern struct utmp *getutline (const struct utmp *__line) __THROW; -libc_hidden_proto(getutline) /* Write out entry pointed to by UTMP_PTR into the utmp file. */ extern struct utmp *pututline (const struct utmp *__utmp_ptr) __THROW; -libc_hidden_proto(pututline) #if 0 /* def __USE_MISC */ diff --git a/libc/misc/utmp/Makefile.in b/libc/misc/utmp/Makefile.in index 715341c85..6c54ade96 100644 --- a/libc/misc/utmp/Makefile.in +++ b/libc/misc/utmp/Makefile.in @@ -8,9 +8,7 @@ subdirs += libc/misc/utmp CSRC-y := -CSRC-$(if $(findstring y,$(UCLIBC_HAS_UTMP)$(UCLIBC_HAS_UTMPX)),y) += wtent.c -CSRC-$(UCLIBC_HAS_UTMP) += utent.c -CSRC-$(UCLIBC_HAS_UTMPX) += utxent.c +CSRC-$(if $(findstring y,$(UCLIBC_HAS_UTMP)$(UCLIBC_HAS_UTMPX)),y) += utent.c MISC_UTMP_DIR := $(top_srcdir)libc/misc/utmp MISC_UTMP_OUT := $(top_builddir)libc/misc/utmp diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c index a258cb46d..3671bb05c 100644 --- a/libc/misc/utmp/utent.c +++ b/libc/misc/utmp/utent.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include "internal/utmp.h" #include #include @@ -27,17 +27,17 @@ __UCLIBC_MUTEX_STATIC(utmplock, PTHREAD_MUTEX_INITIALIZER); /* Some global crap */ static int static_fd = -1; -static struct utmp static_utmp; -static const char default_file_name[] = _PATH_UTMP; -static const char *static_ut_name = default_file_name; +static struct UT static_utmp; +static const char default_file[] = __DEFAULT_PATH_UTMP; +static const char *current_file = default_file; /* This function must be called with the LOCK held */ -static void __setutent_unlocked(void) +static void __set_unlocked(void) { if (static_fd < 0) { - static_fd = open_not_cancel_2(static_ut_name, O_RDWR | O_CLOEXEC); + static_fd = open_not_cancel_2(current_file, O_RDWR | O_CLOEXEC); if (static_fd < 0) { - static_fd = open_not_cancel_2(static_ut_name, O_RDONLY | O_CLOEXEC); + static_fd = open_not_cancel_2(current_file, O_RDONLY | O_CLOEXEC); if (static_fd < 0) { return; /* static_fd remains < 0 */ } @@ -51,22 +51,23 @@ static void __setutent_unlocked(void) lseek(static_fd, 0, SEEK_SET); } #if defined __UCLIBC_HAS_THREADS__ -void setutent(void) +void set(void) { __UCLIBC_MUTEX_LOCK(utmplock); - __setutent_unlocked(); + __set_unlocked(); __UCLIBC_MUTEX_UNLOCK(utmplock); } #else -strong_alias(__setutent_unlocked,setutent) +strong_alias(__set_unlocked,set) #endif -libc_hidden_def(setutent) +/* not used in libc_hidden_def(set) */ +other(setutxent,setutent) /* This function must be called with the LOCK held */ -static struct utmp *__getutent_unlocked(void) +static struct UT *__get_unlocked(void) { if (static_fd < 0) { - __setutent_unlocked(); + __set_unlocked(); if (static_fd < 0) return NULL; } @@ -79,21 +80,22 @@ static struct utmp *__getutent_unlocked(void) return NULL; } #if defined __UCLIBC_HAS_THREADS__ -struct utmp *getutent(void) +struct UT *get(void) { - struct utmp *ret; + struct UT *ret; __UCLIBC_MUTEX_LOCK(utmplock); - ret = __getutent_unlocked(); + ret = __get_unlocked(); __UCLIBC_MUTEX_UNLOCK(utmplock); return ret; } #else -strong_alias(__getutent_unlocked,getutent) +strong_alias(__get_unlocked,get) #endif -libc_hidden_def(getutent) +/* not used in libc_hidden_def(get) */ +other(getutxent,getutent) -void endutent(void) +void end(void) { __UCLIBC_MUTEX_LOCK(utmplock); if (static_fd >= 0) @@ -101,12 +103,13 @@ void endutent(void) static_fd = -1; __UCLIBC_MUTEX_UNLOCK(utmplock); } -libc_hidden_def(endutent) +/* not used in libc_hidden_def(end) */ +other(endutxent,endutent) /* This function must be called with the LOCK held */ -static struct utmp *__getutid_unlocked(const struct utmp *utmp_entry) +static struct UT *__getid_unlocked(const struct UT *utmp_entry) { - struct utmp *lutmp; + struct UT *lutmp; unsigned type; /* We use the fact that constants we are interested in are: */ @@ -114,7 +117,7 @@ static struct utmp *__getutid_unlocked(const struct utmp *utmp_entry) type = utmp_entry->ut_type - 1; type /= 4; - while ((lutmp = __getutent_unlocked()) != NULL) { + while ((lutmp = __get_unlocked()) != NULL) { if (type == 0 && lutmp->ut_type == utmp_entry->ut_type) { /* one of RUN_LVL, BOOT_TIME, NEW_TIME, OLD_TIME */ return lutmp; @@ -130,26 +133,27 @@ static struct utmp *__getutid_unlocked(const struct utmp *utmp_entry) return NULL; } #if defined __UCLIBC_HAS_THREADS__ -struct utmp *getutid(const struct utmp *utmp_entry) +struct UT *getid(const struct UT *utmp_entry) { - struct utmp *ret; + struct UT *ret; __UCLIBC_MUTEX_LOCK(utmplock); - ret = __getutid_unlocked(utmp_entry); + ret = __getid_unlocked(utmp_entry); __UCLIBC_MUTEX_UNLOCK(utmplock); return ret; } #else -strong_alias(__getutid_unlocked,getutid) +strong_alias(__getid_unlocked,getid) #endif -libc_hidden_def(getutid) +/* not used in libc_hidden_def(getid) */ +other(getutxid,getutid) -struct utmp *getutline(const struct utmp *utmp_entry) +struct UT *getline(const struct UT *utmp_entry) { - struct utmp *lutmp; + struct UT *lutmp; __UCLIBC_MUTEX_LOCK(utmplock); - while ((lutmp = __getutent_unlocked()) != NULL) { + while ((lutmp = __get_unlocked()) != NULL) { if (lutmp->ut_type == USER_PROCESS || lutmp->ut_type == LOGIN_PROCESS) { if (strncmp(lutmp->ut_line, utmp_entry->ut_line, sizeof(lutmp->ut_line)) == 0) { @@ -160,39 +164,41 @@ struct utmp *getutline(const struct utmp *utmp_entry) __UCLIBC_MUTEX_UNLOCK(utmplock); return lutmp; } -libc_hidden_def(getutline) +/* libc_hidden_def(getline) */ +other(getutxline,getutline) -struct utmp *pututline(const struct utmp *utmp_entry) +struct UT *putline(const struct UT *utmp_entry) { __UCLIBC_MUTEX_LOCK(utmplock); /* Ignore the return value. That way, if they've already positioned the file pointer where they want it, everything will work out. */ - lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR); + lseek(static_fd, (off_t) - sizeof(struct UT), SEEK_CUR); - if (__getutid_unlocked(utmp_entry) != NULL) - lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR); + if (__getid_unlocked(utmp_entry) != NULL) + lseek(static_fd, (off_t) - sizeof(struct UT), SEEK_CUR); else lseek(static_fd, (off_t) 0, SEEK_END); - if (write(static_fd, utmp_entry, sizeof(struct utmp)) - != sizeof(struct utmp)) + if (write(static_fd, utmp_entry, sizeof(struct UT)) + != sizeof(struct UT)) utmp_entry = NULL; __UCLIBC_MUTEX_UNLOCK(utmplock); - return (struct utmp *)utmp_entry; + return (struct UT *)utmp_entry; } -libc_hidden_def(pututline) +/* not used in libc_hidden_def(putline) */ +other(pututxline,pututline) -int utmpname(const char *new_ut_name) +int name(const char *new_file) { __UCLIBC_MUTEX_LOCK(utmplock); - if (new_ut_name != NULL) { - if (static_ut_name != default_file_name) - free((char *)static_ut_name); - static_ut_name = strdup(new_ut_name); - if (static_ut_name == NULL) { + if (new_file != NULL) { + if (current_file != default_file) + free((char *)current_file); + current_file = strdup(new_file); + if (current_file == NULL) { /* We should probably whine about out-of-memory * errors here... Instead just reset to the default */ - static_ut_name = default_file_name; + current_file = default_file; } } @@ -201,6 +207,23 @@ int utmpname(const char *new_ut_name) static_fd = -1; } __UCLIBC_MUTEX_UNLOCK(utmplock); - return 0; /* or maybe return -(static_ut_name != new_ut_name)? */ + return 0; /* or maybe return -(current_file != new_file)? */ } -libc_hidden_def(utmpname) +/* not used in libc_hidden_def(name) */ +other(utmpxname,utmpname) + +void updw(const char *wtmp_file, const struct UT *lutmp) +{ + int fd; + + fd = open_not_cancel_2(wtmp_file, O_APPEND | O_WRONLY); + if (fd >= 0) { + if (lockf(fd, F_LOCK, 0) == 0) { + write_not_cancel(fd, lutmp, sizeof(struct UT)); + lockf(fd, F_ULOCK, 0); + close_not_cancel_no_status(fd); + } + } +} +/* not used in libc_hidden_def(updw) */ +other(updwtmpx,updwtmp) diff --git a/libc/misc/utmp/utxent.c b/libc/misc/utmp/utxent.c deleted file mode 100644 index c32e4da49..000000000 --- a/libc/misc/utmp/utxent.c +++ /dev/null @@ -1,108 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * utexent.c : Support for accessing user accounting database. - * Copyright (C) 2010 STMicroelectronics Ltd. - * - * Author: Salvatore Cro - * - * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - * - */ - -#include -#include -#include -#include - -void setutxent(void) -{ - setutent (); -} - -void endutxent(void) -{ - endutent (); -} - -struct utmpx *getutxent(void) -{ - return (struct utmpx *) getutent (); -} - -struct utmpx *getutxid(const struct utmpx *utmp_entry) -{ - return (struct utmpx *) getutid ((const struct utmp *) utmp_entry); -} - -struct utmpx *getutxline(const struct utmpx *utmp_entry) -{ - return (struct utmpx *) getutline ((const struct utmp *) utmp_entry); -} - -struct utmpx *pututxline (const struct utmpx *utmp_entry) -{ - return (struct utmpx *) pututline ((const struct utmp *) utmp_entry); -} - -int utmpxname (const char *new_ut_name) -{ - return utmpname (new_ut_name); -} - -void updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx) -{ - updwtmp (wtmpx_file, (const struct utmp *) utmpx); -} - -/* Copy the information in UTMPX to UTMP. */ -void getutmp (const struct utmpx *utmpx, struct utmp *utmp) -{ -#if _HAVE_UT_TYPE - 0 - utmp->ut_type = utmpx->ut_type; -#endif -#if _HAVE_UT_PID - 0 - utmp->ut_pid = utmpx->ut_pid; -#endif - memcpy (utmp->ut_line, utmpx->ut_line, sizeof (utmp->ut_line)); - memcpy (utmp->ut_user, utmpx->ut_user, sizeof (utmp->ut_user)); -#if _HAVE_UT_ID - 0 - memcpy (utmp->ut_id, utmpx->ut_id, sizeof (utmp->ut_id)); -#endif -#if _HAVE_UT_HOST - 0 - memcpy (utmp->ut_host, utmpx->ut_host, sizeof (utmp->ut_host)); -#endif -#if _HAVE_UT_TV - 0 - utmp->ut_tv.tv_sec = utmpx->ut_tv.tv_sec; - utmp->ut_tv.tv_usec = utmpx->ut_tv.tv_usec; -#else - utmp->ut_time = utmpx->ut_time; -#endif -} - -/* Copy the information in UTMP to UTMPX. */ -void getutmpx (const struct utmp *utmp, struct utmpx *utmpx) -{ - memset (utmpx, 0, sizeof (struct utmpx)); - -#if _HAVE_UT_TYPE - 0 - utmpx->ut_type = utmp->ut_type; -#endif -#if _HAVE_UT_PID - 0 - utmpx->ut_pid = utmp->ut_pid; -#endif - memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line)); - memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user)); -#if _HAVE_UT_ID - 0 - memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id)); -#endif -#if _HAVE_UT_HOST - 0 - memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host)); -#endif -#if _HAVE_UT_TV - 0 - utmpx->ut_tv.tv_sec = utmp->ut_tv.tv_sec; - utmpx->ut_tv.tv_usec = utmp->ut_tv.tv_usec; -#else - utmpx->ut_time = utmp->ut_time; -#endif -} - diff --git a/libc/misc/utmp/wtent.c b/libc/misc/utmp/wtent.c deleted file mode 100644 index 30939ea43..000000000 --- a/libc/misc/utmp/wtent.c +++ /dev/null @@ -1,50 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * Copyright (C) 2000-2006 Erik Andersen - * - * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - */ - -/* wtmp support rubbish (i.e. complete crap) */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#if 0 -/* This is enabled in uClibc/libutil/logwtmp.c */ -void logwtmp (const char *line, const char *name, const char *host) -{ - struct utmp lutmp; - memset(&lutmp, 0, sizeof(lutmp)); - - lutmp.ut_type = (name && *name) ? USER_PROCESS : DEAD_PROCESS; - lutmp.ut_pid = getpid(); - strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1); - strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1); - strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1); - gettimeofday(&(lutmp.ut_tv), NULL); - - updwtmp(_PATH_WTMP, &lutmp); -} -#endif - -void updwtmp(const char *wtmp_file, const struct utmp *lutmp) -{ - int fd; - - fd = open_not_cancel_2(wtmp_file, O_APPEND | O_WRONLY); - if (fd >= 0) { - if (lockf(fd, F_LOCK, 0) == 0) { - write_not_cancel(fd, lutmp, sizeof(struct utmp)); - lockf(fd, F_ULOCK, 0); - close_not_cancel_no_status(fd); - } - } -} -libc_hidden_def(updwtmp) diff --git a/libc/sysdeps/linux/sh/bits/atomic.h b/libc/sysdeps/linux/sh/bits/atomic.h index 745c85c1d..18ae9ea77 100644 --- a/libc/sysdeps/linux/sh/bits/atomic.h +++ b/libc/sysdeps/linux/sh/bits/atomic.h @@ -68,6 +68,12 @@ typedef uintmax_t uatomic_max_t; r1: saved stack pointer */ +#if __GNUC_PREREQ (4, 7) +# define rNOSP "u" +#else +# define rNOSP "r" +#endif + /* Avoid having lots of different versions of compare and exchange, by having this one complicated version. Parameters: bwl: b, w or l for 8, 16 and 32 bit versions. @@ -94,7 +100,7 @@ typedef uintmax_t uatomic_max_t; movt %0\n\ .endif\n" \ : "=&r" (__arch_result) \ - : "r" (mem), "r" (newval), "r" (oldval) \ + : rNOSP (mem), rNOSP (newval), rNOSP (oldval) \ : "r0", "r1", "t", "memory"); \ __arch_result; }) @@ -150,7 +156,7 @@ typedef uintmax_t uatomic_max_t; mov." #bwl " %1,@%2\n\ 1: mov r1,r15" \ : "=&r" (old), "=&r"(new) \ - : "r" (mem), "r" (value) \ + : rNOSP (mem), rNOSP (value) \ : "r0", "r1", "memory"); \ }) @@ -194,7 +200,7 @@ typedef uintmax_t uatomic_max_t; mov." #bwl " %0,@%1\n\ 1: mov r1,r15" \ : "=&r" (__new) \ - : "r" (mem), "r" (__value) \ + : rNOSP (mem), rNOSP (__value) \ : "r0", "r1", "memory"); \ __new; \ }) diff --git a/libutil/forkpty.c b/libutil/forkpty.c index ec490f053..24643330c 100644 --- a/libutil/forkpty.c +++ b/libutil/forkpty.c @@ -22,9 +22,6 @@ #include #include -libutil_hidden_proto(openpty) -libutil_hidden_proto(login_tty) - int forkpty (int *amaster, char *name, struct termios *termp, struct winsize *winp) { diff --git a/libutil/login.c b/libutil/login.c index 4007e4c7e..971997d4a 100644 --- a/libutil/login.c +++ b/libutil/login.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include "internal/utmp.h" /* Write the given entry into utmp and wtmp. * Note: the match in utmp is done against ut_id field, @@ -11,7 +11,7 @@ */ void login(const struct utmp *entry) { - struct utmp copy; + struct UT copy; char tty_name[sizeof(copy.ut_line) + 6]; int fd; @@ -20,7 +20,7 @@ void login(const struct utmp *entry) // (if there is such a field) with the value USER_PROCESS, // and fills the field ut->ut_pid (if there is such a field) // with the process ID of the calling process. - copy = *entry; + copy = *((const struct UT *)(entry)); #if _HAVE_UT_TYPE - 0 copy.ut_type = USER_PROCESS; #endif diff --git a/libutil/login_tty.c b/libutil/login_tty.c index 3979adcec..366585834 100644 --- a/libutil/login_tty.c +++ b/libutil/login_tty.c @@ -36,7 +36,6 @@ #include #include -libutil_hidden_proto(login_tty) int login_tty(int fd) { (void) setsid(); diff --git a/libutil/logout.c b/libutil/logout.c index 45804552d..0181e23aa 100644 --- a/libutil/logout.c +++ b/libutil/logout.c @@ -18,14 +18,14 @@ #include #include -#include #include +#include "internal/utmp.h" int logout (const char *line) { - struct utmp tmp; - struct utmp *ut; + struct UT tmp; + struct UT *ut; int result = 0; /* if (utmpname (_PATH_UTMP) == -1) return 0; - why? diff --git a/libutil/logwtmp.c b/libutil/logwtmp.c index 6a53b5ff1..99b772fc4 100644 --- a/libutil/logwtmp.c +++ b/libutil/logwtmp.c @@ -9,13 +9,13 @@ #include #include #include -#include #include #include +#include "internal/utmp.h" void logwtmp(const char *line, const char *name, const char *host) { - struct utmp lutmp; + struct UT lutmp; memset(&lutmp, 0, sizeof(lutmp)); lutmp.ut_type = (name && *name) ? USER_PROCESS : DEAD_PROCESS; @@ -36,20 +36,3 @@ void logwtmp(const char *line, const char *name, const char *host) updwtmp(_PATH_WTMP, &lutmp); } - -#if 0 -/* This is enabled in uClibc/libc/misc/utmp/wtent.c */ -void updwtmp(const char *wtmp_file, const struct utmp *lutmp) -{ - int fd; - - fd = open(wtmp_file, O_APPEND | O_WRONLY); - if (fd >= 0) { - if (lockf(fd, F_LOCK, 0) == 0) { - write(fd, lutmp, sizeof(*lutmp)); - lockf(fd, F_ULOCK, 0); - close(fd); - } - } -} -#endif diff --git a/libutil/openpty.c b/libutil/openpty.c index bd8b8d9a4..848dc8d38 100644 --- a/libutil/openpty.c +++ b/libutil/openpty.c @@ -84,7 +84,6 @@ pts_name (int fd, char **pts, size_t buf_len) /* Create pseudo tty master slave pair and set terminal attributes according to TERMP and WINP. Return handles for both ends in AMASTER and ASLAVE, and return the name of the slave end in NAME. */ -libutil_hidden_proto(openpty) int openpty (int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp) diff --git a/test/misc/Makefile.in b/test/misc/Makefile.in index 2fb9652fd..09f631fe3 100644 --- a/test/misc/Makefile.in +++ b/test/misc/Makefile.in @@ -20,6 +20,10 @@ ifeq ($(UCLIBC_HAS_UTMPX),) TESTS_DISABLED += tst-utmpx endif +ifeq ($(UCLIBC_HAS_UTMP),) +TESTS_DISABLED += tst-utmp +endif + DODIFF_dirent := 1 DODIFF_dirent64 := 1 DODIFF_tst-statfs := 1 -- cgit v1.2.3 From fc673e14203e1c9aea353d99ff89a17d46b2ad93 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Thu, 26 Mar 2015 00:03:05 +0100 Subject: SH: add 't' to syscall clobber list Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/sh/bits/syscalls.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libc/sysdeps') diff --git a/libc/sysdeps/linux/sh/bits/syscalls.h b/libc/sysdeps/linux/sh/bits/syscalls.h index b308276c5..efd423ed3 100644 --- a/libc/sysdeps/linux/sh/bits/syscalls.h +++ b/libc/sysdeps/linux/sh/bits/syscalls.h @@ -122,7 +122,7 @@ __asm__ __volatile__ (SYSCALL_INST_STR##nr SYSCALL_INST_PAD \ : "=z" (resultvar) \ : "r" (r3) ASMFMT_##nr \ - : "memory" \ + : "memory", "t" \ ); \ (int) resultvar; \ }) \ -- cgit v1.2.3 From d3c60fc490d714d7610a91555cec67952409b189 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Thu, 26 Mar 2015 18:07:04 +0530 Subject: ARC/signal: shield sa_restorer from compiler toggle side-effects when building uClibc with -O0 (DODEBUG build) the default sigrestorer had some extra glue code generated for stack manipulation which was messing up resume from signal path. So annotate the function with -Os so that gcc would only generate the bare min 2 instruction TRAP sequence Reported-and-Debugged-by: Alexey Brodkin Signed-off-by: Vineet Gupta Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/arc/sigaction.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libc/sysdeps') diff --git a/libc/sysdeps/linux/arc/sigaction.c b/libc/sysdeps/linux/arc/sigaction.c index 4a4c9e2d0..67ca38aca 100644 --- a/libc/sysdeps/linux/arc/sigaction.c +++ b/libc/sysdeps/linux/arc/sigaction.c @@ -13,7 +13,8 @@ /* * Default sigretrun stub if user doesn't specify SA_RESTORER */ -static void __default_rt_sa_restorer(void) +static void attribute_optimize("Os") __attribute_noinline__ +__default_rt_sa_restorer(void) { INTERNAL_SYSCALL_NCS(__NR_rt_sigreturn, , 0); } -- cgit v1.2.3 From 24946289317ea23bb0d1814cca0a499a905f7d6f Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Thu, 26 Mar 2015 14:25:37 +0530 Subject: ARC: don't hard-code ELF_NGREG Signed-off-by: Alexey Brodkin Signed-off-by: Vineet Gupta [updated changelog] Signed-off-by: Vineet Gupta Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/arc/sys/procfs.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'libc/sysdeps') diff --git a/libc/sysdeps/linux/arc/sys/procfs.h b/libc/sysdeps/linux/arc/sys/procfs.h index a9e375b33..a47430340 100755 --- a/libc/sysdeps/linux/arc/sys/procfs.h +++ b/libc/sysdeps/linux/arc/sys/procfs.h @@ -20,17 +20,14 @@ #include #include #include +#include __BEGIN_DECLS /* Type for a general-purpose register. */ typedef unsigned long elf_greg_t; -/* And the whole bunch of them. We could have used `struct - user_regs' directly in the typedef, but tradition says that - the register set is an array, which does have some peculiar - semantics, so leave it that way. */ -#define ELF_NGREG 40 +#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) typedef elf_greg_t elf_gregset_t[ELF_NGREG]; typedef struct { } elf_fpregset_t; -- cgit v1.2.3