summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/_flock_stub.c
Commit message (Collapse)AuthorAgeFilesLines
* Next stage of stdio cleanup: Retire __sFILEX and merge the fields back intojhb2008-04-171-26/+16
| | | | | | | | | | | | | | | | | | | __sFILE. This was supposed to be done in 6.0. Some notes: - Where possible I restored the various lines to their pre-__sFILEX state. - Retire INITEXTRA() and just initialize the wchar bits (orientation and mbstate) explicitly instead. The various places that used INITEXTRA didn't need the locking fields or _up initialized. (Some places needed _up to exist and not be off the end of a NULL or garbage pointer, but they didn't require it to be initialized to a specific value.) - For now, stdio.h "knows" that pthread_t is a 'struct pthread *' to avoid namespace pollution of including all the pthread types in stdio.h. Once we remove all the inlines and make __sFILE private it can go back to using pthread_t, etc. - This does not remove any of the inlines currently and does not change any of the public ABI of 'FILE'. MFC after: 1 month Reviewed by: peter
* Remove 3rd clause, renumber, ok per emailimp2007-01-121-4/+1
|
* Backout the previous revision due to objections.jb2004-03-091-9/+3
|
* On 4.X it was possible for an application to initialise a local FILEjb2004-03-091-3/+9
| | | | | | | | | structure and call stdio functions. In 5.X this was broken when FILE locking was introduced into libc. This change makes most (relevant) stdio functions work again when the _extra file in FILE isn't initialised (and can't be without a libc function to do it since the __sFILEX structure is private to libc).
* Fix the style of the SCM ID's.obrien2002-03-221-3/+3
| | | | I believe have made all of libc .c's as consistent as possible.
* To be consistent, use the __weak_reference macro from <sys/cdefs.h>deischen2001-04-101-4/+4
| | | | | | | | instead of #pragma weak to create weak definitions. This macro is improperly named, though, since a weak definition is not the same thing as a weak reference. Suggested by: bde
* Hide the definition of struct __sFILEX and add the neededdeischen2001-03-011-81/+23
| | | | | | | lock definitions to it. flockfile state is now allocated along with the rest of FILE. This eliminates the need for a separate allocation of flockfile state as well as eliminating the mutex/lock used to serialize its allocation.
* Correctly handle the race itself, too (don't leave it locked).green2001-02-231-0/+1
| | | | | | This is about to be replaced anyway by initialization explicitly instead of lazily, and reducing the complexity of it. As it is now, this will work fine, however.
* Use the right names to call pthread_mutex_{,un}lock so that thingsgreen2001-02-231-2/+2
| | | | work in both the libc only and libc/libc_r case.
* Fix the problems I (and others, undoubtedly) have been having for agreen2001-02-231-3/+12
| | | | | | | | | | | | | | | | | | | | | | while with threaded software in -CURRENT acting very "weird". It has seemed, for example, in Mozilla that threads attempting to do host lookups have been locking up. That's exactly the case. There was a race condition in the implementation of the initialization of the mutex used to protect FILE operations, first of all: multiple instances of FLOCKFILE() in libc could occur on the same FILE at the same time and cause strange behavior by overwriting eachothers' creation of the mutex and the rest of the file lock. Secondly, it's not appropriate to test the "validity" of the file descriptor referenced by the FILE; if the code is calling FLOCKFILE() or FUNLOCKFILE(), it wants the FILE to be locked or unlocked, not to be locked or unlocked on the condition that _file is >= 0. This also could quite easily cause leaks by failing to perform the lock or unlock operation when it actually is needed. Mozilla now works again on -CURRENT when linked to libc_r.so.5 and libc.so.5.
* Fix the current libc breakage in current:imp2001-02-161-0/+10
| | | | | | | | | | | | | o Back out the __std* stuff. Can't figure out how to do this right now, so we'll save it for late. o use _up as a pointer for extra fields that we need to access. o back out the libc major version bump. Submitted by: green reviewed by: peter, imp, green, obrien (to varying degrees). We'll fix the "how do we stop encoding sizeof(FILE) in binaries" part later.
* libc MT-safety, part 2.deischen2001-02-111-22/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a lock to FILE. flockfile and friends are now implemented (for the most part) in libc. flockfile_debug is implemented in libc_r; I suppose it's about time to kill it but will do it in a future commit. Fix a potential deadlock in _fwalk in a threaded environment. A file flag (__SIGN) was added to stdio.h that, when set, tells _fwalk to ignore it in its walk. This seemed to be needed in refill.c because each file needs to be locked when flushing. Add a stub for pthread_self in libc. This is needed by flockfile which is allowed by POSIX to be recursive. Make fgetpos() error return value (-1) match man page. Remove recursive calls to locked functions (stdio); I think I've got them all, but I may have missed a couple. A few K&R -> ANSI conversions along with removal of a few instances of "register". $Id$ -> $FreeBSD$ in libc/stdio/rget.c Not objected to: -arch, a few months ago
* Remove _THREAD_SAFE and make libc thread-safe by default bydeischen2001-01-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Remove leading underscores for the functions (weak symbols here) thatjb1998-05-051-4/+7
| | | | POSIX defines.
* Add FILE locking stubs for libc.jb1998-04-111-0/+78
Change the FILE locking to support kernel threads when linked with libpthread (which you haven't see yet). This requires that libc become thread-safe and thread-aware, testing __isthreaded before attempting to do lock/unlock calls. The impact on non-threaded programs is minor. This change works with libc_r, so it's the best compromise.
OpenPOWER on IntegriCloud