# xuantie-rv/newlib architecture

> Architecture diagram of the GitHub repository xuantie-rv/newlib, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xuantie-rv/newlib
- Repository: https://github.com/xuantie-rv/newlib

## Overview

This is a GNU development-tools source tree, not one application: it combines binary-format and opcode definitions, C library and target syscall support, and the Cygwin POSIX compatibility runtime. A representative Cygwin flow begins with an application’s file or terminal operation, passes through Cygwin’s descriptor and handler layers, and reaches Windows-backed behavior. The tree also includes broader toolchain and debugging support documented by the README. The sampled source is incomplete, so edges are limited to relationships visible in excerpts or the source index.

Main entry points: [`winsup/cygwin/winsup.h`](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/winsup.h) (Runtime interface), [`winsup/cygwin/fhandler.h`](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/fhandler.h) (File handlers), [`winsup/cygwin/fhandler_console.cc`](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/fhandler_console.cc) (Console I/O), [`winsup/cygwin/fhandler_tty.cc`](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/fhandler_tty.cc) (PTY I/O)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Cygwin runtime"]
  node_runtime_api["Runtime interface<br/>[winsup.h]"]
  node_path_resolution["Path resolution<br/>[path.h]"]
  node_descriptor_table["Descriptor table<br/>[dtable.h]"]
  node_file_handlers["File handlers<br/>[fhandler.h]"]
  node_console_io["Console I/O"]
  node_pty_io["PTY I/O<br/>[fhandler_tty.cc]"]
  node_process_state["Process state<br/>[pinfo.h]"]
  node_shared_state[("Shared runtime state<br/>[shared_info.h]")]
  node_cygserver["Cygserver requests<br/>[client.cc]"]
end

subgraph group_libraries["Libraries and targets"]
  node_newlib["C library"]
  node_linux_resolver["DNS resolver<br/>[res_query.c]"]
  node_linux_threads["Linux threads<br/>[manager.c]"]
  node_target_syscalls["Target syscall support"]
end

subgraph group_formats["Binary and opcode support"]
  node_object_formats["Object formats"]
  node_opcode_tables["Opcode tables"]
end

subgraph group_utilities["Developer utilities"]
  node_cygcheck["Cygwin diagnostics<br/>[cygcheck.cc]"]
end

node_application(("POSIX application"))
node_windows_os["Windows OS"]
node_developer(("Toolchain users"))

node_application -.->|"uses POSIX API"| node_runtime_api
node_runtime_api -.->|"resolves paths"| node_path_resolution
node_runtime_api -.->|"uses descriptors"| node_descriptor_table
node_descriptor_table -.->|"dispatches I/O"| node_file_handlers
node_file_handlers -->|"references process state"| node_process_state
node_file_handlers -->|"defines PTY handler"| node_pty_io
node_file_handlers -->|"defines console handler"| node_console_io
node_console_io -->|"uses descriptors"| node_descriptor_table
node_console_io -->|"uses shared state"| node_shared_state
node_pty_io -->|"allocates shared TTY"| node_shared_state
node_pty_io -->|"uses process state"| node_process_state
node_runtime_api -.->|"wraps OS facilities"| node_windows_os
node_developer -->|"runs diagnostics"| node_cygcheck
node_developer -.->|"uses toolchain definitions"| node_object_formats
node_developer -.->|"uses instruction definitions"| node_opcode_tables
node_newlib -.->|"includes resolver"| node_linux_resolver
node_newlib -.->|"includes thread support"| node_linux_threads
node_application -.->|"uses target services"| node_target_syscalls

click node_runtime_api "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/winsup.h"
click node_path_resolution "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/path.h"
click node_descriptor_table "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/dtable.h"
click node_file_handlers "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/fhandler.h"
click node_console_io "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/fhandler_console.cc"
click node_pty_io "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/fhandler_tty.cc"
click node_process_state "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/pinfo.h"
click node_shared_state "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/shared_info.h"
click node_cygserver "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygserver/client.cc"
click node_newlib "https://github.com/xuantie-rv/newlib/tree/xuantie-newlib-3.2.0/newlib/libc"
click node_linux_resolver "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/newlib/libc/sys/linux/net/res_query.c"
click node_linux_threads "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/newlib/libc/sys/linux/linuxthreads/manager.c"
click node_target_syscalls "https://github.com/xuantie-rv/newlib/tree/xuantie-newlib-3.2.0/libgloss"
click node_object_formats "https://github.com/xuantie-rv/newlib/tree/xuantie-newlib-3.2.0/include"
click node_opcode_tables "https://github.com/xuantie-rv/newlib/tree/xuantie-newlib-3.2.0/include/opcode"
click node_cygcheck "https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/utils/cygcheck.cc"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runtime_api,node_path_resolution,node_descriptor_table,node_file_handlers,node_console_io,node_pty_io,node_process_state,node_shared_state,node_cygserver,node_developer toneBlue
class node_newlib,node_linux_resolver,node_linux_threads,node_target_syscalls toneAmber
class node_object_formats,node_opcode_tables toneMint
class node_cygcheck toneRose
class node_application,node_windows_os toneIndigo
```

## Components

### Cygwin runtime

- [Runtime interface](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/winsup.h): `winsup/cygwin/winsup.h`
- [Path resolution](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/path.h): `winsup/cygwin/path.h`
- [Descriptor table](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/dtable.h): `winsup/cygwin/dtable.h`
- [File handlers](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/fhandler.h): `winsup/cygwin/fhandler.h`
- [Console I/O](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/fhandler_console.cc): `winsup/cygwin/fhandler_console.cc`
- [PTY I/O](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/fhandler_tty.cc): `winsup/cygwin/fhandler_tty.cc`
- [Process state](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/pinfo.h): `winsup/cygwin/pinfo.h`
- [Shared runtime state](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygwin/shared_info.h): `winsup/cygwin/shared_info.h`
- [Cygserver requests](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/cygserver/client.cc): `winsup/cygserver/client.cc`

### Libraries and targets

- [C library](https://github.com/xuantie-rv/newlib/tree/xuantie-newlib-3.2.0/newlib/libc): `newlib/libc`
- [DNS resolver](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/newlib/libc/sys/linux/net/res_query.c): `newlib/libc/sys/linux/net/res_query.c`
- [Linux threads](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/newlib/libc/sys/linux/linuxthreads/manager.c): `newlib/libc/sys/linux/linuxthreads/manager.c`
- [Target syscall support](https://github.com/xuantie-rv/newlib/tree/xuantie-newlib-3.2.0/libgloss): `libgloss`

### Binary and opcode support

- [Object formats](https://github.com/xuantie-rv/newlib/tree/xuantie-newlib-3.2.0/include): `include`
- [Opcode tables](https://github.com/xuantie-rv/newlib/tree/xuantie-newlib-3.2.0/include/opcode): `include/opcode`

### Developer utilities

- [Cygwin diagnostics](https://github.com/xuantie-rv/newlib/blob/xuantie-newlib-3.2.0/winsup/utils/cygcheck.cc): `winsup/utils/cygcheck.cc`

### Other components

- **POSIX application**
- **Windows OS**
- **Toolchain users**

## Connections

- POSIX application → Runtime interface: uses POSIX API (evidence: `README`)
- Runtime interface → Path resolution: resolves paths
- Runtime interface → Descriptor table: uses descriptors
- Descriptor table → File handlers: dispatches I/O
- File handlers → Process state: references process state (evidence: `winsup/cygwin/fhandler.h`)
- File handlers → PTY I/O: defines PTY handler (evidence: `winsup/cygwin/fhandler.h`)
- File handlers → Console I/O: defines console handler (evidence: `winsup/cygwin/fhandler.h`)
- Console I/O → Descriptor table: uses descriptors (evidence: `winsup/cygwin/fhandler_console.cc`)
- Console I/O → Shared runtime state: uses shared state (evidence: `winsup/cygwin/fhandler_console.cc`)
- PTY I/O → Shared runtime state: allocates shared TTY (evidence: `winsup/cygwin/fhandler_tty.cc`)
- PTY I/O → Process state: uses process state (evidence: `winsup/cygwin/fhandler_tty.cc`)
- Runtime interface → Windows OS: wraps OS facilities
- Toolchain users → Cygwin diagnostics: runs diagnostics (evidence: `winsup/utils/cygcheck.cc`)
- Toolchain users → Object formats: uses toolchain definitions (evidence: `README`)
- Toolchain users → Opcode tables: uses instruction definitions (evidence: `README`)
- C library → DNS resolver: includes resolver (evidence: `newlib/libc/sys/linux/net/res_query.c`)
- C library → Linux threads: includes thread support (evidence: `newlib/libc/sys/linux/linuxthreads/manager.c`)
- POSIX application → Target syscall support: uses target services
