From nobody Mon Nov 25 00:33:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1718755720; cv=none; d=zohomail.com; s=zohoarc; b=KfeYhDzo0omi7gvUXEGjQm13/b6kEITnJ9qWiXQ0+2jYxYUuhJjxx9h7OWCAqQCsBuhe8RnJm25GOY6jy2gHkSZCAVcGjS2Kzqfh99JAN53WPK/vyO3ZKs2kMD5Dd4N4uGbzw0N1N43GbSWG4kxGkUxwCm5icZ0EsNY3qFZxwnY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718755720; h=Content-Type:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PswgJgfdGa9sop3DP6SyW+B2hdAbdt/AjMlIVsl0w8g=; b=H6IuitIGXDeDwMm57g3tKYXERHR3KzWjRKin+kArcKssQqVrhy2QDhgoSmTjdnkLP+mFDy/z0mK/AKqY2bYkY9xDjGZk5HZAJdHXiw2laSRiwNNsGcDQ73enNDAxw7ZwlUj8v44KaxQoJdfYRk5dRp/bfMa1MEFKpCj+AX3qhRQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718755720988571.2648082283926; Tue, 18 Jun 2024 17:08:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJiri-0007Iw-NH; Tue, 18 Jun 2024 20:07:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3TCFyZgQKCpEC53C19916z.x97Bz7F-yzGz689818F.9C1@flex--rkir.bounces.google.com>) id 1sJira-0007IP-4t for qemu-devel@nongnu.org; Tue, 18 Jun 2024 20:07:47 -0400 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3TCFyZgQKCpEC53C19916z.x97Bz7F-yzGz689818F.9C1@flex--rkir.bounces.google.com>) id 1sJirY-0005rU-Ck for qemu-devel@nongnu.org; Tue, 18 Jun 2024 20:07:45 -0400 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dfe44496da9so10702954276.0 for ; Tue, 18 Jun 2024 17:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718755661; x=1719360461; darn=nongnu.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=PswgJgfdGa9sop3DP6SyW+B2hdAbdt/AjMlIVsl0w8g=; b=iR3jcwi2LZ3fycJPpXZ+G+wGGsdbbY1xk6uTQHBuDouOgs6fDhHs7YNHuUH5e7X6/k +qqyEA9zdZu9cHbEYMPEzG1Va2M1Ps3RMhAsPMpX3Iy69UJnz1bQW7+nOu8FYQSdMAad dhfaQS7xr6IOF8WTSVIdQ6+FJHkKVa7CHIty0D+nPm4VFH45ASVVyiWP3MS5nun7G2cO E6GgFl7yLPCBWTYO2yDsxxmBvXaP7XB8c4AcjNr2GgCyhOZR4vLZGhkQ6CgcYiUTy6Ga 0SKLjTN29I30oa0rKf5c/xQiy2ipRZF8sKU3r3nVZ+dzjJxqjsplGQuoqHr/fr6r4rdD WQDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718755661; x=1719360461; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=PswgJgfdGa9sop3DP6SyW+B2hdAbdt/AjMlIVsl0w8g=; b=pXD4bbHCTTR2ZYSpOaTVA1TdB8NW9eydKsahOHtSQPgyyW11Z3dfsCzDVNHwPzrSrR YNcHVoltOBGuYtweN7L9abC6FHF0ZgCa6xXQkJjJGxtXHY8hvkjCulSsU+Nu0PvAPge9 L9jmOadS7fZ/5EJ5ChM+Ly1tjD+i25aByhexDA9w0uUZRkwN+BhnEChsRS18Tcjihxwf BoYFn2ZHrwu39SURYKLy+VMObKDKM/hm82mO8236kadTvQy8IN5rBtVLCpsYWQLir3e6 R9pfC0H0OUknfxW8fHpILCY3SirnBdoIBiOUOqQghNlDGVQHOWWfCDdlaRwUIRcfmItM /MJA== X-Forwarded-Encrypted: i=1; AJvYcCUwa+54EtJj7HQhy1c/rHPPPWVpkePGxjmWs+RaGXBZHukGvGhXsHKbOpVjD2vCSjN9Ycl+BqanrhLoSi0WNA3/0bltQks= X-Gm-Message-State: AOJu0YzNK8v/YAL4ZgURXFaRJ7c04OmSTBk3Ul7cs74RTJDVoLSywxJi gPiLMFaR8y1o/fXBjGJGrSCnrEIdkFeyw4CDDYtpwpFdJjQjCK8URzNRBamKQnUzXsRM5A== X-Google-Smtp-Source: AGHT+IHZzN2OsvyT9/tDfPbxt1RJOzPfmWC5wOlOCnjjn2R5lOlcwTB1pGtTbZAPk9TJfrBhKL0frUV8 X-Received: from rkir98.kir.corp.google.com ([2620:15c:7d:4:fddf:5bf:9eb2:410e]) (user=rkir job=sendgmr) by 2002:a05:6902:1890:b0:e02:5b08:d3a with SMTP id 3f1490d57ef6-e02bdf6420bmr260170276.0.1718755660868; Tue, 18 Jun 2024 17:07:40 -0700 (PDT) Date: Tue, 18 Jun 2024 17:04:50 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog Message-ID: <20240619000450.893463-1-rkir@google.com> Subject: [PATCH v2] exec: use char* for pointer arithmetic From: Roman Kiryanov To: richard.henderson@linaro.org, qemu-devel@nongnu.org Cc: jansene@google.com, mett@google.com, jpcottin@google.com, Roman Kiryanov Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b49; envelope-from=3TCFyZgQKCpEC53C19916z.x97Bz7F-yzGz689818F.9C1@flex--rkir.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1718755722321100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" void* pointer arithmetic is not in the C standard. This change allows using the QEMU headers with a C++ compiler. Google-Bug-Id: 331190993 Change-Id: I5a064853429f627c17a9213910811dea4ced6174 Signed-off-by: Roman Kiryanov Reviewed-by: Richard Henderson --- v2: change `char*` into `char *` (add the missing space). include/exec/memory.h | 8 ++++---- include/exec/memory_ldst_cached.h.inc | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index d7591a60d9..a6d64e39a5 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2839,7 +2839,7 @@ static inline uint8_t address_space_ldub_cached(Memor= yRegionCache *cache, { assert(addr < cache->len); if (likely(cache->ptr)) { - return ldub_p(cache->ptr + addr); + return ldub_p((char *)cache->ptr + addr); } else { return address_space_ldub_cached_slow(cache, addr, attrs, result); } @@ -2850,7 +2850,7 @@ static inline void address_space_stb_cached(MemoryReg= ionCache *cache, { assert(addr < cache->len); if (likely(cache->ptr)) { - stb_p(cache->ptr + addr, val); + stb_p((char *)cache->ptr + addr, val); } else { address_space_stb_cached_slow(cache, addr, val, attrs, result); } @@ -3123,7 +3123,7 @@ address_space_read_cached(MemoryRegionCache *cache, h= waddr addr, assert(addr < cache->len && len <=3D cache->len - addr); fuzz_dma_read_cb(cache->xlat + addr, len, cache->mrs.mr); if (likely(cache->ptr)) { - memcpy(buf, cache->ptr + addr, len); + memcpy(buf, (char *)cache->ptr + addr, len); return MEMTX_OK; } else { return address_space_read_cached_slow(cache, addr, buf, len); @@ -3144,7 +3144,7 @@ address_space_write_cached(MemoryRegionCache *cache, = hwaddr addr, { assert(addr < cache->len && len <=3D cache->len - addr); if (likely(cache->ptr)) { - memcpy(cache->ptr + addr, buf, len); + memcpy((char *)cache->ptr + addr, buf, len); return MEMTX_OK; } else { return address_space_write_cached_slow(cache, addr, buf, len); diff --git a/include/exec/memory_ldst_cached.h.inc b/include/exec/memory_ld= st_cached.h.inc index d7834f852c..9426663524 100644 --- a/include/exec/memory_ldst_cached.h.inc +++ b/include/exec/memory_ldst_cached.h.inc @@ -30,7 +30,7 @@ static inline uint16_t ADDRESS_SPACE_LD_CACHED(uw)(Memory= RegionCache *cache, assert(addr < cache->len && 2 <=3D cache->len - addr); fuzz_dma_read_cb(cache->xlat + addr, 2, cache->mrs.mr); if (likely(cache->ptr)) { - return LD_P(uw)(cache->ptr + addr); + return LD_P(uw)((char *)cache->ptr + addr); } else { return ADDRESS_SPACE_LD_CACHED_SLOW(uw)(cache, addr, attrs, result= ); } @@ -42,7 +42,7 @@ static inline uint32_t ADDRESS_SPACE_LD_CACHED(l)(MemoryR= egionCache *cache, assert(addr < cache->len && 4 <=3D cache->len - addr); fuzz_dma_read_cb(cache->xlat + addr, 4, cache->mrs.mr); if (likely(cache->ptr)) { - return LD_P(l)(cache->ptr + addr); + return LD_P(l)((char *)cache->ptr + addr); } else { return ADDRESS_SPACE_LD_CACHED_SLOW(l)(cache, addr, attrs, result); } @@ -54,7 +54,7 @@ static inline uint64_t ADDRESS_SPACE_LD_CACHED(q)(MemoryR= egionCache *cache, assert(addr < cache->len && 8 <=3D cache->len - addr); fuzz_dma_read_cb(cache->xlat + addr, 8, cache->mrs.mr); if (likely(cache->ptr)) { - return LD_P(q)(cache->ptr + addr); + return LD_P(q)((char *)cache->ptr + addr); } else { return ADDRESS_SPACE_LD_CACHED_SLOW(q)(cache, addr, attrs, result); } @@ -76,7 +76,7 @@ static inline void ADDRESS_SPACE_ST_CACHED(w)(MemoryRegio= nCache *cache, { assert(addr < cache->len && 2 <=3D cache->len - addr); if (likely(cache->ptr)) { - ST_P(w)(cache->ptr + addr, val); + ST_P(w)((char *)cache->ptr + addr, val); } else { ADDRESS_SPACE_ST_CACHED_SLOW(w)(cache, addr, val, attrs, result); } @@ -87,7 +87,7 @@ static inline void ADDRESS_SPACE_ST_CACHED(l)(MemoryRegio= nCache *cache, { assert(addr < cache->len && 4 <=3D cache->len - addr); if (likely(cache->ptr)) { - ST_P(l)(cache->ptr + addr, val); + ST_P(l)((char *)cache->ptr + addr, val); } else { ADDRESS_SPACE_ST_CACHED_SLOW(l)(cache, addr, val, attrs, result); } @@ -98,7 +98,7 @@ static inline void ADDRESS_SPACE_ST_CACHED(q)(MemoryRegio= nCache *cache, { assert(addr < cache->len && 8 <=3D cache->len - addr); if (likely(cache->ptr)) { - ST_P(q)(cache->ptr + addr, val); + ST_P(q)((char *)cache->ptr + addr, val); } else { ADDRESS_SPACE_ST_CACHED_SLOW(q)(cache, addr, val, attrs, result); } --=20 2.45.2.627.g7a2c4fd464-goog