This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3 03/18] Add string-maskoff.h generic header



On 10/01/2018 21:24, Paul Eggert wrote:
> On 01/10/2018 04:47 AM, Adhemerval Zanella wrote:
>> +/* Create a mask with high bit of each byte being 1, and the low 7 bits
>> +   being all the opposite of the input mask.  It is used to mask off
>> +   undesirable bits from an aligned read from an unaligned pointer,
>> +   and also taking care to avoid match possible bytes meant to be
>> +   matched.  For instance, on a 64 bits machine with a pointer alignment
>> +   of 3 the function returns 0x7f7f7f0000000000 (input meant to
>> +   be 0xffffff0000000000) for BE and 0x00000000007f7f7f for LE (input
>> +   meant to be 0x0000000000ffffff).  */
>> +static inline op_t
>> +highbit_mask (op_t m)
>> +{
>> +  return m & ~repeat_bytes (0x80);
>> +}
> 
> The first line of the comment does not match the implementation, which would have to be something like "return (m ^ repeat_bytes (0x7f)) | repeat_bytes (0x80);" to match the comment. Also, I suggest replacing "~repeat_bytes (0x80)" with "repeat_bytes (0x7f)" as the latter is a bit simpler.

Thanks, I will change it locally.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]