From patchwork Mon Sep 6 20:47:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 44876 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 F1AB2385C401 for ; Mon, 6 Sep 2021 20:50:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F1AB2385C401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1630961422; bh=sRphFPBS4sglo10DR8SH+DFuQLDbv1VlVoYDSELN5+I=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FbqVMDqPDPfL8Y9l7+KAHi0e5z4KJt99Q/TET3F8G+wMDorW4XrJp6TLcvbQjdCWv QI2HsALExIm4V9jOwDlbdGwde2DLvm+8tzBniYVCFoqBKPcgxznMc0RAZ+ACB4kexb MEV0YDKj72W0JLqdGyqlnNtWdXKJqPdMEMIKWDkw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by sourceware.org (Postfix) with ESMTPS id 116DC385C403 for ; Mon, 6 Sep 2021 20:47:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 116DC385C403 Received: by mail-qk1-x733.google.com with SMTP id m21so7953627qkm.13 for ; Mon, 06 Sep 2021 13:47:54 -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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sRphFPBS4sglo10DR8SH+DFuQLDbv1VlVoYDSELN5+I=; b=OPCtKK+9GQGHx6VlzAOTwi0u5RbGkEFyhbSA6rUXIDdGWx68QmVrAkhv08B9rGoUBh WNTONkr2aax+rjFlBrLOeZvOB35rhdYWrzYVYk4BCAWQ2A8Mh+Hb1PNI8FOJVmnNvdpP sD8A5IYDKj/BBd/4iVdnxBW9QzSSmlrQ49D/BaYYdXL76DPEe+GWQHLwAhACztrep8Wy PCLXzT/EbgcAJC8oeA+53kwM/7rsxOPzKRL2WZkRrNFAHF7HvzldKI++rT2weXdq11zY AJ03gpB0v//8fqECf0ZzkCTBmh/hJt13+DDug2qd8HEqJeUNI2O5qfIIDOIEXOBaFeBl I06g== X-Gm-Message-State: AOAM5310cy1FHbpUODpJOI/acxndSUFKHMX9gUrKjdqFl2KzrxFIwlgZ pzvWSWfXyQXKV1t6WrfecD8RTJEGiaJjvQ== X-Google-Smtp-Source: ABdhPJx9groSV+EkZeyZIA/o2OqPWPneudEAGecXhXuyglH8PxZKCeVqj7KmGuaSagYVoGFQUFNJ0w== X-Received: by 2002:a37:2d04:: with SMTP id t4mr12305204qkh.463.1630961273508; Mon, 06 Sep 2021 13:47:53 -0700 (PDT) Received: from birita.. ([2804:431:c7cb:733d:210:e147:8627:2d6]) by smtp.gmail.com with ESMTPSA id w129sm7468416qkb.61.2021.09.06.13.47.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Sep 2021 13:47:53 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v3 3/4] support: Add support_mutex_pi_monotonic Date: Mon, 6 Sep 2021 17:47:39 -0300 Message-Id: <20210906204740.3988273-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210906204740.3988273-1-adhemerval.zanella@linaro.org> References: <20210906204740.3988273-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 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 Netto Reply-To: Adhemerval Zanella 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/support_mutex_pi_monotonic.c | 33 ++++++++++++++++++++++++++++ support/xthread.h | 4 ++++ 3 files changed, 38 insertions(+) create mode 100644 support/support_mutex_pi_monotonic.c diff --git a/support/Makefile b/support/Makefile index 2a0731796f..fd27c8451e 100644 --- a/support/Makefile +++ b/support/Makefile @@ -63,6 +63,7 @@ libsupport-routines = \ support_format_hostent \ support_format_netent \ support_isolate_in_subprocess \ + support_mutex_pi_monotonic \ support_path_support_time64 \ support_process_state \ support_ptrace \ diff --git a/support/support_mutex_pi_monotonic.c b/support/support_mutex_pi_monotonic.c new file mode 100644 index 0000000000..5535837f92 --- /dev/null +++ b/support/support_mutex_pi_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 +support_mutex_pi_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..30501f5772 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 support_mutex_pi_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