Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A82D7200CCA for ; Wed, 5 Jul 2017 00:37:57 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 9F152162040; Tue, 4 Jul 2017 22:37:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E34FF16203F for ; Wed, 5 Jul 2017 00:37:56 +0200 (CEST) Received: (qmail 50708 invoked by uid 500); 4 Jul 2017 22:37:55 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 50698 invoked by uid 99); 4 Jul 2017 22:37:55 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jul 2017 22:37:55 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 2A7FA3A1970 for ; Tue, 4 Jul 2017 22:37:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1800836 - in /subversion/trunk/subversion: include/private/svn_dep_compat.h libsvn_fs/fs-loader.c libsvn_subr/utf.c Date: Tue, 04 Jul 2017 22:37:52 -0000 To: commits@subversion.apache.org From: philip@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170704223754.2A7FA3A1970@svn01-us-west.apache.org> archived-at: Tue, 04 Jul 2017 22:37:57 -0000 Author: philip Date: Tue Jul 4 22:37:52 2017 New Revision: 1800836 URL: http://svn.apache.org/viewvc?rev=1800836&view=rev Log: Remove some casts when using APR 2 and fix a "missing volatile" bug that was uncovered. * subversion/include/private/svn_dep_compat.h (svn_atomic_casptr, svn_atomic_xchgptr): New. * subversion/libsvn_fs/fs-loader.c (struct fs_type_defn): Add missing volatile to vtable element, change type to void * to avoid cast (we lose no type safety since we never access the value as any other type). (get_library_vtable_direct): Remove explicit cast. * subversion/libsvn_subr/utf.c (atomic_swap): Remove explicit cast. Modified: subversion/trunk/subversion/include/private/svn_dep_compat.h subversion/trunk/subversion/libsvn_fs/fs-loader.c subversion/trunk/subversion/libsvn_subr/utf.c Modified: subversion/trunk/subversion/include/private/svn_dep_compat.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_dep_compat.h?rev=1800836&r1=1800835&r2=1800836&view=diff ============================================================================== --- subversion/trunk/subversion/include/private/svn_dep_compat.h (original) +++ subversion/trunk/subversion/include/private/svn_dep_compat.h Tue Jul 4 22:37:52 2017 @@ -115,6 +115,28 @@ extern "C" { #endif /** + * APR 1 has volatile qualifier bugs in some atomic prototypes that + * are fixed in APR 2: + * https://issues.apache.org/bugzilla/show_bug.cgi?id=50731 + * Subversion code should put the volatile qualifier in the correct + * place when declaring variables which means that casting at the call + * site is necessary when using APR 1. No casts should be used with + * APR 2 as this allows the compiler to check that the variable has + * the correct volatile qualifier. + */ +#if APR_VERSION_AT_LEAST(2,0,0) +#define svn_atomic_casptr(mem, with, cmp) \ + apr_atomic_casptr((mem), (with), (cmp)) +#define svn_atomic_xchgptr(mem, val) \ + apr_atomic_xchgptr((mem), (val)) +#else +#define svn_atomic_casptr(mem, with, cmp) \ + apr_atomic_casptr((void volatile **)(mem), (with), (cmp)) +#define svn_atomic_xchgptr(mem, val) \ + apr_atomic_xchgptr((void volatile **)(mem), (val)) +#endif + +/** * Check at compile time if the Serf version is at least a certain * level. * @param major The major version component of the version checked Modified: subversion/trunk/subversion/libsvn_fs/fs-loader.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs/fs-loader.c?rev=1800836&r1=1800835&r2=1800836&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_fs/fs-loader.c (original) +++ subversion/trunk/subversion/libsvn_fs/fs-loader.c Tue Jul 4 22:37:52 2017 @@ -89,7 +89,7 @@ struct fs_type_defn { const char *fs_type; const char *fsap_name; fs_init_func_t initfunc; - fs_library_vtable_t *vtable; + void * volatile vtable; /* fs_library_vtable_t */ struct fs_type_defn *next; }; @@ -190,7 +190,7 @@ get_library_vtable_direct(fs_library_vta const svn_version_t *fs_version; /* most times, we get lucky */ - *vtable = apr_atomic_casptr((volatile void **)&fst->vtable, NULL, NULL); + *vtable = svn_atomic_casptr(&fst->vtable, NULL, NULL); if (*vtable) return SVN_NO_ERROR; @@ -233,7 +233,7 @@ get_library_vtable_direct(fs_library_vta fs_version->patch, fs_version->tag); /* the vtable will not change. Remember it */ - apr_atomic_casptr((volatile void **)&fst->vtable, *vtable, NULL); + svn_atomic_casptr(&fst->vtable, *vtable, NULL); return SVN_NO_ERROR; } Modified: subversion/trunk/subversion/libsvn_subr/utf.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/utf.c?rev=1800836&r1=1800835&r2=1800836&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_subr/utf.c (original) +++ subversion/trunk/subversion/libsvn_subr/utf.c Tue Jul 4 22:37:52 2017 @@ -190,9 +190,7 @@ static APR_INLINE void* atomic_swap(void * volatile * mem, void *new_value) { #if APR_HAS_THREADS - /* Cast is necessary because of APR bug: - https://issues.apache.org/bugzilla/show_bug.cgi?id=50731 */ - return apr_atomic_xchgptr((volatile void **)mem, new_value); + return svn_atomic_xchgptr(mem, new_value); #else /* no threads - no sync. necessary */ void *old_value = (void*)*mem;