This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] Add a new type attribute always_alias (PR79671)


On 04/06/2017 09:12 PM, Richard Biener wrote:
Right.  The kernel also has many APIs which return multiple
variable-length data blocks, such as getdents64, and many more
interfaces in combination with read/recv system calls.  Variable length

means that you cannot declare the appropriate type after the first data

item, so you technically have to use malloc.

POSIX interfaces which exhibit a similar pattern are getpwnam_r and
friends, but for them, you can probably use malloc without ill effect
(although there are still performance concerns).

Can you give a concrete example which shows the issue and how typeless_storage helps?

An example is in libffi/src/closures.c:

      char buf[MAXPATHLEN * 3];

      if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf)) == NULL)
        return -1;

The intent is that buf is untyped storage, from which the getmntent_r function can allocate objects as needed (instead of using malloc).

Based on your earlier comments, GCC already supports that without any further source code annotations.

Thanks,
Florian


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