Index: .clang-format
===================================================================
--- .clang-format	(revision b1efe3e5141a6213464527b9a7c031bebecefbed)
+++ .clang-format	(revision b1efe3e5141a6213464527b9a7c031bebecefbed)
@@ -0,0 +1,122 @@
+# This format definition attempts to be as close to the style of existing
+# HelenOS code as possible. However, there are several significant issues:
+#
+#    "AlignEscapedNewlines: DontAlign" currently hangs
+#        the formatter on some files.
+#
+#    The formatter currently isn't able to align macro definitions,
+#        and removes existing alignment in files.
+#        (There is a patch for this, but it hasn't been integrated yet.)
+#
+#    SpacesBeforeTrailingComments don't apply to C-style comments.
+#
+#    enum definition is always crammed into a single line if it fits,
+#        and there is no option to put members on separate lines.
+#
+#    Possibly others.
+#
+#
+# Provisions are made to reformat the entire source tree via 'make format',
+# but due to the above, this shouldn't be done except to evaluate the
+# impact. Reformatting a single source file can be done using
+#
+#     clang-format -i source/file.c
+#
+---
+Language:        Cpp
+BasedOnStyle:  LLVM
+AccessModifierOffset: 0
+AlignAfterOpenBracket: DontAlign
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Left
+AlignOperands:   false
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: true
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+  AfterClass:      false
+  AfterControlStatement: false
+  AfterEnum:       false
+  AfterFunction:   true
+  AfterNamespace:  false
+  AfterObjCDeclaration: false
+  AfterStruct:     false
+  AfterUnion:      false
+  BeforeCatch:     false
+  BeforeElse:      false
+  IndentBraces:    false
+  SplitEmptyFunction: true
+  SplitEmptyRecord: true
+  SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: NonAssignment
+BreakBeforeBraces: Custom
+BreakBeforeInheritanceComma: true
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeColon
+BreakStringLiterals: true
+ColumnLimit:     80
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+FixNamespaceComments: true
+ForEachMacros:
+  - foreach
+  - Q_FOREACH
+  - BOOST_FOREACH
+IncludeCategories:
+  - Regex:           '^"'
+    Priority:        3
+  - Regex:           '^<'
+    Priority:        2
+  - Regex:           '.*'
+    Priority:        1
+IncludeIsMainRegex: '(-test)?$'
+IndentCaseLabels: false
+IndentWidth:     8
+IndentWrappedFunctionNames: false
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Right
+ReflowComments:  true
+SortIncludes:    true
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: true
+SpaceAfterTemplateKeyword: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 2
+SpacesInAngles:  false
+SpacesInContainerLiterals: false
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard:        Cpp11
+TabWidth:        8
+UseTab:          ForIndentation
+...
+
Index: Makefile
===================================================================
--- Makefile	(revision b446b02d16cef27e33c81855d516b2f1a5ce70b2)
+++ Makefile	(revision b1efe3e5141a6213464527b9a7c031bebecefbed)
@@ -31,4 +31,5 @@
 
 CSCOPE = cscope
+FORMAT = clang-format
 CHECK = tools/check.sh
 CONFIG = tools/config.py
@@ -64,4 +65,7 @@
 	find boot -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_boot.out
 	find uspace -type f -regex '^.*\.[chsS]$$' | xargs $(CSCOPE) -b -k -u -f$(CSCOPE)_uspace.out
+
+format:
+	find abi kernel boot uspace -type f -regex '^.*\.[ch]$$' | xargs $(FORMAT) -i -sort-includes -style=file
 
 # Pre-integration build check
