From patchwork Thu Feb 4 11:37:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 12067173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E042C433E0 for ; Thu, 4 Feb 2021 11:37:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 079DB64E50 for ; Thu, 4 Feb 2021 11:37:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 079DB64E50 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D1B66E03D; Thu, 4 Feb 2021 11:37:56 +0000 (UTC) Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2FCF06E03D for ; Thu, 4 Feb 2021 11:37:56 +0000 (UTC) Received: by mail-ej1-x62e.google.com with SMTP id sa23so4830666ejb.0 for ; Thu, 04 Feb 2021 03:37:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DDb6Ld176HsxEp/NIJ6/4wTialpYbPckqUtodHtlMks=; b=leKWTs9YeL4kaMLRl170hdryZmQ3Ru6j0cQ8ZQ12SHUnDGmNZzVNHMFHGLdO2Nr5ko SxJeACiVKp97oD3zIaW8O6lB433ukZRH/jzoaIxY9YW70kUYvzTs2ohtdGe06AQLdgUM HzFP4AfsPz0URMVFAap7DVceOV6vcs/NF4jOyJ+DNYtShlfFTvH+0A3U6we7Y+UQRsah MXMfkn1wrhzfGRe+4DYEVi4Ci9dC/9O5gGjrukCMXlW0BbUf5y556jUE4PSMn/sx1Roj o6vPmRgdj+qS54OUgV4MNdiU2OTF85whcB6Ti+EXY5gNLWq5rbbZpxQMDhigk/3P0mFN cjfA== 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:mime-version :content-transfer-encoding; bh=DDb6Ld176HsxEp/NIJ6/4wTialpYbPckqUtodHtlMks=; b=okAN29abX2BwEEqX1CSa1X/nDRlXrN4lmer0Zxu1+Qy3JN6DjsqODFcUF44wl7OOpc pmJL/GLbUeYgwwmTKgeBeDpGFT/6Bi+WyF+Kjiz6NsYZFrgJJDMI08MCFPpXeqtRRUnV 3AwMMAUocfVKOyCru1+0Er/fu/XUKVRNG6DP7r+FFKGMQyb1pcE31Hm3UPFB/kKoE4i3 zZ0iVLqWMvuhskFJI8F6PfTf0guc88Dt3eZzyFyV65j8FzMbywLOKXaGiJPfeNQ3eaCq 7TelqKegxDqOieYtpSf+wKavUEwZRNFyIIelpsvidsq05z5hQQ7gLG7k5l+TyTEanpSr CeAQ== X-Gm-Message-State: AOAM5319m5pV0+b42/Ia2o9F+u/qKKuqHZFcS3k6BzOCLf5qAx0QsGnu qRIhVRc3a9fe51KnIIpTEYHa29bi8vEimA== X-Google-Smtp-Source: ABdhPJwFcmDrEaEfbPxDXv2Fy90vfzctJo2BH/yrwXMw/yY/h/onOzMBlakoIiWHFjNuo1QRlfYFew== X-Received: by 2002:a17:906:4e0c:: with SMTP id z12mr7431402eju.370.1612438674670; Thu, 04 Feb 2021 03:37:54 -0800 (PST) Received: from arch-x1c3.. ([2a00:5f00:102:0:542a:42e9:ace2:c1d0]) by smtp.gmail.com with ESMTPSA id f22sm2353088eje.34.2021.02.04.03.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 03:37:53 -0800 (PST) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/fourcc: introduce DRM_FOURCC_STANDALONE guard Date: Thu, 4 Feb 2021 11:37:42 +0000 Message-Id: <20210204113742.1814456-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pekka Paalanen , emil.l.velikov@gmail.com, James Park Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, the drm_fourcc.h header depends on drm.h for __u32 and __u64. At the same time drm.h pulls a lot of unneeded symbols. Add new guard DRM_FOURCC_STANDALONE, which when set will use local declaration of said symbols. When used on linux - we pull linux/types.h which is used either way. On other platforms, BSDs et al, we need a couple of typedefs. Since those can trigger a warning in some corner-cases*, add some GCC magic to silence them. Note that incorrect type redefinitions will still be flagged, and the GCC pragma is ignored by other compilers. *Corner-case: If one sets DRM_FOURCC_STANDALONE and compiles with C99 or earlier while also using -pedantic _and_ the header lives outside of the standard /usr/include (like BSDs normally do). v2: - Add corner-case handling, based on popular demand. Cc: James Park Cc: Pekka Paalanen Cc: Simon Ser Signed-off-by: Emil Velikov --- include/uapi/drm/drm.h | 10 ++++++++++ include/uapi/drm/drm_fourcc.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 808b48a93330..cd78950e05ce 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -53,6 +53,15 @@ typedef unsigned int drm_handle_t; #include #include #include + +/* + * When using C99 -pedantic the typedefs will trigger a warning. + * If the header is considered a system one (-isystem) those will be + * ignored, yet on the target platforms BSDs, et al - the headers live + * in a non-system location. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" typedef int8_t __s8; typedef uint8_t __u8; typedef int16_t __s16; @@ -63,6 +72,7 @@ typedef int64_t __s64; typedef uint64_t __u64; typedef size_t __kernel_size_t; typedef unsigned long drm_handle_t; +#pragma GCC diagnostic pop #endif diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h index 6f0628eb13a6..84a1f96cc4ef 100644 --- a/include/uapi/drm/drm_fourcc.h +++ b/include/uapi/drm/drm_fourcc.h @@ -24,7 +24,36 @@ #ifndef DRM_FOURCC_H #define DRM_FOURCC_H +/* + * Define DRM_FOURCC_STANDALONE you're interested only FOURCC and do not want + * to pull drm.h into your application. + */ +#ifdef DRM_FOURCC_STANDALONE +#if defined(__linux__) + +#include + +#else /* One of the BSDs */ + +#include + +/* + * When using C99 -pedantic the typedefs will trigger a warning. + * If the header is considered a system one (-isystem) those will be + * ignored, yet on the target platforms BSDs, et al - the headers live + * in a non-system location. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +typedef uint32_t __u32; +typedef uint64_t __u64; +#pragma GCC diagnostic pop + +#endif /* __linux __ */ + +#else #include "drm.h" +#endif /* DRM_FOURCC_STANDALONE */ #if defined(__cplusplus) extern "C" {