1 /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
3 * GNU Library General Public License (LGPL) version 2 or later.
5 * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
15 * When setting the locking mode, glibc returns the previous setting.
16 * glibc treats invalid locking_mode args as FSETLOCKING_INTERNAL.
19 int __fsetlocking(FILE *stream
, int locking_mode
)
21 #ifdef __UCLIBC_HAS_THREADS__
22 int current
= 1 + (stream
->__user_locking
& 1);
24 /* Check constant assumptions. We can't test at build time
25 * since these are enums. */
26 assert((FSETLOCKING_QUERY
== 0) && (FSETLOCKING_INTERNAL
== 1)
27 && (FSETLOCKING_BYCALLER
== 2));
29 __STDIO_STREAM_VALIDATE(stream
);
30 assert(((unsigned int) locking_mode
) <= 2);
32 if (locking_mode
!= FSETLOCKING_QUERY
) {
33 stream
->__user_locking
= ((locking_mode
== FSETLOCKING_BYCALLER
)
35 : _stdio_user_locking
); /* 0 or 2 */
36 __STDIO_STREAM_VALIDATE(stream
);
41 __STDIO_STREAM_VALIDATE(stream
);
42 assert(((unsigned int) locking_mode
) <= 2);
44 return FSETLOCKING_INTERNAL
;
47 libc_hidden_def(__fsetlocking
)