From patchwork Wed Aug 11 20:01:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 44648 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6763D398582D for ; Wed, 11 Aug 2021 20:05:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6763D398582D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628712334; bh=gg61FdkoA48HT1Cr+IPNiLtjRoy9beP/cveBQJL1Sow=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=WmnJyLTSahqvLrtPO/gFJS7xfhMWACWzNBLl2k0qo9R+PSDx5YdlUeH7OJyr2zlru GBGCa0q9XlhPaydzlo4JYdpApfun3xmXmZQlbpsbJjKtZsiMTChPKZBfyWTkP72DlA Bfay2HeH+QGEcxnYd5yzdJkHcEVUIdHSbwRJqV9k= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id B62D33985822 for ; Wed, 11 Aug 2021 20:01:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B62D33985822 Received: by mail-pj1-x1029.google.com with SMTP id bo18so5396132pjb.0 for ; Wed, 11 Aug 2021 13:01:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gg61FdkoA48HT1Cr+IPNiLtjRoy9beP/cveBQJL1Sow=; b=KSs8hT5WjZ+RWB+e1Zgg+ZzdxUoir+INaDpZP038xIKH7gS4CLUWGuIIVJGa3KmEaW vFwTPWjekmakT7qyQwIbEWG/YoVZv0rp4RcybPut53BINHUvNwdiUMYHGFepsPMwIDbh FwOBTkb3ETUpVLILnDQoCj1ySq8zUwq5Tzk+JbbM/HLXdS4VEx0WhHtZy6tO47BhVLOQ ifhB+C6LGLSO17kgZz6lwWVn1G1/smhm5F13o3JFNqWZB7B6PbOV3rQTB8V6q7wKt5ly mIzxfNqDcL2Zjnk8lQJGXds/2jyh81GF7aWASq0IzyXIdRQFikal3FkNXr71KC1qE1iW 1Ddw== X-Gm-Message-State: AOAM532Zsz0IHasiR1BI+F8pcf7T0vMN41G9/MslAESvNcRZoLynkdSs eMj1jJzhdFJKIyJPM2tyHRGCr1P2Omkm2w== X-Google-Smtp-Source: ABdhPJztihLB8yH/vz2cYlzhn+YVXbT1dn04AFAJGeOiGiDNQqljqGv61jRbKEOvbhCXOlQ/rZJAbg== X-Received: by 2002:a63:ff51:: with SMTP id s17mr370114pgk.415.1628712105703; Wed, 11 Aug 2021 13:01:45 -0700 (PDT) Received: from birita.. ([2804:431:c7cb:9dce:70f4:4f7a:652c:7fb]) by smtp.gmail.com with ESMTPSA id r15sm281370pjl.29.2021.08.11.13.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 13:01:45 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 3/4] support: Add xpthread_mutex_pi_support_monotonic Date: Wed, 11 Aug 2021 17:01:32 -0300 Message-Id: <20210811200133.3869287-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210811200133.3869287-1-adhemerval.zanella@linaro.org> References: <20210811200133.3869287-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Cc: Kurt Kanzenbach Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Returns true if Priority Inheritance support CLOCK_MONOTONIC. --- support/Makefile | 1 + support/xpthread_mutex_pi_support_monotonic.c | 33 +++++++++++++++++++ support/xthread.h | 4 +++ 3 files changed, 38 insertions(+) create mode 100644 support/xpthread_mutex_pi_support_monotonic.c diff --git a/support/Makefile b/support/Makefile index a462781718..6360e86646 100644 --- a/support/Makefile +++ b/support/Makefile @@ -179,6 +179,7 @@ libsupport-routines = \ xpthread_sigmask \ xpthread_spin_lock \ xpthread_spin_unlock \ + xpthread_mutex_pi_support_monotonic \ xraise \ xreadlink \ xrealloc \ diff --git a/support/xpthread_mutex_pi_support_monotonic.c b/support/xpthread_mutex_pi_support_monotonic.c new file mode 100644 index 0000000000..eb42622913 --- /dev/null +++ b/support/xpthread_mutex_pi_support_monotonic.c @@ -0,0 +1,33 @@ +/* Returns whether Priority Inheritance support CLOCK_MONOTONIC. + Copyright (C) 2021 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 +#include + +bool +xpthread_mutex_pi_support_monotonic (void) +{ +#ifdef __linux__ + int r = syscall (__NR_futex, &(unsigned int){0}, 13 /* FUTEX_LOCK_PI2 */, + 0, NULL); + return r == 0; +#else + return false; +#endif +} diff --git a/support/xthread.h b/support/xthread.h index a4a4ec5b1e..7074720bd9 100644 --- a/support/xthread.h +++ b/support/xthread.h @@ -21,6 +21,7 @@ #include #include +#include __BEGIN_DECLS @@ -29,6 +30,9 @@ __BEGIN_DECLS exit function, so atexit handlers are executed. */ void delayed_exit (int seconds); +/* Returns true if Priority Inheritance support CLOCK_MONOTONIC. */ +bool xpthread_mutex_pi_support_monotonic (void); + /* Terminate the process (with exit status 1) if VALUE is not zero. In that case, print a failure message to standard output mentioning FUNCTION. The process is terminated with the exit function, so