[Mesa-dev] [PATCH v2 3/5] util: add anon_file.h for all memfd/temp file usage

Emil Velikov emil.l.velikov at gmail.com
Wed Jan 24 12:16:00 UTC 2018


On 24 January 2018 at 11:58, Greg V <greg at unrelenting.technology> wrote:

>>>
>>> +#ifndef __FreeBSD__
>>
>> mkstemp does exist on FreeBSD, right? If so you can drop this guard
>> and simplify the one in os_create_anonymous_file().
>
> The guard is there because this function (create_tmpfile_cloexec) goes
> unused on FreeBSD. os_create_anonymous_file uses shm_open, which does not
> take a filename.
> I could've used shm_open inside create_tmpfile_cloexec but that would cause
> compiler warnings about unused arguments…
>
> I guess I'll just merge create_tmpfile_cloexec into
> os_create_anonymous_file, it's currently separated for no good reason.

I was thinking that FreeBSD can fallback to create_tmpfile_cloexec, if
shm_open fails.
Skimming through shm_open and mk{o,}stemp manuals - they are both
POSIX 2001 standard (kind of, mkostemp is a GNU extension).
Can't we use one across all platforms?

Unused variables/arguments can be annotated with the UNUSED/MAYBE_UNUSED macros.
I won't merge the two functions through. As is they're shorter and
easier to read - plus the compiler can inline things where needed.

Thanks
Emil


More information about the mesa-dev mailing list