Skip to content

feat(libc): implement buffered I/O for fputc#36

Closed
jbreu wants to merge 126 commits into
masterfrom
feature/libc-buffered-io
Closed

feat(libc): implement buffered I/O for fputc#36
jbreu wants to merge 126 commits into
masterfrom
feature/libc-buffered-io

Conversation

@jbreu

@jbreu jbreu commented May 10, 2026

Copy link
Copy Markdown
Owner

Summary

This PR optimizes userland output by implementing a buffered approach for fputc in libc.c.

Changes

  • Buffering: Replaced individual write syscalls per character with a 1KB buffer.
  • Lazy Allocation: The buffer is allocated via malloc on the first write attempt.
  • Line Buffering: Implemented automatic flushing on newline ( ) for interactive console consistency.
  • New Helper: Added fflush(FILE *stream) to manually clear the buffer.

This significantly reduces syscall overhead for standard output and error streams.

@jbreu jbreu closed this May 10, 2026
@jbreu jbreu force-pushed the feature/libc-buffered-io branch from 9856d6b to 1db1cd4 Compare May 10, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant