Add epoll and do more release readiness changes
This change also pays off some of the remaining technical debt with stdio, file descriptors, and memory managemnt polyfills.
This commit is contained in:
@@ -17,11 +17,9 @@
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/limits.h"
|
||||
#include "libc/stdio/internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpencode.internal.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
|
||||
/**
|
||||
* Writes wide character to stream.
|
||||
@@ -29,15 +27,18 @@
|
||||
* @return wc if written or -1 w/ errno
|
||||
*/
|
||||
wint_t fputwc(wchar_t wc, FILE *f) {
|
||||
unsigned i, len;
|
||||
char buf[MB_LEN_MAX];
|
||||
uint64_t w;
|
||||
if (wc != -1) {
|
||||
len = tpencode(buf, sizeof(buf), wc, false);
|
||||
for (i = 0; i < len; ++i) {
|
||||
if (fputc(buf[i], f) == -1) return -1;
|
||||
}
|
||||
w = tpenc(wc);
|
||||
do {
|
||||
if (fputc(w & 0xff, f) != -1) {
|
||||
w >>= 8;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} while (w);
|
||||
return wc;
|
||||
} else {
|
||||
return fseteof(f);
|
||||
return __fseteof(f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user