From patchwork Mon Apr 12 11:22:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wheatley X-Patchwork-Id: 26877 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 29135448BBB for ; Mon, 12 Apr 2021 14:30:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DED3368815A; Mon, 12 Apr 2021 14:30:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3BC2A68010B for ; Mon, 12 Apr 2021 14:30:25 +0300 (EEST) Received: by mail-wm1-f48.google.com with SMTP id y20-20020a1c4b140000b029011f294095d3so8474342wma.3 for ; Mon, 12 Apr 2021 04:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ONNF6FFout+nCDUsBpA/bCLDGmVckWwKiPJ7O1Q35dQ=; b=Lo4ZXcAxCZmMPO383V9MDDOuWCVWURRnH9EDyVsmCG8qbelGJS9cIBggq8lvHxfmAA gVRh1sRrLEHw6BDg7ik88ejgtSNF0pQF9JFf4A4e8vBfsR/ocweyYYzU36VTjnjc1vb6 ljiKqbpm2Gme5ps1bmfYjYDGej8D/td1ml8mgNnG3gMay8PA4Jov8FU84nP7JOR9hGjn aX3hnMSMRi5gFGWG2UIGLLzdBHkXVc2uol8l3iMv8UDtxN9cygnFPdTFNKMsYwasShfg GR9Ihn8cHAsNKkvlpmRUHKDqWLOoa2QxSCBnpa3nlqkJ8ZZOksB7ARkKevZ7hk3GFVad iyBQ== 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; bh=ONNF6FFout+nCDUsBpA/bCLDGmVckWwKiPJ7O1Q35dQ=; b=TrxMi6BS9HibUYWyDbtd7pUrSfLfYMUQ+kesp/XXCIovlg6J+pviakJALITi+R6vW6 KfyETYMdnSicwBb+rE9vI6kqMjwpY7KtaOzz+Bz22/7DN8yml2SzeKf7JQtvz5I7b4Wh +7DB718e8pwQ2sjILRouoq/IgdybELyKVUoipYc507AnwP+1lAfszDTcciLgmF4N4SHY ZyCK+dDuuDgRZFq+6+CMqGp4WYh3lQp7Ds25iDnmysYjdD0LhkBZP75VBfI0nviVgNvg L9I2D0/orj+wuGrKQsp2xWmHaYqhdol1DN5L7cBN2Lhibs0zjUt5x8+uKvHF32CqncYA qdZw== X-Gm-Message-State: AOAM533v/fAz1xrRVmcgRNjR/d2D07T8pcKgq/M6HXNyJ8VrlSCLvqeG UAmGF+M3p4NhVqDkzZoFli5Q4/6cMcs= X-Google-Smtp-Source: ABdhPJwDZiUa2LAwV1L0svHdyHirgrFbTXqP3njI4UubUwdznLN9QtS8VGtthXwfxffAElr4Hj7YsA== X-Received: by 2002:a1c:ed05:: with SMTP id l5mr26422696wmh.154.1618226543577; Mon, 12 Apr 2021 04:22:23 -0700 (PDT) Received: from crayola.ldn.framestore.com (ldndefault.framestore.com. [185.101.14.7]) by smtp.gmail.com with ESMTPSA id g3sm7783422wrp.46.2021.04.12.04.22.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Apr 2021 04:22:23 -0700 (PDT) From: kevin.j.wheatley@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Apr 2021 12:22:09 +0100 Message-Id: <1618226529-22995-1-git-send-email-kevin.j.wheatley@gmail.com> X-Mailer: git-send-email 1.8.5.6 Subject: [FFmpeg-devel] [PATCH] libavutil/cpu: Fix definition of _GNU_SOURCE so it occurs before other includes X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Kevin Wheatley MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Kevin Wheatley This fix moves the potential definition of _GNU_SOURCE prior to any includes of system header files as required by the documentation https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html This corrects the CPU_COUNT macro availability, resulting in sched_getaffinity() being called on Linux systems. This then correctly returns the number of CPUs when run under containers and other cases where processor affinity has been setup prior to running FFmpeg Signed-off-by: Kevin J Wheatley --- libavutil/cpu.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 8e3576a..1496c5d 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -16,6 +16,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + +#if HAVE_SCHED_GETAFFINITY +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif +#include +#endif + #include #include #include @@ -23,16 +32,9 @@ #include "attributes.h" #include "cpu.h" #include "cpu_internal.h" -#include "config.h" #include "opt.h" #include "common.h" -#if HAVE_SCHED_GETAFFINITY -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif -#include -#endif #if HAVE_GETPROCESSAFFINITYMASK || HAVE_WINRT #include #endif