xref: /haiku/src/system/libroot/posix/glibc/libio/flockfile.c (revision e701d86af548314ea459013ba5079df35b635973)
15af32e75SAxel Dörfler /*
2*e701d86aSIngo Weinhold  * Copyright 2003-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3*e701d86aSIngo Weinhold  * Distributed under the terms of the MIT License.
45af32e75SAxel Dörfler  */
55af32e75SAxel Dörfler 
65af32e75SAxel Dörfler 
75af32e75SAxel Dörfler #include "libioP.h"
85af32e75SAxel Dörfler 
95af32e75SAxel Dörfler 
105af32e75SAxel Dörfler #undef _IO_flockfile
115af32e75SAxel Dörfler #undef _IO_funlockfile
125af32e75SAxel Dörfler 
135af32e75SAxel Dörfler 
145af32e75SAxel Dörfler void
_IO_flockfile(_IO_FILE * stream)155af32e75SAxel Dörfler _IO_flockfile(_IO_FILE *stream)
165af32e75SAxel Dörfler {
175af32e75SAxel Dörfler 	__libc_lock_lock_recursive(*stream->_lock);
185af32e75SAxel Dörfler }
195af32e75SAxel Dörfler 
205af32e75SAxel Dörfler 
215af32e75SAxel Dörfler void
_IO_funlockfile(_IO_FILE * stream)225af32e75SAxel Dörfler _IO_funlockfile(_IO_FILE *stream)
235af32e75SAxel Dörfler {
245af32e75SAxel Dörfler 	__libc_lock_unlock_recursive(*stream->_lock);
255af32e75SAxel Dörfler }
265af32e75SAxel Dörfler 
275af32e75SAxel Dörfler 
285af32e75SAxel Dörfler int
_IO_ftrylockfile(_IO_FILE * stream)295af32e75SAxel Dörfler _IO_ftrylockfile(_IO_FILE *stream)
305af32e75SAxel Dörfler {
315af32e75SAxel Dörfler 	// ToDo: that code has probably never been tested!
325af32e75SAxel Dörfler 	//return __libc_lock_trylock_recursive(*stream->_lock);
335af32e75SAxel Dörfler 	return 1;
345af32e75SAxel Dörfler }
359e7de140SJérôme Duval 
369e7de140SJérôme Duval weak_alias (_IO_flockfile, flockfile);
379e7de140SJérôme Duval weak_alias (_IO_funlockfile, funlockfile);
389e7de140SJérôme Duval weak_alias (_IO_ftrylockfile, ftrylockfile);
39