Skip to content

Add <unistd.h>, fileno, isatty, swab, and a placeholder for ungetc#797

Open
ZERICO2005 wants to merge 5 commits intomasterfrom
add_fileno
Open

Add <unistd.h>, fileno, isatty, swab, and a placeholder for ungetc#797
ZERICO2005 wants to merge 5 commits intomasterfrom
add_fileno

Conversation

@ZERICO2005
Copy link
Copy Markdown
Contributor

@ZERICO2005 ZERICO2005 commented Apr 22, 2026

  • All libc fileioc wrappers now include a common "__fileioc_stdio.h" header.
  • Added a weak placeholder ungetc function that always returns EOF.
  • Added weak int fileno(FILE *stream) to <stdio.h>. See "__fileioc_stdio.h" for how the mapping works.
  • Added weak int isatty(int fd), which treats stdin, stdout, and stderr as a tty/terminal, and anything else as not a terminal.
  • Our current implementations of sleep, usleep, and useconds_t from <sys/timers.h> conform to <unistd.h>, so I've made those functions/typedefs available under <unistd.h>.
  • Added typedef __PTRDIFF_TYPE__ ssize_t; to <unistd.h> (This is what Clang libc defines it to).
  • Added void swab(const void *src, void *dst, ssize_t count). Two different assembly versions are provided depending on the desired unspecified behavior for when count is odd.

ungetc, fileno, and isatty are needed for Clang libcxx 22.

Tests for fileno, isatty, and swab were added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant