glibc/sysdeps/unix/sysv/linux/powerpc
Stan Shebs 335c1007bf powerpc: Fix static-linked version of __ppc_get_timebase_freq [BZ #24640]
__ppc_get_timebase_freq() always return 0 when using static linked
glibc.

This is a minimal example.c to reproduce:

    /******************************/
    #include <inttypes.h>
    #include <stdint.h>
    #include <stdio.h>
    #include <sys/platform/ppc.h>

    int main() {
        uint64_t freq = __ppc_get_timebase_freq();
        printf("Time Base frequency = %"PRIu64" Hz\n", freq);
        if (freq == 0)
            return -1;
        return 0;
    }
    /******************************/

Compile command: gcc -static example.c

This bug has been reproduced, fixed and tested on all powerpc platforms
(ppc32, ppc64 and ppc64le).

The underlying code of __ppc_get_timebase_freq uses __get_timebase_freq
that has a different implementation for shared and static version of
glibc.  In the static version, there is an incorrect sense in the if
check for the fd returned when opening /proc/cpuinfo.

This solution is mostly a cherry-pick from:

  commit 4791e4f773d060c1a37b27aac5b03cdfa9327afc
  Author: Stan Shebs <stanshebs@google.com>
  Date:   Fri May 17 12:25:19 2019 -0700
  Subject: Fix sense of a test in the static-linking version of ppc get_clockfreq

That is in branch glibc/google/grte/v5-2.27/master and was mentioned for
inclusion on master here:

  https://www.sourceware.org/ml/libc-alpha/2019-05/msg00409.html

Adapted from original fix for get_clockfreq. That code was moved to
get_timebase_freq.

Also added a static-build testcase for __ppc_get_timebase_freq since the
underlying function has different implementations for shared and static
build.

	[BZ #24640]
	* sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
	[!SHARED] (__get_timebase_freq): Fix sense of a test in the
	static-linking version.
	* sysdeps/unix/sysv/linux/powerpc/Makefile
	(tests-static): Add test-gettimebasefreq-static.
	(tests): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/test-gettimebasefreq-static.c:
	New file.
2019-06-19 19:11:06 -03:00
..
bits termios: Consolidate termios.h 2019-01-03 09:32:12 -02:00
powerpc32 Allow memset local PLT reference for powerpc soft-float. 2019-06-13 12:21:50 +00:00
powerpc64 Linux: Add getdents64 system call 2019-06-07 09:27:01 +02:00
sys Add more spaces before '('. 2019-02-28 15:02:09 +00:00
configure Move architecture cases out of sysdeps/unix/sysv/linux/configure.ac. 2014-06-24 20:53:03 +00:00
configure.ac Move architecture cases out of sysdeps/unix/sysv/linux/configure.ac. 2014-06-24 20:53:03 +00:00
dl-brk.S
dl-cache.h
dl-static.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
dl-sysdep.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
elision-conf.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
elision-conf.h Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
elision-lock.c Remove support for PowerPC SPE extension (powerpc*-*-*gnuspe*). 2019-05-22 10:05:40 -04:00
elision-timed.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
elision-trylock.c Remove support for PowerPC SPE extension (powerpc*-*-*gnuspe*). 2019-05-22 10:05:40 -04:00
elision-unlock.c Remove support for PowerPC SPE extension (powerpc*-*-*gnuspe*). 2019-05-22 10:05:40 -04:00
force-elision.h Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
get_timebase_freq.c powerpc: Fix static-linked version of __ppc_get_timebase_freq [BZ #24640] 2019-06-19 19:11:06 -03:00
gettimeofday.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
htm.h Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
Implies NPTL is no longer an add-on! 2014-07-07 09:29:06 -07:00
init-first.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
ioctl.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
ipc_priv.h sysvipc: Add missing bit of semtimedop s390 consolidation 2019-05-21 10:43:10 -03:00
kernel_sigaction.h m68k: Fix sigaction kernel definition (BZ #23960) 2018-12-18 16:45:10 -02:00
kernel_termios.h Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
kernel-features.h Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
ldconfig.h Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
ldd-rewrite.sed
ldsodefs.h Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
libc-start.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
libc-start.h Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
libc-vdso.h Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
lowlevellock.h Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
Makefile powerpc: Fix static-linked version of __ppc_get_timebase_freq [BZ #24640] 2019-06-19 19:11:06 -03:00
nldbl-abi.h 2006-01-27 Dwayne Grant McConnell <decimal@us.ibm.com> 2006-01-28 00:15:15 +00:00
profil-counter.h
pt-longjmp.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
pthread_attr_setstack.c PowerPC: Move remaining nptl/sysdeps/unix/sysv/linux/powerpc/ files. 2014-05-26 11:45:14 -05:00
pthread_attr_setstacksize.c PowerPC: Move remaining nptl/sysdeps/unix/sysv/linux/powerpc/ files. 2014-05-26 11:45:14 -05:00
pthread_mutex_cond_lock.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
pthread_mutex_lock.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
pthread_mutex_timedlock.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
pthread_mutex_trylock.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
readelflib.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
rt-sysdep.c Update. 2004-04-19 06:19:34 +00:00
sigcontextinfo.h Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
syscall.S Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
sysconf.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
sysdep.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
test-gettimebasefreq-static.c powerpc: Fix static-linked version of __ppc_get_timebase_freq [BZ #24640] 2019-06-19 19:11:06 -03:00
test-gettimebasefreq.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
test-powerpc-linux-sysconf.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
time.c Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
Versions Revert {send,sendm,recv,recvm}msg conformance changes 2016-06-10 11:58:16 -03:00