Cleaning up FILE in stdio..



Way back in the 4.x days we had a fiasco over changing the size of FILE
(struct __sFILE) to add locking for multithreaded apps because
the 'stdin', 'stdout', and 'stderr' symbols were direct references to the
global array of FILE objects. The first fix was to move the locking fields
into a private 'struct __sFILEX' to preserve the size of FILE. Later the
stdin/out/err symbols were fixed to reference standalone pointers instead of
the global array. Given that, I think at this point we can safely merge
__sFILEX back into __sFILE w/o breaking anything. This is assuming that the
contents and layout of FILE are not a public ABI (i.e. we malloc the things
internally and consumers should just treat the pointer value as a cookie and
not grub around in the internals). In addition to removing the __sFILEX
stuff, I'd like to change the fd member of FILE to be an int so you can open
more than 32k files via fopen(). Otherwise, if fopen() gets an fd that is >
SHORT_MAX, it gets sign extended when the fd is passed to read(), close(),
etc. and those calls fail with EBADF.

Comments?

--
John Baldwin
_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Cleaning up FILE in stdio..
    ... the 'stdin', 'stdout', and 'stderr' symbols were direct references to the ... The first fix was to move the locking fields ... into a private 'struct __sFILEX' to preserve the size of FILE. ... not grub around in the internals). ...
    (freebsd-arch)
  • Re: [patch 0/9] buffered write deadlock fix
    ... and then teaching the pagefault code to avoid locking ... ab/ba deadlocking so I dropped it. ... struct backing_dev_info; ...
    (Linux-Kernel)
  • Volatile, pthread mutexes, structure pointers, and non-locked reads
    ... It's unclear to me if I need to use volatile and/or add extra locking ... around a field of a struct to avoid the compiler optimizing away a read ... I've read that if I use locking around all accesses to a variable then ... pthread_mutex_unlock(globalMutex); ...
    (comp.programming.threads)
  • Re: How to create an array of data types only
    ... > like to do is create a global array of the class types ... through it using the print_type_names template function. ... struct TypeList ... typedef T Head; ...
    (comp.lang.cpp)
  • [PATCH 4/7] fuse: add POSIX file locking support
    ... This patch adds POSIX file locking support to the fuse interface. ... +struct fuse_file_lock { ...
    (Linux-Kernel)