On 01/24/2018 15:16, Emil Velikov wrote:
On 24 January 2018 at 11:58, Greg V <[email protected]> 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?
We don't want shm_open semantics in general though. That wouldn't be an
anonymous fd. Shared memory actually gets garbage collected when you
unlink it.
Only FreeBSD extended shm_open to accept the SHM_ANON constant to
provide anonymous memory file descriptors, i.e. the same thing that
Linux did with a separate syscall (memfd_create).
I can't imagine a situation when shm_open(SHM_ANON) would fail but
mkostemp would succeed.
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.
More functions — more terrible ifdefs…
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev