mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 08:12:28 +00:00
Refactor some code
- Write tests for cthreads - Fix bugs in pe2.com tool - Fix ASAN issue with GetDosEnviron() - Consolidate the cthread header files - Some code size optimizations for MODE= - Attempted to squash a tls linker warning - Attempted to get futexes working on FreeBSD
This commit is contained in:
parent
909e54510d
commit
425ff5dff0
61 changed files with 529 additions and 382 deletions
|
@ -16,7 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
/**
|
||||
|
@ -24,15 +23,12 @@
|
|||
*
|
||||
* @param c is byte to buffer or write, which is masked
|
||||
* @return c as unsigned char if written or -1 w/ errno
|
||||
* @threadsafe
|
||||
*/
|
||||
int fputc_unlocked(int c, FILE *f) {
|
||||
unsigned char b;
|
||||
if (c != '\n' && f->beg < f->size && f->bufmode != _IONBF) {
|
||||
f->buf[f->beg++] = c;
|
||||
return c & 255;
|
||||
} else {
|
||||
b = c;
|
||||
if (!fwrite_unlocked(&b, 1, 1, f)) return -1;
|
||||
return b;
|
||||
}
|
||||
int fputc(int c, FILE *f) {
|
||||
int rc;
|
||||
flockfile(f);
|
||||
rc = fputc_unlocked(c, f);
|
||||
funlockfile(f);
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue