From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 224A4469FD for ; Wed, 2 Aug 2023 07:02:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5B6C068C534; Wed, 2 Aug 2023 10:02:15 +0300 (EEST) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C586268BABF for ; Wed, 2 Aug 2023 10:02:09 +0300 (EEST) Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2b9c907bc68so89655251fa.2 for ; Wed, 02 Aug 2023 00:02:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20221208.gappssmtp.com; s=20221208; t=1690959729; x=1691564529; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=BwsGSQjsBUY5dRPAAiL+CVHLOy4zCOyIpztBtO8fMOk=; b=nyMLJakVECc65HTMRjpTjCU+b32EYnS1w4+1E1ksTrwYPsKMo/+IDwAtQerAPvTsf7 16o25g1MO6kmvxNuV9Uly9gZ8hiAu3mdyA/LVaz0LaxpE7cpBNj1l3Miho24MRTmDoKd twozUiniylsowfseXCpG61GzVLFK1B2G9NhxwhXuXXtEH2pagrHhRHF5Vrnf5m43nocN Di3oQeXeEAaq9abV9BDtKgXBHdtbSWU4+lXvmbKhnAG/f8U1icUbCFo6wVEMEKnUNTZv C9j48dJSfsSFZjxYfDHi2TrxyFG6e6567SS4wy7ijpSaxdxFZgHqzHvbnPD9qw/k4kXB 5fMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690959729; x=1691564529; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BwsGSQjsBUY5dRPAAiL+CVHLOy4zCOyIpztBtO8fMOk=; b=OwBpg+SlISVNYoKTFOkxAjio+iX8ebFcRsG0RiPq1v+k1xfPrVB14pOirmcz3czwDq kPvFc/HFiWgId/lJQ3TJVLbY5yIwJV6AVJk89UqV4A4lK9K206Sm5DchFkRZ5NTj/nLk 17Z7mrSFCD+rOP58ajjwYbtFTG5XqpAMigfW/EjNuPIhl6PJVDn6a6T63ZWSVSBcF1S8 PPz858crD1V5DUhueUYj40JKlyJlUp96XT9QL8bKlP7DH1yaatue8oEyk2r3YxxKlQFu 4vRa0o5zzzXnTX++A+HEUffnE/tmu+T7vB/jjGBeCKrNzS7VY8411ZyO03fbm2W+mMKp lGgQ== X-Gm-Message-State: ABy/qLZcDo1MVKaq0+EtGtpj5Lfghz8hNBXmo1aHYHOuc7PrKTcezqth iKgZ/ShbTuSewi+nBpeIyQEa1GVMcmkqgcWaZjyHbA== X-Google-Smtp-Source: APBJJlFfMztm1vcZAQ73PGu4DqtVbgACrs50THHfNgxOG04hPTQyeYL14XjgewReqN4Dj6JLCr33bQ== X-Received: by 2002:a2e:7e0b:0:b0:2b4:65ef:3af5 with SMTP id z11-20020a2e7e0b000000b002b465ef3af5mr4157862ljc.30.1690959728683; Wed, 02 Aug 2023 00:02:08 -0700 (PDT) Received: from localhost.localdomain (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id d13-20020a2e330d000000b002b6cb40e9aasm3312538ljc.103.2023.08.02.00.02.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 00:02:08 -0700 (PDT) From: =?UTF-8?q?Martin=20Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Aug 2023 10:02:06 +0300 Message-Id: <20230802070206.28917-1-martin@martin.st> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] intreadwrite: Indicate potential aliasing in AV_RN/AV_WN for Clang/MSVC mode X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: While MSVC proper doesn't have a way to signal potential aliasing corresponding to __attribute__((may_alias)) (which is what av_alias expands to, if supported), Clang does support it. When building with Clang in MSVC mode, __GNUC__ isn't defined but _MSC_VER is, so Clang uses the MSVC implementation of AV_RN/AV_WN which uses __unaligned. Add the av_alias macro there, to indicate that the reads/writes can alias other writes. Adding the attribute within the cast itself doesn't seem to have any effect, it only has an effect if added in a type definition. Alternatively the __GNUC__ specific codepath right above could also be used whenever __clang__ is defined; numerous __GNUC__ checks also separately check for __clang__ to use them when building with Clang in MSVC mode. This fixes a couple HEVC decoder tests when built with Clang 14 or newer in MSVC mode (with issues observed on all of x86_64, armv7 and aarch64). --- libavutil/intreadwrite.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h index c4679fdba4..126ac3c7f8 100644 --- a/libavutil/intreadwrite.h +++ b/libavutil/intreadwrite.h @@ -224,8 +224,12 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; #elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_X64) || defined(_M_ARM64)) && AV_HAVE_FAST_UNALIGNED -# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p))) -# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v)) +typedef __unaligned uint64_t av_alias unaligned_64; +typedef __unaligned uint32_t av_alias unaligned_32; +typedef __unaligned uint16_t av_alias unaligned_16; + +# define AV_RN(s, p) (*((const unaligned_##s*)(p))) +# define AV_WN(s, p, v) (*((unaligned_##s*)(p)) = (v)) #elif AV_HAVE_FAST_UNALIGNED -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".