xv6, line by line
.clang-format

.clang-format

text · 10 lines · annotated 100% · upstream

About this file

Configuration for clang-format, a tool that rewrites C source files into a consistent layout (indentation, line breaks, brace placement). make fmt runs it on every .c and .h file in kernel/, user/ and mkfs/ (Makefile:202), and the CI job fails if that changes anything (.github/workflows/test.yml:9). So every C file you read on this site is exactly in the format these settings produce.

The file is YAML. It does not name a base style, so clang-format starts from its default, the LLVM style: indent by 2 spaces, lines at most 80 characters. The lines here change only what xv6 does differently. The file needs clang-format 20 or later: BreakAfterReturnType appeared in version 19 (replacing AlwaysBreakAfterReturnType) and the value Never for ReflowComments in 20; an older version stops with an error about the configuration.

1SortIncludes: Never
2ReflowComments: Never
4BreakAfterReturnType: TopLevelDefinitions
5BreakBeforeBraces: Custom
6BraceWrapping:
7 AfterFunction: true
8AlignConsecutiveMacros: Consecutive
9ContinuationIndentWidth: 2
10BreakStringLiterals: false