From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id BF6363858CDB for ; Fri, 14 Jul 2023 12:06:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF6363858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-6b8b6f7399aso1444228a34.1 for ; Fri, 14 Jul 2023 05:06:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689336373; x=1691928373; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=enArHy56KP7AlyhQTkOP2LxOCng873A8cItiJgXfeDI=; b=KQQRXWYYJedLpZoGweTQNF5BPC59+qG7DDanSsjr6qr9QzdVNn3KisLQ9djSGlMS3s DDrrCXwVeXXrzS2tSzt9DM4V6gRt2asTaX8p9ZhwhbxIA/6DLicUGZq3Mg/6lIgNvZ+j UjVIny0tQybe8aEP0SzdavR2XOMkrviB/9eNdkyz4aHxi574R06pPrSHB5PT1dP3+W5g 0OlKwFibczclkiVwa/0B3CfYpfXzsVtlbXsESDRhzrBir+eAOVPWOkd34X4tTaL6tCdi 7HLON3tUffjm0FCvp5yHcudqicGiEgKMeOiSdSrT9o2uUrbg5JfdqMrW1XhbhUXbVo6i xKrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689336373; x=1691928373; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=enArHy56KP7AlyhQTkOP2LxOCng873A8cItiJgXfeDI=; b=U2v53XCTmIGjQPdVJnUHwyrC1ODKvwC76+T5sP7x6vG9w32CL7sbn5MVycI2HeAz3f mpt3rip9vebV06tMUBDYEh5leMCAUwLBp6SQb/i3w0AxnuDPcaBjqPv69TY3FbaarUdQ HW0InjrWtfaHRCoti6qpFHV2nOay1SZzq9d/tOQrnugnieQcCiWof8VR3yiMPabRYXLQ l0U9P3LYXV6gwEbpMKrQJWIwR2QlEnrIl7fAixWvlA5XqT0Eta/em4pgka7J6DPMeogm pBx6tYGww2M5rTT/WdE2DyRCa0Ym+LQccaiMzMiQle90EIhUgOnWqF2kQUPC1WZdRfE3 Y50g== X-Gm-Message-State: ABy/qLZGg0ufYAztDWPdoU+L5aAFJUxYfTrGoTHjaT5wcpRTvtWbsIav MzS0Kb8Z3s2C/7IQNcxNREZnvSg6wLBVYsqfue2Icg== X-Google-Smtp-Source: APBJJlF6HTCKcZwSlafjQ0G3TJBNyaWDGTbIVqmHHvgoTLlCe8ini0eX3IxLZu9rQZP+c2MDQJa98A== X-Received: by 2002:a9d:5906:0:b0:6b9:bd9d:e333 with SMTP id t6-20020a9d5906000000b006b9bd9de333mr1494123oth.3.1689336373054; Fri, 14 Jul 2023 05:06:13 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:5656:48d5:22ee:3be1:494a? ([2804:1b3:a7c0:5656:48d5:22ee:3be1:494a]) by smtp.gmail.com with ESMTPSA id z21-20020a05683010d500b006b89dafb721sm3697009oto.78.2023.07.14.05.06.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Jul 2023 05:06:12 -0700 (PDT) Message-ID: <818704c3-c83d-d40d-cef4-aac207086005@linaro.org> Date: Fri, 14 Jul 2023 09:06:09 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v5 1/6] stdlib: Optimization qsort{_r} swap implementation To: Paul Eggert , libc-alpha@sourceware.org References: <20230713132540.2854320-1-adhemerval.zanella@linaro.org> <20230713132540.2854320-2-adhemerval.zanella@linaro.org> <5b14fe86-97de-9ced-bcb4-0ae9a068e814@cs.ucla.edu> <831f05e0-f209-abe5-8f46-134b6576f2c7@cs.ucla.edu> Content-Language: en-US From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <831f05e0-f209-abe5-8f46-134b6576f2c7@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 13/07/23 22:01, Paul Eggert wrote: > On 2023-07-13 15:17, Paul Eggert wrote: > >>> +  if (is_aligned (pbase, size, 8)) >> >> Change "8" to "alignof (uint64_t)". > > > Oops, scratch that. The size must be a multiple of sizeof (uint64_t) and the alignment must be a multiple of alignof (uint64_t). Since sizeof (uint64_t) must be a multiple of alignof (uint64_t) what you wrote was safe (but confusing), whereas what I wrote was not. > > To help avoid confusion by future readers, I suggest rewriting the comments and parameters for is_aligned to be something like the following. This shouldn't change the machine code. > >   /* If this function returns true, elements can be safely copied using >      word loads and stores.  Otherwise, it might not be safe. >      BASE (as an integer) must be a multiple of the word alignment. >      TOTAL_SIZE must be a multiple of WORDSIZE. I think you meant SIZE here instead of TOTAL_SIZE. >      Since WORDSIZE must be a multiple of the word alignment, >      and WORDSIZE is a power of two on all supported platforms, >      this function for speed merely checks that BASE and SIZE >      are both multiples of the word size.  */ >   __attribute_const__ __always_inline static bool >   is_aligned (const void *base, size_t size, size_t wordsize) >   { >     return (((uintptr_t) base | size) & (wordsize - 1)) == 0; >   } > Alright, I changed this version.