Skip to content

Code Style and Design

Oguzhan KAYNAK edited this page Dec 3, 2026 · 2 revisions

Code Style and Design

Style

WebKit code style, enforced by tools:

  • .clang-format (BasedOnStyle: WebKit): scripts/build.sh format / format-check
  • .clang-tidy: bugprone-*, clang-analyzer-*, performance-* and the naming rules below: scripts/build.sh tidy
What Style
types, namespaces, enum values PascalCase
functions, variables, fields camelCase
class members / statics m_name / s_name
macros UPPER_CASE

Kernel code is in namespace Kernel::, the user program library in User::, the code both share in Common:: (the heap) and Abi:: (the system call numbers and errors). Where the kernel and the user library offer the same thing, they use the same names and signatures: Threading::Thread t(entry, arg); t.wait(); on either side.

The kernel and libc are built without SIMD (-mno-sse, ...); the build fails if an SSE instruction ends up in the image.

Design

  • No singletons. A subsystem is a class that owns its state.
  • Dependencies are passed in by constructor reference, so they show in the signatures: AddressSpace kernelSpace(pmm);
  • Hardware behind interfaces (see Drivers and Console).
  • kernelMain is the composition root and constructs everything in order.
  • Globals only at C/assembly boundaries (ISR dispatch, the heap behind kmalloc and new, the user program runtime behind int 0x80, printf), each one explicitly bound by kernelMain.

More: docs/style.md

Clone this wiki locally