From owner-svn-src-all@freebsd.org Fri Dec 2 19:20:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0930DC6329A; Fri, 2 Dec 2016 19:20:28 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A2F9AA22; Fri, 2 Dec 2016 19:20:27 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uB2JKQnE074989; Fri, 2 Dec 2016 19:20:26 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uB2JKQZY074988; Fri, 2 Dec 2016 19:20:26 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201612021920.uB2JKQZY074988@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Fri, 2 Dec 2016 19:20:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r309431 - vendor/compiler-rt/dist/test/sanitizer_common/TestCases/Linux X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Dec 2016 19:20:28 -0000 Author: dim Date: Fri Dec 2 19:20:26 2016 New Revision: 309431 URL: https://svnweb.freebsd.org/changeset/base/309431 Log: Vendor import of compiler-rt release_39 branch r288513: https://llvm.org/svn/llvm-project/compiler-rt/branches/release_39@288513 Modified: vendor/compiler-rt/dist/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc Modified: vendor/compiler-rt/dist/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc ============================================================================== --- vendor/compiler-rt/dist/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc Fri Dec 2 19:20:23 2016 (r309430) +++ vendor/compiler-rt/dist/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc Fri Dec 2 19:20:26 2016 (r309431) @@ -17,6 +17,21 @@ typedef uint64_t semval_t; typedef unsigned semval_t; #endif +// glibc 2.21 has introduced some changes in the way the semaphore value is +// handled for 32-bit platforms, but since these changes are not ABI-breaking +// they are not versioned. On newer platforms such as ARM, there is only one +// version of the symbol, so it's enough to check the glibc version. However, +// for old platforms such as i386, glibc contains two or even three versions of +// the sem_init symbol, and the sanitizers always pick the oldest one. +// Therefore, it is not enough to rely on the __GLIBC_PREREQ macro - we should +// instead check the platform as well to make sure we only expect the new +// behavior on platforms where the older symbols do not exist. +#if defined(__arm__) && __GLIBC_PREREQ(2, 21) +#define GET_SEM_VALUE(V) ((V) >> 1) +#else +#define GET_SEM_VALUE(V) (V) +#endif + void my_sem_init(bool priv, int value, semval_t *a, unsigned char *b) { sem_t sem; memset(&sem, 0xAB, sizeof(sem)); @@ -34,10 +49,10 @@ int main() { unsigned char b; my_sem_init(false, 42, &a, &b); - assert(a == 42); + assert(GET_SEM_VALUE(a) == 42); assert(b != 0xAB); my_sem_init(true, 43, &a, &b); - assert(a == 43); + assert(GET_SEM_VALUE(a) == 43); assert(b != 0xAB); }