public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Janne Blomqvist <blomqvist.janne@gmail.com>
To: Thomas Koenig <tkoenig@netcologne.de>
Cc: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch, fortran] Implement maxloc and minloc for character
Date: Tue, 21 Nov 2017 20:47:00 -0000	[thread overview]
Message-ID: <CAO9iq9Gh4t-Oa9mmfpPXMJjJbcOv_-8Ke8qDD9ONADQC4oxsdQ@mail.gmail.com> (raw)
In-Reply-To: <09d35ad1-6883-0372-7a1a-840c8c4b07f9@netcologne.de>

On Tue, Nov 21, 2017 at 9:50 PM, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Hi Janne,
>
>
>>> So, any other comments about my patch? OK for trunk?
>>
>>
>> - In many cases the copyright notice has "This file is part of the GNU
>> Fortran 95 runtime library (libgfortran)." It's a while since we've
>> called ourselves "GNU Fortran 95", so just remove the "95".
>
>
> That's what I got for copying over an old version of maxloc
> (when it still didn't have NAN handling) as a basis for my own
> patch. This also meant that I had an old copyright notice. Fixed.

Uh, it seems the patch you posted didn't actually fix this?

>> - It seems in the library you're using int for string lengths? Please
>> use gfc_charlen_type instead (in the frontend, gfc_charlen_type_node).
>> (Most of the charlen->size_t patch is fixing up places where we're
>> accidentally using int instead of gfc_charlen_type..).
>
>
> Fixed.

Not everywhere? At least

zgrep "int len" p8.diff.gz

turns up some cases?

>> - Why are you using GFC_INTEGER_1 / GFC_INTEGER_4 to loop over the
>> arrays rather than char/gfc_char4_t? Not sure if it makes any
>> difference in practice, but it sure seems confusing..
>
>
> The reason has to do with evil m4 magic. I used a macro
> from iparm.m4, atype_code. Changing m4 code should mostly
> be restricted to those cases where it is _really_ necessary
> (people, say, not without justification, that m4 is a write-only
> langauge).

Fair enough. :)

>> - Not really related to your patch, but memcmp_char4 sure looks
>> redundant. Isn't it the same as memcmp(a, b, size*4), in which case we
>> could use optimized memcmp implementations?
>
>
> Big/little endian issues.
>
> Consider the following short program:
>
> #include <stdio.h>
> #include <string.h>
>
> char a[4] = { 1, 2, 3, 4};
> char b[4] = { 4, 3, 2, 1};
>
> int main()
> {
>   int i, j;
>   memcpy (&i, a, sizeof(i));
>   memcpy (&j, b, sizeof(j));
>   printf("memcmp           : ");
>   if (memcmp (&i,&j,sizeof(i)))
>     printf("larger\n");
>   else
>     printf("smaller\n");
>
>   printf("Direct comparison: ");
>   if (i > j)
>     printf("larger\n");
>   else
>     printf("smaller\n");
>
>   return 0;
> }
>
> On my x86_64 system, this prints
>
> memcmp           : larger
>
>
> Direct comparison: larger
>
> On a big-endian system, this prints
>
> memcmp           : larger
> Direct comparison: smaller

Ooh, indeed.

> However, I just learned about the __BYTE_ORDER__ macro.
> We could use that (and in places where we currently have
> a runtime check, for example in replacing the big_endian
> global variable in libgfortran). But that is for another day.

Yup.

> So, attached is a new version of the patch. No update
> on the ChangeLog. OK for trunk?

Yup, just really fix the copyright and string length stuff first. Thanks!


-- 
Janne Blomqvist

  reply	other threads:[~2017-11-21 20:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-19 22:04 Thomas Koenig
2017-11-20  8:41 ` Janne Blomqvist
2017-11-20 18:33   ` Thomas Koenig
2017-11-21 16:25     ` Janne Blomqvist
2017-11-21 19:53       ` Thomas Koenig
2017-11-21 20:47         ` Janne Blomqvist [this message]
2017-11-22 18:16           ` Thomas Koenig
2017-11-23 13:25             ` Janne Blomqvist
2017-11-23 14:03               ` Janne Blomqvist
2017-11-23 14:06                 ` Ramana Radhakrishnan
2017-11-23 14:10                   ` Janne Blomqvist
2017-11-23 18:40               ` Thomas Koenig
2017-11-24  9:33                 ` Janne Blomqvist

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAO9iq9Gh4t-Oa9mmfpPXMJjJbcOv_-8Ke8qDD9ONADQC4oxsdQ@mail.gmail.com \
    --to=blomqvist.janne@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tkoenig@netcologne.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).