From patchwork Wed Sep 26 18:37:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147642 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1073987lji; Wed, 26 Sep 2018 11:45:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV63PzZmCrSXGSPClVrqGVzCAoNmRZ2+CWVsD1m2jM1FyZ8eqRkb1GH3NniUPOygox+qOvp7t X-Received: by 2002:a37:1413:: with SMTP id e19-v6mr5117636qkh.295.1537987559520; Wed, 26 Sep 2018 11:45:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987559; cv=none; d=google.com; s=arc-20160816; b=HtZctp2lwXwVb2b900O9prAjmDudwoQlZuPAGRyRPzGo2iSYBGTpcAu9iYrt/fB55d myiM6rfyRpU7A95AO91tWoCgMLPt1PvifwFidcxde6MCfbpBbf9noXizGPB83E2wloU8 cgcoAgCXX9FFZ0d1ooKDQyOngufO8wVXTI2zffYzkEue0+eAPu9t4Rendp3IMmwYFqwp al0fIkhCuxwivv17i8ACei8Vt3hL3bGlge0f2u25SXYegkHhifpSV/NuHFRVHMGFenUW hcX0k6CbaV26pWAMVRYOMx3VocF14owip82i6LNsondpwsKkh8a3P+bOA7cfXQ/nIlQt X2xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=0BtRPf/GqT2Gcz1kpvT8HmkgarCmz1fRFhyUubjsPFc=; b=j3IoTOV+u5aYecG4qvgX2y29+Axhegr4r8W6ufdWqtsE95oosWRP2b4EjfGEsqnMuM P+0y5oJhdeXowvciy1kLi4drt/khuli2A0fEJx2Td8kP9vtKdnQGbFak5L0nPW1sImcN NXlIB+pfbz7KhADNMVyFplS9FbLluzA2k2UJyvgeAJMN6GJuBkZ9nrflMXvM+6irH0TK QSMEVQP9nFQ3SvYo2LliZKk3/MjDy25RTTV88+Znw3gQrDiT0XGrLGXlbNr9KJWbALV2 NWicqXPVKMfrh6K44X6Bn+4pITwsJE+jmmJopwXr5V5BHWp21sWh9Qtnc8W5517YZDzr 7HMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jeWBsXWZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k79-v6si2368938qke.129.2018.09.26.11.45.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:45:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jeWBsXWZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Eow-0001xc-V3 for patch@linaro.org; Wed, 26 Sep 2018 14:45:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egn-0001hE-QT for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Egk-0007Pt-Nb for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:33 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:40831) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egk-0007Mf-Dt for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:30 -0400 Received: by mail-pg1-x543.google.com with SMTP id n31-v6so7527749pgm.7 for ; Wed, 26 Sep 2018 11:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0BtRPf/GqT2Gcz1kpvT8HmkgarCmz1fRFhyUubjsPFc=; b=jeWBsXWZP4y0nToQs5ITONjrl06hO7Tt8rzyjVyFzWTBfEQxg8Ew9q8Mbu1F7Mt0Ia 6dVnw/FR3CoRzKMJcfGipHHCgkyj2/8ISH62T5biUmWuZbQM66J9zjLhZH4/UXIhM0tB 21Htme5xQEB7wAgIW4EumzecpUdSrQIfDRm2M= 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:in-reply-to :references; bh=0BtRPf/GqT2Gcz1kpvT8HmkgarCmz1fRFhyUubjsPFc=; b=UlWdnCT40FUM1y3f7fV/tUasFB5Dcu+xsGHlYfBmfBDn4y6FGBWcbZTwINPEAIk2ut CfxKu+ogeBHWwQHe+hhk0kqBDst8Ms6mWEkNm+Rrr4rvmqFW9iFVIwPgUl/uQpxIcyNT kdXTFzqs3bfe4JM1OB2ZQ7o8z5Q6utQRbaBcva7gCqR6TiQ6rX5g1e33HK3ROynOhu5h tMxH137bQ7OWF+rDMeKITFYY6BDfayYTydbfId8s3sDnv1DidmCaP/kpSa/g6BcBUmb+ 2/hZnXb3vdNkkCB2ULJXjCtsYnSzJ3hdOUsFD9DNd/62FVrUamdi7fPclbCh/fqjKRAs 2zkg== X-Gm-Message-State: ABuFfoj3dK/Yd2ERGWUFbNCohNCryWe6RUCEMVxS6UAHUCyuEDSDjdd6 1eC6uq85XHTgmlDhExsb2QRjen/WdRU= X-Received: by 2002:a62:20d8:: with SMTP id m85-v6mr7573490pfj.74.1537987046016; Wed, 26 Sep 2018 11:37:26 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:05 -0700 Message-Id: <20180926183709.21293-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PULL 09/13] qht: constify qht_lookup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" seqlock_read_begin takes a const param since c04649eeea ("seqlock: constify seqlock_read_begin", 2018-08-23), so we can constify the entire lookup. Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- include/qemu/qht.h | 4 ++-- util/qht.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/include/qemu/qht.h b/include/qemu/qht.h index 6484837487..2e2d6bca93 100644 --- a/include/qemu/qht.h +++ b/include/qemu/qht.h @@ -104,7 +104,7 @@ bool qht_insert(struct qht *ht, void *p, uint32_t hash, void **existing); * Returns the corresponding pointer when a match is found. * Returns NULL otherwise. */ -void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, +void *qht_lookup_custom(const struct qht *ht, const void *userp, uint32_t hash, qht_lookup_func_t func); /** @@ -115,7 +115,7 @@ void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, * * Calls qht_lookup_custom() using @ht's default comparison function. */ -void *qht_lookup(struct qht *ht, const void *userp, uint32_t hash); +void *qht_lookup(const struct qht *ht, const void *userp, uint32_t hash); /** * qht_remove - remove a pointer from the hash table diff --git a/util/qht.c b/util/qht.c index 3564a7e20f..020dfe6912 100644 --- a/util/qht.c +++ b/util/qht.c @@ -236,7 +236,7 @@ static inline void qht_head_init(struct qht_bucket *b) } static inline -struct qht_bucket *qht_map_to_bucket(struct qht_map *map, uint32_t hash) +struct qht_bucket *qht_map_to_bucket(const struct qht_map *map, uint32_t hash) { return &map->buckets[hash & (map->n_buckets - 1)]; } @@ -482,10 +482,10 @@ bool qht_reset_size(struct qht *ht, size_t n_elems) } static inline -void *qht_do_lookup(struct qht_bucket *head, qht_lookup_func_t func, +void *qht_do_lookup(const struct qht_bucket *head, qht_lookup_func_t func, const void *userp, uint32_t hash) { - struct qht_bucket *b = head; + const struct qht_bucket *b = head; int i; do { @@ -509,7 +509,7 @@ void *qht_do_lookup(struct qht_bucket *head, qht_lookup_func_t func, } static __attribute__((noinline)) -void *qht_lookup__slowpath(struct qht_bucket *b, qht_lookup_func_t func, +void *qht_lookup__slowpath(const struct qht_bucket *b, qht_lookup_func_t func, const void *userp, uint32_t hash) { unsigned int version; @@ -522,11 +522,11 @@ void *qht_lookup__slowpath(struct qht_bucket *b, qht_lookup_func_t func, return ret; } -void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, +void *qht_lookup_custom(const struct qht *ht, const void *userp, uint32_t hash, qht_lookup_func_t func) { - struct qht_bucket *b; - struct qht_map *map; + const struct qht_bucket *b; + const struct qht_map *map; unsigned int version; void *ret; @@ -545,7 +545,7 @@ void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, return qht_lookup__slowpath(b, func, userp, hash); } -void *qht_lookup(struct qht *ht, const void *userp, uint32_t hash) +void *qht_lookup(const struct qht *ht, const void *userp, uint32_t hash) { return qht_lookup_custom(ht, userp, hash, ht->cmp); }