mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Apply even more fixups
- Finish cleaning up the stdio unlocked APIs - Make __cxa_finalize() properly thread safe - Don't log locks if threads aren't being used - Add some more mutex guards to places using _mmi - Specific lock names now appear in the --ftrace logs - Fix mkdeps.com generating invalid Makefiles sometimes - Simplify and fix bugs in the test runner infrastructure - Fix issue where sometimes some functions wouldn't be logged
This commit is contained in:
parent
4ddfc47d6e
commit
8cdec62f5b
87 changed files with 955 additions and 899 deletions
|
@ -17,24 +17,19 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
|
||||
/**
|
||||
* Writes wide character to stream.
|
||||
*
|
||||
* @return wc if written or -1 w/ errno
|
||||
* @param wc has wide character
|
||||
* @param f is file object stream pointer
|
||||
* @return wide character if written or -1 w/ errno
|
||||
* @threadsafe
|
||||
*/
|
||||
wint_t fputwc_unlocked(wchar_t wc, FILE *f) {
|
||||
uint64_t w;
|
||||
if (wc != -1) {
|
||||
w = tpenc(wc);
|
||||
do {
|
||||
if (fputc_unlocked(w, f) == -1) {
|
||||
return -1;
|
||||
}
|
||||
} while ((w >>= 8));
|
||||
return wc;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
wint_t fputwc(wchar_t wc, FILE *f) {
|
||||
wint_t rc;
|
||||
flockfile(f);
|
||||
rc = fputwc_unlocked(wc, f);
|
||||
funlockfile(f);
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue