diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000..d2314f72ac2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,13 @@ +--- +Language: Cpp +BasedOnStyle: WebKit +SpaceAfterTemplateKeyword: false +AlignEscapedNewlines: true +AlignTrailingComments: true +BreakBeforeInheritanceComma: true +BreakConstructorInitializers: BeforeComma +IndentPPDirectives: AfterHash +BreakBeforeBraces: Custom +BraceWrapping: + AfterFunction: true + AfterEnum: true diff --git a/AK/AKString.h b/AK/AKString.h index 80014ac8e1a..b93843b719a 100644 --- a/AK/AKString.h +++ b/AK/AKString.h @@ -3,18 +3,18 @@ #include #include #include +#include #include #include -#include #include namespace AK { class String { public: - ~String() { } + ~String() {} - String() { } + String() {} String(StringView view) : m_impl(StringImpl::create(view.characters(), view.length())) @@ -96,7 +96,11 @@ public: bool is_empty() const { return length() == 0; } ssize_t length() const { return m_impl ? m_impl->length() : 0; } const char* characters() const { return m_impl ? m_impl->characters() : nullptr; } - char operator[](ssize_t i) const { ASSERT(m_impl); return (*m_impl)[i]; } + char operator[](ssize_t i) const + { + ASSERT(m_impl); + return (*m_impl)[i]; + } bool ends_with(const String&) const; @@ -131,7 +135,7 @@ public: static String copy(const BufferType& buffer, ShouldChomp should_chomp = NoChomp) { if (buffer.is_null()) - return { }; + return {}; if (buffer.is_empty()) return empty(); return String((const char*)buffer.data(), buffer.size(), should_chomp); diff --git a/AK/Assertions.h b/AK/Assertions.h index bd2404cd684..35c92442b23 100644 --- a/AK/Assertions.h +++ b/AK/Assertions.h @@ -1,13 +1,13 @@ #pragma once #ifdef KERNEL -#include +# include #else -#include -#ifndef __serenity__ -#define ASSERT assert -#define ASSERT_NOT_REACHED assert(false) -#endif +# include +# ifndef __serenity__ +# define ASSERT assert +# define ASSERT_NOT_REACHED assert(false) +# endif #endif namespace AK { @@ -17,4 +17,3 @@ inline void not_implemented() { ASSERT(false); } } using AK::not_implemented; - diff --git a/AK/Badge.h b/AK/Badge.h index 46ae8fbce98..0bcb62de4c5 100644 --- a/AK/Badge.h +++ b/AK/Badge.h @@ -3,5 +3,5 @@ template class Badge { friend T; - Badge() { } + Badge() {} }; diff --git a/AK/Bitmap.h b/AK/Bitmap.h index ad7c304e0cf..1c013cc3c06 100644 --- a/AK/Bitmap.h +++ b/AK/Bitmap.h @@ -1,9 +1,9 @@ #pragma once +#include "Assertions.h" #include "StdLibExtras.h" #include "Types.h" #include "kmalloc.h" -#include "Assertions.h" namespace AK { @@ -77,4 +77,3 @@ private: } using AK::Bitmap; - diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index 45b213713df..c472e940224 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -1,9 +1,9 @@ #pragma once -#include "Types.h" #include "StdLibExtras.h" -#include +#include "Types.h" #include +#include #include namespace AK { @@ -28,8 +28,16 @@ public: m_data = nullptr; } - byte& operator[](int i) { ASSERT(i < m_size); return m_data[i]; } - const byte& operator[](int i) const { ASSERT(i < m_size); return m_data[i]; } + byte& operator[](int i) + { + ASSERT(i < m_size); + return m_data[i]; + } + const byte& operator[](int i) const + { + ASSERT(i < m_size); + return m_data[i]; + } bool is_empty() const { return !m_size; } int size() const { return m_size; } @@ -52,11 +60,16 @@ public: void grow(int size); private: - enum ConstructionMode { Uninitialized, Copy, Wrap, Adopt }; - explicit ByteBufferImpl(int); // For ConstructionMode=Uninitialized + enum ConstructionMode { + Uninitialized, + Copy, + Wrap, + Adopt + }; + explicit ByteBufferImpl(int); // For ConstructionMode=Uninitialized ByteBufferImpl(const void*, int, ConstructionMode); // For ConstructionMode=Copy - ByteBufferImpl(void*, int, ConstructionMode); // For ConstructionMode=Wrap/Adopt - ByteBufferImpl() { } + ByteBufferImpl(void*, int, ConstructionMode); // For ConstructionMode=Wrap/Adopt + ByteBufferImpl() {} byte* m_data { nullptr }; int m_size { 0 }; @@ -65,8 +78,8 @@ private: class ByteBuffer { public: - ByteBuffer() { } - ByteBuffer(std::nullptr_t) { } + ByteBuffer() {} + ByteBuffer(std::nullptr_t) {} ByteBuffer(const ByteBuffer& other) : m_impl(other.m_impl.copy_ref()) { @@ -101,8 +114,16 @@ public: bool operator!() const { return is_null(); } bool is_null() const { return m_impl == nullptr; } - byte& operator[](ssize_t i) { ASSERT(m_impl); return (*m_impl)[i]; } - byte operator[](ssize_t i) const { ASSERT(m_impl); return (*m_impl)[i]; } + byte& operator[](ssize_t i) + { + ASSERT(m_impl); + return (*m_impl)[i]; + } + byte operator[](ssize_t i) const + { + ASSERT(m_impl); + return (*m_impl)[i]; + } bool is_empty() const { return !m_impl || m_impl->is_empty(); } ssize_t size() const { return m_impl ? m_impl->size() : 0; } @@ -121,7 +142,7 @@ public: ByteBuffer isolated_copy() const { if (!m_impl) - return { }; + return {}; return copy(m_impl->pointer(), m_impl->size()); } @@ -135,9 +156,9 @@ public: ByteBuffer slice(ssize_t offset, ssize_t size) const { if (is_null()) - return { }; + return {}; if (offset >= this->size()) - return { }; + return {}; if (offset + size >= this->size()) size = this->size() - offset; return copy(offset_pointer(offset), size); @@ -241,4 +262,3 @@ inline Retained ByteBufferImpl::adopt(void* data, int size) } using AK::ByteBuffer; - diff --git a/AK/CircularQueue.h b/AK/CircularQueue.h index 605402e0c1e..7f1ce3ccf9c 100644 --- a/AK/CircularQueue.h +++ b/AK/CircularQueue.h @@ -60,9 +60,14 @@ public: } const T& operator*() const { return m_queue.m_elements[m_index]; } + private: friend class CircularQueue; - ConstIterator(const CircularQueue& queue, const int index) : m_queue(queue), m_index(index) { } + ConstIterator(const CircularQueue& queue, const int index) + : m_queue(queue) + , m_index(index) + { + } const CircularQueue& m_queue; int m_index { 0 }; }; @@ -82,4 +87,3 @@ private: } using AK::CircularQueue; - diff --git a/AK/DoublyLinkedList.h b/AK/DoublyLinkedList.h index 2aa804175b9..b3135f62061 100644 --- a/AK/DoublyLinkedList.h +++ b/AK/DoublyLinkedList.h @@ -9,22 +9,28 @@ template class DoublyLinkedList { private: struct Node { - explicit Node(const T& v) : value(v) { } - explicit Node(T&& v) : value(move(v)) { } + explicit Node(const T& v) + : value(v) + { + } + explicit Node(T&& v) + : value(move(v)) + { + } T value; Node* next { nullptr }; Node* prev { nullptr }; }; public: - DoublyLinkedList() { } + DoublyLinkedList() {} ~DoublyLinkedList() { clear(); } bool is_empty() const { return !head(); } void clear() { - for (auto* node = m_head; node; ) { + for (auto* node = m_head; node;) { auto* next = node->next; delete node; node = next; @@ -33,15 +39,30 @@ public: m_tail = nullptr; } - T& first() { ASSERT(head()); return head()->value; } - const T& first() const { ASSERT(head()); return head()->value; } - T& last() { ASSERT(head()); return tail()->value; } - const T& last() const { ASSERT(head()); return tail()->value; } + T& first() + { + ASSERT(head()); + return head()->value; + } + const T& first() const + { + ASSERT(head()); + return head()->value; + } + T& last() + { + ASSERT(head()); + return tail()->value; + } + const T& last() const + { + ASSERT(head()); + return tail()->value; + } void append(T&& value) { append_node(new Node(move(value))); - } void append(const T& value) @@ -62,14 +83,22 @@ public: public: bool operator!=(const Iterator& other) const { return m_node != other.m_node; } bool operator==(const Iterator& other) const { return m_node == other.m_node; } - Iterator& operator++() { m_node = m_node->next; return *this; } + Iterator& operator++() + { + m_node = m_node->next; + return *this; + } T& operator*() { return m_node->value; } T* operator->() { return &m_node->value; } bool is_end() const { return !m_node; } static Iterator universal_end() { return Iterator(nullptr); } + private: friend class DoublyLinkedList; - explicit Iterator(DoublyLinkedList::Node* node) : m_node(node) { } + explicit Iterator(DoublyLinkedList::Node* node) + : m_node(node) + { + } DoublyLinkedList::Node* m_node; }; @@ -80,14 +109,22 @@ public: public: bool operator!=(const ConstIterator& other) const { return m_node != other.m_node; } bool operator==(const ConstIterator& other) const { return m_node == other.m_node; } - ConstIterator& operator++() { m_node = m_node->next; return *this; } + ConstIterator& operator++() + { + m_node = m_node->next; + return *this; + } const T& operator*() const { return m_node->value; } const T* operator->() const { return &m_node->value; } bool is_end() const { return !m_node; } static ConstIterator universal_end() { return ConstIterator(nullptr); } + private: friend class DoublyLinkedList; - explicit ConstIterator(const DoublyLinkedList::Node* node) : m_node(node) { } + explicit ConstIterator(const DoublyLinkedList::Node* node) + : m_node(node) + { + } const DoublyLinkedList::Node* m_node; }; @@ -163,4 +200,3 @@ private: } using AK::DoublyLinkedList; - diff --git a/AK/FileSystemPath.cpp b/AK/FileSystemPath.cpp index e094c1de3d0..07d8d5ea829 100644 --- a/AK/FileSystemPath.cpp +++ b/AK/FileSystemPath.cpp @@ -1,7 +1,7 @@ #include "FileSystemPath.h" +#include "StringBuilder.h" #include "Vector.h" #include "kstdio.h" -#include "StringBuilder.h" namespace AK { @@ -14,7 +14,7 @@ FileSystemPath::FileSystemPath(const String& s) bool FileSystemPath::canonicalize(bool resolve_symbolic_links) { // FIXME: Implement "resolve_symbolic_links" - (void) resolve_symbolic_links; + (void)resolve_symbolic_links; auto parts = m_string.split('/'); Vector canonical_parts; diff --git a/AK/FileSystemPath.h b/AK/FileSystemPath.h index 3e565232692..b62160a5264 100644 --- a/AK/FileSystemPath.h +++ b/AK/FileSystemPath.h @@ -6,7 +6,7 @@ namespace AK { class FileSystemPath { public: - FileSystemPath() { } + FileSystemPath() {} explicit FileSystemPath(const String&); bool is_valid() const { return m_is_valid; } diff --git a/AK/Function.h b/AK/Function.h index b2d10aa0fe9..bea6708ca5d 100644 --- a/AK/Function.h +++ b/AK/Function.h @@ -31,13 +31,14 @@ namespace AK { -template class Function; +template +class Function; -template +template class Function { public: Function() = default; - Function(std::nullptr_t) { } + Function(std::nullptr_t) {} template::value && IsFunction::Type>::value) && IsRvalueReference::value>::Type> Function(CallableType&& callable) @@ -82,7 +83,7 @@ public: private: class CallableWrapperBase { public: - virtual ~CallableWrapperBase() { } + virtual ~CallableWrapperBase() {} virtual Out call(In...) const = 0; }; @@ -109,4 +110,3 @@ private: } using AK::Function; - diff --git a/AK/HashFunctions.h b/AK/HashFunctions.h index 21bfaff94e8..4155d23c670 100644 --- a/AK/HashFunctions.h +++ b/AK/HashFunctions.h @@ -17,4 +17,3 @@ inline unsigned pair_int_hash(dword key1, dword key2) { return int_hash((int_hash(key1) * 209) ^ (int_hash(key2 * 413))); } - diff --git a/AK/HashMap.h b/AK/HashMap.h index 828a9017e15..bd58a5a8e61 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -32,7 +32,7 @@ private: }; public: - HashMap() { } + HashMap() {} HashMap(HashMap&& other) : m_table(move(other.m_table)) @@ -115,13 +115,13 @@ private: template void HashMap::set(const K& key, V&& value) { - m_table.set(Entry{key, move(value)}); + m_table.set(Entry { key, move(value) }); } template void HashMap::set(const K& key, const V& value) { - m_table.set(Entry{key, value}); + m_table.set(Entry { key, value }); } template @@ -148,4 +148,3 @@ auto HashMap::find(const K& key) const -> ConstIteratorType } using AK::HashMap; - diff --git a/AK/HashTable.h b/AK/HashTable.h index 8a4b5f847d6..7720a38f86a 100644 --- a/AK/HashTable.h +++ b/AK/HashTable.h @@ -2,15 +2,16 @@ #include "Assertions.h" #include "DoublyLinkedList.h" -#include "Traits.h" #include "StdLibExtras.h" +#include "Traits.h" #include "kstdio.h" //#define HASHTABLE_DEBUG namespace AK { -template> class HashTable; +template> +class HashTable; template class HashTable { @@ -20,7 +21,7 @@ private: }; public: - HashTable() { } + HashTable() {} explicit HashTable(HashTable&& other) : m_buckets(other.m_buckets) , m_size(other.m_size) @@ -112,6 +113,7 @@ public: return; } } + private: friend class HashTable; explicit Iterator(HashTable& table, bool is_end, typename DoublyLinkedList::Iterator bucket_iterator = DoublyLinkedList::Iterator::universal_end(), int bucket_index = 0) @@ -190,6 +192,7 @@ public: return; } } + private: friend class HashTable; ConstIterator(const HashTable& table, bool is_end, typename DoublyLinkedList::ConstIterator bucket_iterator = DoublyLinkedList::ConstIterator::universal_end(), int bucket_index = 0) @@ -285,7 +288,6 @@ void HashTable::set(const T& value) m_size++; } - template void HashTable::rehash(int new_capacity) { @@ -308,14 +310,14 @@ void HashTable::rehash(int new_capacity) } } - delete [] old_buckets; + delete[] old_buckets; } template void HashTable::clear() { if (m_buckets) { - delete [] m_buckets; + delete[] m_buckets; m_buckets = nullptr; } m_capacity = 0; @@ -429,4 +431,3 @@ void HashTable::dump() const } using AK::HashTable; - diff --git a/AK/InlineLinkedList.h b/AK/InlineLinkedList.h index a6156c42840..08e4fbdb265 100644 --- a/AK/InlineLinkedList.h +++ b/AK/InlineLinkedList.h @@ -5,47 +5,54 @@ namespace AK { -template class InlineLinkedListNode { +template +class InlineLinkedListNode { public: InlineLinkedListNode(); - + void set_prev(T*); void set_next(T*); - + T* prev() const; T* next() const; }; -template inline InlineLinkedListNode::InlineLinkedListNode() +template +inline InlineLinkedListNode::InlineLinkedListNode() { set_prev(0); set_next(0); } -template inline void InlineLinkedListNode::set_prev(T* prev) +template +inline void InlineLinkedListNode::set_prev(T* prev) { static_cast(this)->m_prev = prev; } -template inline void InlineLinkedListNode::set_next(T* next) +template +inline void InlineLinkedListNode::set_next(T* next) { static_cast(this)->m_next = next; } -template inline T* InlineLinkedListNode::prev() const +template +inline T* InlineLinkedListNode::prev() const { return static_cast(this)->m_prev; } -template inline T* InlineLinkedListNode::next() const +template +inline T* InlineLinkedListNode::next() const { return static_cast(this)->m_next; } -template class InlineLinkedList { +template +class InlineLinkedList { public: - InlineLinkedList() { } - + InlineLinkedList() {} + bool is_empty() const { return !m_head; } size_t size_slow() const; void clear(); @@ -75,7 +82,8 @@ private: T* m_tail { nullptr }; }; -template inline size_t InlineLinkedList::size_slow() const +template +inline size_t InlineLinkedList::size_slow() const { size_t size = 0; for (T* node = m_head; node; node = node->next()) @@ -83,13 +91,15 @@ template inline size_t InlineLinkedList::size_slow() const return size; } -template inline void InlineLinkedList::clear() +template +inline void InlineLinkedList::clear() { m_head = 0; m_tail = 0; } -template inline void InlineLinkedList::prepend(T* node) +template +inline void InlineLinkedList::prepend(T* node) { if (!m_head) { ASSERT(!m_tail); @@ -107,7 +117,8 @@ template inline void InlineLinkedList::prepend(T* node) m_head = node; } -template inline void InlineLinkedList::append(T* node) +template +inline void InlineLinkedList::append(T* node) { if (!m_tail) { ASSERT(!m_head); @@ -125,7 +136,8 @@ template inline void InlineLinkedList::append(T* node) m_tail = node; } -template inline void InlineLinkedList::remove(T* node) +template +inline void InlineLinkedList::remove(T* node) { if (node->prev()) { ASSERT(node != m_head); @@ -144,7 +156,8 @@ template inline void InlineLinkedList::remove(T* node) } } -template inline T* InlineLinkedList::remove_head() +template +inline T* InlineLinkedList::remove_head() { T* node = head(); if (node) @@ -152,7 +165,8 @@ template inline T* InlineLinkedList::remove_head() return node; } -template inline T* InlineLinkedList::remove_tail() +template +inline T* InlineLinkedList::remove_tail() { T* node = tail(); if (node) @@ -160,7 +174,8 @@ template inline T* InlineLinkedList::remove_tail() return node; } -template inline void InlineLinkedList::append(InlineLinkedList& other) +template +inline void InlineLinkedList::append(InlineLinkedList& other) { if (!other.head()) return; diff --git a/AK/MappedFile.cpp b/AK/MappedFile.cpp index a65f76b9abf..b234fa19c67 100644 --- a/AK/MappedFile.cpp +++ b/AK/MappedFile.cpp @@ -1,9 +1,9 @@ #include +#include +#include #include #include -#include #include -#include //#define DEBUG_MAPPED_FILE @@ -14,7 +14,7 @@ MappedFile::MappedFile(const String& file_name) { m_size = PAGE_SIZE; m_fd = open(m_file_name.characters(), O_RDONLY | O_CLOEXEC); - + if (m_fd != -1) { struct stat st; fstat(m_fd, &st); @@ -44,7 +44,7 @@ void MappedFile::unmap() ASSERT(rc == 0); rc = close(m_fd); ASSERT(rc == 0); - m_file_name = { }; + m_file_name = {}; m_size = 0; m_fd = -1; m_map = (void*)-1; @@ -74,4 +74,3 @@ MappedFile& MappedFile::operator=(MappedFile&& other) } } - diff --git a/AK/MappedFile.h b/AK/MappedFile.h index 0398bff7bdb..513fd28e5e5 100644 --- a/AK/MappedFile.h +++ b/AK/MappedFile.h @@ -6,7 +6,7 @@ namespace AK { class MappedFile { public: - MappedFile() { } + MappedFile() {} explicit MappedFile(const String& file_name); MappedFile(MappedFile&&); ~MappedFile(); @@ -30,4 +30,3 @@ private: } using AK::MappedFile; - diff --git a/AK/NetworkOrdered.h b/AK/NetworkOrdered.h index 22805bdf50e..4c5aa273cd8 100644 --- a/AK/NetworkOrdered.h +++ b/AK/NetworkOrdered.h @@ -18,7 +18,8 @@ template } template -class [[gnu::packed]] NetworkOrdered { +class [[gnu::packed]] NetworkOrdered +{ public: NetworkOrdered() : m_network_value(0) diff --git a/AK/Noncopyable.h b/AK/Noncopyable.h index ff7df2346b7..2e2b9d0cbce 100644 --- a/AK/Noncopyable.h +++ b/AK/Noncopyable.h @@ -1,6 +1,6 @@ #pragma once #define AK_MAKE_NONCOPYABLE(c) \ -private: \ - c(const c&) = delete; \ +private: \ + c(const c&) = delete; \ c& operator=(const c&) = delete; diff --git a/AK/OwnPtr.h b/AK/OwnPtr.h index 828aca3110a..64168e85960 100644 --- a/AK/OwnPtr.h +++ b/AK/OwnPtr.h @@ -1,24 +1,34 @@ #pragma once #include "StdLibExtras.h" -#include "Types.h" #include "Traits.h" +#include "Types.h" namespace AK { template class OwnPtr { public: - OwnPtr() { } - explicit OwnPtr(T* ptr) : m_ptr(ptr) { } - OwnPtr(OwnPtr&& other) : m_ptr(other.leak_ptr()) { } - template OwnPtr(OwnPtr&& other) : m_ptr(static_cast(other.leak_ptr())) { } - OwnPtr(std::nullptr_t) { }; + OwnPtr() {} + explicit OwnPtr(T* ptr) + : m_ptr(ptr) + { + } + OwnPtr(OwnPtr&& other) + : m_ptr(other.leak_ptr()) + { + } + template + OwnPtr(OwnPtr&& other) + : m_ptr(static_cast(other.leak_ptr())) + { + } + OwnPtr(std::nullptr_t) {}; ~OwnPtr() { clear(); #ifdef SANITIZE_PTRS - if constexpr(sizeof(T*) == 8) + if constexpr (sizeof(T*) == 8) m_ptr = (T*)(0xe1e1e1e1e1e1e1e1); else m_ptr = (T*)(0xe1e1e1e1); @@ -91,7 +101,8 @@ private: T* m_ptr = nullptr; }; -template inline OwnPtr +template +inline OwnPtr make(Args&&... args) { return OwnPtr(new T(AK::forward(args)...)); @@ -105,6 +116,5 @@ struct Traits> { } -using AK::OwnPtr; using AK::make; - +using AK::OwnPtr; diff --git a/AK/QuickSort.h b/AK/QuickSort.h index 790c25786c3..2d196d29770 100644 --- a/AK/QuickSort.h +++ b/AK/QuickSort.h @@ -8,7 +8,7 @@ bool is_less_than(const T& a, const T& b) return a < b; } -template +template void quick_sort(Iterator start, Iterator end, LessThan less_than = is_less_than) { int size = end - start; @@ -24,7 +24,7 @@ void quick_sort(Iterator start, Iterator end, LessThan less_than = is_less_than) int i = 1; for (int j = 1; j < size; ++j) { if (less_than(*(start + j), pivot)) { - swap(*(start+j), *(start + i)); + swap(*(start + j), *(start + i)); ++i; } } diff --git a/AK/RetainPtr.h b/AK/RetainPtr.h index d7140ab1c7c..0044202dee3 100644 --- a/AK/RetainPtr.h +++ b/AK/RetainPtr.h @@ -1,38 +1,80 @@ #pragma once -#include #include +#include namespace AK { template class RetainPtr { public: - enum AdoptTag { Adopt }; + enum AdoptTag { + Adopt + }; - RetainPtr() { } - RetainPtr(const T* ptr) : m_ptr(const_cast(ptr)) { retain_if_not_null(m_ptr); } - RetainPtr(T* ptr) : m_ptr(ptr) { retain_if_not_null(m_ptr); } - RetainPtr(T& object) : m_ptr(&object) { m_ptr->retain(); } - RetainPtr(const T& object) : m_ptr(const_cast(&object)) { m_ptr->retain(); } - RetainPtr(AdoptTag, T& object) : m_ptr(&object) { } - RetainPtr(RetainPtr& other) : m_ptr(other.copy_ref().leak_ref()) { } - RetainPtr(RetainPtr&& other) : m_ptr(other.leak_ref()) { } - template RetainPtr(Retained&& other) : m_ptr(static_cast(&other.leak_ref())) { } - template RetainPtr(RetainPtr&& other) : m_ptr(static_cast(other.leak_ref())) { } - RetainPtr(const RetainPtr& other) : m_ptr(const_cast(other).copy_ref().leak_ref()) { } - template RetainPtr(const RetainPtr& other) : m_ptr(const_cast&>(other).copy_ref().leak_ref()) { } + RetainPtr() {} + RetainPtr(const T* ptr) + : m_ptr(const_cast(ptr)) + { + retain_if_not_null(m_ptr); + } + RetainPtr(T* ptr) + : m_ptr(ptr) + { + retain_if_not_null(m_ptr); + } + RetainPtr(T& object) + : m_ptr(&object) + { + m_ptr->retain(); + } + RetainPtr(const T& object) + : m_ptr(const_cast(&object)) + { + m_ptr->retain(); + } + RetainPtr(AdoptTag, T& object) + : m_ptr(&object) + { + } + RetainPtr(RetainPtr& other) + : m_ptr(other.copy_ref().leak_ref()) + { + } + RetainPtr(RetainPtr&& other) + : m_ptr(other.leak_ref()) + { + } + template + RetainPtr(Retained&& other) + : m_ptr(static_cast(&other.leak_ref())) + { + } + template + RetainPtr(RetainPtr&& other) + : m_ptr(static_cast(other.leak_ref())) + { + } + RetainPtr(const RetainPtr& other) + : m_ptr(const_cast(other).copy_ref().leak_ref()) + { + } + template + RetainPtr(const RetainPtr& other) + : m_ptr(const_cast&>(other).copy_ref().leak_ref()) + { + } ~RetainPtr() { clear(); #ifdef SANITIZE_PTRS - if constexpr(sizeof(T*) == 8) + if constexpr (sizeof(T*) == 8) m_ptr = (T*)(0xe0e0e0e0e0e0e0e0); else m_ptr = (T*)(0xe0e0e0e0); #endif } - RetainPtr(std::nullptr_t) { } + RetainPtr(std::nullptr_t) {} RetainPtr& operator=(RetainPtr&& other) { @@ -143,4 +185,3 @@ private: } using AK::RetainPtr; - diff --git a/AK/Retainable.h b/AK/Retainable.h index fb6a06c4ade..be928f8521d 100644 --- a/AK/Retainable.h +++ b/AK/Retainable.h @@ -6,27 +6,27 @@ namespace AK { template -constexpr auto call_will_be_destroyed_if_present(T* object) -> decltype(object->will_be_destroyed(), TrueType { }) +constexpr auto call_will_be_destroyed_if_present(T* object) -> decltype(object->will_be_destroyed(), TrueType {}) { object->will_be_destroyed(); - return { }; + return {}; } constexpr auto call_will_be_destroyed_if_present(...) -> FalseType { - return { }; + return {}; } template -constexpr auto call_one_retain_left_if_present(T* object) -> decltype(object->one_retain_left(), TrueType { }) +constexpr auto call_one_retain_left_if_present(T* object) -> decltype(object->one_retain_left(), TrueType {}) { object->one_retain_left(); - return { }; + return {}; } constexpr auto call_one_retain_left_if_present(...) -> FalseType { - return { }; + return {}; } class RetainableBase { @@ -43,7 +43,7 @@ public: } protected: - RetainableBase() { } + RetainableBase() {} ~RetainableBase() { ASSERT(!m_retain_count); @@ -76,4 +76,3 @@ public: } using AK::Retainable; - diff --git a/AK/Retained.h b/AK/Retained.h index f583576c42d..e1aa22f8ecb 100644 --- a/AK/Retained.h +++ b/AK/Retained.h @@ -4,15 +4,15 @@ #include #ifdef __clang__ -#define CONSUMABLE(initial_state) __attribute__((consumable(initial_state))) -#define CALLABLE_WHEN(...) __attribute__((callable_when(__VA_ARGS__))) -#define SET_TYPESTATE(state) __attribute__((set_typestate(state))) -#define RETURN_TYPESTATE(state) __attribute__((return_typestate(state))) +# define CONSUMABLE(initial_state) __attribute__((consumable(initial_state))) +# define CALLABLE_WHEN(...) __attribute__((callable_when(__VA_ARGS__))) +# define SET_TYPESTATE(state) __attribute__((set_typestate(state))) +# define RETURN_TYPESTATE(state) __attribute__((return_typestate(state))) #else -#define CONSUMABLE(initial_state) -#define CALLABLE_WHEN(state) -#define SET_TYPESTATE(state) -#define RETURN_TYPESTATE(state) +# define CONSUMABLE(initial_state) +# define CALLABLE_WHEN(state) +# define SET_TYPESTATE(state) +# define RETURN_TYPESTATE(state) #endif namespace AK { @@ -34,30 +34,75 @@ inline void release_if_not_null(T* ptr) template class CONSUMABLE(unconsumed) Retained { public: - enum AdoptTag { Adopt }; + enum AdoptTag { + Adopt + }; - RETURN_TYPESTATE(unconsumed) Retained(const T& object) : m_ptr(const_cast(&object)) { m_ptr->retain(); } - RETURN_TYPESTATE(unconsumed) Retained(T& object) : m_ptr(&object) { m_ptr->retain(); } - template RETURN_TYPESTATE(unconsumed) Retained(U& object) : m_ptr(&static_cast(object)) { m_ptr->retain(); } - RETURN_TYPESTATE(unconsumed) Retained(AdoptTag, T& object) : m_ptr(&object) { } - RETURN_TYPESTATE(unconsumed) Retained(Retained& other) : m_ptr(&other.copy_ref().leak_ref()) { } - RETURN_TYPESTATE(unconsumed) Retained(Retained&& other) : m_ptr(&other.leak_ref()) { } - template RETURN_TYPESTATE(unconsumed) Retained(Retained&& other) : m_ptr(static_cast(&other.leak_ref())) { } - RETURN_TYPESTATE(unconsumed) Retained(const Retained& other) : m_ptr(&const_cast(other).copy_ref().leak_ref()) { } - template RETURN_TYPESTATE(unconsumed) Retained(const Retained& other) : m_ptr(&const_cast&>(other).copy_ref().leak_ref()) { } + RETURN_TYPESTATE(unconsumed) + Retained(const T& object) + : m_ptr(const_cast(&object)) + { + m_ptr->retain(); + } + RETURN_TYPESTATE(unconsumed) + Retained(T& object) + : m_ptr(&object) + { + m_ptr->retain(); + } + template + RETURN_TYPESTATE(unconsumed) + Retained(U& object) + : m_ptr(&static_cast(object)) + { + m_ptr->retain(); + } + RETURN_TYPESTATE(unconsumed) + Retained(AdoptTag, T& object) + : m_ptr(&object) + { + } + RETURN_TYPESTATE(unconsumed) + Retained(Retained& other) + : m_ptr(&other.copy_ref().leak_ref()) + { + } + RETURN_TYPESTATE(unconsumed) + Retained(Retained&& other) + : m_ptr(&other.leak_ref()) + { + } + template + RETURN_TYPESTATE(unconsumed) + Retained(Retained&& other) + : m_ptr(static_cast(&other.leak_ref())) + { + } + RETURN_TYPESTATE(unconsumed) + Retained(const Retained& other) + : m_ptr(&const_cast(other).copy_ref().leak_ref()) + { + } + template + RETURN_TYPESTATE(unconsumed) + Retained(const Retained& other) + : m_ptr(&const_cast&>(other).copy_ref().leak_ref()) + { + } ~Retained() { release_if_not_null(m_ptr); m_ptr = nullptr; #ifdef SANITIZE_PTRS - if constexpr(sizeof(T*) == 8) + if constexpr (sizeof(T*) == 8) m_ptr = (T*)(0xb0b0b0b0b0b0b0b0); else m_ptr = (T*)(0xb0b0b0b0); #endif } - CALLABLE_WHEN(unconsumed) Retained& operator=(Retained&& other) + CALLABLE_WHEN(unconsumed) + Retained& operator=(Retained&& other) { if (this != &other) { release_if_not_null(m_ptr); @@ -67,7 +112,8 @@ public: } template - CALLABLE_WHEN(unconsumed) Retained& operator=(Retained&& other) + CALLABLE_WHEN(unconsumed) + Retained& operator=(Retained&& other) { if (this != static_cast(&other)) { release_if_not_null(m_ptr); @@ -76,7 +122,8 @@ public: return *this; } - CALLABLE_WHEN(unconsumed) Retained& operator=(T& object) + CALLABLE_WHEN(unconsumed) + Retained& operator=(T& object) { if (m_ptr != &object) release_if_not_null(m_ptr); @@ -85,12 +132,14 @@ public: return *this; } - CALLABLE_WHEN(unconsumed) Retained copy_ref() const + CALLABLE_WHEN(unconsumed) + Retained copy_ref() const { return Retained(*m_ptr); } - CALLABLE_WHEN(unconsumed) SET_TYPESTATE(consumed) + CALLABLE_WHEN(unconsumed) + SET_TYPESTATE(consumed) T& leak_ref() { ASSERT(m_ptr); @@ -99,20 +148,60 @@ public: return *leakedPtr; } - CALLABLE_WHEN(unconsumed) T* ptr() { ASSERT(m_ptr); return m_ptr; } - CALLABLE_WHEN(unconsumed) const T* ptr() const { ASSERT(m_ptr); return m_ptr; } + CALLABLE_WHEN(unconsumed) + T* ptr() + { + ASSERT(m_ptr); + return m_ptr; + } + CALLABLE_WHEN(unconsumed) + const T* ptr() const + { + ASSERT(m_ptr); + return m_ptr; + } - CALLABLE_WHEN(unconsumed) T* operator->() { ASSERT(m_ptr); return m_ptr; } - CALLABLE_WHEN(unconsumed) const T* operator->() const { ASSERT(m_ptr); return m_ptr; } + CALLABLE_WHEN(unconsumed) + T* operator->() + { + ASSERT(m_ptr); + return m_ptr; + } + CALLABLE_WHEN(unconsumed) + const T* operator->() const + { + ASSERT(m_ptr); + return m_ptr; + } - CALLABLE_WHEN(unconsumed) T& operator*() { ASSERT(m_ptr); return *m_ptr; } - CALLABLE_WHEN(unconsumed) const T& operator*() const { ASSERT(m_ptr); return *m_ptr; } + CALLABLE_WHEN(unconsumed) + T& operator*() + { + ASSERT(m_ptr); + return *m_ptr; + } + CALLABLE_WHEN(unconsumed) + const T& operator*() const + { + ASSERT(m_ptr); + return *m_ptr; + } - CALLABLE_WHEN(unconsumed) operator T*() { ASSERT(m_ptr); return m_ptr; } - CALLABLE_WHEN(unconsumed) operator const T*() const { ASSERT(m_ptr); return m_ptr; } + CALLABLE_WHEN(unconsumed) + operator T*() + { + ASSERT(m_ptr); + return m_ptr; + } + CALLABLE_WHEN(unconsumed) + operator const T*() const + { + ASSERT(m_ptr); + return m_ptr; + } private: - Retained() { } + Retained() {} T* m_ptr { nullptr }; }; @@ -125,5 +214,5 @@ inline Retained adopt(T& object) } -using AK::Retained; using AK::adopt; +using AK::Retained; diff --git a/AK/SinglyLinkedList.h b/AK/SinglyLinkedList.h index 022b6f95717..c14fe97b452 100644 --- a/AK/SinglyLinkedList.h +++ b/AK/SinglyLinkedList.h @@ -8,13 +8,16 @@ template class SinglyLinkedList { private: struct Node { - explicit Node(T&& v) : value(v) { } + explicit Node(T&& v) + : value(v) + { + } T value; Node* next { nullptr }; }; public: - SinglyLinkedList() { } + SinglyLinkedList() {} ~SinglyLinkedList() { clear(); } bool is_empty() const { return !head(); } @@ -29,7 +32,7 @@ public: void clear() { - for (auto* node = m_head; node; ) { + for (auto* node = m_head; node;) { auto* next = node->next; delete node; node = next; @@ -38,10 +41,26 @@ public: m_tail = nullptr; } - T& first() { ASSERT(head()); return head()->value; } - const T& first() const { ASSERT(head()); return head()->value; } - T& last() { ASSERT(head()); return tail()->value; } - const T& last() const { ASSERT(head()); return tail()->value; } + T& first() + { + ASSERT(head()); + return head()->value; + } + const T& first() const + { + ASSERT(head()); + return head()->value; + } + T& last() + { + ASSERT(head()); + return tail()->value; + } + const T& last() const + { + ASSERT(head()); + return tail()->value; + } T take_first() { @@ -79,13 +98,21 @@ public: class Iterator { public: bool operator!=(const Iterator& other) { return m_node != other.m_node; } - Iterator& operator++() { m_node = m_node->next; return *this; } + Iterator& operator++() + { + m_node = m_node->next; + return *this; + } T& operator*() { return m_node->value; } bool is_end() const { return !m_node; } static Iterator universal_end() { return Iterator(nullptr); } + private: friend class SinglyLinkedList; - explicit Iterator(SinglyLinkedList::Node* node) : m_node(node) { } + explicit Iterator(SinglyLinkedList::Node* node) + : m_node(node) + { + } SinglyLinkedList::Node* m_node; }; @@ -95,13 +122,21 @@ public: class ConstIterator { public: bool operator!=(const ConstIterator& other) { return m_node != other.m_node; } - ConstIterator& operator++() { m_node = m_node->next; return *this; } + ConstIterator& operator++() + { + m_node = m_node->next; + return *this; + } const T& operator*() const { return m_node->value; } bool is_end() const { return !m_node; } static ConstIterator universal_end() { return ConstIterator(nullptr); } + private: friend class SinglyLinkedList; - explicit ConstIterator(const SinglyLinkedList::Node* node) : m_node(node) { } + explicit ConstIterator(const SinglyLinkedList::Node* node) + : m_node(node) + { + } const SinglyLinkedList::Node* m_node; }; @@ -142,4 +177,3 @@ private: } using AK::SinglyLinkedList; - diff --git a/AK/StdLibExtras.cpp b/AK/StdLibExtras.cpp index ee8aa862d97..491fe645ed1 100644 --- a/AK/StdLibExtras.cpp +++ b/AK/StdLibExtras.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include @@ -20,32 +20,33 @@ void* mmx_memcpy(void* dest, const void* src, size_t len) "rep movsb\n" : "=S"(src_ptr), "=D"(dest_ptr), "=c"(prologue) : "0"(src_ptr), "1"(dest_ptr), "2"(prologue) - : "memory" - ); + : "memory"); } for (dword i = len / 64; i; --i) { asm volatile( - "movq (%0), %%mm0\n" - "movq 8(%0), %%mm1\n" - "movq 16(%0), %%mm2\n" - "movq 24(%0), %%mm3\n" - "movq 32(%0), %%mm4\n" - "movq 40(%0), %%mm5\n" - "movq 48(%0), %%mm6\n" - "movq 56(%0), %%mm7\n" - "movq %%mm0, (%1)\n" - "movq %%mm1, 8(%1)\n" - "movq %%mm2, 16(%1)\n" - "movq %%mm3, 24(%1)\n" - "movq %%mm4, 32(%1)\n" - "movq %%mm5, 40(%1)\n" - "movq %%mm6, 48(%1)\n" - "movq %%mm7, 56(%1)\n" - :: "r" (src_ptr), "r" (dest_ptr) : "memory"); + "movq (%0), %%mm0\n" + "movq 8(%0), %%mm1\n" + "movq 16(%0), %%mm2\n" + "movq 24(%0), %%mm3\n" + "movq 32(%0), %%mm4\n" + "movq 40(%0), %%mm5\n" + "movq 48(%0), %%mm6\n" + "movq 56(%0), %%mm7\n" + "movq %%mm0, (%1)\n" + "movq %%mm1, 8(%1)\n" + "movq %%mm2, 16(%1)\n" + "movq %%mm3, 24(%1)\n" + "movq %%mm4, 32(%1)\n" + "movq %%mm5, 40(%1)\n" + "movq %%mm6, 48(%1)\n" + "movq %%mm7, 56(%1)\n" ::"r"(src_ptr), + "r"(dest_ptr) + : "memory"); src_ptr += 64; dest_ptr += 64; } - asm volatile("emms":::"memory"); + asm volatile("emms" :: + : "memory"); // Whatever remains we'll have to memcpy. len %= 64; if (len) @@ -62,13 +63,15 @@ static inline uint32_t divq(uint64_t n, uint32_t d) uint32_t n0 = n; uint32_t q; uint32_t r; - asm volatile("divl %4" : "=d"(r), "=a"(q) : "0"(n1), "1"(n0), "rm"(d)); + asm volatile("divl %4" + : "=d"(r), "=a"(q) + : "0"(n1), "1"(n0), "rm"(d)); return q; } static uint64_t unsigned_divide64(uint64_t n, uint64_t d) { - if ((d >> 32) == 0) { + if ((d >> 32) == 0) { uint64_t b = 1ULL << 32; uint32_t n1 = n >> 32; uint32_t n0 = n; @@ -149,5 +152,4 @@ uint64_t __udivmoddi4(uint64_t n, uint64_t d, uint64_t* r) return q; } #endif - } diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index d090ad861d7..f233ab4219e 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -1,10 +1,10 @@ #pragma once #ifdef KERNEL -#include +# include #else -#include -#include +# include +# include #endif #define UNUSED_PARAM(x) (void)x @@ -27,8 +27,7 @@ extern "C" void* mmx_memcpy(void* to, const void* from, size_t); "rep movsl\n" : "=S"(src), "=D"(dest), "=c"(count) : "S"(src), "D"(dest), "c"(count) - : "memory" - ); + : "memory"); } [[gnu::always_inline]] inline void fast_dword_fill(dword* dest, dword value, size_t count) @@ -37,13 +36,12 @@ extern "C" void* mmx_memcpy(void* to, const void* from, size_t); "rep stosl\n" : "=D"(dest), "=c"(count) : "D"(dest), "c"(count), "a"(value) - : "memory" - ); + : "memory"); } inline constexpr dword round_up_to_power_of_two(dword value, dword power_of_two) { - return ((value - 1) & ~ (power_of_two - 1)) + power_of_two; + return ((value - 1) & ~(power_of_two - 1)) + power_of_two; } namespace AK { @@ -60,7 +58,6 @@ inline T max(const T& a, const T& b) return a < b ? b : a; } - template static inline T ceil_div(T a, U b) { @@ -72,16 +69,16 @@ static inline T ceil_div(T a, U b) } #ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wconsumed" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wconsumed" #endif -template +template T&& move(T& arg) { return static_cast(arg); } #ifdef __clang__ -#pragma clang diagnostic pop +# pragma clang diagnostic pop #endif template @@ -107,26 +104,37 @@ template void swap(T& a, U& b) { U tmp = move((U&)a); - a = (T&&)move(b); + a = (T &&) move(b); b = move(tmp); } template -struct EnableIf -{ +struct EnableIf { }; template -struct EnableIf -{ +struct EnableIf { typedef T Type; }; -template struct RemoveConst { typedef T Type; }; -template struct RemoveConst { typedef T Type; }; -template struct RemoveVolatile { typedef T Type; }; -template struct RemoveVolatile { typedef T Type; }; -template struct RemoveCV { +template +struct RemoveConst { + typedef T Type; +}; +template +struct RemoveConst { + typedef T Type; +}; +template +struct RemoveVolatile { + typedef T Type; +}; +template +struct RemoveVolatile { + typedef T Type; +}; +template +struct RemoveCV { typedef typename RemoveVolatile::Type>::Type Type; }; @@ -143,69 +151,145 @@ typedef IntegralConstant FalseType; typedef IntegralConstant TrueType; template -struct __IsPointerHelper : FalseType { }; +struct __IsPointerHelper : FalseType { +}; template -struct __IsPointerHelper : TrueType { }; +struct __IsPointerHelper : TrueType { +}; template -struct IsPointer : __IsPointerHelper::Type> { }; +struct IsPointer : __IsPointerHelper::Type> { +}; -template struct IsFunction : FalseType { }; +template +struct IsFunction : FalseType { +}; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; -template struct IsFunction : TrueType { }; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; +template +struct IsFunction : TrueType { +}; -template struct IsRvalueReference : FalseType { }; -template struct IsRvalueReference : TrueType { }; +template +struct IsRvalueReference : FalseType { +}; +template +struct IsRvalueReference : TrueType { +}; -template struct RemovePointer { typedef T Type; }; -template struct RemovePointer { typedef T Type; }; -template struct RemovePointer { typedef T Type; }; -template struct RemovePointer { typedef T Type; }; -template struct RemovePointer { typedef T Type; }; +template +struct RemovePointer { + typedef T Type; +}; +template +struct RemovePointer { + typedef T Type; +}; +template +struct RemovePointer { + typedef T Type; +}; +template +struct RemovePointer { + typedef T Type; +}; +template +struct RemovePointer { + typedef T Type; +}; template struct IsSame { - enum { value = 0 }; + enum { + value = 0 + }; }; template struct IsSame { - enum { value = 1 }; + enum { + value = 1 + }; }; } -using AK::min; -using AK::max; -using AK::move; -using AK::forward; -using AK::exchange; -using AK::swap; using AK::ceil_div; +using AK::exchange; +using AK::forward; using AK::IsSame; +using AK::max; +using AK::min; +using AK::move; +using AK::swap; diff --git a/AK/String.cpp b/AK/String.cpp index 8544e4c98a3..5ec6f355ee1 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -38,7 +38,7 @@ String String::empty() String String::isolated_copy() const { if (!m_impl) - return { }; + return {}; if (!m_impl->length()) return empty(); char* buffer; @@ -50,7 +50,7 @@ String String::isolated_copy() const String String::substring(int start, int length) const { if (!length) - return { }; + return {}; ASSERT(m_impl); ASSERT(start + length <= m_impl->length()); // FIXME: This needs some input bounds checking. @@ -60,7 +60,7 @@ String String::substring(int start, int length) const StringView String::substring_view(int start, int length) const { if (!length) - return { }; + return {}; ASSERT(m_impl); ASSERT(start + length <= m_impl->length()); // FIXME: This needs some input bounds checking. @@ -70,7 +70,7 @@ StringView String::substring_view(int start, int length) const Vector String::split(const char separator) const { if (is_empty()) - return { }; + return {}; Vector v; ssize_t substart = 0; @@ -94,7 +94,7 @@ Vector String::split(const char separator) const Vector String::split_view(const char separator) const { if (is_empty()) - return { }; + return {}; Vector v; ssize_t substart = 0; @@ -232,7 +232,7 @@ bool String::match_helper(const String& mask) const if (!*++mask_ptr) return true; mp = mask_ptr; - cp = string_ptr+1; + cp = string_ptr + 1; } else if ((*mask_ptr == *string_ptr) || (*mask_ptr == '?')) { mask_ptr++; string_ptr++; diff --git a/AK/StringBuilder.cpp b/AK/StringBuilder.cpp index 08776dd3f36..0fe550242e0 100644 --- a/AK/StringBuilder.cpp +++ b/AK/StringBuilder.cpp @@ -1,7 +1,7 @@ #include "StringBuilder.h" -#include #include "printf.cpp" #include +#include namespace AK { @@ -43,9 +43,10 @@ void StringBuilder::append(char ch) void StringBuilder::appendvf(const char* fmt, va_list ap) { - printf_internal([this] (char*&, char ch) { + printf_internal([this](char*&, char ch) { append(ch); - }, nullptr, fmt, ap); + }, + nullptr, fmt, ap); } void StringBuilder::appendf(const char* fmt, ...) @@ -71,4 +72,3 @@ String StringBuilder::to_string() } } - diff --git a/AK/StringBuilder.h b/AK/StringBuilder.h index f6c17dbf85c..700540942aa 100644 --- a/AK/StringBuilder.h +++ b/AK/StringBuilder.h @@ -9,7 +9,7 @@ namespace AK { class StringBuilder { public: explicit StringBuilder(ssize_t initial_capacity = 16); - ~StringBuilder() { } + ~StringBuilder() {} void append(const String&); void append(char); @@ -30,4 +30,3 @@ private: } using AK::StringBuilder; - diff --git a/AK/StringImpl.cpp b/AK/StringImpl.cpp index 5b8e6c742f6..2799e237d6d 100644 --- a/AK/StringImpl.cpp +++ b/AK/StringImpl.cpp @@ -1,7 +1,7 @@ #include "StringImpl.h" +#include "HashTable.h" #include "StdLibExtras.h" #include "kmalloc.h" -#include "HashTable.h" //#define DEBUG_STRINGIMPL @@ -26,7 +26,8 @@ static StringImpl* s_the_empty_stringimpl = nullptr; StringImpl& StringImpl::the_empty_stringimpl() { if (!s_the_empty_stringimpl) - s_the_empty_stringimpl = new StringImpl(ConstructTheEmptyStringImpl);; + s_the_empty_stringimpl = new StringImpl(ConstructTheEmptyStringImpl); + ; return *s_the_empty_stringimpl; } @@ -168,4 +169,3 @@ void StringImpl::compute_hash() const } } - diff --git a/AK/StringImpl.h b/AK/StringImpl.h index c7ecfd3c24c..babca34e104 100644 --- a/AK/StringImpl.h +++ b/AK/StringImpl.h @@ -1,12 +1,15 @@ #pragma once -#include "Retainable.h" #include "RetainPtr.h" +#include "Retainable.h" #include "Types.h" namespace AK { -enum ShouldChomp { NoChomp, Chomp }; +enum ShouldChomp { + NoChomp, + Chomp +}; class StringImpl : public Retainable { public: @@ -22,7 +25,11 @@ public: ssize_t length() const { return m_length; } const char* characters() const { return m_characters; } - char operator[](ssize_t i) const { ASSERT(i >= 0 && i < m_length); return m_characters[i]; } + char operator[](ssize_t i) const + { + ASSERT(i >= 0 && i < m_length); + return m_characters[i]; + } unsigned hash() const { @@ -32,10 +39,17 @@ public: } private: - enum ConstructTheEmptyStringImplTag { ConstructTheEmptyStringImpl }; - explicit StringImpl(ConstructTheEmptyStringImplTag) : m_characters("") { } + enum ConstructTheEmptyStringImplTag { + ConstructTheEmptyStringImpl + }; + explicit StringImpl(ConstructTheEmptyStringImplTag) + : m_characters("") + { + } - enum ConstructWithInlineBufferTag { ConstructWithInlineBuffer }; + enum ConstructWithInlineBufferTag { + ConstructWithInlineBuffer + }; StringImpl(ConstructWithInlineBufferTag, ssize_t length); void compute_hash() const; @@ -63,6 +77,6 @@ inline dword string_hash(const char* characters, int length) } -using AK::StringImpl; using AK::Chomp; using AK::string_hash; +using AK::StringImpl; diff --git a/AK/StringView.cpp b/AK/StringView.cpp index 06fe6752e50..77fc057c391 100644 --- a/AK/StringView.cpp +++ b/AK/StringView.cpp @@ -1,12 +1,12 @@ -#include #include +#include namespace AK { Vector StringView::split_view(const char separator) const { if (is_empty()) - return { }; + return {}; Vector v; ssize_t substart = 0; @@ -30,7 +30,7 @@ Vector StringView::split_view(const char separator) const StringView StringView::substring_view(int start, int length) const { if (!length) - return { }; + return {}; ASSERT(start + length <= m_length); return { m_characters + start, length }; } @@ -50,5 +50,4 @@ unsigned StringView::to_uint(bool& ok) const return value; } - } diff --git a/AK/StringView.h b/AK/StringView.h index 51ccd2f67c7..ced68488a02 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -8,9 +8,17 @@ class String; class StringView { public: - StringView() { } - StringView(const char* characters, int length) : m_characters(characters), m_length(length) { } - StringView(const unsigned char* characters, int length) : m_characters((const char*)characters), m_length(length) { } + StringView() {} + StringView(const char* characters, int length) + : m_characters(characters) + , m_length(length) + { + } + StringView(const unsigned char* characters, int length) + : m_characters((const char*)characters) + , m_length(length) + { + } StringView(const char* cstring) : m_characters(cstring) { diff --git a/AK/TemporaryChange.h b/AK/TemporaryChange.h index 274672a490c..6248bb865bb 100644 --- a/AK/TemporaryChange.h +++ b/AK/TemporaryChange.h @@ -5,7 +5,12 @@ namespace AK { template class TemporaryChange { public: - TemporaryChange(T& variable, T value) : m_variable(variable), m_old_value(variable) { m_variable = value; } + TemporaryChange(T& variable, T value) + : m_variable(variable) + , m_old_value(variable) + { + m_variable = value; + } ~TemporaryChange() { m_variable = m_old_value; } private: diff --git a/AK/Traits.h b/AK/Traits.h index 7c88a2e7cb5..c147fa3cbd3 100644 --- a/AK/Traits.h +++ b/AK/Traits.h @@ -1,13 +1,12 @@ #pragma once -#include "kstdio.h" #include "HashFunctions.h" +#include "kstdio.h" namespace AK { template -struct Traits -{ +struct Traits { }; template<> @@ -38,4 +37,3 @@ struct Traits { }; } - diff --git a/AK/Types.h b/AK/Types.h index fb8501d21dd..67649954303 100644 --- a/AK/Types.h +++ b/AK/Types.h @@ -30,8 +30,8 @@ typedef signed_dword int32_t; typedef signed_qword int64_t; #else -#include -#include +# include +# include typedef uint8_t byte; typedef uint16_t word; @@ -48,9 +48,11 @@ constexpr unsigned KB = 1024; constexpr unsigned MB = KB * KB; constexpr unsigned GB = KB * KB * KB; -enum class IterationDecision { Continue, Abort }; +enum class IterationDecision { + Continue, + Abort +}; namespace std { typedef decltype(nullptr) nullptr_t; } - diff --git a/AK/Vector.h b/AK/Vector.h index 2ebe8f92b1e..c1b9c5622f0 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -112,8 +112,16 @@ public: return m_outline_buffer; } - const T& at(int i) const { ASSERT(i >= 0 && i < m_size); return data()[i]; } - T& at(int i) { ASSERT(i >= 0 && i < m_size); return data()[i]; } + const T& at(int i) const + { + ASSERT(i >= 0 && i < m_size); + return data()[i]; + } + T& at(int i) + { + ASSERT(i >= 0 && i < m_size); + return data()[i]; + } const T& operator[](int i) const { return at(i); } T& operator[](int i) { return at(i); } @@ -314,8 +322,16 @@ public: bool operator<(const Iterator& other) { return m_index < other.m_index; } bool operator>(const Iterator& other) { return m_index > other.m_index; } bool operator>=(const Iterator& other) { return m_index >= other.m_index; } - Iterator& operator++() { ++m_index; return *this; } - Iterator& operator--() { --m_index; return *this; } + Iterator& operator++() + { + ++m_index; + return *this; + } + Iterator& operator--() + { + --m_index; + return *this; + } Iterator operator-(int value) { return { m_vector, m_index - value }; } Iterator operator+(int value) { return { m_vector, m_index + value }; } Iterator& operator=(const Iterator& other) @@ -325,9 +341,14 @@ public: } T& operator*() { return m_vector[m_index]; } int operator-(const Iterator& other) { return m_index - other.m_index; } + private: friend class Vector; - Iterator(Vector& vector, int index) : m_vector(vector), m_index(index) { } + Iterator(Vector& vector, int index) + : m_vector(vector) + , m_index(index) + { + } Vector& m_vector; int m_index { 0 }; }; @@ -342,8 +363,16 @@ public: bool operator<(const ConstIterator& other) { return m_index < other.m_index; } bool operator>(const ConstIterator& other) { return m_index > other.m_index; } bool operator>=(const ConstIterator& other) { return m_index >= other.m_index; } - ConstIterator& operator++() { ++m_index; return *this; } - ConstIterator& operator--() { --m_index; return *this; } + ConstIterator& operator++() + { + ++m_index; + return *this; + } + ConstIterator& operator--() + { + --m_index; + return *this; + } ConstIterator operator-(int value) { return { m_vector, m_index - value }; } ConstIterator operator+(int value) { return { m_vector, m_index + value }; } ConstIterator& operator=(const ConstIterator& other) @@ -353,9 +382,14 @@ public: } const T& operator*() const { return m_vector[m_index]; } int operator-(const ConstIterator& other) { return m_index - other.m_index; } + private: friend class Vector; - ConstIterator(const Vector& vector, const int index) : m_vector(vector), m_index(index) { } + ConstIterator(const Vector& vector, const int index) + : m_vector(vector) + , m_index(index) + { + } const Vector& m_vector; int m_index { 0 }; }; @@ -377,8 +411,16 @@ private: T* slot(int i) { return &data()[i]; } const T* slot(int i) const { return &data()[i]; } - T* inline_buffer() { static_assert(inline_capacity > 0); return reinterpret_cast(m_inline_buffer_storage); } - const T* inline_buffer() const { static_assert(inline_capacity > 0); return reinterpret_cast(m_inline_buffer_storage); } + T* inline_buffer() + { + static_assert(inline_capacity > 0); + return reinterpret_cast(m_inline_buffer_storage); + } + const T* inline_buffer() const + { + static_assert(inline_capacity > 0); + return reinterpret_cast(m_inline_buffer_storage); + } int m_size { 0 }; int m_capacity { 0 }; diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index 89dbcd93f4b..30d118e1780 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -4,14 +4,16 @@ namespace AK { -template class OwnPtr; +template +class OwnPtr; template class WeakPtr { friend class Weakable; + public: - WeakPtr() { } - WeakPtr(std::nullptr_t) { } + WeakPtr() {} + WeakPtr(std::nullptr_t) {} template WeakPtr(WeakPtr&& other) @@ -48,7 +50,10 @@ public: bool operator==(const OwnPtr& other) const { return ptr() == other.ptr(); } private: - WeakPtr(RetainPtr>&& link) : m_link(move(link)) { } + WeakPtr(RetainPtr>&& link) + : m_link(move(link)) + { + } RetainPtr> m_link; }; @@ -64,4 +69,3 @@ inline WeakPtr Weakable::make_weak_ptr() } using AK::WeakPtr; - diff --git a/AK/Weakable.h b/AK/Weakable.h index c9590c2be15..d5b55050d32 100644 --- a/AK/Weakable.h +++ b/AK/Weakable.h @@ -1,23 +1,29 @@ #pragma once #include "Assertions.h" -#include "Retainable.h" #include "RetainPtr.h" +#include "Retainable.h" namespace AK { -template class Weakable; -template class WeakPtr; +template +class Weakable; +template +class WeakPtr; template class WeakLink : public Retainable> { friend class Weakable; + public: T* ptr() { return static_cast(m_ptr); } const T* ptr() const { return static_cast(m_ptr); } private: - explicit WeakLink(T& weakable) : m_ptr(&weakable) { } + explicit WeakLink(T& weakable) + : m_ptr(&weakable) + { + } T* m_ptr; }; @@ -25,11 +31,12 @@ template class Weakable { private: class Link; + public: WeakPtr make_weak_ptr(); protected: - Weakable() { } + Weakable() {} ~Weakable() { diff --git a/AK/kmalloc.h b/AK/kmalloc.h index c31352ec010..c1068d7f67a 100644 --- a/AK/kmalloc.h +++ b/AK/kmalloc.h @@ -1,25 +1,26 @@ #pragma once #ifdef KERNEL -#define AK_MAKE_ETERNAL \ -public: \ - void* operator new(size_t size) { return kmalloc_eternal(size); } \ -private: +# define AK_MAKE_ETERNAL \ + public: \ + void* operator new(size_t size) { return kmalloc_eternal(size); } \ + \ + private: #else -#define AK_MAKE_ETERNAL +# define AK_MAKE_ETERNAL #endif #ifdef KERNEL -#include +# include #else -#include +# include -#define kcalloc calloc -#define kmalloc malloc -#define kfree free -#define krealloc realloc +# define kcalloc calloc +# define kmalloc malloc +# define kfree free +# define krealloc realloc -#ifdef __serenity__ +# ifdef __serenity__ inline void* operator new(size_t size) { return kmalloc(size); @@ -44,6 +45,6 @@ inline void* operator new(size_t, void* ptr) { return ptr; } -#endif +# endif #endif diff --git a/AK/printf.cpp b/AK/printf.cpp index 68d29e5dc66..0b5ee149ad7 100644 --- a/AK/printf.cpp +++ b/AK/printf.cpp @@ -169,7 +169,6 @@ template return fieldWidth; } - template [[gnu::always_inline]] inline int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth) { @@ -183,7 +182,7 @@ template template [[gnu::always_inline]] inline int printf_internal(PutChFunc putch, char* buffer, const char*& fmt, char*& ap) { - const char *p; + const char* p; int ret = 0; char* bufptr = buffer; @@ -195,7 +194,7 @@ template unsigned long_qualifiers = 0; bool alternate_form = 0; if (*p == '%' && *(p + 1)) { -one_more: + one_more: ++p; if (*p == ' ') { leftPad = true; @@ -223,87 +222,81 @@ one_more: if (*(p + 1)) goto one_more; } - switch( *p ) - { - case 's': - { - const char* sp = va_arg(ap, const char*); - ret += print_string(putch, bufptr, sp ? sp : "(null)", leftPad, fieldWidth); - } - break; + switch (*p) { + case 's': { + const char* sp = va_arg(ap, const char*); + ret += print_string(putch, bufptr, sp ? sp : "(null)", leftPad, fieldWidth); + } break; - case 'd': - ret += print_signed_number(putch, bufptr, va_arg(ap, int), leftPad, zeroPad, fieldWidth); - break; + case 'd': + ret += print_signed_number(putch, bufptr, va_arg(ap, int), leftPad, zeroPad, fieldWidth); + break; - case 'u': - ret += print_number(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth); - break; + case 'u': + ret += print_number(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth); + break; - case 'Q': - ret += print_qword(putch, bufptr, va_arg(ap, qword), leftPad, zeroPad, fieldWidth); - break; + case 'Q': + ret += print_qword(putch, bufptr, va_arg(ap, qword), leftPad, zeroPad, fieldWidth); + break; - case 'q': - ret += print_hex(putch, bufptr, va_arg(ap, qword), 16); - break; + case 'q': + ret += print_hex(putch, bufptr, va_arg(ap, qword), 16); + break; #ifndef KERNEL - case 'f': - // FIXME: Print as float! - ret += print_number(putch, bufptr, (int)va_arg(ap, double), leftPad, zeroPad, fieldWidth); - break; + case 'f': + // FIXME: Print as float! + ret += print_number(putch, bufptr, (int)va_arg(ap, double), leftPad, zeroPad, fieldWidth); + break; #endif - case 'o': - if (alternate_form) { - putch(bufptr, '0'); - ++ret; - } - ret += print_octal_number(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth); - break; - - case 'x': - if (alternate_form) { - putch(bufptr, '0'); - putch(bufptr, 'x'); - ret += 2; - } - ret += print_hex(putch, bufptr, va_arg(ap, dword), 8); - break; - - case 'w': - ret += print_hex(putch, bufptr, va_arg(ap, int), 4); - break; - - case 'b': - ret += print_hex(putch, bufptr, va_arg(ap, int), 2); - break; - - case 'c': - putch(bufptr, (char)va_arg(ap, int)); + case 'o': + if (alternate_form) { + putch(bufptr, '0'); ++ret; - break; + } + ret += print_octal_number(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth); + break; - case '%': - putch(bufptr, '%'); - ++ret; - break; - - case 'p': + case 'x': + if (alternate_form) { putch(bufptr, '0'); putch(bufptr, 'x'); ret += 2; - ret += print_hex(putch, bufptr, va_arg(ap, dword), 8); - break; + } + ret += print_hex(putch, bufptr, va_arg(ap, dword), 8); + break; + + case 'w': + ret += print_hex(putch, bufptr, va_arg(ap, int), 4); + break; + + case 'b': + ret += print_hex(putch, bufptr, va_arg(ap, int), 2); + break; + + case 'c': + putch(bufptr, (char)va_arg(ap, int)); + ++ret; + break; + + case '%': + putch(bufptr, '%'); + ++ret; + break; + + case 'p': + putch(bufptr, '0'); + putch(bufptr, 'x'); + ret += 2; + ret += print_hex(putch, bufptr, va_arg(ap, dword), 8); + break; } - } - else { + } else { putch(bufptr, *p); ++ret; } } return ret; } - - diff --git a/Applications/FileManager/DirectoryView.h b/Applications/FileManager/DirectoryView.h index 58ff16d628b..c494419e5de 100644 --- a/Applications/FileManager/DirectoryView.h +++ b/Applications/FileManager/DirectoryView.h @@ -1,10 +1,10 @@ #pragma once #include -#include +#include #include #include -#include +#include #include class DirectoryView final : public GStackWidget { @@ -26,7 +26,12 @@ public: Function on_status_message; Function on_thumbnail_progress; - enum ViewMode { Invalid, List, Icon }; + enum ViewMode + { + Invalid, + List, + Icon + }; void set_view_mode(ViewMode); ViewMode view_mode() const { return m_view_mode; } @@ -41,7 +46,7 @@ private: ViewMode m_view_mode { Invalid }; Retained m_model; - int m_path_history_position{ 0 }; + int m_path_history_position { 0 }; Vector m_path_history; void add_path_to_history(const String& path); diff --git a/Applications/FontEditor/FontEditor.h b/Applications/FontEditor/FontEditor.h index 3d41d6b768d..9132c5029a7 100644 --- a/Applications/FontEditor/FontEditor.h +++ b/Applications/FontEditor/FontEditor.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class GlyphEditorWidget; class GlyphMapWidget; diff --git a/Applications/FontEditor/GlyphEditorWidget.h b/Applications/FontEditor/GlyphEditorWidget.h index 2e9c311ccdd..3784c054b51 100644 --- a/Applications/FontEditor/GlyphEditorWidget.h +++ b/Applications/FontEditor/GlyphEditorWidget.h @@ -1,5 +1,5 @@ -#include #include +#include class GlyphEditorWidget final : public GFrame { public: diff --git a/Applications/FontEditor/GlyphMapWidget.h b/Applications/FontEditor/GlyphMapWidget.h index 07aafbe2e14..e5746aff0b5 100644 --- a/Applications/FontEditor/GlyphMapWidget.h +++ b/Applications/FontEditor/GlyphMapWidget.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class GlyphMapWidget final : public GFrame { public: diff --git a/Applications/IRCClient/IRCAppWindow.h b/Applications/IRCClient/IRCAppWindow.h index e34c281f2ef..96e0867a67f 100644 --- a/Applications/IRCClient/IRCAppWindow.h +++ b/Applications/IRCClient/IRCAppWindow.h @@ -1,9 +1,9 @@ #pragma once -#include -#include #include "IRCClient.h" #include "IRCWindow.h" +#include +#include class GAction; class GStackWidget; diff --git a/Applications/IRCClient/IRCChannel.h b/Applications/IRCClient/IRCChannel.h index 8770dd181d3..de9132639a2 100644 --- a/Applications/IRCClient/IRCChannel.h +++ b/Applications/IRCClient/IRCChannel.h @@ -1,11 +1,11 @@ #pragma once +#include "IRCLogBuffer.h" #include #include -#include -#include #include -#include "IRCLogBuffer.h" +#include +#include class IRCClient; class IRCChannelMemberListModel; diff --git a/Applications/IRCClient/IRCChannelMemberListModel.h b/Applications/IRCClient/IRCChannelMemberListModel.h index 2f67cf15caf..ac380ec62d9 100644 --- a/Applications/IRCClient/IRCChannelMemberListModel.h +++ b/Applications/IRCClient/IRCChannelMemberListModel.h @@ -1,13 +1,16 @@ #pragma once -#include #include +#include class IRCChannel; class IRCChannelMemberListModel final : public GModel { public: - enum Column { Name }; + enum Column + { + Name + }; static Retained create(IRCChannel& channel) { return adopt(*new IRCChannelMemberListModel(channel)); } virtual ~IRCChannelMemberListModel() override; diff --git a/Applications/IRCClient/IRCClient.h b/Applications/IRCClient/IRCClient.h index 2ae4c348fad..ac02b9e9fc6 100644 --- a/Applications/IRCClient/IRCClient.h +++ b/Applications/IRCClient/IRCClient.h @@ -1,13 +1,13 @@ #pragma once -#include -#include -#include -#include -#include -#include #include "IRCLogBuffer.h" #include "IRCWindow.h" +#include +#include +#include +#include +#include +#include class IRCChannel; class IRCQuery; @@ -17,6 +17,7 @@ class CNotifier; class IRCClient final : public CObject { friend class IRCChannel; friend class IRCQuery; + public: IRCClient(); virtual ~IRCClient() override; diff --git a/Applications/IRCClient/IRCLogBuffer.h b/Applications/IRCClient/IRCLogBuffer.h index e1b6b472dd4..7d2bdff220f 100644 --- a/Applications/IRCClient/IRCLogBuffer.h +++ b/Applications/IRCClient/IRCLogBuffer.h @@ -2,8 +2,8 @@ #include #include -#include #include +#include #include class IRCLogBufferModel; diff --git a/Applications/IRCClient/IRCLogBufferModel.h b/Applications/IRCClient/IRCLogBufferModel.h index 5be8237d075..d5479da8870 100644 --- a/Applications/IRCClient/IRCLogBufferModel.h +++ b/Applications/IRCClient/IRCLogBufferModel.h @@ -6,7 +6,8 @@ class IRCLogBuffer; class IRCLogBufferModel final : public GModel { public: - enum Column { + enum Column + { Timestamp = 0, Name, Text, diff --git a/Applications/IRCClient/IRCQuery.h b/Applications/IRCClient/IRCQuery.h index 8d26d92881f..88f941fbdf0 100644 --- a/Applications/IRCClient/IRCQuery.h +++ b/Applications/IRCClient/IRCQuery.h @@ -1,11 +1,11 @@ #pragma once +#include "IRCLogBuffer.h" #include #include -#include -#include #include -#include "IRCLogBuffer.h" +#include +#include class IRCClient; class IRCWindow; diff --git a/Applications/IRCClient/IRCWindow.h b/Applications/IRCClient/IRCWindow.h index 2fce542fe53..f8fe692542b 100644 --- a/Applications/IRCClient/IRCWindow.h +++ b/Applications/IRCClient/IRCWindow.h @@ -11,7 +11,8 @@ class GTextEditor; class IRCWindow : public GWidget { public: - enum Type { + enum Type + { Server, Channel, Query, diff --git a/Applications/IRCClient/IRCWindowListModel.h b/Applications/IRCClient/IRCWindowListModel.h index d565eb78e30..93fa6b6abda 100644 --- a/Applications/IRCClient/IRCWindowListModel.h +++ b/Applications/IRCClient/IRCWindowListModel.h @@ -1,14 +1,15 @@ #pragma once -#include #include +#include class IRCClient; class IRCWindow; class IRCWindowListModel final : public GModel { public: - enum Column { + enum Column + { Name, }; diff --git a/Applications/ProcessManager/GraphWidget.h b/Applications/ProcessManager/GraphWidget.h index 83971c20bc6..1d39beb1f14 100644 --- a/Applications/ProcessManager/GraphWidget.h +++ b/Applications/ProcessManager/GraphWidget.h @@ -1,5 +1,5 @@ -#include #include +#include class GraphWidget final : public GFrame { public: diff --git a/Applications/ProcessManager/MemoryStatsWidget.h b/Applications/ProcessManager/MemoryStatsWidget.h index 2f6b1dc1832..e3912b9b94d 100644 --- a/Applications/ProcessManager/MemoryStatsWidget.h +++ b/Applications/ProcessManager/MemoryStatsWidget.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class GLabel; class GraphWidget; diff --git a/Applications/ProcessManager/ProcessModel.h b/Applications/ProcessManager/ProcessModel.h index 92ff292a0ba..3f6b18b1114 100644 --- a/Applications/ProcessManager/ProcessModel.h +++ b/Applications/ProcessManager/ProcessModel.h @@ -3,15 +3,16 @@ #include #include #include -#include #include +#include #include class GraphWidget; class ProcessModel final : public GModel { public: - enum Column { + enum Column + { Icon = 0, Name, CPU, diff --git a/Applications/ProcessManager/ProcessTableView.h b/Applications/ProcessManager/ProcessTableView.h index 28aef8ce0eb..24c45e33656 100644 --- a/Applications/ProcessManager/ProcessTableView.h +++ b/Applications/ProcessManager/ProcessTableView.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include class GraphWidget; @@ -19,4 +19,3 @@ public: private: virtual void model_notification(const GModelNotification&) override; }; - diff --git a/Applications/Taskbar/TaskbarButton.h b/Applications/Taskbar/TaskbarButton.h index 6cb790521a9..2a84b0b410d 100644 --- a/Applications/Taskbar/TaskbarButton.h +++ b/Applications/Taskbar/TaskbarButton.h @@ -1,7 +1,7 @@ #pragma once -#include #include "WindowIdentifier.h" +#include class TaskbarButton final : public GButton { public: diff --git a/Applications/Taskbar/TaskbarWindow.h b/Applications/Taskbar/TaskbarWindow.h index 856185343f1..fbfd4a50c46 100644 --- a/Applications/Taskbar/TaskbarWindow.h +++ b/Applications/Taskbar/TaskbarWindow.h @@ -1,6 +1,6 @@ -#include -#include #include "WindowList.h" +#include +#include class TaskbarWindow final : public GWindow { public: diff --git a/Applications/Taskbar/WindowIdentifier.h b/Applications/Taskbar/WindowIdentifier.h index afed91a288f..f5fcd65bfc1 100644 --- a/Applications/Taskbar/WindowIdentifier.h +++ b/Applications/Taskbar/WindowIdentifier.h @@ -18,6 +18,7 @@ public: { return m_client_id == other.m_client_id && m_window_id == other.m_window_id; } + private: int m_client_id { -1 }; int m_window_id { -1 }; diff --git a/Applications/Taskbar/WindowList.h b/Applications/Taskbar/WindowList.h index 6ebaaa53287..12cefb52ab3 100644 --- a/Applications/Taskbar/WindowList.h +++ b/Applications/Taskbar/WindowList.h @@ -1,10 +1,10 @@ #pragma once +#include "WindowIdentifier.h" #include #include -#include #include -#include "WindowIdentifier.h" +#include class Window { public: @@ -64,7 +64,8 @@ class WindowList { public: static WindowList& the(); - template void for_each_window(Callback callback) + template + void for_each_window(Callback callback) { for (auto& it : m_windows) callback(*it.value); diff --git a/Applications/Terminal/Terminal.h b/Applications/Terminal/Terminal.h index 52484080d70..4a84165256c 100644 --- a/Applications/Terminal/Terminal.h +++ b/Applications/Terminal/Terminal.h @@ -3,12 +3,12 @@ #include #include #include -#include -#include -#include +#include #include #include -#include +#include +#include +#include class Font; @@ -45,7 +45,6 @@ private: void invalidate_cursor(); void set_window_title(const String&); - void inject_string(const String&); void unimplemented_escape(); void unimplemented_xterm_escape(); @@ -107,7 +106,11 @@ private: bool dirty { false }; word length { 0 }; }; - Line& line(size_t index) { ASSERT(index < m_rows); return *m_lines[index]; } + Line& line(size_t index) + { + ASSERT(index < m_rows); + return *m_lines[index]; + } Line** m_lines { nullptr }; @@ -125,7 +128,8 @@ private: void execute_escape_sequence(byte final); void execute_xterm_command(); - enum EscapeState { + enum EscapeState + { Normal, ExpectBracket, ExpectParameter, diff --git a/DevTools/VisualBuilder/VBForm.h b/DevTools/VisualBuilder/VBForm.h index bae95532331..37ced0a6511 100644 --- a/DevTools/VisualBuilder/VBForm.h +++ b/DevTools/VisualBuilder/VBForm.h @@ -1,11 +1,12 @@ #pragma once -#include -#include #include "VBWidget.h" +#include +#include class VBForm : public GWidget { friend class VBWidget; + public: explicit VBForm(const String& name, GWidget* parent = nullptr); virtual ~VBForm() override; @@ -43,7 +44,8 @@ private: void add_to_selection(VBWidget&); void remove_from_selection(VBWidget&); void delete_selected_widgets(); - template void for_each_selected_widget(Callback); + template + void for_each_selected_widget(Callback); VBWidget* single_selected_widget(); diff --git a/DevTools/VisualBuilder/VBProperty.h b/DevTools/VisualBuilder/VBProperty.h index 9d70c66c8e5..57a8bab87ae 100644 --- a/DevTools/VisualBuilder/VBProperty.h +++ b/DevTools/VisualBuilder/VBProperty.h @@ -9,6 +9,7 @@ class VBWidget; class VBProperty { friend class VBWidget; + public: VBProperty(VBWidget&, const String& name, const GVariant& value); VBProperty(VBWidget&, const String& name, Function&& getter, Function&& setter); diff --git a/DevTools/VisualBuilder/VBWidget.h b/DevTools/VisualBuilder/VBWidget.h index afd240b081d..73951570989 100644 --- a/DevTools/VisualBuilder/VBWidget.h +++ b/DevTools/VisualBuilder/VBWidget.h @@ -1,12 +1,12 @@ #pragma once -#include +#include "VBWidgetType.h" +#include +#include #include #include #include -#include -#include -#include "VBWidgetType.h" +#include class GPainter; class GVariant; @@ -15,7 +15,18 @@ class VBForm; class VBProperty; class VBWidgetPropertyModel; -enum class Direction { None, Left, UpLeft, Up, UpRight, Right, DownRight, Down, DownLeft }; +enum class Direction +{ + None, + Left, + UpLeft, + Up, + UpRight, + Right, + DownRight, + Down, + DownLeft +}; template inline void for_each_direction(Callback callback) { @@ -29,8 +40,10 @@ inline void for_each_direction(Callback callback) callback(Direction::DownLeft); } -class VBWidget : public Retainable, public Weakable { +class VBWidget : public Retainable + , public Weakable { friend class VBWidgetPropertyModel; + public: static Retained create(VBWidgetType type, VBForm& form) { return adopt(*new VBWidget(type, form)); } ~VBWidget(); diff --git a/DevTools/VisualBuilder/VBWidgetPropertyModel.h b/DevTools/VisualBuilder/VBWidgetPropertyModel.h index b84bffc697a..2aa45424244 100644 --- a/DevTools/VisualBuilder/VBWidgetPropertyModel.h +++ b/DevTools/VisualBuilder/VBWidgetPropertyModel.h @@ -7,7 +7,8 @@ class VBProperty; class VBWidgetPropertyModel : public GModel { public: - enum Column { + enum Column + { Name = 0, Value, __Count diff --git a/DevTools/VisualBuilder/VBWidgetRegistry.h b/DevTools/VisualBuilder/VBWidgetRegistry.h index d2af1f941e4..bd08a1d5749 100644 --- a/DevTools/VisualBuilder/VBWidgetRegistry.h +++ b/DevTools/VisualBuilder/VBWidgetRegistry.h @@ -1,9 +1,9 @@ #pragma once #include "VBWidgetType.h" +#include #include #include -#include class GWidget; class VBProperty; @@ -11,7 +11,8 @@ class VBWidget; class VBWidgetRegistry { public: - template static void for_each_widget_type(Callback callback) + template + static void for_each_widget_type(Callback callback) { for (unsigned i = 1; i < (unsigned)VBWidgetType::__Count; ++i) callback((VBWidgetType)i); diff --git a/DevTools/VisualBuilder/VBWidgetType.h b/DevTools/VisualBuilder/VBWidgetType.h index 1d0487a478a..a816a7cf529 100644 --- a/DevTools/VisualBuilder/VBWidgetType.h +++ b/DevTools/VisualBuilder/VBWidgetType.h @@ -1,6 +1,7 @@ #pragma once -enum class VBWidgetType { +enum class VBWidgetType +{ None = 0, GWidget, GButton, diff --git a/Games/Minesweeper/Field.h b/Games/Minesweeper/Field.h index 3d033b8f817..5af284a4661 100644 --- a/Games/Minesweeper/Field.h +++ b/Games/Minesweeper/Field.h @@ -1,8 +1,8 @@ #pragma once -#include -#include #include +#include +#include class Field; class GButton; @@ -13,7 +13,7 @@ class SquareLabel; class Square { AK_MAKE_NONCOPYABLE(Square) public: - Square() { } + Square() {} ~Square(); Field* field { nullptr }; @@ -27,12 +27,14 @@ public: SquareButton* button { nullptr }; SquareLabel* label { nullptr }; - template void for_each_neighbor(Callback); + template + void for_each_neighbor(Callback); }; class Field final : public GFrame { friend class Square; friend class SquareLabel; + public: Field(GLabel& flag_label, GLabel& time_label, GButton& face_button, GWidget* parent); virtual ~Field() override; @@ -66,9 +68,15 @@ private: void flood_fill(Square&); - template void for_each_square(Callback); + template + void for_each_square(Callback); - enum class Face { Default, Good, Bad }; + enum class Face + { + Default, + Good, + Bad + }; void set_face(Face); int m_rows { 9 }; diff --git a/Games/Snake/SnakeGame.h b/Games/Snake/SnakeGame.h index 8f8a67c9a95..704e80c0d34 100644 --- a/Games/Snake/SnakeGame.h +++ b/Games/Snake/SnakeGame.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class SnakeGame : public GWidget { public: diff --git a/Kernel/Alarm.h b/Kernel/Alarm.h index a724a06ec13..ba8fb6211f0 100644 --- a/Kernel/Alarm.h +++ b/Kernel/Alarm.h @@ -2,8 +2,8 @@ class Alarm { public: - Alarm() { } - virtual ~Alarm() { } + Alarm() {} + virtual ~Alarm() {} virtual bool is_ringing() const = 0; }; diff --git a/Kernel/Assertions.h b/Kernel/Assertions.h index 8eada59219d..de744bf11f2 100644 --- a/Kernel/Assertions.h +++ b/Kernel/Assertions.h @@ -1,17 +1,24 @@ #pragma once -#include #include +#include #ifdef DEBUG [[noreturn]] void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func); -#define ASSERT(expr) (static_cast(expr) ? (void)0 : __assertion_failed(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__)) -#define ASSERT_NOT_REACHED() ASSERT(false) +# define ASSERT(expr) (static_cast(expr) ? (void)0 : __assertion_failed(# expr, __FILE__, __LINE__, __PRETTY_FUNCTION__)) +# define ASSERT_NOT_REACHED() ASSERT(false) #else -#define ASSERT(expr) -#define ASSERT_NOT_REACHED() CRASH() +# define ASSERT(expr) +# define ASSERT_NOT_REACHED() CRASH() #endif -#define CRASH() do { asm volatile("ud2"); } while(0) -#define RELEASE_ASSERT(x) do { if (!(x)) CRASH(); } while(0) +#define CRASH() \ + do { \ + asm volatile("ud2"); \ + } while (0) +#define RELEASE_ASSERT(x) \ + do { \ + if (!(x)) \ + CRASH(); \ + } while (0) #define ASSERT_INTERRUPTS_DISABLED() ASSERT(!(cpu_flags() & 0x200)) #define ASSERT_INTERRUPTS_ENABLED() ASSERT(cpu_flags() & 0x200) diff --git a/Kernel/Console.h b/Kernel/Console.h index 45101a8d0d8..59fe006c4e0 100644 --- a/Kernel/Console.h +++ b/Kernel/Console.h @@ -35,4 +35,3 @@ private: ConsoleImplementation* m_implementation { nullptr }; CircularQueue m_logbuffer; }; - diff --git a/Kernel/Devices/BXVGADevice.h b/Kernel/Devices/BXVGADevice.h index 96207d400d9..d7977244750 100644 --- a/Kernel/Devices/BXVGADevice.h +++ b/Kernel/Devices/BXVGADevice.h @@ -1,10 +1,10 @@ #pragma once -#include #include -#include -#include +#include #include +#include +#include class BXVGADevice final : public BlockDevice { AK_MAKE_ETERNAL diff --git a/Kernel/Devices/BlockDevice.h b/Kernel/Devices/BlockDevice.h index c96d4d31856..d76d90614d0 100644 --- a/Kernel/Devices/BlockDevice.h +++ b/Kernel/Devices/BlockDevice.h @@ -10,7 +10,10 @@ public: virtual bool is_seekable() const override { return true; } protected: - BlockDevice(unsigned major, unsigned minor) : Device(major, minor) { } + BlockDevice(unsigned major, unsigned minor) + : Device(major, minor) + { + } private: virtual bool is_block_device() const final { return true; } diff --git a/Kernel/Devices/CharacterDevice.h b/Kernel/Devices/CharacterDevice.h index 6dedf20743f..3e4778b2602 100644 --- a/Kernel/Devices/CharacterDevice.h +++ b/Kernel/Devices/CharacterDevice.h @@ -7,7 +7,10 @@ public: virtual ~CharacterDevice() override; protected: - CharacterDevice(unsigned major, unsigned minor) : Device(major, minor) { } + CharacterDevice(unsigned major, unsigned minor) + : Device(major, minor) + { + } private: virtual bool is_character_device() const final { return true; } diff --git a/Kernel/Devices/DiskDevice.h b/Kernel/Devices/DiskDevice.h index badf92b0cae..66a51a8f413 100644 --- a/Kernel/Devices/DiskDevice.h +++ b/Kernel/Devices/DiskDevice.h @@ -23,4 +23,3 @@ public: protected: DiskDevice(); }; - diff --git a/Kernel/Devices/FileBackedDiskDevice.h b/Kernel/Devices/FileBackedDiskDevice.h index c16c848f8b1..667f3af427d 100644 --- a/Kernel/Devices/FileBackedDiskDevice.h +++ b/Kernel/Devices/FileBackedDiskDevice.h @@ -1,9 +1,9 @@ #pragma once -#include -#include #include +#include #include +#include #include class FileBackedDiskDevice final : public DiskDevice { @@ -30,4 +30,3 @@ private: DiskOffset m_file_length { 0 }; unsigned m_block_size { 0 }; }; - diff --git a/Kernel/Devices/FullDevice.h b/Kernel/Devices/FullDevice.h index c88e6f6857b..9974e47c4d4 100644 --- a/Kernel/Devices/FullDevice.h +++ b/Kernel/Devices/FullDevice.h @@ -16,4 +16,3 @@ private: virtual bool can_write(FileDescriptor&) const override { return true; } virtual const char* class_name() const override { return "FullDevice"; } }; - diff --git a/Kernel/Devices/IDEDiskDevice.h b/Kernel/Devices/IDEDiskDevice.h index d87ab9e690d..7f5cfbd99e0 100644 --- a/Kernel/Devices/IDEDiskDevice.h +++ b/Kernel/Devices/IDEDiskDevice.h @@ -1,9 +1,9 @@ #pragma once -#include #include #include #include +#include #include #include #include @@ -14,7 +14,8 @@ struct PhysicalRegionDescriptor { word end_of_table { 0 }; }; -class IDEDiskDevice final : public IRQHandler, public DiskDevice { +class IDEDiskDevice final : public IRQHandler + , public DiskDevice { AK_MAKE_ETERNAL public: static Retained create(); @@ -58,4 +59,3 @@ private: word m_bus_master_base { 0 }; Lockable m_dma_enabled; }; - diff --git a/Kernel/Devices/KeyboardDevice.h b/Kernel/Devices/KeyboardDevice.h index c6e9fa972e5..16f134b2a73 100644 --- a/Kernel/Devices/KeyboardDevice.h +++ b/Kernel/Devices/KeyboardDevice.h @@ -1,15 +1,16 @@ #pragma once -#include -#include -#include -#include #include "IRQHandler.h" #include "KeyCode.h" +#include +#include +#include +#include class KeyboardClient; -class KeyboardDevice final : public IRQHandler, public CharacterDevice { +class KeyboardDevice final : public IRQHandler + , public CharacterDevice { AK_MAKE_ETERNAL public: using Event = KeyEvent; diff --git a/Kernel/Devices/NullDevice.h b/Kernel/Devices/NullDevice.h index b00cfeed673..47ba7baf5ac 100644 --- a/Kernel/Devices/NullDevice.h +++ b/Kernel/Devices/NullDevice.h @@ -18,4 +18,3 @@ private: virtual bool can_read(FileDescriptor&) const override; virtual const char* class_name() const override { return "NullDevice"; } }; - diff --git a/Kernel/Devices/PS2MouseDevice.h b/Kernel/Devices/PS2MouseDevice.h index 6a04ab672c7..de97cfe4e19 100644 --- a/Kernel/Devices/PS2MouseDevice.h +++ b/Kernel/Devices/PS2MouseDevice.h @@ -1,11 +1,12 @@ #pragma once -#include -#include -#include #include +#include +#include +#include -class PS2MouseDevice final : public IRQHandler, public CharacterDevice { +class PS2MouseDevice final : public IRQHandler + , public CharacterDevice { public: PS2MouseDevice(); virtual ~PS2MouseDevice() override; diff --git a/Kernel/Devices/RandomDevice.h b/Kernel/Devices/RandomDevice.h index fe7fd1a439d..ecce3c6bfb7 100644 --- a/Kernel/Devices/RandomDevice.h +++ b/Kernel/Devices/RandomDevice.h @@ -18,4 +18,3 @@ private: virtual bool can_write(FileDescriptor&) const override { return true; } virtual const char* class_name() const override { return "RandomDevice"; } }; - diff --git a/Kernel/Devices/ZeroDevice.h b/Kernel/Devices/ZeroDevice.h index 74cfb603619..930f3adec2f 100644 --- a/Kernel/Devices/ZeroDevice.h +++ b/Kernel/Devices/ZeroDevice.h @@ -16,4 +16,3 @@ private: virtual bool can_write(FileDescriptor&) const override { return true; } virtual const char* class_name() const override { return "ZeroDevice"; } }; - diff --git a/Kernel/FileSystem/DevPtsFS.h b/Kernel/FileSystem/DevPtsFS.h index 9898ea0786f..fc638bd5802 100644 --- a/Kernel/FileSystem/DevPtsFS.h +++ b/Kernel/FileSystem/DevPtsFS.h @@ -26,4 +26,3 @@ private: HashTable m_slave_ptys; }; - diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h index c958bac4111..21e4e856b3e 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -1,9 +1,9 @@ #pragma once -#include +#include #include #include -#include +#include struct ext2_group_desc; struct ext2_inode; @@ -13,6 +13,7 @@ class Ext2FS; class Ext2FSInode final : public Inode { friend class Ext2FS; + public: virtual ~Ext2FSInode() override; @@ -59,8 +60,9 @@ private: class Ext2FS final : public DiskBackedFS { friend class Ext2FSInode; + public: - static Retained create(Retained&&); + static Retained create(Retained&&); virtual ~Ext2FS() override; virtual bool initialize() override; diff --git a/Kernel/FileSystem/FIFO.h b/Kernel/FileSystem/FIFO.h index b9eea984cba..72faae428d4 100644 --- a/Kernel/FileSystem/FIFO.h +++ b/Kernel/FileSystem/FIFO.h @@ -1,15 +1,18 @@ #pragma once #include -#include #include +#include class FileDescriptor; class FIFO final : public File { public: - enum class Direction : byte { - Neither, Reader, Writer + enum class Direction : byte + { + Neither, + Reader, + Writer }; static RetainPtr from_fifo_id(dword); diff --git a/Kernel/FileSystem/FileDescriptor.h b/Kernel/FileSystem/FileDescriptor.h index 2f9b98c42b4..30ebbce5591 100644 --- a/Kernel/FileSystem/FileDescriptor.h +++ b/Kernel/FileSystem/FileDescriptor.h @@ -1,14 +1,14 @@ #pragma once -#include -#include -#include -#include -#include +#include #include #include #include -#include +#include +#include +#include +#include +#include #include class File; @@ -119,4 +119,3 @@ private: SocketRole m_socket_role { SocketRole::None }; FIFO::Direction m_fifo_direction { FIFO::Direction::Neither }; }; - diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h index 800391036d9..097d479b008 100644 --- a/Kernel/FileSystem/FileSystem.h +++ b/Kernel/FileSystem/FileSystem.h @@ -1,20 +1,20 @@ #pragma once -#include #include "InodeIdentifier.h" #include "InodeMetadata.h" #include "UnixTypes.h" +#include #include +#include #include #include -#include #include -#include -#include -#include -#include +#include #include +#include +#include #include +#include static const dword mepoch = 476763780; @@ -25,6 +25,7 @@ class VMObject; class FS : public Retainable { friend class Inode; + public: virtual ~FS(); @@ -57,7 +58,7 @@ public: virtual RetainPtr get_inode(InodeIdentifier) const = 0; - virtual void flush_writes() { } + virtual void flush_writes() {} protected: FS(); @@ -93,4 +94,3 @@ struct Traits { }; } - diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index 520b271f887..f7f560ce37e 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -1,12 +1,12 @@ #pragma once -#include #include #include +#include #include +#include #include #include -#include #include #include @@ -17,10 +17,11 @@ class VMObject; class Inode : public Retainable { friend class VFS; friend class FS; + public: virtual ~Inode(); - virtual void one_retain_left() { } + virtual void one_retain_left() {} FS& fs() { return m_fs; } const FS& fs() const { return m_fs; } @@ -89,4 +90,3 @@ private: RetainPtr m_socket; bool m_metadata_dirty { false }; }; - diff --git a/Kernel/FileSystem/InodeIdentifier.h b/Kernel/FileSystem/InodeIdentifier.h index cb0c24f8c37..95c1bc62261 100644 --- a/Kernel/FileSystem/InodeIdentifier.h +++ b/Kernel/FileSystem/InodeIdentifier.h @@ -8,7 +8,7 @@ struct InodeMetadata; class InodeIdentifier { public: - InodeIdentifier() { } + InodeIdentifier() {} InodeIdentifier(dword fsid, dword inode) : m_fsid(fsid) , m_index(inode) @@ -39,4 +39,3 @@ private: dword m_fsid { 0 }; dword m_index { 0 }; }; - diff --git a/Kernel/FileSystem/InodeMetadata.h b/Kernel/FileSystem/InodeMetadata.h index ee24330f9d4..f151fbe0483 100644 --- a/Kernel/FileSystem/InodeMetadata.h +++ b/Kernel/FileSystem/InodeMetadata.h @@ -84,5 +84,3 @@ struct InodeMetadata { unsigned major_device { 0 }; unsigned minor_device { 0 }; }; - - diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h index 5693806d4ee..a8e27a35acb 100644 --- a/Kernel/FileSystem/ProcFS.h +++ b/Kernel/FileSystem/ProcFS.h @@ -1,9 +1,9 @@ #pragma once -#include #include #include #include +#include class Process; @@ -11,6 +11,7 @@ class ProcFSInode; class ProcFS final : public FS { friend class ProcFSInode; + public: [[gnu::pure]] static ProcFS& the(); @@ -34,7 +35,7 @@ private: ProcFS(); struct ProcFSDirectoryEntry { - ProcFSDirectoryEntry() { } + ProcFSDirectoryEntry() {} ProcFSDirectoryEntry(const char* a_name, unsigned a_proc_file_type, Function&& a_read_callback = nullptr, Function&& a_write_callback = nullptr, RetainPtr&& a_inode = nullptr) : name(a_name) , proc_file_type(a_proc_file_type) @@ -69,6 +70,7 @@ struct ProcFSInodeCustomData { class ProcFSInode final : public Inode { friend class ProcFS; + public: virtual ~ProcFSInode() override; diff --git a/Kernel/FileSystem/SyntheticFileSystem.h b/Kernel/FileSystem/SyntheticFileSystem.h index 2e1cfc2254c..291d8918dcc 100644 --- a/Kernel/FileSystem/SyntheticFileSystem.h +++ b/Kernel/FileSystem/SyntheticFileSystem.h @@ -1,9 +1,9 @@ #pragma once +#include #include #include #include -#include class SynthFSInode; @@ -47,6 +47,7 @@ struct SynthFSInodeCustomData { class SynthFSInode final : public Inode { friend class SynthFS; friend class DevPtsFS; + public: virtual ~SynthFSInode() override; diff --git a/Kernel/FileSystem/VirtualFileSystem.h b/Kernel/FileSystem/VirtualFileSystem.h index 16b0dafbad1..04ef61a432b 100644 --- a/Kernel/FileSystem/VirtualFileSystem.h +++ b/Kernel/FileSystem/VirtualFileSystem.h @@ -1,14 +1,14 @@ #pragma once +#include "FileSystem.h" +#include "InodeIdentifier.h" +#include "InodeMetadata.h" +#include +#include #include #include #include -#include #include -#include -#include "InodeIdentifier.h" -#include "InodeMetadata.h" -#include "FileSystem.h" #include #define O_RDONLY 0 @@ -116,4 +116,3 @@ private: Vector> m_mounts; HashMap m_devices; }; - diff --git a/Kernel/FileSystem/ext2_fs.h b/Kernel/FileSystem/ext2_fs.h index 4f0856acf1d..372423f0eca 100644 --- a/Kernel/FileSystem/ext2_fs.h +++ b/Kernel/FileSystem/ext2_fs.h @@ -16,7 +16,7 @@ #ifndef _LINUX_EXT2_FS_H #define _LINUX_EXT2_FS_H -#include "ext2_types.h" /* Changed from linux/types.h */ +#include "ext2_types.h" /* Changed from linux/types.h */ /* * The second extended filesystem constants/structures @@ -31,149 +31,145 @@ * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files */ #define EXT2_PREALLOCATE -#define EXT2_DEFAULT_PREALLOC_BLOCKS 8 +#define EXT2_DEFAULT_PREALLOC_BLOCKS 8 /* * The second extended file system version */ -#define EXT2FS_DATE "95/08/09" -#define EXT2FS_VERSION "0.5b" +#define EXT2FS_DATE "95/08/09" +#define EXT2FS_VERSION "0.5b" /* * Special inode numbers */ -#define EXT2_BAD_INO 1 /* Bad blocks inode */ -#define EXT2_ROOT_INO 2 /* Root inode */ -#define EXT2_ACL_IDX_INO 3 /* ACL inode */ -#define EXT2_ACL_DATA_INO 4 /* ACL inode */ -#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ -#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ -#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */ -#define EXT2_JOURNAL_INO 8 /* Journal inode */ +#define EXT2_BAD_INO 1 /* Bad blocks inode */ +#define EXT2_ROOT_INO 2 /* Root inode */ +#define EXT2_ACL_IDX_INO 3 /* ACL inode */ +#define EXT2_ACL_DATA_INO 4 /* ACL inode */ +#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ +#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ +#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */ +#define EXT2_JOURNAL_INO 8 /* Journal inode */ /* First non-reserved inode for old ext2 filesystems */ -#define EXT2_GOOD_OLD_FIRST_INO 11 +#define EXT2_GOOD_OLD_FIRST_INO 11 /* * The second extended file system magic number */ -#define EXT2_SUPER_MAGIC 0xEF53 +#define EXT2_SUPER_MAGIC 0xEF53 #ifdef __KERNEL__ -#define EXT2_SB(sb) (&((sb)->u.ext2_sb)) +# define EXT2_SB(sb) (&((sb)->u.ext2_sb)) #else /* Assume that user mode programs are passing in an ext2fs superblock, not * a kernel struct super_block. This will allow us to call the feature-test * macros from user land. */ -#define EXT2_SB(sb) (sb) +# define EXT2_SB(sb) (sb) #endif /* * Maximal count of links to a file */ -#define EXT2_LINK_MAX 65000 +#define EXT2_LINK_MAX 65000 /* * Macro-instructions used to manage several block sizes */ -#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */ -#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */ -#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE) -#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE) +#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */ +#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */ +#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE) +#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE) #ifdef __KERNEL__ -#define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize) -#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) -#define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->addr_per_block_bits) -#define EXT2_INODE_SIZE(s) (EXT2_SB(s)->s_inode_size) -#define EXT2_FIRST_INO(s) (EXT2_SB(s)->s_first_ino) +# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize) +# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) +# define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->addr_per_block_bits) +# define EXT2_INODE_SIZE(s) (EXT2_SB(s)->s_inode_size) +# define EXT2_FIRST_INO(s) (EXT2_SB(s)->s_first_ino) #else -#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) -#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) -#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ - EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size) -#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ - EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino) +# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) +# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) +# define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size) +# define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino) #endif -#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(__u32)) +#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(__u32)) /* * Macro-instructions used to manage fragments */ -#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE -#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE -#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE +#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE +#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE +#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE #ifdef __KERNEL__ -# define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->s_frag_size) -# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->s_frags_per_block) +# define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->s_frag_size) +# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->s_frags_per_block) #else -# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) -# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) +# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) +# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) #endif /* * ACL structures */ -struct ext2_acl_header /* Header of Access Control Lists */ +struct ext2_acl_header /* Header of Access Control Lists */ { - __u32 aclh_size; - __u32 aclh_file_count; - __u32 aclh_acle_count; - __u32 aclh_first_acle; + __u32 aclh_size; + __u32 aclh_file_count; + __u32 aclh_acle_count; + __u32 aclh_first_acle; }; -struct ext2_acl_entry /* Access Control List Entry */ +struct ext2_acl_entry /* Access Control List Entry */ { - __u32 acle_size; - __u16 acle_perms; /* Access permissions */ - __u16 acle_type; /* Type of entry */ - __u16 acle_tag; /* User or group identity */ - __u16 acle_pad1; - __u32 acle_next; /* Pointer on next entry for the */ - /* same inode or on next free entry */ + __u32 acle_size; + __u16 acle_perms; /* Access permissions */ + __u16 acle_type; /* Type of entry */ + __u16 acle_tag; /* User or group identity */ + __u16 acle_pad1; + __u32 acle_next; /* Pointer on next entry for the */ + /* same inode or on next free entry */ }; /* * Structure of a blocks group descriptor */ -struct ext2_group_desc -{ - __u32 bg_block_bitmap; /* Blocks bitmap block */ - __u32 bg_inode_bitmap; /* Inodes bitmap block */ - __u32 bg_inode_table; /* Inodes table block */ - __u16 bg_free_blocks_count; /* Free blocks count */ - __u16 bg_free_inodes_count; /* Free inodes count */ - __u16 bg_used_dirs_count; /* Directories count */ - __u16 bg_flags; - __u32 bg_reserved[2]; - __u16 bg_itable_unused; /* Unused inodes count */ - __u16 bg_checksum; /* crc16(s_uuid+grouo_num+group_desc)*/ +struct ext2_group_desc { + __u32 bg_block_bitmap; /* Blocks bitmap block */ + __u32 bg_inode_bitmap; /* Inodes bitmap block */ + __u32 bg_inode_table; /* Inodes table block */ + __u16 bg_free_blocks_count; /* Free blocks count */ + __u16 bg_free_inodes_count; /* Free inodes count */ + __u16 bg_used_dirs_count; /* Directories count */ + __u16 bg_flags; + __u32 bg_reserved[2]; + __u16 bg_itable_unused; /* Unused inodes count */ + __u16 bg_checksum; /* crc16(s_uuid+grouo_num+group_desc)*/ }; -struct ext4_group_desc -{ - __u32 bg_block_bitmap; /* Blocks bitmap block */ - __u32 bg_inode_bitmap; /* Inodes bitmap block */ - __u32 bg_inode_table; /* Inodes table block */ - __u16 bg_free_blocks_count; /* Free blocks count */ - __u16 bg_free_inodes_count; /* Free inodes count */ - __u16 bg_used_dirs_count; /* Directories count */ - __u16 bg_flags; - __u32 bg_reserved[2]; - __u16 bg_itable_unused; /* Unused inodes count */ - __u16 bg_checksum; /* crc16(s_uuid+grouo_num+group_desc)*/ - __u32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */ - __u32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */ - __u32 bg_inode_table_hi; /* Inodes table block MSB */ - __u16 bg_free_blocks_count_hi;/* Free blocks count MSB */ - __u16 bg_free_inodes_count_hi;/* Free inodes count MSB */ - __u16 bg_used_dirs_count_hi; /* Directories count MSB */ - __u16 bg_pad; - __u32 bg_reserved2[3]; +struct ext4_group_desc { + __u32 bg_block_bitmap; /* Blocks bitmap block */ + __u32 bg_inode_bitmap; /* Inodes bitmap block */ + __u32 bg_inode_table; /* Inodes table block */ + __u16 bg_free_blocks_count; /* Free blocks count */ + __u16 bg_free_inodes_count; /* Free inodes count */ + __u16 bg_used_dirs_count; /* Directories count */ + __u16 bg_flags; + __u32 bg_reserved[2]; + __u16 bg_itable_unused; /* Unused inodes count */ + __u16 bg_checksum; /* crc16(s_uuid+grouo_num+group_desc)*/ + __u32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */ + __u32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */ + __u32 bg_inode_table_hi; /* Inodes table block MSB */ + __u16 bg_free_blocks_count_hi; /* Free blocks count MSB */ + __u16 bg_free_inodes_count_hi; /* Free inodes count MSB */ + __u16 bg_used_dirs_count_hi; /* Directories count MSB */ + __u16 bg_pad; + __u32 bg_reserved2[3]; }; -#define EXT2_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not initialized */ -#define EXT2_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not initialized */ -#define EXT2_BG_INODE_ZEROED 0x0004 /* On-disk itable initialized to zero */ +#define EXT2_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not initialized */ +#define EXT2_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not initialized */ +#define EXT2_BG_INODE_ZEROED 0x0004 /* On-disk itable initialized to zero */ /* * Data structures used by the directory indexing feature @@ -188,95 +184,93 @@ struct ext4_group_desc * Sincerely, the paranoia department. */ struct ext2_dx_root_info { - __u32 reserved_zero; - __u8 hash_version; /* 0 now, 1 at release */ - __u8 info_length; /* 8 */ - __u8 indirect_levels; - __u8 unused_flags; + __u32 reserved_zero; + __u8 hash_version; /* 0 now, 1 at release */ + __u8 info_length; /* 8 */ + __u8 indirect_levels; + __u8 unused_flags; }; -#define EXT2_HASH_LEGACY 0 -#define EXT2_HASH_HALF_MD4 1 -#define EXT2_HASH_TEA 2 -#define EXT2_HASH_LEGACY_UNSIGNED 3 /* reserved for userspace lib */ -#define EXT2_HASH_HALF_MD4_UNSIGNED 4 /* reserved for userspace lib */ -#define EXT2_HASH_TEA_UNSIGNED 5 /* reserved for userspace lib */ +#define EXT2_HASH_LEGACY 0 +#define EXT2_HASH_HALF_MD4 1 +#define EXT2_HASH_TEA 2 +#define EXT2_HASH_LEGACY_UNSIGNED 3 /* reserved for userspace lib */ +#define EXT2_HASH_HALF_MD4_UNSIGNED 4 /* reserved for userspace lib */ +#define EXT2_HASH_TEA_UNSIGNED 5 /* reserved for userspace lib */ -#define EXT2_HASH_FLAG_INCOMPAT 0x1 +#define EXT2_HASH_FLAG_INCOMPAT 0x1 struct ext2_dx_entry { - __u32 hash; - __u32 block; + __u32 hash; + __u32 block; }; struct ext2_dx_countlimit { - __u16 limit; - __u16 count; + __u16 limit; + __u16 count; }; - /* * Macro-instructions used to manage group descriptors */ -#define EXT2_MIN_DESC_SIZE 32 -#define EXT2_MIN_DESC_SIZE_64BIT 64 -#define EXT2_MAX_DESC_SIZE EXT2_MIN_BLOCK_SIZE -#define EXT2_DESC_SIZE(s) \ - ((EXT2_SB(s)->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) ? \ - (s)->s_desc_size : EXT2_MIN_DESC_SIZE) +#define EXT2_MIN_DESC_SIZE 32 +#define EXT2_MIN_DESC_SIZE_64BIT 64 +#define EXT2_MAX_DESC_SIZE EXT2_MIN_BLOCK_SIZE +#define EXT2_DESC_SIZE(s) \ + ((EXT2_SB(s)->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) ? (s)->s_desc_size : EXT2_MIN_DESC_SIZE) -#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group) -#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group) -#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s)) +#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group) +#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group) +#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_INODE_SIZE(s)) /* limits imposed by 16-bit value gd_free_{blocks,inode}_count */ -#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8) -#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s)) +#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8) +#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s)) #ifdef __KERNEL__ -#define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block) -#define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits) +# define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block) +# define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits) #else -#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s)) +# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s)) #endif /* * Constants relative to the data blocks */ -#define EXT2_NDIR_BLOCKS 12 -#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS -#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) -#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) -#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) +#define EXT2_NDIR_BLOCKS 12 +#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS +#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) +#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) +#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) /* * Inode flags */ -#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */ -#define EXT2_UNRM_FL 0x00000002 /* Undelete */ -#define EXT2_COMPR_FL 0x00000004 /* Compress file */ -#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */ -#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */ -#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */ -#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */ -#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */ +#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */ +#define EXT2_UNRM_FL 0x00000002 /* Undelete */ +#define EXT2_COMPR_FL 0x00000004 /* Compress file */ +#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */ +#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */ +#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */ +#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */ +#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */ /* Reserved for compression usage... */ -#define EXT2_DIRTY_FL 0x00000100 -#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */ -#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */ -#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */ +#define EXT2_DIRTY_FL 0x00000100 +#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */ +#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */ +#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */ /* End compression flags --- maybe not all used */ -#define EXT2_BTREE_FL 0x00001000 /* btree format dir */ -#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */ -#define EXT2_IMAGIC_FL 0x00002000 -#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */ -#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */ -#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */ -#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/ -#define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */ -#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */ -#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ +#define EXT2_BTREE_FL 0x00001000 /* btree format dir */ +#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */ +#define EXT2_IMAGIC_FL 0x00002000 +#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */ +#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */ +#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */ +#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/ +#define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */ +#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */ +#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ -#define EXT2_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */ -#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */ +#define EXT2_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */ +#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */ /* * ioctl commands @@ -284,244 +278,243 @@ struct ext2_dx_countlimit { /* Used for online resize */ struct ext2_new_group_input { - __u32 group; /* Group number for this data */ - __u32 block_bitmap; /* Absolute block number of block bitmap */ - __u32 inode_bitmap; /* Absolute block number of inode bitmap */ - __u32 inode_table; /* Absolute block number of inode table start */ - __u32 blocks_count; /* Total number of blocks in this group */ - __u16 reserved_blocks; /* Number of reserved blocks in this group */ - __u16 unused; /* Number of reserved GDT blocks in group */ + __u32 group; /* Group number for this data */ + __u32 block_bitmap; /* Absolute block number of block bitmap */ + __u32 inode_bitmap; /* Absolute block number of inode bitmap */ + __u32 inode_table; /* Absolute block number of inode table start */ + __u32 blocks_count; /* Total number of blocks in this group */ + __u16 reserved_blocks; /* Number of reserved blocks in this group */ + __u16 unused; /* Number of reserved GDT blocks in group */ }; struct ext4_new_group_input { - __u32 group; /* Group number for this data */ - __u64 block_bitmap; /* Absolute block number of block bitmap */ - __u64 inode_bitmap; /* Absolute block number of inode bitmap */ - __u64 inode_table; /* Absolute block number of inode table start */ - __u32 blocks_count; /* Total number of blocks in this group */ - __u16 reserved_blocks; /* Number of reserved blocks in this group */ - __u16 unused; + __u32 group; /* Group number for this data */ + __u64 block_bitmap; /* Absolute block number of block bitmap */ + __u64 inode_bitmap; /* Absolute block number of inode bitmap */ + __u64 inode_table; /* Absolute block number of inode table start */ + __u32 blocks_count; /* Total number of blocks in this group */ + __u16 reserved_blocks; /* Number of reserved blocks in this group */ + __u16 unused; }; -#ifdef __GNU__ /* Needed for the Hurd */ -#define _IOT_ext2_new_group_input _IOT (_IOTS(__u32), 5, _IOTS(__u16), 2, 0, 0) +#ifdef __GNU__ /* Needed for the Hurd */ +# define _IOT_ext2_new_group_input _IOT(_IOTS(__u32), 5, _IOTS(__u16), 2, 0, 0) #endif -#define EXT2_IOC_GETFLAGS _IOR('f', 1, long) -#define EXT2_IOC_SETFLAGS _IOW('f', 2, long) -#define EXT2_IOC_GETVERSION _IOR('v', 1, long) -#define EXT2_IOC_SETVERSION _IOW('v', 2, long) -#define EXT2_IOC_GETVERSION_NEW _IOR('f', 3, long) -#define EXT2_IOC_SETVERSION_NEW _IOW('f', 4, long) -#define EXT2_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long) -#define EXT2_IOC_GROUP_ADD _IOW('f', 8,struct ext2_new_group_input) -#define EXT4_IOC_GROUP_ADD _IOW('f', 8,struct ext4_new_group_input) +#define EXT2_IOC_GETFLAGS _IOR('f', 1, long) +#define EXT2_IOC_SETFLAGS _IOW('f', 2, long) +#define EXT2_IOC_GETVERSION _IOR('v', 1, long) +#define EXT2_IOC_SETVERSION _IOW('v', 2, long) +#define EXT2_IOC_GETVERSION_NEW _IOR('f', 3, long) +#define EXT2_IOC_SETVERSION_NEW _IOW('f', 4, long) +#define EXT2_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long) +#define EXT2_IOC_GROUP_ADD _IOW('f', 8, struct ext2_new_group_input) +#define EXT4_IOC_GROUP_ADD _IOW('f', 8, struct ext4_new_group_input) /* * Structure of an inode on the disk */ struct ext2_inode { - __u16 i_mode; /* File mode */ - __u16 i_uid; /* Low 16 bits of Owner Uid */ - __u32 i_size; /* Size in bytes */ - __u32 i_atime; /* Access time */ - __u32 i_ctime; /* Inode change time */ - __u32 i_mtime; /* Modification time */ - __u32 i_dtime; /* Deletion Time */ - __u16 i_gid; /* Low 16 bits of Group Id */ - __u16 i_links_count; /* Links count */ - __u32 i_blocks; /* Blocks count */ - __u32 i_flags; /* File flags */ - union { - struct { - __u32 l_i_version; /* was l_i_reserved1 */ - } linux1; - struct { - __u32 h_i_translator; - } hurd1; - } osd1; /* OS dependent 1 */ - __u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ - __u32 i_generation; /* File version (for NFS) */ - __u32 i_file_acl; /* File ACL */ - __u32 i_dir_acl; /* Directory ACL */ - __u32 i_faddr; /* Fragment address */ - union { - struct { - __u16 l_i_blocks_hi; - __u16 l_i_file_acl_high; - __u16 l_i_uid_high; /* these 2 fields */ - __u16 l_i_gid_high; /* were reserved2[0] */ - __u32 l_i_reserved2; - } linux2; - struct { - __u8 h_i_frag; /* Fragment number */ - __u8 h_i_fsize; /* Fragment size */ - __u16 h_i_mode_high; - __u16 h_i_uid_high; - __u16 h_i_gid_high; - __u32 h_i_author; - } hurd2; - } osd2; /* OS dependent 2 */ + __u16 i_mode; /* File mode */ + __u16 i_uid; /* Low 16 bits of Owner Uid */ + __u32 i_size; /* Size in bytes */ + __u32 i_atime; /* Access time */ + __u32 i_ctime; /* Inode change time */ + __u32 i_mtime; /* Modification time */ + __u32 i_dtime; /* Deletion Time */ + __u16 i_gid; /* Low 16 bits of Group Id */ + __u16 i_links_count; /* Links count */ + __u32 i_blocks; /* Blocks count */ + __u32 i_flags; /* File flags */ + union { + struct { + __u32 l_i_version; /* was l_i_reserved1 */ + } linux1; + struct { + __u32 h_i_translator; + } hurd1; + } osd1; /* OS dependent 1 */ + __u32 i_block[EXT2_N_BLOCKS]; /* Pointers to blocks */ + __u32 i_generation; /* File version (for NFS) */ + __u32 i_file_acl; /* File ACL */ + __u32 i_dir_acl; /* Directory ACL */ + __u32 i_faddr; /* Fragment address */ + union { + struct { + __u16 l_i_blocks_hi; + __u16 l_i_file_acl_high; + __u16 l_i_uid_high; /* these 2 fields */ + __u16 l_i_gid_high; /* were reserved2[0] */ + __u32 l_i_reserved2; + } linux2; + struct { + __u8 h_i_frag; /* Fragment number */ + __u8 h_i_fsize; /* Fragment size */ + __u16 h_i_mode_high; + __u16 h_i_uid_high; + __u16 h_i_gid_high; + __u32 h_i_author; + } hurd2; + } osd2; /* OS dependent 2 */ }; /* * Permanent part of an large inode on the disk */ struct ext2_inode_large { - __u16 i_mode; /* File mode */ - __u16 i_uid; /* Low 16 bits of Owner Uid */ - __u32 i_size; /* Size in bytes */ - __u32 i_atime; /* Access time */ - __u32 i_ctime; /* Inode Change time */ - __u32 i_mtime; /* Modification time */ - __u32 i_dtime; /* Deletion Time */ - __u16 i_gid; /* Low 16 bits of Group Id */ - __u16 i_links_count; /* Links count */ - __u32 i_blocks; /* Blocks count */ - __u32 i_flags; /* File flags */ - union { - struct { - __u32 l_i_version; /* was l_i_reserved1 */ - } linux1; - struct { - __u32 h_i_translator; - } hurd1; - } osd1; /* OS dependent 1 */ - __u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ - __u32 i_generation; /* File version (for NFS) */ - __u32 i_file_acl; /* File ACL */ - __u32 i_dir_acl; /* Directory ACL */ - __u32 i_faddr; /* Fragment address */ - union { - struct { - __u16 l_i_blocks_hi; - __u16 l_i_file_acl_high; - __u16 l_i_uid_high; /* these 2 fields */ - __u16 l_i_gid_high; /* were reserved2[0] */ - __u32 l_i_reserved2; - } linux2; - struct { - __u8 h_i_frag; /* Fragment number */ - __u8 h_i_fsize; /* Fragment size */ - __u16 h_i_mode_high; - __u16 h_i_uid_high; - __u16 h_i_gid_high; - __u32 h_i_author; - } hurd2; - } osd2; /* OS dependent 2 */ - __u16 i_extra_isize; - __u16 i_pad1; - __u32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */ - __u32 i_mtime_extra; /* extra Modification time (nsec << 2 | epoch) */ - __u32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */ - __u32 i_crtime; /* File creation time */ - __u32 i_crtime_extra; /* extra File creation time (nsec << 2 | epoch)*/ - __u32 i_version_hi; /* high 32 bits for 64-bit version */ + __u16 i_mode; /* File mode */ + __u16 i_uid; /* Low 16 bits of Owner Uid */ + __u32 i_size; /* Size in bytes */ + __u32 i_atime; /* Access time */ + __u32 i_ctime; /* Inode Change time */ + __u32 i_mtime; /* Modification time */ + __u32 i_dtime; /* Deletion Time */ + __u16 i_gid; /* Low 16 bits of Group Id */ + __u16 i_links_count; /* Links count */ + __u32 i_blocks; /* Blocks count */ + __u32 i_flags; /* File flags */ + union { + struct { + __u32 l_i_version; /* was l_i_reserved1 */ + } linux1; + struct { + __u32 h_i_translator; + } hurd1; + } osd1; /* OS dependent 1 */ + __u32 i_block[EXT2_N_BLOCKS]; /* Pointers to blocks */ + __u32 i_generation; /* File version (for NFS) */ + __u32 i_file_acl; /* File ACL */ + __u32 i_dir_acl; /* Directory ACL */ + __u32 i_faddr; /* Fragment address */ + union { + struct { + __u16 l_i_blocks_hi; + __u16 l_i_file_acl_high; + __u16 l_i_uid_high; /* these 2 fields */ + __u16 l_i_gid_high; /* were reserved2[0] */ + __u32 l_i_reserved2; + } linux2; + struct { + __u8 h_i_frag; /* Fragment number */ + __u8 h_i_fsize; /* Fragment size */ + __u16 h_i_mode_high; + __u16 h_i_uid_high; + __u16 h_i_gid_high; + __u32 h_i_author; + } hurd2; + } osd2; /* OS dependent 2 */ + __u16 i_extra_isize; + __u16 i_pad1; + __u32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */ + __u32 i_mtime_extra; /* extra Modification time (nsec << 2 | epoch) */ + __u32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */ + __u32 i_crtime; /* File creation time */ + __u32 i_crtime_extra; /* extra File creation time (nsec << 2 | epoch)*/ + __u32 i_version_hi; /* high 32 bits for 64-bit version */ }; -#define i_size_high i_dir_acl +#define i_size_high i_dir_acl #if defined(__KERNEL__) || defined(__linux__) -#define i_reserved1 osd1.linux1.l_i_reserved1 -#define i_frag osd2.linux2.l_i_frag -#define i_fsize osd2.linux2.l_i_fsize -#define i_uid_low i_uid -#define i_gid_low i_gid -#define i_uid_high osd2.linux2.l_i_uid_high -#define i_gid_high osd2.linux2.l_i_gid_high -#define i_reserved2 osd2.linux2.l_i_reserved2 +# define i_reserved1 osd1.linux1.l_i_reserved1 +# define i_frag osd2.linux2.l_i_frag +# define i_fsize osd2.linux2.l_i_fsize +# define i_uid_low i_uid +# define i_gid_low i_gid +# define i_uid_high osd2.linux2.l_i_uid_high +# define i_gid_high osd2.linux2.l_i_gid_high +# define i_reserved2 osd2.linux2.l_i_reserved2 #else -#if defined(__GNU__) +# if defined(__GNU__) -#define i_translator osd1.hurd1.h_i_translator -#define i_frag osd2.hurd2.h_i_frag; -#define i_fsize osd2.hurd2.h_i_fsize; -#define i_uid_high osd2.hurd2.h_i_uid_high -#define i_gid_high osd2.hurd2.h_i_gid_high -#define i_author osd2.hurd2.h_i_author +# define i_translator osd1.hurd1.h_i_translator +# define i_frag osd2.hurd2.h_i_frag; +# define i_fsize osd2.hurd2.h_i_fsize; +# define i_uid_high osd2.hurd2.h_i_uid_high +# define i_gid_high osd2.hurd2.h_i_gid_high +# define i_author osd2.hurd2.h_i_author -#endif /* __GNU__ */ -#endif /* defined(__KERNEL__) || defined(__linux__) */ +# endif /* __GNU__ */ +#endif /* defined(__KERNEL__) || defined(__linux__) */ -#define inode_uid(inode) ((inode).i_uid | (inode).osd2.linux2.l_i_uid_high << 16) -#define inode_gid(inode) ((inode).i_gid | (inode).osd2.linux2.l_i_gid_high << 16) -#define ext2fs_set_i_uid_high(inode,x) ((inode).osd2.linux2.l_i_uid_high = (x)) -#define ext2fs_set_i_gid_high(inode,x) ((inode).osd2.linux2.l_i_gid_high = (x)) +#define inode_uid(inode) ((inode).i_uid | (inode).osd2.linux2.l_i_uid_high << 16) +#define inode_gid(inode) ((inode).i_gid | (inode).osd2.linux2.l_i_gid_high << 16) +#define ext2fs_set_i_uid_high(inode, x) ((inode).osd2.linux2.l_i_uid_high = (x)) +#define ext2fs_set_i_gid_high(inode, x) ((inode).osd2.linux2.l_i_gid_high = (x)) /* * File system states */ -#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ -#define EXT2_ERROR_FS 0x0002 /* Errors detected */ -#define EXT3_ORPHAN_FS 0x0004 /* Orphans being recovered */ +#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ +#define EXT2_ERROR_FS 0x0002 /* Errors detected */ +#define EXT3_ORPHAN_FS 0x0004 /* Orphans being recovered */ /* * Misc. filesystem flags */ -#define EXT2_FLAGS_SIGNED_HASH 0x0001 /* Signed dirhash in use */ -#define EXT2_FLAGS_UNSIGNED_HASH 0x0002 /* Unsigned dirhash in use */ -#define EXT2_FLAGS_TEST_FILESYS 0x0004 /* OK for use on development code */ +#define EXT2_FLAGS_SIGNED_HASH 0x0001 /* Signed dirhash in use */ +#define EXT2_FLAGS_UNSIGNED_HASH 0x0002 /* Unsigned dirhash in use */ +#define EXT2_FLAGS_TEST_FILESYS 0x0004 /* OK for use on development code */ /* * Mount flags */ -#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */ -#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ -#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ -#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ -#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ -#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ -#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */ -#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */ +#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */ +#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ +#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ +#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ +#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ +#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ +#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */ +#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */ -#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt -#define set_opt(o, opt) o |= EXT2_MOUNT_##opt -#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \ - EXT2_MOUNT_##opt) +#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt +#define set_opt(o, opt) o |= EXT2_MOUNT_##opt +#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_##opt) /* * Maximal mount counts between two filesystem checks */ -#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ -#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ /* * Behaviour when detecting errors */ -#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ -#define EXT2_ERRORS_RO 2 /* Remount fs read-only */ -#define EXT2_ERRORS_PANIC 3 /* Panic */ -#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE +#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ +#define EXT2_ERRORS_RO 2 /* Remount fs read-only */ +#define EXT2_ERRORS_PANIC 3 /* Panic */ +#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE /* * Structure of the super block */ struct ext2_super_block { - __u32 s_inodes_count; /* Inodes count */ - __u32 s_blocks_count; /* Blocks count */ - __u32 s_r_blocks_count; /* Reserved blocks count */ - __u32 s_free_blocks_count; /* Free blocks count */ - __u32 s_free_inodes_count; /* Free inodes count */ - __u32 s_first_data_block; /* First Data Block */ - __u32 s_log_block_size; /* Block size */ - __s32 s_log_frag_size; /* Fragment size */ - __u32 s_blocks_per_group; /* # Blocks per group */ - __u32 s_frags_per_group; /* # Fragments per group */ - __u32 s_inodes_per_group; /* # Inodes per group */ - __u32 s_mtime; /* Mount time */ - __u32 s_wtime; /* Write time */ - __u16 s_mnt_count; /* Mount count */ - __s16 s_max_mnt_count; /* Maximal mount count */ - __u16 s_magic; /* Magic signature */ - __u16 s_state; /* File system state */ - __u16 s_errors; /* Behaviour when detecting errors */ - __u16 s_minor_rev_level; /* minor revision level */ - __u32 s_lastcheck; /* time of last check */ - __u32 s_checkinterval; /* max. time between checks */ - __u32 s_creator_os; /* OS */ - __u32 s_rev_level; /* Revision level */ - __u16 s_def_resuid; /* Default uid for reserved blocks */ - __u16 s_def_resgid; /* Default gid for reserved blocks */ - /* + __u32 s_inodes_count; /* Inodes count */ + __u32 s_blocks_count; /* Blocks count */ + __u32 s_r_blocks_count; /* Reserved blocks count */ + __u32 s_free_blocks_count; /* Free blocks count */ + __u32 s_free_inodes_count; /* Free inodes count */ + __u32 s_first_data_block; /* First Data Block */ + __u32 s_log_block_size; /* Block size */ + __s32 s_log_frag_size; /* Fragment size */ + __u32 s_blocks_per_group; /* # Blocks per group */ + __u32 s_frags_per_group; /* # Fragments per group */ + __u32 s_inodes_per_group; /* # Inodes per group */ + __u32 s_mtime; /* Mount time */ + __u32 s_wtime; /* Write time */ + __u16 s_mnt_count; /* Mount count */ + __s16 s_max_mnt_count; /* Maximal mount count */ + __u16 s_magic; /* Magic signature */ + __u16 s_state; /* File system state */ + __u16 s_errors; /* Behaviour when detecting errors */ + __u16 s_minor_rev_level; /* minor revision level */ + __u32 s_lastcheck; /* time of last check */ + __u32 s_checkinterval; /* max. time between checks */ + __u32 s_creator_os; /* OS */ + __u32 s_rev_level; /* Revision level */ + __u16 s_def_resuid; /* Default uid for reserved blocks */ + __u16 s_def_resgid; /* Default gid for reserved blocks */ + /* * These fields are for EXT2_DYNAMIC_REV superblocks only. * * Note: the difference between the compatible feature set and @@ -534,142 +527,138 @@ struct ext2_super_block { * feature set, it must abort and not try to meddle with * things it doesn't understand... */ - __u32 s_first_ino; /* First non-reserved inode */ - __u16 s_inode_size; /* size of inode structure */ - __u16 s_block_group_nr; /* block group # of this superblock */ - __u32 s_feature_compat; /* compatible feature set */ - __u32 s_feature_incompat; /* incompatible feature set */ - __u32 s_feature_ro_compat; /* readonly-compatible feature set */ - __u8 s_uuid[16]; /* 128-bit uuid for volume */ - char s_volume_name[16]; /* volume name */ - char s_last_mounted[64]; /* directory where last mounted */ - __u32 s_algorithm_usage_bitmap; /* For compression */ - /* + __u32 s_first_ino; /* First non-reserved inode */ + __u16 s_inode_size; /* size of inode structure */ + __u16 s_block_group_nr; /* block group # of this superblock */ + __u32 s_feature_compat; /* compatible feature set */ + __u32 s_feature_incompat; /* incompatible feature set */ + __u32 s_feature_ro_compat; /* readonly-compatible feature set */ + __u8 s_uuid[16]; /* 128-bit uuid for volume */ + char s_volume_name[16]; /* volume name */ + char s_last_mounted[64]; /* directory where last mounted */ + __u32 s_algorithm_usage_bitmap; /* For compression */ + /* * Performance hints. Directory preallocation should only * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on. */ - __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ - __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ - __u16 s_reserved_gdt_blocks; /* Per group table for online growth */ - /* + __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ + __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ + __u16 s_reserved_gdt_blocks; /* Per group table for online growth */ + /* * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set. */ - __u8 s_journal_uuid[16]; /* uuid of journal superblock */ - __u32 s_journal_inum; /* inode number of journal file */ - __u32 s_journal_dev; /* device number of journal file */ - __u32 s_last_orphan; /* start of list of inodes to delete */ - __u32 s_hash_seed[4]; /* HTREE hash seed */ - __u8 s_def_hash_version; /* Default hash version to use */ - __u8 s_jnl_backup_type; /* Default type of journal backup */ - __u16 s_desc_size; /* Group desc. size: INCOMPAT_64BIT */ - __u32 s_default_mount_opts; - __u32 s_first_meta_bg; /* First metablock group */ - __u32 s_mkfs_time; /* When the filesystem was created */ - __u32 s_jnl_blocks[17]; /* Backup of the journal inode */ - __u32 s_blocks_count_hi; /* Blocks count high 32bits */ - __u32 s_r_blocks_count_hi; /* Reserved blocks count high 32 bits*/ - __u32 s_free_blocks_hi; /* Free blocks count */ - __u16 s_min_extra_isize; /* All inodes have at least # bytes */ - __u16 s_want_extra_isize; /* New inodes should reserve # bytes */ - __u32 s_flags; /* Miscellaneous flags */ - __u16 s_raid_stride; /* RAID stride */ - __u16 s_mmp_interval; /* # seconds to wait in MMP checking */ - __u64 s_mmp_block; /* Block for multi-mount protection */ - __u32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/ - __u8 s_log_groups_per_flex; /* FLEX_BG group size */ - __u8 s_reserved_char_pad; - __u16 s_reserved_pad; /* Padding to next 32bits */ - __u32 s_reserved[162]; /* Padding to the end of the block */ + __u8 s_journal_uuid[16]; /* uuid of journal superblock */ + __u32 s_journal_inum; /* inode number of journal file */ + __u32 s_journal_dev; /* device number of journal file */ + __u32 s_last_orphan; /* start of list of inodes to delete */ + __u32 s_hash_seed[4]; /* HTREE hash seed */ + __u8 s_def_hash_version; /* Default hash version to use */ + __u8 s_jnl_backup_type; /* Default type of journal backup */ + __u16 s_desc_size; /* Group desc. size: INCOMPAT_64BIT */ + __u32 s_default_mount_opts; + __u32 s_first_meta_bg; /* First metablock group */ + __u32 s_mkfs_time; /* When the filesystem was created */ + __u32 s_jnl_blocks[17]; /* Backup of the journal inode */ + __u32 s_blocks_count_hi; /* Blocks count high 32bits */ + __u32 s_r_blocks_count_hi; /* Reserved blocks count high 32 bits*/ + __u32 s_free_blocks_hi; /* Free blocks count */ + __u16 s_min_extra_isize; /* All inodes have at least # bytes */ + __u16 s_want_extra_isize; /* New inodes should reserve # bytes */ + __u32 s_flags; /* Miscellaneous flags */ + __u16 s_raid_stride; /* RAID stride */ + __u16 s_mmp_interval; /* # seconds to wait in MMP checking */ + __u64 s_mmp_block; /* Block for multi-mount protection */ + __u32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/ + __u8 s_log_groups_per_flex; /* FLEX_BG group size */ + __u8 s_reserved_char_pad; + __u16 s_reserved_pad; /* Padding to next 32bits */ + __u32 s_reserved[162]; /* Padding to the end of the block */ }; /* * Codes for operating systems */ -#define EXT2_OS_LINUX 0 -#define EXT2_OS_HURD 1 -#define EXT2_OBSO_OS_MASIX 2 -#define EXT2_OS_FREEBSD 3 -#define EXT2_OS_LITES 4 +#define EXT2_OS_LINUX 0 +#define EXT2_OS_HURD 1 +#define EXT2_OBSO_OS_MASIX 2 +#define EXT2_OS_FREEBSD 3 +#define EXT2_OS_LITES 4 /* * Revision levels */ -#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ -#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ +#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ +#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ -#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV -#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV +#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV +#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV #define EXT2_GOOD_OLD_INODE_SIZE 128 /* * Journal inode backup types */ -#define EXT3_JNL_BACKUP_BLOCKS 1 +#define EXT3_JNL_BACKUP_BLOCKS 1 /* * Feature set definitions */ -#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_feature_compat & (mask) ) -#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_feature_ro_compat & (mask) ) -#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_feature_incompat & (mask) ) +#define EXT2_HAS_COMPAT_FEATURE(sb, mask) \ + (EXT2_SB(sb)->s_feature_compat & (mask)) +#define EXT2_HAS_RO_COMPAT_FEATURE(sb, mask) \ + (EXT2_SB(sb)->s_feature_ro_compat & (mask)) +#define EXT2_HAS_INCOMPAT_FEATURE(sb, mask) \ + (EXT2_SB(sb)->s_feature_incompat & (mask)) -#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 -#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 -#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 -#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 -#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010 -#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 -#define EXT2_FEATURE_COMPAT_LAZY_BG 0x0040 +#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 +#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 +#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 +#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 +#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010 +#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 +#define EXT2_FEATURE_COMPAT_LAZY_BG 0x0040 -#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 -#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 +#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 +#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 /* #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 not used */ -#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008 -#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010 -#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020 -#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040 +#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008 +#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010 +#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020 +#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040 -#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 -#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 -#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */ -#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */ -#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010 -#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040 -#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 -#define EXT4_FEATURE_INCOMPAT_MMP 0x0100 -#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 +#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 +#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 +#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */ +#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */ +#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010 +#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040 +#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 +#define EXT4_FEATURE_INCOMPAT_MMP 0x0100 +#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 - -#define EXT2_FEATURE_COMPAT_SUPP 0 -#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE) -#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ - EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ - EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \ - EXT2_FEATURE_RO_COMPAT_BTREE_DIR) +#define EXT2_FEATURE_COMPAT_SUPP 0 +#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE) +#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER | EXT2_FEATURE_RO_COMPAT_LARGE_FILE | EXT4_FEATURE_RO_COMPAT_DIR_NLINK | EXT2_FEATURE_RO_COMPAT_BTREE_DIR) /* * Default values for user and/or group using reserved blocks */ -#define EXT2_DEF_RESUID 0 -#define EXT2_DEF_RESGID 0 +#define EXT2_DEF_RESUID 0 +#define EXT2_DEF_RESGID 0 /* * Default mount options */ -#define EXT2_DEFM_DEBUG 0x0001 -#define EXT2_DEFM_BSDGROUPS 0x0002 -#define EXT2_DEFM_XATTR_USER 0x0004 -#define EXT2_DEFM_ACL 0x0008 -#define EXT2_DEFM_UID16 0x0010 -#define EXT3_DEFM_JMODE 0x0060 -#define EXT3_DEFM_JMODE_DATA 0x0020 -#define EXT3_DEFM_JMODE_ORDERED 0x0040 -#define EXT3_DEFM_JMODE_WBACK 0x0060 +#define EXT2_DEFM_DEBUG 0x0001 +#define EXT2_DEFM_BSDGROUPS 0x0002 +#define EXT2_DEFM_XATTR_USER 0x0004 +#define EXT2_DEFM_ACL 0x0008 +#define EXT2_DEFM_UID16 0x0010 +#define EXT3_DEFM_JMODE 0x0060 +#define EXT3_DEFM_JMODE_DATA 0x0020 +#define EXT3_DEFM_JMODE_ORDERED 0x0040 +#define EXT3_DEFM_JMODE_WBACK 0x0060 /* * Structure of a directory entry @@ -677,10 +666,10 @@ struct ext2_super_block { #define EXT2_NAME_LEN 255 struct ext2_dir_entry { - __u32 inode; /* Inode number */ - __u16 rec_len; /* Directory entry length */ - __u16 name_len; /* Name length */ - char name[EXT2_NAME_LEN]; /* File name */ + __u32 inode; /* Inode number */ + __u16 rec_len; /* Directory entry length */ + __u16 name_len; /* Name length */ + char name[EXT2_NAME_LEN]; /* File name */ }; /* @@ -690,61 +679,60 @@ struct ext2_dir_entry { * file_type field. */ struct ext2_dir_entry_2 { - __u32 inode; /* Inode number */ - __u16 rec_len; /* Directory entry length */ - __u8 name_len; /* Name length */ - __u8 file_type; - char name[EXT2_NAME_LEN]; /* File name */ + __u32 inode; /* Inode number */ + __u16 rec_len; /* Directory entry length */ + __u8 name_len; /* Name length */ + __u8 file_type; + char name[EXT2_NAME_LEN]; /* File name */ }; /* * Ext2 directory file types. Only the low 3 bits are used. The * other bits are reserved for now. */ -#define EXT2_FT_UNKNOWN 0 -#define EXT2_FT_REG_FILE 1 -#define EXT2_FT_DIR 2 -#define EXT2_FT_CHRDEV 3 -#define EXT2_FT_BLKDEV 4 -#define EXT2_FT_FIFO 5 -#define EXT2_FT_SOCK 6 -#define EXT2_FT_SYMLINK 7 +#define EXT2_FT_UNKNOWN 0 +#define EXT2_FT_REG_FILE 1 +#define EXT2_FT_DIR 2 +#define EXT2_FT_CHRDEV 3 +#define EXT2_FT_BLKDEV 4 +#define EXT2_FT_FIFO 5 +#define EXT2_FT_SOCK 6 +#define EXT2_FT_SYMLINK 7 -#define EXT2_FT_MAX 8 +#define EXT2_FT_MAX 8 /* * EXT2_DIR_PAD defines the directory entries boundaries * * NOTE: It must be a multiple of 4 */ -#define EXT2_DIR_PAD 4 -#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) -#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ - ~EXT2_DIR_ROUND) +#define EXT2_DIR_PAD 4 +#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) +#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & ~EXT2_DIR_ROUND) /* * This structure will be used for multiple mount protection. It will be * written into the block number saved in the s_mmp_block field in the * superblock. */ -#define EXT2_MMP_MAGIC 0x004D4D50 /* ASCII for MMP */ -#define EXT2_MMP_CLEAN 0xFF4D4D50 /* Value of mmp_seq for clean unmount */ -#define EXT2_MMP_FSCK_ON 0xE24D4D50 /* Value of mmp_seq when being fscked */ +#define EXT2_MMP_MAGIC 0x004D4D50 /* ASCII for MMP */ +#define EXT2_MMP_CLEAN 0xFF4D4D50 /* Value of mmp_seq for clean unmount */ +#define EXT2_MMP_FSCK_ON 0xE24D4D50 /* Value of mmp_seq when being fscked */ struct mmp_struct { - __u32 mmp_magic; - __u32 mmp_seq; - __u64 mmp_time; - char mmp_nodename[64]; - char mmp_bdevname[32]; - __u16 mmp_interval; - __u16 mmp_pad1; - __u32 mmp_pad2; + __u32 mmp_magic; + __u32 mmp_seq; + __u64 mmp_time; + char mmp_nodename[64]; + char mmp_bdevname[32]; + __u16 mmp_interval; + __u16 mmp_pad1; + __u32 mmp_pad2; }; /* * Interval in number of seconds to update the MMP sequence number. */ -#define EXT2_MMP_DEF_INTERVAL 5 +#define EXT2_MMP_DEF_INTERVAL 5 -#endif /* _LINUX_EXT2_FS_H */ +#endif /* _LINUX_EXT2_FS_H */ diff --git a/Kernel/FileSystem/ext2_types.h b/Kernel/FileSystem/ext2_types.h index 27277fa3fe2..10160466cfa 100644 --- a/Kernel/FileSystem/ext2_types.h +++ b/Kernel/FileSystem/ext2_types.h @@ -3,140 +3,141 @@ * everything we need. (cross fingers) Other header files may have * also defined the types that we need. */ -#if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \ - !defined(_EXT2_TYPES_H)) -#define _EXT2_TYPES_H +#if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && !defined(_EXT2_TYPES_H)) +# define _EXT2_TYPES_H -#define __S8_TYPEDEF __signed__ char -#define __U8_TYPEDEF unsigned char -#define __S16_TYPEDEF __signed__ short -#define __U16_TYPEDEF unsigned short -#define __S32_TYPEDEF __signed__ int -#define __U32_TYPEDEF unsigned int -#define __S64_TYPEDEF __signed__ long long -#define __U64_TYPEDEF unsigned long long +# define __S8_TYPEDEF __signed__ char +# define __U8_TYPEDEF unsigned char +# define __S16_TYPEDEF __signed__ short +# define __U16_TYPEDEF unsigned short +# define __S32_TYPEDEF __signed__ int +# define __U32_TYPEDEF unsigned int +# define __S64_TYPEDEF __signed__ long long +# define __U64_TYPEDEF unsigned long long -#ifdef __U8_TYPEDEF +# ifdef __U8_TYPEDEF typedef __U8_TYPEDEF __u8; -#else +# else typedef unsigned char __u8; -#endif +# endif -#ifdef __S8_TYPEDEF +# ifdef __S8_TYPEDEF typedef __S8_TYPEDEF __s8; -#else +# else typedef signed char __s8; -#endif +# endif -#ifdef __U16_TYPEDEF +# ifdef __U16_TYPEDEF typedef __U16_TYPEDEF __u16; -#else -#if (4 == 2) -typedef unsigned int __u16; -#else -#if (2 == 2) -typedef unsigned short __u16; -#else - ?==error: undefined 16 bit type -#endif /* SIZEOF_SHORT == 2 */ -#endif /* SIZEOF_INT == 2 */ -#endif /* __U16_TYPEDEF */ +# else +# if (4 == 2) +typedef unsigned int __u16; +# else +# if (2 == 2) +typedef unsigned short __u16; +# else +? == error : undefined 16 bit type +# endif /* SIZEOF_SHORT == 2 */ +# endif /* SIZEOF_INT == 2 */ +# endif /* __U16_TYPEDEF */ -#ifdef __S16_TYPEDEF +# ifdef __S16_TYPEDEF typedef __S16_TYPEDEF __s16; -#else -#if (4 == 2) -typedef int __s16; -#else -#if (2 == 2) -typedef short __s16; -#else - ?==error: undefined 16 bit type -#endif /* SIZEOF_SHORT == 2 */ -#endif /* SIZEOF_INT == 2 */ -#endif /* __S16_TYPEDEF */ +# else +# if (4 == 2) +typedef int __s16; +# else +# if (2 == 2) +typedef short __s16; +# else + ? == error + : undefined 16 bit type +# endif /* SIZEOF_SHORT == 2 */ +# endif /* SIZEOF_INT == 2 */ +# endif /* __S16_TYPEDEF */ - -#ifdef __U32_TYPEDEF +# ifdef __U32_TYPEDEF typedef __U32_TYPEDEF __u32; -#else -#if (4 == 4) -typedef unsigned int __u32; -#else -#if (4 == 4) -typedef unsigned long __u32; -#else -#if (2 == 4) -typedef unsigned short __u32; -#else - ?== error: undefined 32 bit type -#endif /* SIZEOF_SHORT == 4 */ -#endif /* SIZEOF_LONG == 4 */ -#endif /* SIZEOF_INT == 4 */ -#endif /* __U32_TYPEDEF */ +# else +# if (4 == 4) +typedef unsigned int __u32; +# else +# if (4 == 4) +typedef unsigned long __u32; +# else +# if (2 == 4) + typedef unsigned short __u32; +# else + ? == error + : undefined 32 bit type +# endif /* SIZEOF_SHORT == 4 */ +# endif /* SIZEOF_LONG == 4 */ +# endif /* SIZEOF_INT == 4 */ +# endif /* __U32_TYPEDEF */ -#ifdef __S32_TYPEDEF +# ifdef __S32_TYPEDEF typedef __S32_TYPEDEF __s32; -#else -#if (4 == 4) -typedef int __s32; -#else -#if (4 == 4) -typedef long __s32; -#else -#if (2 == 4) -typedef short __s32; -#else - ?== error: undefined 32 bit type -#endif /* SIZEOF_SHORT == 4 */ -#endif /* SIZEOF_LONG == 4 */ -#endif /* SIZEOF_INT == 4 */ -#endif /* __S32_TYPEDEF */ +# else +# if (4 == 4) +typedef int __s32; +# else +# if (4 == 4) +typedef long __s32; +# else +# if (2 == 4) +typedef short __s32; +# else + ? == error + : undefined 32 bit type +# endif /* SIZEOF_SHORT == 4 */ +# endif /* SIZEOF_LONG == 4 */ +# endif /* SIZEOF_INT == 4 */ +# endif /* __S32_TYPEDEF */ -#ifdef __U64_TYPEDEF +# ifdef __U64_TYPEDEF typedef __U64_TYPEDEF __u64; -#else -#if (4 == 8) -typedef unsigned int __u64; -#else -#if (4 == 8) -typedef unsigned long __u64; -#else -#if (8 == 8) -typedef unsigned long long __u64; -#endif /* SIZEOF_LONG_LONG == 8 */ -#endif /* SIZEOF_LONG == 8 */ -#endif /* SIZEOF_INT == 8 */ -#endif /* __U64_TYPEDEF */ +# else +# if (4 == 8) +typedef unsigned int __u64; +# else +# if (4 == 8) +typedef unsigned long __u64; +# else +# if (8 == 8) +typedef unsigned long long __u64; +# endif /* SIZEOF_LONG_LONG == 8 */ +# endif /* SIZEOF_LONG == 8 */ +# endif /* SIZEOF_INT == 8 */ +# endif /* __U64_TYPEDEF */ -#ifdef __S64_TYPEDEF +# ifdef __S64_TYPEDEF typedef __S64_TYPEDEF __s64; -#else -#if (4 == 8) -typedef int __s64; -#else -#if (4 == 8) -typedef long __s64; -#else -#if (8 == 8) -#if defined(__GNUC__) -typedef __signed__ long long __s64; -#else -typedef signed long long __s64; -#endif /* __GNUC__ */ -#endif /* SIZEOF_LONG_LONG == 8 */ -#endif /* SIZEOF_LONG == 8 */ -#endif /* SIZEOF_INT == 8 */ -#endif /* __S64_TYPEDEF */ +# else +# if (4 == 8) +typedef int __s64; +# else +# if (4 == 8) +typedef long __s64; +# else +# if (8 == 8) +# if defined(__GNUC__) +typedef __signed__ long long __s64; +# else +typedef signed long long __s64; +# endif /* __GNUC__ */ +# endif /* SIZEOF_LONG_LONG == 8 */ +# endif /* SIZEOF_LONG == 8 */ +# endif /* SIZEOF_INT == 8 */ +# endif /* __S64_TYPEDEF */ -#undef __S8_TYPEDEF -#undef __U8_TYPEDEF -#undef __S16_TYPEDEF -#undef __U16_TYPEDEF -#undef __S32_TYPEDEF -#undef __U32_TYPEDEF -#undef __S64_TYPEDEF -#undef __U64_TYPEDEF +# undef __S8_TYPEDEF +# undef __U8_TYPEDEF +# undef __S16_TYPEDEF +# undef __U16_TYPEDEF +# undef __S32_TYPEDEF +# undef __U32_TYPEDEF +# undef __S64_TYPEDEF +# undef __U64_TYPEDEF #endif /* _*_TYPES_H */ diff --git a/Kernel/IO.h b/Kernel/IO.h index 5453b984942..259911264cd 100644 --- a/Kernel/IO.h +++ b/Kernel/IO.h @@ -7,47 +7,58 @@ namespace IO { inline byte in8(word port) { byte value; - asm volatile("inb %1, %0":"=a"(value):"Nd"(port)); + asm volatile("inb %1, %0" + : "=a"(value) + : "Nd"(port)); return value; } inline word in16(word port) { word value; - asm volatile("inw %1, %0":"=a"(value):"Nd"(port)); + asm volatile("inw %1, %0" + : "=a"(value) + : "Nd"(port)); return value; } inline dword in32(word port) { dword value; - asm volatile("inl %1, %0":"=a"(value):"Nd"(port)); + asm volatile("inl %1, %0" + : "=a"(value) + : "Nd"(port)); return value; } inline void repeated_in16(word port, byte* buffer, int buffer_size) { - asm volatile("rep insw" : "+D"(buffer), "+c"(buffer_size) : "d"(port) : "memory"); + asm volatile("rep insw" + : "+D"(buffer), "+c"(buffer_size) + : "d"(port) + : "memory"); } inline void out8(word port, byte value) { - asm volatile("outb %0, %1"::"a"(value), "Nd"(port)); + asm volatile("outb %0, %1" ::"a"(value), "Nd"(port)); } inline void out16(word port, word value) { - asm volatile("outw %0, %1"::"a"(value), "Nd"(port)); + asm volatile("outw %0, %1" ::"a"(value), "Nd"(port)); } inline void out32(word port, dword value) { - asm volatile("outl %0, %1"::"a"(value), "Nd"(port)); + asm volatile("outl %0, %1" ::"a"(value), "Nd"(port)); } inline void repeated_out16(word port, const byte* data, int data_size) { - asm volatile("rep outsw" : "+S"(data), "+c"(data_size) : "d"(port)); + asm volatile("rep outsw" + : "+S"(data), "+c"(data_size) + : "d"(port)); } } diff --git a/Kernel/IRQHandler.h b/Kernel/IRQHandler.h index e856b84e461..4abadf6b202 100644 --- a/Kernel/IRQHandler.h +++ b/Kernel/IRQHandler.h @@ -18,4 +18,3 @@ protected: private: byte m_irq_number { 0 }; }; - diff --git a/Kernel/KResult.h b/Kernel/KResult.h index 1cc740bc742..291e9ea2eac 100644 --- a/Kernel/KResult.h +++ b/Kernel/KResult.h @@ -3,20 +3,31 @@ #include #include -enum KSuccessTag { KSuccess }; +enum KSuccessTag +{ + KSuccess +}; class KResult { public: - explicit KResult(int negative_e) : m_error(negative_e) { ASSERT(negative_e <= 0); } - KResult(KSuccessTag) : m_error(0) { } + explicit KResult(int negative_e) + : m_error(negative_e) + { + ASSERT(negative_e <= 0); + } + KResult(KSuccessTag) + : m_error(0) + { + } operator int() const { return m_error; } bool is_success() const { return m_error == ESUCCESS; } bool is_error() const { return !is_success(); } private: - template friend class KResultOr; - KResult() { } + template + friend class KResultOr; + KResult() {} int m_error { 0 }; }; @@ -27,7 +38,8 @@ public: KResultOr(KResult error) : m_error(error) , m_is_error(true) - { } + { + } KResultOr(T&& value) { @@ -54,9 +66,21 @@ public: } bool is_error() const { return m_is_error; } - KResult error() const { ASSERT(m_is_error); return m_error; } - T& value() { ASSERT(!m_is_error); return *reinterpret_cast(&m_storage); } - const T& value() const { ASSERT(!m_is_error); return *reinterpret_cast(&m_storage); } + KResult error() const + { + ASSERT(m_is_error); + return m_error; + } + T& value() + { + ASSERT(!m_is_error); + return *reinterpret_cast(&m_storage); + } + const T& value() const + { + ASSERT(!m_is_error); + return *reinterpret_cast(&m_storage); + } T release_value() { @@ -71,4 +95,3 @@ private: KResult m_error; bool m_is_error { false }; }; - diff --git a/Kernel/KeyCode.h b/Kernel/KeyCode.h index 310c950ca92..67c065625fd 100644 --- a/Kernel/KeyCode.h +++ b/Kernel/KeyCode.h @@ -2,7 +2,8 @@ #include -enum KeyCode : byte { +enum KeyCode : byte +{ Key_Invalid = 0, Key_Escape, Key_Tab, @@ -113,7 +114,8 @@ enum KeyCode : byte { Key_Shift = Key_LeftShift, }; -enum KeyModifier { +enum KeyModifier +{ Mod_None = 0x00, Mod_Alt = 0x01, Mod_Ctrl = 0x02, diff --git a/Kernel/LinearAddress.h b/Kernel/LinearAddress.h index c3064a9af43..3b0eecea02c 100644 --- a/Kernel/LinearAddress.h +++ b/Kernel/LinearAddress.h @@ -4,8 +4,11 @@ class LinearAddress { public: - LinearAddress() { } - explicit LinearAddress(dword address) : m_address(address) { } + LinearAddress() {} + explicit LinearAddress(dword address) + : m_address(address) + { + } bool is_null() const { return m_address == 0; } diff --git a/Kernel/Lock.h b/Kernel/Lock.h index c61df5f647d..fcd9a69a948 100644 --- a/Kernel/Lock.h +++ b/Kernel/Lock.h @@ -2,9 +2,9 @@ #include #include -#include -#include #include +#include +#include class Thread; extern Thread* current; @@ -14,16 +14,19 @@ static inline dword CAS(volatile dword* mem, dword newval, dword oldval) dword ret; asm volatile( "cmpxchgl %2, %1" - :"=a"(ret), "+m"(*mem) - :"r"(newval), "0"(oldval) - :"cc", "memory"); + : "=a"(ret), "+m"(*mem) + : "r"(newval), "0"(oldval) + : "cc", "memory"); return ret; } class Lock { public: - Lock(const char* name = nullptr) : m_name(name) { } - ~Lock() { } + Lock(const char* name = nullptr) + : m_name(name) + { + } + ~Lock() {} void lock(); void unlock(); @@ -40,7 +43,11 @@ private: class Locker { public: - [[gnu::always_inline]] inline explicit Locker(Lock& l) : m_lock(l) { lock(); } + [[gnu::always_inline]] inline explicit Locker(Lock& l) + : m_lock(l) + { + lock(); + } [[gnu::always_inline]] inline ~Locker() { unlock(); } [[gnu::always_inline]] inline void unlock() { m_lock.unlock(); } [[gnu::always_inline]] inline void lock() { m_lock.lock(); } @@ -123,8 +130,11 @@ inline bool Lock::unlock_if_locked() template class Lockable { public: - Lockable() { } - Lockable(T&& resource) : m_resource(move(resource)) { } + Lockable() {} + Lockable(T&& resource) + : m_resource(move(resource)) + { + } Lock& lock() { return m_lock; } T& resource() { return m_resource; } @@ -138,4 +148,3 @@ private: T m_resource; Lock m_lock; }; - diff --git a/Kernel/Net/ARP.h b/Kernel/Net/ARP.h index ddfcd54f63d..2fecc2b0a0d 100644 --- a/Kernel/Net/ARP.h +++ b/Kernel/Net/ARP.h @@ -1,23 +1,26 @@ #pragma once -#include -#include #include +#include +#include struct ARPOperation { -enum : word { - Request = 1, - Response = 2, -}; + enum : word + { + Request = 1, + Response = 2, + }; }; struct ARPHardwareType { -enum : word { - Ethernet = 1, -}; + enum : word + { + Ethernet = 1, + }; }; -class [[gnu::packed]] ARPPacket { +class [[gnu::packed]] ARPPacket +{ public: word hardware_type() const { return ntohs(m_hardware_type); } void set_hardware_type(word w) { m_hardware_type = htons(w); } diff --git a/Kernel/Net/E1000NetworkAdapter.h b/Kernel/Net/E1000NetworkAdapter.h index cf9bdb3ba53..e2050853d58 100644 --- a/Kernel/Net/E1000NetworkAdapter.h +++ b/Kernel/Net/E1000NetworkAdapter.h @@ -1,12 +1,13 @@ #pragma once +#include +#include #include #include #include -#include -#include -class E1000NetworkAdapter final : public NetworkAdapter, public IRQHandler { +class E1000NetworkAdapter final : public NetworkAdapter + , public IRQHandler { public: static E1000NetworkAdapter* the(); @@ -21,7 +22,8 @@ private: virtual void handle_irq() override; virtual const char* class_name() const override { return "E1000NetworkAdapter"; } - struct [[gnu::packed]] e1000_rx_desc { + struct [[gnu::packed]] e1000_rx_desc + { volatile uint64_t addr { 0 }; volatile uint16_t length { 0 }; volatile uint16_t checksum { 0 }; @@ -30,7 +32,8 @@ private: volatile uint16_t special { 0 }; }; - struct [[gnu::packed]] e1000_tx_desc { + struct [[gnu::packed]] e1000_tx_desc + { volatile uint64_t addr { 0 }; volatile uint16_t length { 0 }; volatile uint8_t cso { 0 }; diff --git a/Kernel/Net/EtherType.h b/Kernel/Net/EtherType.h index 027967ff771..42edc16427f 100644 --- a/Kernel/Net/EtherType.h +++ b/Kernel/Net/EtherType.h @@ -3,8 +3,9 @@ #include struct EtherType { -enum : word { - ARP = 0x0806, - IPv4 = 0x0800, -}; + enum : word + { + ARP = 0x0806, + IPv4 = 0x0800, + }; }; diff --git a/Kernel/Net/EthernetFrameHeader.h b/Kernel/Net/EthernetFrameHeader.h index 18afc9242bb..137285230e7 100644 --- a/Kernel/Net/EthernetFrameHeader.h +++ b/Kernel/Net/EthernetFrameHeader.h @@ -1,12 +1,13 @@ #pragma once -#include #include +#include -class [[gnu::packed]] EthernetFrameHeader { +class [[gnu::packed]] EthernetFrameHeader +{ public: - EthernetFrameHeader() { } - ~EthernetFrameHeader() { } + EthernetFrameHeader() {} + ~EthernetFrameHeader() {} MACAddress destination() const { return m_destination; } void set_destination(const MACAddress& address) { m_destination = address; } @@ -28,4 +29,3 @@ private: }; static_assert(sizeof(EthernetFrameHeader) == 14); - diff --git a/Kernel/Net/ICMP.h b/Kernel/Net/ICMP.h index efc6cf4ca60..2433626a64d 100644 --- a/Kernel/Net/ICMP.h +++ b/Kernel/Net/ICMP.h @@ -1,19 +1,21 @@ #pragma once -#include #include +#include struct ICMPType { -enum { - EchoReply = 0, - EchoRequest = 8, -}; + enum + { + EchoReply = 0, + EchoRequest = 8, + }; }; -class [[gnu::packed]] ICMPHeader { +class [[gnu::packed]] ICMPHeader +{ public: - ICMPHeader() { } - ~ICMPHeader() { } + ICMPHeader() {} + ~ICMPHeader() {} byte type() const { return m_type; } void set_type(byte b) { m_type = b; } @@ -36,7 +38,8 @@ private: static_assert(sizeof(ICMPHeader) == 4); -struct [[gnu::packed]] ICMPEchoPacket { +struct [[gnu::packed]] ICMPEchoPacket +{ ICMPHeader header; NetworkOrdered identifier; NetworkOrdered sequence_number; diff --git a/Kernel/Net/IPv4.h b/Kernel/Net/IPv4.h index 61232b78e28..0c858d94d02 100644 --- a/Kernel/Net/IPv4.h +++ b/Kernel/Net/IPv4.h @@ -5,7 +5,8 @@ #include #include -enum class IPv4Protocol : word { +enum class IPv4Protocol : word +{ ICMP = 1, TCP = 6, UDP = 17, @@ -13,9 +14,10 @@ enum class IPv4Protocol : word { NetworkOrdered internet_checksum(const void*, size_t); -class [[gnu::packed]] IPv4Address { +class [[gnu::packed]] IPv4Address +{ public: - IPv4Address() { } + IPv4Address() {} IPv4Address(const byte data[4]) { m_data[0] = data[0]; @@ -64,7 +66,8 @@ struct Traits { } -class [[gnu::packed]] IPv4Packet { +class [[gnu::packed]] IPv4Packet +{ public: byte version() const { return (m_version_and_ihl >> 4) & 0xf; } void set_version(byte version) { m_version_and_ihl = (m_version_and_ihl & 0x0f) | (version << 4); } diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h index 33b4f9d420f..4f18d63113c 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -1,11 +1,11 @@ #pragma once -#include -#include -#include #include -#include #include +#include +#include +#include +#include class IPv4SocketHandle; class TCPSocketHandle; @@ -86,7 +86,7 @@ private: class IPv4SocketHandle : public SocketHandle { public: - IPv4SocketHandle() { } + IPv4SocketHandle() {} IPv4SocketHandle(RetainPtr&& socket) : SocketHandle(move(socket)) diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h index db481912f23..3328fd4eba7 100644 --- a/Kernel/Net/LocalSocket.h +++ b/Kernel/Net/LocalSocket.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class FileDescriptor; @@ -39,4 +39,3 @@ private: DoubleBuffer m_for_client; DoubleBuffer m_for_server; }; - diff --git a/Kernel/Net/MACAddress.h b/Kernel/Net/MACAddress.h index 0c2de93b270..3cf906decb6 100644 --- a/Kernel/Net/MACAddress.h +++ b/Kernel/Net/MACAddress.h @@ -1,18 +1,19 @@ #pragma once -#include #include +#include #include #include -class [[gnu::packed]] MACAddress { +class [[gnu::packed]] MACAddress +{ public: - MACAddress() { } + MACAddress() {} MACAddress(const byte data[6]) { memcpy(m_data, data, 6); } - ~MACAddress() { } + ~MACAddress() {} byte operator[](int i) const { diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h index 3a7d0755c71..fd24d7ca411 100644 --- a/Kernel/Net/NetworkAdapter.h +++ b/Kernel/Net/NetworkAdapter.h @@ -3,19 +3,23 @@ #include #include #include -#include -#include +#include #include #include -#include +#include +#include class NetworkAdapter; class PacketQueueAlarm final : public Alarm { public: - PacketQueueAlarm(NetworkAdapter& adapter) : m_adapter(adapter) { } - virtual ~PacketQueueAlarm() override { } + PacketQueueAlarm(NetworkAdapter& adapter) + : m_adapter(adapter) + { + } + virtual ~PacketQueueAlarm() override {} virtual bool is_ringing() const override; + private: NetworkAdapter& m_adapter; }; diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h index 0fb9544cbb2..45693a2ffc4 100644 --- a/Kernel/Net/Socket.h +++ b/Kernel/Net/Socket.h @@ -1,16 +1,27 @@ #pragma once -#include -#include -#include #include +#include +#include #include #include -#include #include +#include +#include -enum class SocketRole : byte { None, Listener, Accepted, Connected, Connecting }; -enum class ShouldBlock { No = 0, Yes = 1 }; +enum class SocketRole : byte +{ + None, + Listener, + Accepted, + Connected, + Connecting +}; +enum class ShouldBlock +{ + No = 0, + Yes = 1 +}; class FileDescriptor; @@ -85,7 +96,7 @@ private: class SocketHandle { public: - SocketHandle() { } + SocketHandle() {} SocketHandle(RetainPtr&& socket) : m_socket(move(socket)) diff --git a/Kernel/Net/TCP.h b/Kernel/Net/TCP.h index e2eac614496..8138ed3d525 100644 --- a/Kernel/Net/TCP.h +++ b/Kernel/Net/TCP.h @@ -3,20 +3,22 @@ #include struct TCPFlags { -enum : word { - FIN = 0x01, - SYN = 0x02, - RST = 0x04, - PUSH = 0x08, - ACK = 0x10, - URG = 0x20 -}; + enum : word + { + FIN = 0x01, + SYN = 0x02, + RST = 0x04, + PUSH = 0x08, + ACK = 0x10, + URG = 0x20 + }; }; -class [[gnu::packed]] TCPPacket { +class [[gnu::packed]] TCPPacket +{ public: - TCPPacket() { } - ~TCPPacket() { } + TCPPacket() {} + ~TCPPacket() {} size_t header_size() const { return data_offset() * sizeof(dword); } diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h index c248b9d9ba9..35856d7ae81 100644 --- a/Kernel/Net/TCPSocket.h +++ b/Kernel/Net/TCPSocket.h @@ -7,7 +7,8 @@ public: static Retained create(int protocol); virtual ~TCPSocket() override; - enum class State { + enum class State + { Disconnected, Connecting, Connected, @@ -47,7 +48,7 @@ private: class TCPSocketHandle : public SocketHandle { public: - TCPSocketHandle() { } + TCPSocketHandle() {} TCPSocketHandle(RetainPtr&& socket) : SocketHandle(move(socket)) diff --git a/Kernel/Net/UDP.h b/Kernel/Net/UDP.h index ba6d02af376..7ec39719cd4 100644 --- a/Kernel/Net/UDP.h +++ b/Kernel/Net/UDP.h @@ -2,10 +2,11 @@ #include -class [[gnu::packed]] UDPPacket { +class [[gnu::packed]] UDPPacket +{ public: - UDPPacket() { } - ~UDPPacket() { } + UDPPacket() {} + ~UDPPacket() {} word source_port() const { return m_source_port; } void set_source_port(word port) { m_source_port = port; } diff --git a/Kernel/Net/UDPSocket.h b/Kernel/Net/UDPSocket.h index ea94887754f..a76eaa7fe70 100644 --- a/Kernel/Net/UDPSocket.h +++ b/Kernel/Net/UDPSocket.h @@ -25,7 +25,7 @@ private: class UDPSocketHandle : public SocketHandle { public: - UDPSocketHandle() { } + UDPSocketHandle() {} UDPSocketHandle(RetainPtr&& socket) : SocketHandle(move(socket)) @@ -46,4 +46,3 @@ public: UDPSocket& socket() { return static_cast(SocketHandle::socket()); } const UDPSocket& socket() const { return static_cast(SocketHandle::socket()); } }; - diff --git a/Kernel/PCI.h b/Kernel/PCI.h index e8330d42455..f295fb8f4dd 100644 --- a/Kernel/PCI.h +++ b/Kernel/PCI.h @@ -18,8 +18,13 @@ struct ID { }; struct Address { - Address() { } - Address(byte bus, byte slot, byte function) : m_bus(bus), m_slot(slot), m_function(function) { } + Address() {} + Address(byte bus, byte slot, byte function) + : m_bus(bus) + , m_slot(slot) + , m_function(function) + { + } bool is_null() const { return !m_bus && !m_slot && !m_function; } operator bool() const { return !is_null(); } diff --git a/Kernel/PIC.h b/Kernel/PIC.h index 2f6304139c9..7b0dcbe6a51 100644 --- a/Kernel/PIC.h +++ b/Kernel/PIC.h @@ -15,7 +15,10 @@ word get_irr(); class IRQHandlerScope { public: - explicit IRQHandlerScope(byte irq) : m_irq(irq) { } + explicit IRQHandlerScope(byte irq) + : m_irq(irq) + { + } ~IRQHandlerScope() { PIC::eoi(m_irq); } private: diff --git a/Kernel/PhysicalAddress.h b/Kernel/PhysicalAddress.h index 1f8ff12b4f9..6fd869dca69 100644 --- a/Kernel/PhysicalAddress.h +++ b/Kernel/PhysicalAddress.h @@ -2,8 +2,11 @@ class PhysicalAddress { public: - PhysicalAddress() { } - explicit PhysicalAddress(dword address) : m_address(address) { } + PhysicalAddress() {} + explicit PhysicalAddress(dword address) + : m_address(address) + { + } PhysicalAddress offset(dword o) const { return PhysicalAddress(m_address + o); } dword get() const { return m_address; } @@ -22,4 +25,3 @@ public: private: dword m_address { 0 }; }; - diff --git a/Kernel/Process.h b/Kernel/Process.h index 328cb3a7880..242219d889a 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -1,18 +1,18 @@ #pragma once -#include -#include #include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #include class ELFLoader; @@ -24,9 +24,11 @@ class ProcessTracer; void kgettimeofday(timeval&); -class Process : public InlineLinkedListNode, public Weakable { +class Process : public InlineLinkedListNode + , public Weakable { friend class InlineLinkedListNode; friend class Thread; + public: static Process* create_kernel_process(String&& name, void (*entry)()); static Process* create_user_process(const String& path, uid_t, gid_t, pid_t ppid, int& error, Vector&& arguments = Vector(), Vector&& environment = Vector(), TTY* = nullptr); @@ -35,14 +37,16 @@ public: static Vector all_pids(); static Vector all_processes(); - enum Priority { + enum Priority + { IdlePriority, LowPriority, NormalPriority, HighPriority, }; - enum RingLevel { + enum RingLevel + { Ring0 = 0, Ring3 = 3, }; @@ -83,10 +87,14 @@ public: FileDescriptor* file_descriptor(int fd); const FileDescriptor* file_descriptor(int fd) const; - template static void for_each(Callback); - template static void for_each_in_pgrp(pid_t, Callback); - template void for_each_child(Callback); - template void for_each_thread(Callback) const; + template + static void for_each(Callback); + template + static void for_each_in_pgrp(pid_t, Callback); + template + void for_each_child(Callback); + template + void for_each_thread(Callback) const; void die(); void finalize(); @@ -179,7 +187,7 @@ public: int sys$getsockname(int sockfd, sockaddr* addr, socklen_t* addrlen); int sys$getpeername(int sockfd, sockaddr* addr, socklen_t* addrlen); int sys$restore_signal_mask(dword mask); - int sys$create_thread(int(*)(void*), void*); + int sys$create_thread(int (*)(void*), void*); void sys$exit_thread(int code); int sys$rename(const char* oldpath, const char* newpath); int sys$systrace(pid_t); @@ -216,8 +224,10 @@ public: bool validate_read(const void*, ssize_t) const; bool validate_write(void*, ssize_t) const; bool validate_read_str(const char* str); - template bool validate_read_typed(T* value, size_t count = 1) { return validate_read(value, sizeof(T) * count); } - template bool validate_write_typed(T* value, size_t count = 1) { return validate_write(value, sizeof(T) * count); } + template + bool validate_read_typed(T* value, size_t count = 1) { return validate_read(value, sizeof(T) * count); } + template + bool validate_write_typed(T* value, size_t count = 1) { return validate_write(value, sizeof(T) * count); } Inode& cwd_inode(); Inode* executable_inode() { return m_executable.ptr(); } @@ -365,6 +375,7 @@ public: Process* operator->() { return &m_process; } Process& operator*() { return m_process; } + private: Process& m_process; }; diff --git a/Kernel/ProcessTracer.h b/Kernel/ProcessTracer.h index 9db8aa60a46..b0b0321b67b 100644 --- a/Kernel/ProcessTracer.h +++ b/Kernel/ProcessTracer.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include class ProcessTracer : public File { diff --git a/Kernel/RTC.h b/Kernel/RTC.h index 7fe25b33927..3ae5a441a5f 100644 --- a/Kernel/RTC.h +++ b/Kernel/RTC.h @@ -10,4 +10,3 @@ time_t boot_time(); void read_registers(unsigned& year, unsigned& month, unsigned& day, unsigned& hour, unsigned& minute, unsigned& second); } - diff --git a/Kernel/Scheduler.h b/Kernel/Scheduler.h index da3c5c8e3e8..76b4a8d070d 100644 --- a/Kernel/Scheduler.h +++ b/Kernel/Scheduler.h @@ -26,6 +26,7 @@ public: static Process* colonel(); static bool is_active(); static void beep(); + private: static void prepare_for_iret_to_new_process(); }; diff --git a/Kernel/SharedMemory.h b/Kernel/SharedMemory.h index ffbb7ac4687..4c8520ce12b 100644 --- a/Kernel/SharedMemory.h +++ b/Kernel/SharedMemory.h @@ -1,11 +1,11 @@ #pragma once -#include -#include #include +#include +#include +#include #include #include -#include class VMObject; diff --git a/Kernel/StdLib.h b/Kernel/StdLib.h index 3f32de47977..6fa43e3563d 100644 --- a/Kernel/StdLib.h +++ b/Kernel/StdLib.h @@ -12,12 +12,11 @@ char* strncpy(char*, const char*, size_t); int strcmp(char const*, const char*); size_t strlen(const char*); void* memset(void*, int, size_t); -char *strdup(const char*); +char* strdup(const char*); int memcmp(const void*, const void*, size_t); char* strrchr(const char* str, int ch); void* memmove(void* dest, const void* src, size_t n); inline word ntohs(word w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); } inline word htons(word w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); } - } diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index 2d093f6a748..c6ff1bc686b 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -3,116 +3,116 @@ #include #include -#define ENUMERATE_SYSCALLS \ - __ENUMERATE_SYSCALL(sleep) \ - __ENUMERATE_SYSCALL(yield) \ - __ENUMERATE_SYSCALL(putch) \ - __ENUMERATE_SYSCALL(open) \ - __ENUMERATE_SYSCALL(close) \ - __ENUMERATE_SYSCALL(read) \ - __ENUMERATE_SYSCALL(lseek) \ - __ENUMERATE_SYSCALL(kill) \ - __ENUMERATE_SYSCALL(getuid) \ - __ENUMERATE_SYSCALL(exit) \ - __ENUMERATE_SYSCALL(getgid) \ - __ENUMERATE_SYSCALL(getpid) \ - __ENUMERATE_SYSCALL(waitpid) \ - __ENUMERATE_SYSCALL(mmap) \ - __ENUMERATE_SYSCALL(munmap) \ - __ENUMERATE_SYSCALL(get_dir_entries) \ - __ENUMERATE_SYSCALL(lstat) \ - __ENUMERATE_SYSCALL(getcwd) \ - __ENUMERATE_SYSCALL(gettimeofday) \ - __ENUMERATE_SYSCALL(gethostname) \ - __ENUMERATE_SYSCALL(chdir) \ - __ENUMERATE_SYSCALL(uname) \ - __ENUMERATE_SYSCALL(set_mmap_name) \ - __ENUMERATE_SYSCALL(readlink) \ - __ENUMERATE_SYSCALL(write) \ - __ENUMERATE_SYSCALL(ttyname_r) \ - __ENUMERATE_SYSCALL(stat) \ - __ENUMERATE_SYSCALL(getsid) \ - __ENUMERATE_SYSCALL(setsid) \ - __ENUMERATE_SYSCALL(getpgid) \ - __ENUMERATE_SYSCALL(setpgid) \ - __ENUMERATE_SYSCALL(getpgrp) \ - __ENUMERATE_SYSCALL(fork) \ - __ENUMERATE_SYSCALL(execve) \ - __ENUMERATE_SYSCALL(geteuid) \ - __ENUMERATE_SYSCALL(getegid) \ - __ENUMERATE_SYSCALL(isatty) \ - __ENUMERATE_SYSCALL(getdtablesize) \ - __ENUMERATE_SYSCALL(dup) \ - __ENUMERATE_SYSCALL(dup2) \ - __ENUMERATE_SYSCALL(sigaction) \ - __ENUMERATE_SYSCALL(getppid) \ - __ENUMERATE_SYSCALL(umask) \ - __ENUMERATE_SYSCALL(getgroups) \ - __ENUMERATE_SYSCALL(setgroups) \ - __ENUMERATE_SYSCALL(sigreturn) \ - __ENUMERATE_SYSCALL(sigprocmask) \ - __ENUMERATE_SYSCALL(sigpending) \ - __ENUMERATE_SYSCALL(pipe) \ - __ENUMERATE_SYSCALL(killpg) \ - __ENUMERATE_SYSCALL(setuid) \ - __ENUMERATE_SYSCALL(setgid) \ - __ENUMERATE_SYSCALL(alarm) \ - __ENUMERATE_SYSCALL(fstat) \ - __ENUMERATE_SYSCALL(access) \ - __ENUMERATE_SYSCALL(fcntl) \ - __ENUMERATE_SYSCALL(ioctl) \ - __ENUMERATE_SYSCALL(mkdir) \ - __ENUMERATE_SYSCALL(times) \ - __ENUMERATE_SYSCALL(utime) \ - __ENUMERATE_SYSCALL(sync) \ - __ENUMERATE_SYSCALL(ptsname_r) \ - __ENUMERATE_SYSCALL(select) \ - __ENUMERATE_SYSCALL(unlink) \ - __ENUMERATE_SYSCALL(poll) \ - __ENUMERATE_SYSCALL(read_tsc) \ - __ENUMERATE_SYSCALL(rmdir) \ - __ENUMERATE_SYSCALL(chmod) \ - __ENUMERATE_SYSCALL(usleep) \ - __ENUMERATE_SYSCALL(socket) \ - __ENUMERATE_SYSCALL(bind) \ - __ENUMERATE_SYSCALL(accept) \ - __ENUMERATE_SYSCALL(listen) \ - __ENUMERATE_SYSCALL(connect) \ - __ENUMERATE_SYSCALL(create_shared_buffer) \ - __ENUMERATE_SYSCALL(get_shared_buffer) \ - __ENUMERATE_SYSCALL(release_shared_buffer) \ - __ENUMERATE_SYSCALL(link) \ - __ENUMERATE_SYSCALL(chown) \ - __ENUMERATE_SYSCALL(fchmod) \ - __ENUMERATE_SYSCALL(symlink) \ - __ENUMERATE_SYSCALL(restore_signal_mask) \ +#define ENUMERATE_SYSCALLS \ + __ENUMERATE_SYSCALL(sleep) \ + __ENUMERATE_SYSCALL(yield) \ + __ENUMERATE_SYSCALL(putch) \ + __ENUMERATE_SYSCALL(open) \ + __ENUMERATE_SYSCALL(close) \ + __ENUMERATE_SYSCALL(read) \ + __ENUMERATE_SYSCALL(lseek) \ + __ENUMERATE_SYSCALL(kill) \ + __ENUMERATE_SYSCALL(getuid) \ + __ENUMERATE_SYSCALL(exit) \ + __ENUMERATE_SYSCALL(getgid) \ + __ENUMERATE_SYSCALL(getpid) \ + __ENUMERATE_SYSCALL(waitpid) \ + __ENUMERATE_SYSCALL(mmap) \ + __ENUMERATE_SYSCALL(munmap) \ + __ENUMERATE_SYSCALL(get_dir_entries) \ + __ENUMERATE_SYSCALL(lstat) \ + __ENUMERATE_SYSCALL(getcwd) \ + __ENUMERATE_SYSCALL(gettimeofday) \ + __ENUMERATE_SYSCALL(gethostname) \ + __ENUMERATE_SYSCALL(chdir) \ + __ENUMERATE_SYSCALL(uname) \ + __ENUMERATE_SYSCALL(set_mmap_name) \ + __ENUMERATE_SYSCALL(readlink) \ + __ENUMERATE_SYSCALL(write) \ + __ENUMERATE_SYSCALL(ttyname_r) \ + __ENUMERATE_SYSCALL(stat) \ + __ENUMERATE_SYSCALL(getsid) \ + __ENUMERATE_SYSCALL(setsid) \ + __ENUMERATE_SYSCALL(getpgid) \ + __ENUMERATE_SYSCALL(setpgid) \ + __ENUMERATE_SYSCALL(getpgrp) \ + __ENUMERATE_SYSCALL(fork) \ + __ENUMERATE_SYSCALL(execve) \ + __ENUMERATE_SYSCALL(geteuid) \ + __ENUMERATE_SYSCALL(getegid) \ + __ENUMERATE_SYSCALL(isatty) \ + __ENUMERATE_SYSCALL(getdtablesize) \ + __ENUMERATE_SYSCALL(dup) \ + __ENUMERATE_SYSCALL(dup2) \ + __ENUMERATE_SYSCALL(sigaction) \ + __ENUMERATE_SYSCALL(getppid) \ + __ENUMERATE_SYSCALL(umask) \ + __ENUMERATE_SYSCALL(getgroups) \ + __ENUMERATE_SYSCALL(setgroups) \ + __ENUMERATE_SYSCALL(sigreturn) \ + __ENUMERATE_SYSCALL(sigprocmask) \ + __ENUMERATE_SYSCALL(sigpending) \ + __ENUMERATE_SYSCALL(pipe) \ + __ENUMERATE_SYSCALL(killpg) \ + __ENUMERATE_SYSCALL(setuid) \ + __ENUMERATE_SYSCALL(setgid) \ + __ENUMERATE_SYSCALL(alarm) \ + __ENUMERATE_SYSCALL(fstat) \ + __ENUMERATE_SYSCALL(access) \ + __ENUMERATE_SYSCALL(fcntl) \ + __ENUMERATE_SYSCALL(ioctl) \ + __ENUMERATE_SYSCALL(mkdir) \ + __ENUMERATE_SYSCALL(times) \ + __ENUMERATE_SYSCALL(utime) \ + __ENUMERATE_SYSCALL(sync) \ + __ENUMERATE_SYSCALL(ptsname_r) \ + __ENUMERATE_SYSCALL(select) \ + __ENUMERATE_SYSCALL(unlink) \ + __ENUMERATE_SYSCALL(poll) \ + __ENUMERATE_SYSCALL(read_tsc) \ + __ENUMERATE_SYSCALL(rmdir) \ + __ENUMERATE_SYSCALL(chmod) \ + __ENUMERATE_SYSCALL(usleep) \ + __ENUMERATE_SYSCALL(socket) \ + __ENUMERATE_SYSCALL(bind) \ + __ENUMERATE_SYSCALL(accept) \ + __ENUMERATE_SYSCALL(listen) \ + __ENUMERATE_SYSCALL(connect) \ + __ENUMERATE_SYSCALL(create_shared_buffer) \ + __ENUMERATE_SYSCALL(get_shared_buffer) \ + __ENUMERATE_SYSCALL(release_shared_buffer) \ + __ENUMERATE_SYSCALL(link) \ + __ENUMERATE_SYSCALL(chown) \ + __ENUMERATE_SYSCALL(fchmod) \ + __ENUMERATE_SYSCALL(symlink) \ + __ENUMERATE_SYSCALL(restore_signal_mask) \ __ENUMERATE_SYSCALL(get_shared_buffer_size) \ - __ENUMERATE_SYSCALL(seal_shared_buffer) \ - __ENUMERATE_SYSCALL(sendto) \ - __ENUMERATE_SYSCALL(recvfrom) \ - __ENUMERATE_SYSCALL(getsockopt) \ - __ENUMERATE_SYSCALL(setsockopt) \ - __ENUMERATE_SYSCALL(create_thread) \ - __ENUMERATE_SYSCALL(gettid) \ - __ENUMERATE_SYSCALL(donate) \ - __ENUMERATE_SYSCALL(rename) \ - __ENUMERATE_SYSCALL(shm_open) \ - __ENUMERATE_SYSCALL(shm_close) \ - __ENUMERATE_SYSCALL(ftruncate) \ - __ENUMERATE_SYSCALL(systrace) \ - __ENUMERATE_SYSCALL(exit_thread) \ - __ENUMERATE_SYSCALL(mknod) \ - __ENUMERATE_SYSCALL(writev) \ - __ENUMERATE_SYSCALL(beep) \ - __ENUMERATE_SYSCALL(getsockname) \ - __ENUMERATE_SYSCALL(getpeername) \ - + __ENUMERATE_SYSCALL(seal_shared_buffer) \ + __ENUMERATE_SYSCALL(sendto) \ + __ENUMERATE_SYSCALL(recvfrom) \ + __ENUMERATE_SYSCALL(getsockopt) \ + __ENUMERATE_SYSCALL(setsockopt) \ + __ENUMERATE_SYSCALL(create_thread) \ + __ENUMERATE_SYSCALL(gettid) \ + __ENUMERATE_SYSCALL(donate) \ + __ENUMERATE_SYSCALL(rename) \ + __ENUMERATE_SYSCALL(shm_open) \ + __ENUMERATE_SYSCALL(shm_close) \ + __ENUMERATE_SYSCALL(ftruncate) \ + __ENUMERATE_SYSCALL(systrace) \ + __ENUMERATE_SYSCALL(exit_thread) \ + __ENUMERATE_SYSCALL(mknod) \ + __ENUMERATE_SYSCALL(writev) \ + __ENUMERATE_SYSCALL(beep) \ + __ENUMERATE_SYSCALL(getsockname) \ + __ENUMERATE_SYSCALL(getpeername) namespace Syscall { -enum Function { +enum Function +{ #undef __ENUMERATE_SYSCALL -#define __ENUMERATE_SYSCALL(x) SC_ ##x , +#define __ENUMERATE_SYSCALL(x) SC_##x, ENUMERATE_SYSCALLS #undef __ENUMERATE_SYSCALL }; @@ -121,8 +121,10 @@ inline constexpr const char* to_string(Function function) { switch (function) { #undef __ENUMERATE_SYSCALL -#define __ENUMERATE_SYSCALL(x) case SC_ ##x: return #x; - ENUMERATE_SYSCALLS +#define __ENUMERATE_SYSCALL(x) \ + case SC_##x: \ + return #x; + ENUMERATE_SYSCALLS #undef __ENUMERATE_SYSCALL } return "Unknown"; @@ -152,7 +154,7 @@ struct SC_sendto_params { const void* data; size_t data_length; int flags; - const void* addr; // const sockaddr* + const void* addr; // const sockaddr* size_t addr_length; // socklen_t }; @@ -161,7 +163,7 @@ struct SC_recvfrom_params { void* buffer; size_t buffer_length; int flags; - void* addr; // sockaddr* + void* addr; // sockaddr* void* addr_length; // socklen_t* }; @@ -187,7 +189,10 @@ int sync(); inline dword invoke(Function function) { dword result; - asm volatile("int $0x82":"=a"(result):"a"(function):"memory"); + asm volatile("int $0x82" + : "=a"(result) + : "a"(function) + : "memory"); return result; } @@ -195,7 +200,10 @@ template inline dword invoke(Function function, T1 arg1) { dword result; - asm volatile("int $0x82":"=a"(result):"a"(function),"d"((dword)arg1):"memory"); + asm volatile("int $0x82" + : "=a"(result) + : "a"(function), "d"((dword)arg1) + : "memory"); return result; } @@ -203,7 +211,10 @@ template inline dword invoke(Function function, T1 arg1, T2 arg2) { dword result; - asm volatile("int $0x82":"=a"(result):"a"(function),"d"((dword)arg1),"c"((dword)arg2):"memory"); + asm volatile("int $0x82" + : "=a"(result) + : "a"(function), "d"((dword)arg1), "c"((dword)arg2) + : "memory"); return result; } @@ -211,7 +222,10 @@ template inline dword invoke(Function function, T1 arg1, T2 arg2, T3 arg3) { dword result; - asm volatile("int $0x82":"=a"(result):"a"(function),"d"((dword)arg1),"c"((dword)arg2),"b"((dword)arg3):"memory"); + asm volatile("int $0x82" + : "=a"(result) + : "a"(function), "d"((dword)arg1), "c"((dword)arg2), "b"((dword)arg3) + : "memory"); return result; } #endif @@ -219,7 +233,7 @@ inline dword invoke(Function function, T1 arg1, T2 arg2, T3 arg3) } #undef __ENUMERATE_SYSCALL -#define __ENUMERATE_SYSCALL(x) using Syscall::SC_ ##x; - ENUMERATE_SYSCALLS +#define __ENUMERATE_SYSCALL(x) using Syscall::SC_##x; +ENUMERATE_SYSCALLS #undef __ENUMERATE_SYSCALL #define syscall Syscall::invoke diff --git a/Kernel/TTY/PTYMultiplexer.h b/Kernel/TTY/PTYMultiplexer.h index c5979ba9917..1d06d6f4d81 100644 --- a/Kernel/TTY/PTYMultiplexer.h +++ b/Kernel/TTY/PTYMultiplexer.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include class MasterPTY; diff --git a/Kernel/TTY/SlavePTY.h b/Kernel/TTY/SlavePTY.h index f764c436494..ffe7ebd8b1a 100644 --- a/Kernel/TTY/SlavePTY.h +++ b/Kernel/TTY/SlavePTY.h @@ -35,4 +35,3 @@ private: InodeIdentifier m_devpts_inode_id; String m_tty_name; }; - diff --git a/Kernel/TTY/TTY.h b/Kernel/TTY/TTY.h index 56fbcb3c6f8..e6d489579c8 100644 --- a/Kernel/TTY/TTY.h +++ b/Kernel/TTY/TTY.h @@ -52,4 +52,3 @@ private: unsigned short m_rows { 0 }; unsigned short m_columns { 0 }; }; - diff --git a/Kernel/TTY/VirtualConsole.h b/Kernel/TTY/VirtualConsole.h index eb0c11b3fe9..8e89fac8535 100644 --- a/Kernel/TTY/VirtualConsole.h +++ b/Kernel/TTY/VirtualConsole.h @@ -1,13 +1,19 @@ #pragma once -#include -#include #include "Console.h" +#include +#include -class VirtualConsole final : public TTY, public KeyboardClient, public ConsoleImplementation { +class VirtualConsole final : public TTY + , public KeyboardClient + , public ConsoleImplementation { AK_MAKE_ETERNAL public: - enum InitialContents { Cleared, AdoptCurrentVGABuffer }; + enum InitialContents + { + Cleared, + AdoptCurrentVGABuffer + }; VirtualConsole(unsigned index, InitialContents = Cleared); virtual ~VirtualConsole() override; @@ -67,7 +73,8 @@ private: void execute_escape_sequence(byte final); - enum EscapeState { + enum EscapeState + { Normal, ExpectBracket, ExpectParameter, diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 11091f6d3b8..40f7abba118 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -1,15 +1,15 @@ #pragma once -#include -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include +#include +#include class Alarm; class FileDescriptor; @@ -17,7 +17,11 @@ class Process; class Region; class Thread; -enum class ShouldUnblockThread { No = 0, Yes }; +enum class ShouldUnblockThread +{ + No = 0, + Yes +}; struct SignalActionData { LinearAddress handler_or_sigaction; @@ -31,6 +35,7 @@ extern InlineLinkedList* g_nonrunnable_threads; class Thread : public InlineLinkedListNode { friend class Process; friend class Scheduler; + public: explicit Thread(Process&); ~Thread(); @@ -49,7 +54,8 @@ public: void finalize(); - enum State : byte { + enum State : byte + { Invalid = 0, Runnable, Running, @@ -136,11 +142,16 @@ public: InlineLinkedList* thread_list() { return m_thread_list; } void set_thread_list(InlineLinkedList*); - template static void for_each_in_state(State, Callback); - template static void for_each_living(Callback); - template static void for_each_runnable(Callback); - template static void for_each_nonrunnable(Callback); - template static void for_each(Callback); + template + static void for_each_in_state(State, Callback); + template + static void for_each_living(Callback); + template + static void for_each_runnable(Callback); + template + static void for_each_nonrunnable(Callback); + template + static void for_each(Callback); static bool is_runnable_state(Thread::State state) { diff --git a/Kernel/UnixTypes.h b/Kernel/UnixTypes.h index 62ed18d1c6d..4e092e8e881 100644 --- a/Kernel/UnixTypes.h +++ b/Kernel/UnixTypes.h @@ -56,160 +56,160 @@ #define VEOL2 16 /* c_iflag bits */ -#define IGNBRK 0000001 -#define BRKINT 0000002 -#define IGNPAR 0000004 -#define PARMRK 0000010 -#define INPCK 0000020 -#define ISTRIP 0000040 -#define INLCR 0000100 -#define IGNCR 0000200 -#define ICRNL 0000400 -#define IUCLC 0001000 -#define IXON 0002000 -#define IXANY 0004000 -#define IXOFF 0010000 -#define IMAXBEL 0020000 -#define IUTF8 0040000 +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 +#define IUTF8 0040000 /* c_oflag bits */ -#define OPOST 0000001 -#define OLCUC 0000002 -#define ONLCR 0000004 -#define OCRNL 0000010 -#define ONOCR 0000020 -#define ONLRET 0000040 -#define OFILL 0000100 -#define OFDEL 0000200 +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 #if defined __USE_MISC || defined __USE_XOPEN -# define NLDLY 0000400 -# define NL0 0000000 -# define NL1 0000400 -# define CRDLY 0003000 -# define CR0 0000000 -# define CR1 0001000 -# define CR2 0002000 -# define CR3 0003000 -# define TABDLY 0014000 -# define TAB0 0000000 -# define TAB1 0004000 -# define TAB2 0010000 -# define TAB3 0014000 -# define BSDLY 0020000 -# define BS0 0000000 -# define BS1 0020000 -# define FFDLY 0100000 -# define FF0 0000000 -# define FF1 0100000 +# define NLDLY 0000400 +# define NL0 0000000 +# define NL1 0000400 +# define CRDLY 0003000 +# define CR0 0000000 +# define CR1 0001000 +# define CR2 0002000 +# define CR3 0003000 +# define TABDLY 0014000 +# define TAB0 0000000 +# define TAB1 0004000 +# define TAB2 0010000 +# define TAB3 0014000 +# define BSDLY 0020000 +# define BS0 0000000 +# define BS1 0020000 +# define FFDLY 0100000 +# define FF0 0000000 +# define FF1 0100000 #endif -#define VTDLY 0040000 -#define VT0 0000000 -#define VT1 0040000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 #ifdef __USE_MISC -# define XTABS 0014000 +# define XTABS 0014000 #endif /* c_cflag bit meaning */ #ifdef __USE_MISC -# define CBAUD 0010017 +# define CBAUD 0010017 #endif -#define B0 0000000 /* hang up */ -#define B50 0000001 -#define B75 0000002 -#define B110 0000003 -#define B134 0000004 -#define B150 0000005 -#define B200 0000006 -#define B300 0000007 -#define B600 0000010 -#define B1200 0000011 -#define B1800 0000012 -#define B2400 0000013 -#define B4800 0000014 -#define B9600 0000015 -#define B19200 0000016 -#define B38400 0000017 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 #ifdef __USE_MISC -# define EXTA B19200 -# define EXTB B38400 +# define EXTA B19200 +# define EXTB B38400 #endif -#define CSIZE 0000060 -#define CS5 0000000 -#define CS6 0000020 -#define CS7 0000040 -#define CS8 0000060 -#define CSTOPB 0000100 -#define CREAD 0000200 -#define PARENB 0000400 -#define PARODD 0001000 -#define HUPCL 0002000 -#define CLOCAL 0004000 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 #ifdef __USE_MISC -# define CBAUDEX 0010000 +# define CBAUDEX 0010000 #endif -#define B57600 0010001 -#define B115200 0010002 -#define B230400 0010003 -#define B460800 0010004 -#define B500000 0010005 -#define B576000 0010006 -#define B921600 0010007 -#define B1000000 0010010 -#define B1152000 0010011 -#define B1500000 0010012 -#define B2000000 0010013 -#define B2500000 0010014 -#define B3000000 0010015 -#define B3500000 0010016 -#define B4000000 0010017 +#define B57600 0010001 +#define B115200 0010002 +#define B230400 0010003 +#define B460800 0010004 +#define B500000 0010005 +#define B576000 0010006 +#define B921600 0010007 +#define B1000000 0010010 +#define B1152000 0010011 +#define B1500000 0010012 +#define B2000000 0010013 +#define B2500000 0010014 +#define B3000000 0010015 +#define B3500000 0010016 +#define B4000000 0010017 #define __MAX_BAUD B4000000 #ifdef __USE_MISC -# define CIBAUD 002003600000 /* input baud rate (not used) */ -# define CMSPAR 010000000000 /* mark or space (stick) parity */ -# define CRTSCTS 020000000000 /* flow control */ +# define CIBAUD 002003600000 /* input baud rate (not used) */ +# define CMSPAR 010000000000 /* mark or space (stick) parity */ +# define CRTSCTS 020000000000 /* flow control */ #endif /* c_lflag bits */ -#define ISIG 0000001 -#define ICANON 0000002 +#define ISIG 0000001 +#define ICANON 0000002 #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K) -# define XCASE 0000004 +# define XCASE 0000004 #endif -#define ECHO 0000010 -#define ECHOE 0000020 -#define ECHOK 0000040 -#define ECHONL 0000100 -#define NOFLSH 0000200 -#define TOSTOP 0000400 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 #ifdef __USE_MISC -# define ECHOCTL 0001000 -# define ECHOPRT 0002000 -# define ECHOKE 0004000 -# define FLUSHO 0010000 -# define PENDIN 0040000 +# define ECHOCTL 0001000 +# define ECHOPRT 0002000 +# define ECHOKE 0004000 +# define FLUSHO 0010000 +# define PENDIN 0040000 #endif -#define IEXTEN 0100000 +#define IEXTEN 0100000 #ifdef __USE_MISC -# define EXTPROC 0200000 +# define EXTPROC 0200000 #endif /* tcflow() and TCXONC use these */ -#define TCOOFF 0 -#define TCOON 1 -#define TCIOFF 2 -#define TCION 3 +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 /* tcflush() and TCFLSH use these */ -#define TCIFLUSH 0 -#define TCOFLUSH 1 -#define TCIOFLUSH 2 +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 /* tcsetattr uses these */ -#define TCSANOW 0 -#define TCSADRAIN 1 -#define TCSAFLUSH 2 +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 struct winsize { unsigned short ws_row; @@ -281,36 +281,36 @@ struct termios { tcflag_t c_oflag; tcflag_t c_cflag; tcflag_t c_lflag; - cc_t c_cc[NCCS]; - speed_t c_ispeed; - speed_t c_ospeed; + cc_t c_cc[NCCS]; + speed_t c_ispeed; + speed_t c_ospeed; }; struct stat { - dev_t st_dev; /* ID of device containing file */ - ino_t st_ino; /* inode number */ - mode_t st_mode; /* protection */ - nlink_t st_nlink; /* number of hard links */ - uid_t st_uid; /* user ID of owner */ - gid_t st_gid; /* group ID of owner */ - dev_t st_rdev; /* device ID (if special file) */ - off_t st_size; /* total size, in bytes */ + dev_t st_dev; /* ID of device containing file */ + ino_t st_ino; /* inode number */ + mode_t st_mode; /* protection */ + nlink_t st_nlink; /* number of hard links */ + uid_t st_uid; /* user ID of owner */ + gid_t st_gid; /* group ID of owner */ + dev_t st_rdev; /* device ID (if special file) */ + off_t st_size; /* total size, in bytes */ blksize_t st_blksize; /* blocksize for file system I/O */ - blkcnt_t st_blocks; /* number of 512B blocks allocated */ - time_t st_atime; /* time of last access */ - time_t st_mtime; /* time of last modification */ - time_t st_ctime; /* time of last status change */ + blkcnt_t st_blocks; /* number of 512B blocks allocated */ + time_t st_atime; /* time of last access */ + time_t st_mtime; /* time of last modification */ + time_t st_ctime; /* time of last status change */ }; -#define POLLIN (1u << 0) -#define POLLPRI (1u << 2) -#define POLLOUT (1u << 3) -#define POLLERR (1u << 4) -#define POLLHUP (1u << 5) +#define POLLIN (1u << 0) +#define POLLPRI (1u << 2) +#define POLLOUT (1u << 3) +#define POLLERR (1u << 4) +#define POLLHUP (1u << 5) #define POLLNVAL (1u << 6) struct pollfd { - int fd; + int fd; short events; short revents; }; @@ -345,7 +345,7 @@ struct sockaddr { char sa_data[14]; }; -#define S_IFSOCK 0140000 +#define S_IFSOCK 0140000 #define UNIX_PATH_MAX 108 struct sockaddr_un { @@ -388,7 +388,8 @@ struct utsname { char machine[UTSNAME_ENTRY_LEN]; }; -struct [[gnu::packed]] FarPtr { +struct [[gnu::packed]] FarPtr +{ dword offset { 0 }; word selector { 0 }; }; diff --git a/Kernel/VM/MemoryManager.h b/Kernel/VM/MemoryManager.h index 3615826fb3b..b45cfcbf006 100644 --- a/Kernel/VM/MemoryManager.h +++ b/Kernel/VM/MemoryManager.h @@ -1,27 +1,28 @@ #pragma once -#include #include "i386.h" -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include #include +#include #include #include #include #include -#include -#define PAGE_ROUND_UP(x) ((((dword)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1))) +#define PAGE_ROUND_UP(x) ((((dword)(x)) + PAGE_SIZE - 1) & (~(PAGE_SIZE - 1))) class SynthFSInode; -enum class PageFaultResponse { +enum class PageFaultResponse +{ ShouldCrash, Continue, }; @@ -36,6 +37,7 @@ class MemoryManager { friend class VMObject; friend ByteBuffer procfs$mm(InodeIdentifier); friend ByteBuffer procfs$memstat(InodeIdentifier); + public: [[gnu::pure]] static MemoryManager& the(); @@ -54,7 +56,11 @@ public: bool validate_user_read(const Process&, LinearAddress) const; bool validate_user_write(const Process&, LinearAddress) const; - enum class ShouldZeroFill { No, Yes }; + enum class ShouldZeroFill + { + No, + Yes + }; RetainPtr allocate_physical_page(ShouldZeroFill); RetainPtr allocate_supervisor_physical_page(); @@ -106,7 +112,10 @@ private: PageDirectory& kernel_page_directory() { return *m_kernel_page_directory; } struct PageDirectoryEntry { - explicit PageDirectoryEntry(dword* pde) : m_pde(pde) { } + explicit PageDirectoryEntry(dword* pde) + : m_pde(pde) + { + } dword* page_table_base() { return reinterpret_cast(raw() & 0xfffff000u); } void set_page_table_base(dword value) @@ -118,7 +127,8 @@ private: dword raw() const { return *m_pde; } dword* ptr() { return m_pde; } - enum Flags { + enum Flags + { Present = 1 << 0, ReadWrite = 1 << 1, UserSupervisor = 1 << 2, @@ -153,7 +163,10 @@ private: }; struct PageTableEntry { - explicit PageTableEntry(dword* pte) : m_pte(pte) { } + explicit PageTableEntry(dword* pte) + : m_pte(pte) + { + } dword* physical_page_base() { return reinterpret_cast(raw() & 0xfffff000u); } void set_physical_page_base(dword value) @@ -165,7 +178,8 @@ private: dword raw() const { return *m_pte; } dword* ptr() { return m_pte; } - enum Flags { + enum Flags + { Present = 1 << 0, ReadWrite = 1 << 1, UserSupervisor = 1 << 2, diff --git a/Kernel/VM/PageDirectory.h b/Kernel/VM/PageDirectory.h index 409a5f919c2..8207389ab79 100644 --- a/Kernel/VM/PageDirectory.h +++ b/Kernel/VM/PageDirectory.h @@ -1,13 +1,14 @@ #pragma once +#include +#include +#include #include #include -#include -#include -#include class PageDirectory : public Retainable { friend class MemoryManager; + public: static Retained create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr) { return adopt(*new PageDirectory(parent_range_allocator)); } static Retained create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); } diff --git a/Kernel/VM/PhysicalPage.h b/Kernel/VM/PhysicalPage.h index 2d9cd886779..bf2726bcef6 100644 --- a/Kernel/VM/PhysicalPage.h +++ b/Kernel/VM/PhysicalPage.h @@ -1,13 +1,14 @@ #pragma once +#include #include #include -#include class PhysicalPage { friend class MemoryManager; friend class PageDirectory; friend class VMObject; + public: PhysicalAddress paddr() const { return m_paddr; } @@ -35,7 +36,7 @@ public: private: PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true); - ~PhysicalPage() { } + ~PhysicalPage() {} void return_to_freelist(); diff --git a/Kernel/VM/RangeAllocator.h b/Kernel/VM/RangeAllocator.h index e80e1278ca6..7381aa5db76 100644 --- a/Kernel/VM/RangeAllocator.h +++ b/Kernel/VM/RangeAllocator.h @@ -1,12 +1,13 @@ #pragma once -#include #include +#include class Range { friend class RangeAllocator; + public: - Range() { } + Range() {} Range(LinearAddress base, size_t size) : m_base(base) , m_size(size) diff --git a/Kernel/VM/Region.h b/Kernel/VM/Region.h index 806fa6460c7..254469cf1d4 100644 --- a/Kernel/VM/Region.h +++ b/Kernel/VM/Region.h @@ -10,6 +10,7 @@ class VMObject; class Region : public Retainable { friend class MemoryManager; + public: Region(const Range&, String&&, bool r, bool w, bool cow = false); Region(const Range&, Retained&&, size_t offset_in_vmo, String&&, bool r, bool w, bool cow = false); diff --git a/Kernel/VM/VMObject.h b/Kernel/VM/VMObject.h index 4a0fee7436d..0f7b9c4fea4 100644 --- a/Kernel/VM/VMObject.h +++ b/Kernel/VM/VMObject.h @@ -1,11 +1,11 @@ #pragma once -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #include #include #include @@ -13,8 +13,10 @@ class Inode; class PhysicalPage; -class VMObject : public Retainable, public Weakable { +class VMObject : public Retainable + , public Weakable { friend class MemoryManager; + public: static Retained create_file_backed(RetainPtr&&); static Retained create_anonymous(size_t); @@ -46,7 +48,8 @@ private: explicit VMObject(size_t); VMObject(PhysicalAddress, size_t); - template void for_each_region(Callback); + template + void for_each_region(Callback); String m_name; bool m_allow_cpu_caching { true }; diff --git a/Kernel/i386.h b/Kernel/i386.h index c770d452868..a323947d039 100644 --- a/Kernel/i386.h +++ b/Kernel/i386.h @@ -1,12 +1,13 @@ #pragma once -#include #include +#include #define PAGE_SIZE 4096 #define PAGE_MASK 0xfffff000 -struct [[gnu::packed]] TSS32 { +struct [[gnu::packed]] TSS32 +{ word backlink, __blh; dword esp0; word ss0, __ss0h; @@ -15,7 +16,7 @@ struct [[gnu::packed]] TSS32 { dword esp2; word ss2, __ss2h; dword cr3, eip, eflags; - dword eax,ecx,edx,ebx,esp,ebp,esi,edi; + dword eax, ecx, edx, ebx, esp, ebp, esi, edi; word es, __esh; word cs, __csh; word ss, __ssh; @@ -26,7 +27,8 @@ struct [[gnu::packed]] TSS32 { word trace, iomapbase; }; -union [[gnu::packed]] Descriptor { +union [[gnu::packed]] Descriptor +{ struct { word limit_lo; word base_lo; @@ -47,7 +49,8 @@ union [[gnu::packed]] Descriptor { dword high; }; - enum Type { + enum Type + { Invalid = 0, AvailableTSS_16bit = 0x1, LDT = 0x2, @@ -65,7 +68,7 @@ union [[gnu::packed]] Descriptor { void set_base(void* b) { - base_lo = (dword)(b) & 0xffff; + base_lo = (dword)(b)&0xffff; base_hi = ((dword)(b) >> 16) & 0xff; base_hi2 = ((dword)(b) >> 24) & 0xff; } @@ -97,22 +100,27 @@ void write_gdt_entry(word selector, Descriptor&); [[noreturn]] static inline void hang() { asm volatile("cli; hlt"); - for (;;) { } + for (;;) { + } } -#define LSW(x) ((dword)(x) & 0xFFFF) +#define LSW(x) ((dword)(x)&0xFFFF) #define MSW(x) (((dword)(x) >> 16) & 0xFFFF) -#define LSB(x) ((x) & 0xFF) -#define MSB(x) (((x)>>8) & 0xFF) +#define LSB(x) ((x)&0xFF) +#define MSB(x) (((x) >> 8) & 0xFF) -#define cli() asm volatile("cli" ::: "memory") -#define sti() asm volatile("sti" ::: "memory") -#define memory_barrier() asm volatile ("" ::: "memory") +#define cli() asm volatile("cli" :: \ + : "memory") +#define sti() asm volatile("sti" :: \ + : "memory") +#define memory_barrier() asm volatile("" :: \ + : "memory") inline dword cpu_cr3() { dword cr3; - asm volatile("movl %%cr3, %%eax":"=a"(cr3)); + asm volatile("movl %%cr3, %%eax" + : "=a"(cr3)); return cr3; } @@ -122,8 +130,7 @@ inline dword cpu_flags() asm volatile( "pushf\n" "pop %0\n" - :"=rm"(flags) - ::"memory"); + : "=rm"(flags)::"memory"); return flags; } @@ -173,15 +180,16 @@ private: #define IRQ_VECTOR_BASE 0x50 struct PageFaultFlags { -enum Flags { - NotPresent = 0x00, - ProtectionViolation = 0x01, - Read = 0x00, - Write = 0x02, - UserMode = 0x04, - SupervisorMode = 0x00, - InstructionFetch = 0x08, -}; + enum Flags + { + NotPresent = 0x00, + ProtectionViolation = 0x01, + Read = 0x00, + Write = 0x02, + UserMode = 0x04, + SupervisorMode = 0x00, + InstructionFetch = 0x08, + }; }; class PageFault { @@ -208,7 +216,8 @@ private: LinearAddress m_laddr; }; -struct [[gnu::packed]] RegisterDump { +struct [[gnu::packed]] RegisterDump +{ word ss; word gs; word fs; @@ -230,7 +239,8 @@ struct [[gnu::packed]] RegisterDump { word ss_if_crossRing; }; -struct [[gnu::packed]] RegisterDumpWithExceptionCode { +struct [[gnu::packed]] RegisterDumpWithExceptionCode +{ word ss; word gs; word fs; @@ -254,7 +264,8 @@ struct [[gnu::packed]] RegisterDumpWithExceptionCode { word ss_if_crossRing; }; -struct [[gnu::aligned(16)]] FPUState { +struct [[gnu::aligned(16)]] FPUState +{ byte buffer[512]; }; @@ -265,11 +276,14 @@ inline constexpr dword page_base_of(dword address) class CPUID { public: - CPUID(dword function) { asm volatile("cpuid" : "=a" (m_eax), "=b" (m_ebx), "=c" (m_ecx), "=d" (m_edx) : "a" (function), "c" (0)); } + CPUID(dword function) { asm volatile("cpuid" + : "=a"(m_eax), "=b"(m_ebx), "=c"(m_ecx), "=d"(m_edx) + : "a"(function), "c"(0)); } dword eax() const { return m_eax; } dword ebx() const { return m_ebx; } dword ecx() const { return m_ecx; } dword edx() const { return m_edx; } + private: dword m_eax { 0xffffffff }; dword m_ebx { 0xffffffff }; @@ -279,7 +293,8 @@ private: inline void read_tsc(dword& lsw, dword& msw) { - asm volatile("rdtsc":"=d"(msw),"=a"(lsw)); + asm volatile("rdtsc" + : "=d"(msw), "=a"(lsw)); } struct Stopwatch { @@ -290,6 +305,7 @@ struct Stopwatch { }; uint64_t qw { 0 }; }; + public: Stopwatch(const char* name) : m_name(name) diff --git a/Kernel/i8253.h b/Kernel/i8253.h index c537036f2ad..573399d1a12 100644 --- a/Kernel/i8253.h +++ b/Kernel/i8253.h @@ -2,26 +2,26 @@ #include -#define TICKS_PER_SECOND 1000 +#define TICKS_PER_SECOND 1000 /* Timer related ports */ -#define TIMER0_CTL 0x40 -#define TIMER1_CTL 0x41 -#define TIMER2_CTL 0x42 -#define PIT_CTL 0x43 +#define TIMER0_CTL 0x40 +#define TIMER1_CTL 0x41 +#define TIMER2_CTL 0x42 +#define PIT_CTL 0x43 /* Building blocks for PIT_CTL */ -#define TIMER0_SELECT 0x00 -#define TIMER1_SELECT 0x40 -#define TIMER2_SELECT 0x80 +#define TIMER0_SELECT 0x00 +#define TIMER1_SELECT 0x40 +#define TIMER2_SELECT 0x80 -#define MODE_COUNTDOWN 0x00 -#define MODE_ONESHOT 0x02 -#define MODE_RATE 0x04 -#define MODE_SQUARE_WAVE 0x06 +#define MODE_COUNTDOWN 0x00 +#define MODE_ONESHOT 0x02 +#define MODE_RATE 0x04 +#define MODE_SQUARE_WAVE 0x06 -#define WRITE_WORD 0x30 +#define WRITE_WORD 0x30 -#define BASE_FREQUENCY 1193182 +#define BASE_FREQUENCY 1193182 namespace PIT { diff --git a/Kernel/kstdio.h b/Kernel/kstdio.h index d44d215f643..00509e320cc 100644 --- a/Kernel/kstdio.h +++ b/Kernel/kstdio.h @@ -1,11 +1,11 @@ #pragma once extern "C" { -int dbgprintf(const char *fmt, ...); -int kprintf(const char *fmt, ...); -int ksprintf(char* buf, const char *fmt, ...); +int dbgprintf(const char* fmt, ...); +int kprintf(const char* fmt, ...); +int ksprintf(char* buf, const char* fmt, ...); } #ifndef USERLAND -#define printf dbgprintf +# define printf dbgprintf #endif diff --git a/Kernel/makeall.sh b/Kernel/makeall.sh index 09dbc404635..fc2fa28cad8 100755 --- a/Kernel/makeall.sh +++ b/Kernel/makeall.sh @@ -38,6 +38,7 @@ build_targets="$build_targets ." # the kernel for targ in $build_targets; do echo "Building $targ" + #(cd "$targ" && find . -name "*.c" -o -name "*.cpp" -o -name "*.h" -exec clang-format -i {} \;) $make_cmd -C "$targ" clean $make_cmd -C "$targ" diff --git a/LibC/SharedBuffer.h b/LibC/SharedBuffer.h index 33de7c7a6e4..24fd3715161 100644 --- a/LibC/SharedBuffer.h +++ b/LibC/SharedBuffer.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class SharedBuffer : public Retainable { public: diff --git a/LibC/alloca.h b/LibC/alloca.h index 08130193042..db619d9b438 100644 --- a/LibC/alloca.h +++ b/LibC/alloca.h @@ -1,4 +1,3 @@ #pragma once #define alloca __builtin_alloca - diff --git a/LibC/arpa/inet.h b/LibC/arpa/inet.h index ec2292ef67b..0c0c966a689 100644 --- a/LibC/arpa/inet.h +++ b/LibC/arpa/inet.h @@ -33,4 +33,3 @@ static inline uint32_t ntohl(uint32_t ns) } __END_DECLS - diff --git a/LibC/assert.h b/LibC/assert.h index 21e380fe4ed..9c86d09f0fb 100644 --- a/LibC/assert.h +++ b/LibC/assert.h @@ -6,16 +6,18 @@ __BEGIN_DECLS #ifdef DEBUG __attribute__((noreturn)) void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func); -#define assert(expr) ((expr) ? (void)0 : __assertion_failed(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__)) -#define ASSERT_NOT_REACHED() assert(false) +# define assert(expr) ((expr) ? (void)0 : __assertion_failed(# expr, __FILE__, __LINE__, __PRETTY_FUNCTION__)) +# define ASSERT_NOT_REACHED() assert(false) #else -#define assert(expr) -#define ASSERT_NOT_REACHED() CRASH() +# define assert(expr) +# define ASSERT_NOT_REACHED() CRASH() #endif -#define CRASH() do { asm volatile("ud2"); } while(0) +#define CRASH() \ + do { \ + asm volatile("ud2"); \ + } while (0) #define ASSERT assert #define RELEASE_ASSERT assert __END_DECLS - diff --git a/LibC/ctype.h b/LibC/ctype.h index 17ab57c4718..c551c3fc8e9 100644 --- a/LibC/ctype.h +++ b/LibC/ctype.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include __BEGIN_DECLS @@ -38,12 +38,12 @@ int isupper(int); #define isxdigit(c) (_ctype_[(int)(c)] & (_N | _X)) #define isspace(c) (_ctype_[(int)(c)] & (_S)) #define ispunct(c) (_ctype_[(int)(c)] & (_P)) -#define isprint(c) (_ctype_[(int)(c)] & (_P|_U|_L|_N|_B)) -#define isgraph(c) (_ctype_[(int)(c)] & (_P|_U|_L|_N)) +#define isprint(c) (_ctype_[(int)(c)] & (_P | _U | _L | _N | _B)) +#define isgraph(c) (_ctype_[(int)(c)] & (_P | _U | _L | _N)) #define islower(c) ((_ctype_[(int)(c)] & (_U | _L)) == _L) #define isupper(c) ((_ctype_[(int)(c)] & (_U | _L)) == _U) #define isascii(c) ((unsigned)c <= 127) -#define toascii(c) ((c) & 127) +#define toascii(c) ((c)&127) __END_DECLS diff --git a/LibC/dirent.h b/LibC/dirent.h index 9b0e77cdb30..27164519bf6 100644 --- a/LibC/dirent.h +++ b/LibC/dirent.h @@ -27,4 +27,3 @@ int closedir(DIR*); struct dirent* readdir(DIR*); __END_DECLS - diff --git a/LibC/dlfcn.h b/LibC/dlfcn.h index 0b9505fe624..f07144a9158 100644 --- a/LibC/dlfcn.h +++ b/LibC/dlfcn.h @@ -10,8 +10,8 @@ __BEGIN_DECLS #define RTLD_LOCAL 4 int dlclose(void*); -char *dlerror(); -void *dlopen(const char*, int); -void *dlsym(void*, const char*); +char* dlerror(); +void* dlopen(const char*, int); +void* dlsym(void*, const char*); __END_DECLS diff --git a/LibC/errno.h b/LibC/errno.h index 967cc18b37a..3d3bf850299 100644 --- a/LibC/errno.h +++ b/LibC/errno.h @@ -1,18 +1,18 @@ #pragma once -#include #include +#include #define __RETURN_WITH_ERRNO(rc, good_ret, bad_ret) \ - do { \ - if (rc < 0) { \ - errno = -rc; \ - return (bad_ret); \ - } else { \ - errno = 0; \ - return (good_ret); \ - } \ - } while(0) + do { \ + if (rc < 0) { \ + errno = -rc; \ + return (bad_ret); \ + } else { \ + errno = 0; \ + return (good_ret); \ + } \ + } while (0) __BEGIN_DECLS diff --git a/LibC/errno_numbers.h b/LibC/errno_numbers.h index 2527d44e97d..7421967c92f 100644 --- a/LibC/errno_numbers.h +++ b/LibC/errno_numbers.h @@ -1,74 +1,74 @@ #pragma once -#define ESUCCESS 0 -#define EPERM 1 -#define ENOENT 2 -#define ESRCH 3 -#define EINTR 4 -#define EIO 5 -#define ENXIO 6 -#define E2BIG 7 -#define ENOEXEC 8 -#define EBADF 9 -#define ECHILD 10 -#define EAGAIN 11 -#define ENOMEM 12 -#define EACCES 13 -#define EFAULT 14 -#define ENOTBLK 15 -#define EBUSY 16 -#define EEXIST 17 -#define EXDEV 18 -#define ENODEV 19 -#define ENOTDIR 20 -#define EISDIR 21 -#define EINVAL 22 -#define ENFILE 23 -#define EMFILE 24 -#define ENOTTY 25 -#define ETXTBSY 26 -#define EFBIG 27 -#define ENOSPC 28 -#define ESPIPE 29 -#define EROFS 30 -#define EMLINK 31 -#define EPIPE 32 -#define ERANGE 33 -#define ENAMETOOLONG 34 -#define ELOOP 35 -#define EOVERFLOW 36 -#define EOPNOTSUPP 37 -#define ENOSYS 38 -#define ENOTIMPL 39 -#define EAFNOSUPPORT 40 -#define ENOTSOCK 41 -#define EADDRINUSE 42 -#define EWHYTHO 43 -#define ENOTEMPTY 44 -#define EDOM 45 -#define ECONNREFUSED 46 -#define EADDRNOTAVAIL 47 -#define EISCONN 48 -#define ECONNABORTED 49 -#define EALREADY 50 -#define ECONNRESET 51 -#define EDESTADDRREQ 52 -#define EHOSTUNREACH 53 -#define EILSEQ 54 -#define EMSGSIZE 55 -#define ENETDOWN 56 -#define ENETUNREACH 57 -#define ENETRESET 58 -#define ENOBUFS 59 -#define ENOLCK 60 -#define ENOMSG 61 -#define ENOPROTOOPT 62 -#define ENOTCONN 63 -#define EWOULDBLOCK 64 +#define ESUCCESS 0 +#define EPERM 1 +#define ENOENT 2 +#define ESRCH 3 +#define EINTR 4 +#define EIO 5 +#define ENXIO 6 +#define E2BIG 7 +#define ENOEXEC 8 +#define EBADF 9 +#define ECHILD 10 +#define EAGAIN 11 +#define ENOMEM 12 +#define EACCES 13 +#define EFAULT 14 +#define ENOTBLK 15 +#define EBUSY 16 +#define EEXIST 17 +#define EXDEV 18 +#define ENODEV 19 +#define ENOTDIR 20 +#define EISDIR 21 +#define EINVAL 22 +#define ENFILE 23 +#define EMFILE 24 +#define ENOTTY 25 +#define ETXTBSY 26 +#define EFBIG 27 +#define ENOSPC 28 +#define ESPIPE 29 +#define EROFS 30 +#define EMLINK 31 +#define EPIPE 32 +#define ERANGE 33 +#define ENAMETOOLONG 34 +#define ELOOP 35 +#define EOVERFLOW 36 +#define EOPNOTSUPP 37 +#define ENOSYS 38 +#define ENOTIMPL 39 +#define EAFNOSUPPORT 40 +#define ENOTSOCK 41 +#define EADDRINUSE 42 +#define EWHYTHO 43 +#define ENOTEMPTY 44 +#define EDOM 45 +#define ECONNREFUSED 46 +#define EADDRNOTAVAIL 47 +#define EISCONN 48 +#define ECONNABORTED 49 +#define EALREADY 50 +#define ECONNRESET 51 +#define EDESTADDRREQ 52 +#define EHOSTUNREACH 53 +#define EILSEQ 54 +#define EMSGSIZE 55 +#define ENETDOWN 56 +#define ENETUNREACH 57 +#define ENETRESET 58 +#define ENOBUFS 59 +#define ENOLCK 60 +#define ENOMSG 61 +#define ENOPROTOOPT 62 +#define ENOTCONN 63 +#define EWOULDBLOCK 64 #define EPROTONOSUPPORT 65 -#define EDEADLK 66 -#define ETIMEDOUT 67 -#define EPROTOTYPE 68 -#define EINPROGRESS 69 -#define ENOTHREAD 70 -#define EMAXERRNO 71 +#define EDEADLK 66 +#define ETIMEDOUT 67 +#define EPROTOTYPE 68 +#define EINPROGRESS 69 +#define ENOTHREAD 70 +#define EMAXERRNO 71 diff --git a/LibC/fcntl.h b/LibC/fcntl.h index 5f67104bf33..b49d3ef3720 100644 --- a/LibC/fcntl.h +++ b/LibC/fcntl.h @@ -26,14 +26,14 @@ __BEGIN_DECLS #define O_NOFOLLOW 00400000 #define O_CLOEXEC 02000000 -#define S_IFMT 0170000 -#define S_IFDIR 0040000 -#define S_IFCHR 0020000 -#define S_IFBLK 0060000 -#define S_IFREG 0100000 -#define S_IFIFO 0010000 -#define S_IFLNK 0120000 -#define S_IFSOCK 0140000 +#define S_IFMT 0170000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFBLK 0060000 +#define S_IFREG 0100000 +#define S_IFIFO 0010000 +#define S_IFLNK 0120000 +#define S_IFSOCK 0140000 #define S_ISUID 04000 #define S_ISGID 02000 diff --git a/LibC/iconv.h b/LibC/iconv.h index 4f5b9ae2bc8..70831a25652 100644 --- a/LibC/iconv.h +++ b/LibC/iconv.h @@ -4,7 +4,7 @@ __BEGIN_DECLS -typedef void * iconv_t; +typedef void* iconv_t; extern iconv_t iconv_open(const char* tocode, const char* fromcode); extern size_t iconv(iconv_t, char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft); diff --git a/LibC/locale.h b/LibC/locale.h index b1c4e94275b..0f5c52e6683 100644 --- a/LibC/locale.h +++ b/LibC/locale.h @@ -4,7 +4,8 @@ __BEGIN_DECLS -enum { +enum +{ LC_ALL, LC_NUMERIC, LC_CTYPE, @@ -23,4 +24,3 @@ struct lconv* localeconv(); char* setlocale(int category, const char* locale); __END_DECLS - diff --git a/LibC/mman.h b/LibC/mman.h index 73ea753fd92..f8b408026dd 100644 --- a/LibC/mman.h +++ b/LibC/mman.h @@ -26,4 +26,3 @@ int shm_open(const char* name, int flags, mode_t); int shm_unlink(const char* name); __END_DECLS - diff --git a/LibC/mntent.h b/LibC/mntent.h index 5627cb121a4..91406bbb8e1 100644 --- a/LibC/mntent.h +++ b/LibC/mntent.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include __BEGIN_DECLS @@ -20,4 +20,3 @@ struct mntent { struct mntent* getmntent(FILE* stream); __END_DECLS - diff --git a/LibC/netdb.h b/LibC/netdb.h index 492802f59b5..ed75e482405 100644 --- a/LibC/netdb.h +++ b/LibC/netdb.h @@ -14,7 +14,7 @@ struct hostent { #define h_addr h_addr_list[0] }; -struct hostent *gethostbyname(const char*); +struct hostent* gethostbyname(const char*); struct servent { char* s_name; diff --git a/LibC/netinet/in.h b/LibC/netinet/in.h index f0a59de8be6..7a43b59b85c 100644 --- a/LibC/netinet/in.h +++ b/LibC/netinet/in.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include __BEGIN_DECLS diff --git a/LibC/netinet/ip_icmp.h b/LibC/netinet/ip_icmp.h index 7f18bea1103..7b278aac90b 100644 --- a/LibC/netinet/ip_icmp.h +++ b/LibC/netinet/ip_icmp.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include __BEGIN_DECLS @@ -19,4 +19,3 @@ struct icmphdr { }; __END_DECLS - diff --git a/LibC/poll.h b/LibC/poll.h index 1a52049c821..02d3e660593 100644 --- a/LibC/poll.h +++ b/LibC/poll.h @@ -4,15 +4,15 @@ __BEGIN_DECLS -#define POLLIN (1u << 0) -#define POLLPRI (1u << 2) -#define POLLOUT (1u << 3) -#define POLLERR (1u << 4) -#define POLLHUP (1u << 5) +#define POLLIN (1u << 0) +#define POLLPRI (1u << 2) +#define POLLOUT (1u << 3) +#define POLLERR (1u << 4) +#define POLLHUP (1u << 5) #define POLLNVAL (1u << 6) struct pollfd { - int fd; + int fd; short events; short revents; }; @@ -20,4 +20,3 @@ struct pollfd { int poll(struct pollfd* fds, int nfds, int timeout); __END_DECLS - diff --git a/LibC/pthread.h b/LibC/pthread.h index b98717b2240..d5848d08212 100644 --- a/LibC/pthread.h +++ b/LibC/pthread.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include __BEGIN_DECLS @@ -15,61 +15,61 @@ typedef void* pthread_cond_t; typedef void* pthread_spinlock_t; typedef void* pthread_condattr_t; -int pthread_create(pthread_t, pthread_attr_t*, void*(*)(void*), void*); +int pthread_create(pthread_t, pthread_attr_t*, void* (*)(void*), void*); void pthread_exit(void*); int pthread_kill(pthread_t, int); -void pthread_cleanup_push(void(*)(void*), void*); +void pthread_cleanup_push(void (*)(void*), void*); void pthread_cleanup_pop(int); int pthread_join(pthread_t, void**); int pthread_mutex_lock(pthread_mutex_t*); -int pthread_mutex_trylock(pthread_mutex_t*mutex); +int pthread_mutex_trylock(pthread_mutex_t* mutex); int pthread_mutex_unlock(pthread_mutex_t*); int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*); int pthread_mutex_destroy(pthread_mutex_t*); int pthread_attr_init(pthread_attr_t*); int pthread_attr_destroy(pthread_attr_t*); -int pthread_once(pthread_once_t*, void(*)(void)); +int pthread_once(pthread_once_t*, void (*)(void)); #define PTHREAD_ONCE_INIT 0 pthread_once_t once_control = PTHREAD_ONCE_INIT; -void *pthread_getspecific(pthread_key_t key); -int pthread_setspecific(pthread_key_t key, const void *value); +void* pthread_getspecific(pthread_key_t key); +int pthread_setspecific(pthread_key_t key, const void* value); #define PTHREAD_MUTEX_NORMAL 0 #define PTHREAD_MUTEX_RECURSIVE 1 #define PTHREAD_MUTEX_INITIALIZER 0 #define PTHREAD_COND_INITIALIZER 0 -int pthread_key_create(pthread_key_t *key, void (*destructor)(void*)); +int pthread_key_create(pthread_key_t* key, void (*destructor)(void*)); int pthread_key_delete(pthread_key_t key); -int pthread_cond_broadcast(pthread_cond_t *); -int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *); -int pthread_cond_signal(pthread_cond_t *); -int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *); -int pthread_condattr_destroy(pthread_condattr_t *); +int pthread_cond_broadcast(pthread_cond_t*); +int pthread_cond_init(pthread_cond_t*, const pthread_condattr_t*); +int pthread_cond_signal(pthread_cond_t*); +int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*); +int pthread_condattr_destroy(pthread_condattr_t*); int pthread_cancel(pthread_t); -void pthread_cleanup_push(void (*)(void *), void *); +void pthread_cleanup_push(void (*)(void*), void*); void pthread_cleanup_pop(int); -int pthread_cond_broadcast(pthread_cond_t *); -int pthread_cond_destroy(pthread_cond_t *); -int pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *, const struct timespec *); -int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *); -int pthread_condattr_destroy(pthread_condattr_t *); +int pthread_cond_broadcast(pthread_cond_t*); +int pthread_cond_destroy(pthread_cond_t*); +int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const struct timespec*); +int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*); +int pthread_condattr_destroy(pthread_condattr_t*); void pthread_testcancel(void); -int pthread_spin_destroy(pthread_spinlock_t *); -int pthread_spin_init(pthread_spinlock_t *, int); -int pthread_spin_lock(pthread_spinlock_t *); -int pthread_spin_trylock(pthread_spinlock_t *); -int pthread_spin_unlock(pthread_spinlock_t *); -int pthread_cond_destroy(pthread_cond_t *); +int pthread_spin_destroy(pthread_spinlock_t*); +int pthread_spin_init(pthread_spinlock_t*, int); +int pthread_spin_lock(pthread_spinlock_t*); +int pthread_spin_trylock(pthread_spinlock_t*); +int pthread_spin_unlock(pthread_spinlock_t*); +int pthread_cond_destroy(pthread_cond_t*); pthread_t pthread_self(void); int pthread_detach(pthread_t); int pthread_equal(pthread_t, pthread_t); -void pthread_exit(void *); -int pthread_mutexattr_init(pthread_mutexattr_t *); -int pthread_mutexattr_settype(pthread_mutexattr_t *, int); -int pthread_mutexattr_destroy(pthread_mutexattr_t *); +void pthread_exit(void*); +int pthread_mutexattr_init(pthread_mutexattr_t*); +int pthread_mutexattr_settype(pthread_mutexattr_t*, int); +int pthread_mutexattr_destroy(pthread_mutexattr_t*); __END_DECLS diff --git a/LibC/serenity.h b/LibC/serenity.h index d753063d7a9..aa8aa26c742 100644 --- a/LibC/serenity.h +++ b/LibC/serenity.h @@ -5,7 +5,6 @@ #ifdef __cplusplus - struct Stopwatch { union SplitQword { struct { @@ -14,6 +13,7 @@ struct Stopwatch { }; uint64_t qw { 0 }; }; + public: Stopwatch(const char* name) : m_name(name) diff --git a/LibC/setjmp.h b/LibC/setjmp.h index 01980ac8b53..a6511a38f6c 100644 --- a/LibC/setjmp.h +++ b/LibC/setjmp.h @@ -1,10 +1,10 @@ #pragma once -#include -#include -#include #include #include +#include +#include +#include __BEGIN_DECLS diff --git a/LibC/signal.h b/LibC/signal.h index 77ee5365120..798f5dad134 100644 --- a/LibC/signal.h +++ b/LibC/signal.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include __BEGIN_DECLS @@ -50,4 +50,3 @@ extern const char* sys_siglist[NSIG]; #define SIG_SETMASK 2 __END_DECLS - diff --git a/LibC/signal_numbers.h b/LibC/signal_numbers.h index 5c974cbf1c3..3ce9ec04272 100644 --- a/LibC/signal_numbers.h +++ b/LibC/signal_numbers.h @@ -1,35 +1,35 @@ #pragma once -#define SIGINVAL 0 -#define SIGHUP 1 -#define SIGINT 2 -#define SIGQUIT 3 -#define SIGILL 4 -#define SIGTRAP 5 -#define SIGABRT 6 -#define SIGBUS 7 -#define SIGFPE 8 -#define SIGKILL 9 -#define SIGUSR1 10 -#define SIGSEGV 11 -#define SIGUSR2 12 -#define SIGPIPE 13 -#define SIGALRM 14 -#define SIGTERM 15 -#define SIGSTKFLT 16 -#define SIGCHLD 17 -#define SIGCONT 18 -#define SIGSTOP 19 -#define SIGTSTP 20 -#define SIGTTIN 21 -#define SIGTTOU 22 -#define SIGURG 23 -#define SIGXCPU 24 -#define SIGXFSZ 25 -#define SIGVTALRM 26 -#define SIGPROF 27 -#define SIGWINCH 28 -#define SIGIO 29 -#define SIGPWR 30 -#define SIGSYS 31 -#define NSIG 32 +#define SIGINVAL 0 +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPWR 30 +#define SIGSYS 31 +#define NSIG 32 diff --git a/LibC/stdarg.h b/LibC/stdarg.h index 366964cb275..facdcd67e2e 100644 --- a/LibC/stdarg.h +++ b/LibC/stdarg.h @@ -1,10 +1,10 @@ #pragma once #ifdef KERNEL -#define __BEGIN_DECLS -#define __END_DECLS +# define __BEGIN_DECLS +# define __END_DECLS #else -#include +# include #endif __BEGIN_DECLS @@ -16,4 +16,3 @@ typedef __builtin_va_list va_list; #define va_arg(v, l) __builtin_va_arg(v, l) __END_DECLS - diff --git a/LibC/stdbool.h b/LibC/stdbool.h index 96d0d4dd92f..6b4e36f93b6 100644 --- a/LibC/stdbool.h +++ b/LibC/stdbool.h @@ -2,14 +2,14 @@ #ifndef __cplusplus -#include +# include __BEGIN_DECLS -#define bool _Bool -#define true 1 -#define false 0 -#define __bool_true_false_are_Defined 1 +# define bool _Bool +# define true 1 +# define false 0 +# define __bool_true_false_are_Defined 1 __END_DECLS diff --git a/LibC/stddef.h b/LibC/stddef.h index 61a20c763ac..73f82c14894 100644 --- a/LibC/stddef.h +++ b/LibC/stddef.h @@ -4,9 +4,9 @@ #include #ifdef __cplusplus -#define NULL nullptr +# define NULL nullptr #else -#define NULL ((void*)0) +# define NULL ((void*)0) #endif typedef __PTRDIFF_TYPE__ ptrdiff_t; diff --git a/LibC/stdint.h b/LibC/stdint.h index 4d0dc2bdfcf..8dfe1207127 100644 --- a/LibC/stdint.h +++ b/LibC/stdint.h @@ -55,9 +55,9 @@ typedef __INTMAX_TYPE__ intmax_t; #define INTMAX_MIN (-INTMAX_MAX - 1) #define INT8_MIN (-128) -#define INT16_MIN (-32767-1) -#define INT32_MIN (-2147483647-1) -#define INT64_MIN (-9223372036854775807LL-1LL) +#define INT16_MIN (-32767 - 1) +#define INT32_MIN (-2147483647 - 1) +#define INT64_MIN (-9223372036854775807LL - 1LL) #define INT8_MAX (127) #define INT16_MAX (32767) #define INT32_MAX (2147483647) @@ -101,8 +101,7 @@ typedef __INTMAX_TYPE__ intmax_t; #define UINT_LEAST32_MAX UINT32_MAX #define UINT_LEAST64_MAX UINT64_MAX -#define INT64_C(x) x##LL +#define INT64_C(x) x##LL #define UINT64_C(x) x##ULL __END_DECLS - diff --git a/LibC/stdio.h b/LibC/stdio.h index 8f41e746366..54f64173d84 100644 --- a/LibC/stdio.h +++ b/LibC/stdio.h @@ -2,16 +2,16 @@ #define _STDIO_H // Make GMP believe we exist. +#include +#include #include #include -#include -#include #define BUFSIZ 1024 __BEGIN_DECLS - #ifndef EOF -#define EOF (-1) +#ifndef EOF +# define EOF (-1) #endif #define SEEK_SET 0 @@ -57,7 +57,8 @@ int getchar(); int ungetc(int c, FILE*); int remove(const char* pathname); FILE* fdopen(int fd, const char* mode); -FILE* fopen(const char* pathname, const char* mode); FILE* freopen(const char* pathname, const char* mode, FILE*); +FILE* fopen(const char* pathname, const char* mode); +FILE* freopen(const char* pathname, const char* mode, FILE*); int fclose(FILE*); void rewind(FILE*); void clearerr(FILE*); @@ -81,7 +82,7 @@ int puts(const char*); int fputs(const char*, FILE*); void perror(const char*); int scanf(const char* fmt, ...); -int sscanf (const char* str, const char* fmt, ...); +int sscanf(const char* str, const char* fmt, ...); int fscanf(FILE*, const char* fmt, ...); int vfscanf(FILE*, const char*, va_list); int vsscanf(const char*, const char*, va_list); @@ -95,4 +96,3 @@ FILE* popen(const char* command, const char* type); int pclose(FILE*); __END_DECLS - diff --git a/LibC/stdlib.h b/LibC/stdlib.h index 25e9a585dd6..22493e5e984 100644 --- a/LibC/stdlib.h +++ b/LibC/stdlib.h @@ -1,8 +1,8 @@ #pragma once +#include #include #include -#include __BEGIN_DECLS @@ -13,7 +13,7 @@ __BEGIN_DECLS __attribute__((malloc)) __attribute__((alloc_size(1))) void* malloc(size_t); __attribute__((malloc)) __attribute__((alloc_size(1, 2))) void* calloc(size_t nmemb, size_t); void free(void*); -void* realloc(void *ptr, size_t); +void* realloc(void* ptr, size_t); char* getenv(const char* name); int putenv(char*); int unsetenv(const char*); @@ -36,7 +36,7 @@ long labs(long); double atof(const char*); int system(const char* command); char* mktemp(char*); -void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); +void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*)); #define RAND_MAX 32767 int rand(); @@ -45,10 +45,15 @@ void srand(unsigned seed); long int random(); void srandom(unsigned seed); -typedef struct { int quot; int rem; } div_t; +typedef struct { + int quot; + int rem; +} div_t; div_t div(int, int); -typedef struct { long quot; long rem; } ldiv_t; +typedef struct { + long quot; + long rem; +} ldiv_t; ldiv_t ldiv(long, long); __END_DECLS - diff --git a/LibC/string.h b/LibC/string.h index b71f6c602c9..9d02da28b36 100644 --- a/LibC/string.h +++ b/LibC/string.h @@ -24,16 +24,15 @@ char* strncpy(char* dest, const char* src, size_t); char* strchr(const char*, int c); char* strstr(const char* haystack, const char* needle); char* strrchr(const char*, int c); -char* strcat(char *dest, const char *src); -char* strncat(char *dest, const char *src, size_t); +char* strcat(char* dest, const char* src); +char* strncat(char* dest, const char* src, size_t); size_t strspn(const char*, const char* accept); size_t strcspn(const char*, const char* reject); char* strerror(int errnum); char* strsignal(int signum); char* strpbrk(const char*, const char* accept); -char *strtok(char* str, const char* delim); -int strcoll(const char *s1, const char *s2); -size_t strxfrm(char *dest, const char *src, size_t n); +char* strtok(char* str, const char* delim); +int strcoll(const char* s1, const char* s2); +size_t strxfrm(char* dest, const char* src, size_t n); __END_DECLS - diff --git a/LibC/sys/cdefs.h b/LibC/sys/cdefs.h index f74a8541f5c..8f05740393d 100644 --- a/LibC/sys/cdefs.h +++ b/LibC/sys/cdefs.h @@ -5,11 +5,11 @@ #define ALWAYS_INLINE inline __attribute__((always_inline)) #ifdef __cplusplus -#define __BEGIN_DECLS extern "C" { -#define __END_DECLS } +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } #else -#define __BEGIN_DECLS -#define __END_DECLS +# define __BEGIN_DECLS +# define __END_DECLS #endif #undef __P @@ -20,4 +20,3 @@ #ifdef __cplusplus //extern "C" int main(int, char**); #endif - diff --git a/LibC/sys/ioctl_numbers.h b/LibC/sys/ioctl_numbers.h index 85edc5dbfe6..f8ac61aedaa 100644 --- a/LibC/sys/ioctl_numbers.h +++ b/LibC/sys/ioctl_numbers.h @@ -1,6 +1,7 @@ #pragma once -enum IOCtlNumber { +enum IOCtlNumber +{ TIOCGPGRP, TIOCSPGRP, TCGETS, @@ -12,4 +13,3 @@ enum IOCtlNumber { TIOCNOTTY, TIOCSWINSZ, }; - diff --git a/LibC/sys/resource.h b/LibC/sys/resource.h index 7b21cf8e55e..cce5dc69694 100644 --- a/LibC/sys/resource.h +++ b/LibC/sys/resource.h @@ -27,6 +27,6 @@ struct rusage { #define RUSAGE_SELF 1 #define RUSAGE_CHILDREN 2 -int getrusage(int who, struct rusage *usage); +int getrusage(int who, struct rusage* usage); __END_DECLS diff --git a/LibC/sys/select.h b/LibC/sys/select.h index 9cc8abae4c9..55bad8e20bb 100644 --- a/LibC/sys/select.h +++ b/LibC/sys/select.h @@ -1,13 +1,12 @@ #pragma once +#include +#include #include #include -#include -#include __BEGIN_DECLS int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout); __END_DECLS - diff --git a/LibC/sys/socket.h b/LibC/sys/socket.h index b1dc322e1b3..6923965652b 100644 --- a/LibC/sys/socket.h +++ b/LibC/sys/socket.h @@ -1,8 +1,8 @@ #pragma once +#include #include #include -#include #include __BEGIN_DECLS @@ -68,4 +68,3 @@ int getsockname(int sockfd, struct sockaddr*, socklen_t*); int getpeername(int sockfd, struct sockaddr*, socklen_t*); __END_DECLS - diff --git a/LibC/sys/stat.h b/LibC/sys/stat.h index d337dfc2946..fc6a36a33cc 100644 --- a/LibC/sys/stat.h +++ b/LibC/sys/stat.h @@ -1,18 +1,18 @@ #pragma once +#include #include #include -#include __BEGIN_DECLS -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) +#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) +#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) +#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) +#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) +#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) mode_t umask(mode_t); int chmod(const char* pathname, mode_t); diff --git a/LibC/sys/time.h b/LibC/sys/time.h index fef0236f82e..a28472f842b 100644 --- a/LibC/sys/time.h +++ b/LibC/sys/time.h @@ -15,6 +15,6 @@ struct timezone { int tz_dsttime; }; -int gettimeofday(struct timeval* __restrict__, void* __restrict__) __attribute__((nonnull(1))); +int gettimeofday(struct timeval* __restrict__, void* __restrict__) __attribute__((nonnull(1))); __END_DECLS diff --git a/LibC/sys/types.h b/LibC/sys/types.h index 9f806759dc2..4c4a20e7e45 100644 --- a/LibC/sys/types.h +++ b/LibC/sys/types.h @@ -38,19 +38,19 @@ typedef uint32_t clock_t; typedef __socklen_t socklen_t; struct stat { - dev_t st_dev; /* ID of device containing file */ - ino_t st_ino; /* inode number */ - mode_t st_mode; /* protection */ - nlink_t st_nlink; /* number of hard links */ - uid_t st_uid; /* user ID of owner */ - gid_t st_gid; /* group ID of owner */ - dev_t st_rdev; /* device ID (if special file) */ - off_t st_size; /* total size, in bytes */ + dev_t st_dev; /* ID of device containing file */ + ino_t st_ino; /* inode number */ + mode_t st_mode; /* protection */ + nlink_t st_nlink; /* number of hard links */ + uid_t st_uid; /* user ID of owner */ + gid_t st_gid; /* group ID of owner */ + dev_t st_rdev; /* device ID (if special file) */ + off_t st_size; /* total size, in bytes */ blksize_t st_blksize; /* blocksize for file system I/O */ - blkcnt_t st_blocks; /* number of 512B blocks allocated */ - time_t st_atime; /* time of last access */ - time_t st_mtime; /* time of last modification */ - time_t st_ctime; /* time of last status change */ + blkcnt_t st_blocks; /* number of 512B blocks allocated */ + time_t st_atime; /* time of last access */ + time_t st_mtime; /* time of last modification */ + time_t st_ctime; /* time of last status change */ }; struct utimbuf { @@ -59,4 +59,3 @@ struct utimbuf { }; __END_DECLS - diff --git a/LibC/sys/utsname.h b/LibC/sys/utsname.h index e617b2e34dc..6e903dfb4be 100644 --- a/LibC/sys/utsname.h +++ b/LibC/sys/utsname.h @@ -17,4 +17,3 @@ struct utsname { int uname(struct utsname*); __END_DECLS - diff --git a/LibC/termcap.h b/LibC/termcap.h index e9136d9c2be..d160b8aff5b 100644 --- a/LibC/termcap.h +++ b/LibC/termcap.h @@ -16,4 +16,3 @@ char* tgoto(const char* cap, int col, int row); int tputs(const char* str, int affcnt, int (*putc)(int)); __END_DECLS - diff --git a/LibC/termios.h b/LibC/termios.h index 01529f3df9d..d408ea17000 100644 --- a/LibC/termios.h +++ b/LibC/termios.h @@ -16,9 +16,9 @@ struct termios { tcflag_t c_oflag; tcflag_t c_cflag; tcflag_t c_lflag; - cc_t c_cc[NCCS]; - speed_t c_ispeed; - speed_t c_ospeed; + cc_t c_cc[NCCS]; + speed_t c_ispeed; + speed_t c_ospeed; }; int tcgetattr(int fd, struct termios*); @@ -46,160 +46,159 @@ int tcflush(int fd, int queue_selector); #define VEOL2 16 /* c_iflag bits */ -#define IGNBRK 0000001 -#define BRKINT 0000002 -#define IGNPAR 0000004 -#define PARMRK 0000010 -#define INPCK 0000020 -#define ISTRIP 0000040 -#define INLCR 0000100 -#define IGNCR 0000200 -#define ICRNL 0000400 -#define IUCLC 0001000 -#define IXON 0002000 -#define IXANY 0004000 -#define IXOFF 0010000 -#define IMAXBEL 0020000 -#define IUTF8 0040000 +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 +#define IUTF8 0040000 /* c_oflag bits */ -#define OPOST 0000001 -#define OLCUC 0000002 -#define ONLCR 0000004 -#define OCRNL 0000010 -#define ONOCR 0000020 -#define ONLRET 0000040 -#define OFILL 0000100 -#define OFDEL 0000200 +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 #if defined __USE_MISC || defined __USE_XOPEN -# define NLDLY 0000400 -# define NL0 0000000 -# define NL1 0000400 -# define CRDLY 0003000 -# define CR0 0000000 -# define CR1 0001000 -# define CR2 0002000 -# define CR3 0003000 -# define TABDLY 0014000 -# define TAB0 0000000 -# define TAB1 0004000 -# define TAB2 0010000 -# define TAB3 0014000 -# define BSDLY 0020000 -# define BS0 0000000 -# define BS1 0020000 -# define FFDLY 0100000 -# define FF0 0000000 -# define FF1 0100000 +# define NLDLY 0000400 +# define NL0 0000000 +# define NL1 0000400 +# define CRDLY 0003000 +# define CR0 0000000 +# define CR1 0001000 +# define CR2 0002000 +# define CR3 0003000 +# define TABDLY 0014000 +# define TAB0 0000000 +# define TAB1 0004000 +# define TAB2 0010000 +# define TAB3 0014000 +# define BSDLY 0020000 +# define BS0 0000000 +# define BS1 0020000 +# define FFDLY 0100000 +# define FF0 0000000 +# define FF1 0100000 #endif -#define VTDLY 0040000 -#define VT0 0000000 -#define VT1 0040000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 #ifdef __USE_MISC -# define XTABS 0014000 +# define XTABS 0014000 #endif /* c_cflag bit meaning */ #ifdef __USE_MISC -# define CBAUD 0010017 +# define CBAUD 0010017 #endif -#define B0 0000000 /* hang up */ -#define B50 0000001 -#define B75 0000002 -#define B110 0000003 -#define B134 0000004 -#define B150 0000005 -#define B200 0000006 -#define B300 0000007 -#define B600 0000010 -#define B1200 0000011 -#define B1800 0000012 -#define B2400 0000013 -#define B4800 0000014 -#define B9600 0000015 -#define B19200 0000016 -#define B38400 0000017 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 #ifdef __USE_MISC -# define EXTA B19200 -# define EXTB B38400 +# define EXTA B19200 +# define EXTB B38400 #endif -#define CSIZE 0000060 -#define CS5 0000000 -#define CS6 0000020 -#define CS7 0000040 -#define CS8 0000060 -#define CSTOPB 0000100 -#define CREAD 0000200 -#define PARENB 0000400 -#define PARODD 0001000 -#define HUPCL 0002000 -#define CLOCAL 0004000 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 #ifdef __USE_MISC -# define CBAUDEX 0010000 +# define CBAUDEX 0010000 #endif -#define B57600 0010001 -#define B115200 0010002 -#define B230400 0010003 -#define B460800 0010004 -#define B500000 0010005 -#define B576000 0010006 -#define B921600 0010007 -#define B1000000 0010010 -#define B1152000 0010011 -#define B1500000 0010012 -#define B2000000 0010013 -#define B2500000 0010014 -#define B3000000 0010015 -#define B3500000 0010016 -#define B4000000 0010017 +#define B57600 0010001 +#define B115200 0010002 +#define B230400 0010003 +#define B460800 0010004 +#define B500000 0010005 +#define B576000 0010006 +#define B921600 0010007 +#define B1000000 0010010 +#define B1152000 0010011 +#define B1500000 0010012 +#define B2000000 0010013 +#define B2500000 0010014 +#define B3000000 0010015 +#define B3500000 0010016 +#define B4000000 0010017 #define __MAX_BAUD B4000000 #ifdef __USE_MISC -# define CIBAUD 002003600000 /* input baud rate (not used) */ -# define CMSPAR 010000000000 /* mark or space (stick) parity */ -# define CRTSCTS 020000000000 /* flow control */ +# define CIBAUD 002003600000 /* input baud rate (not used) */ +# define CMSPAR 010000000000 /* mark or space (stick) parity */ +# define CRTSCTS 020000000000 /* flow control */ #endif /* c_lflag bits */ -#define ISIG 0000001 -#define ICANON 0000002 +#define ISIG 0000001 +#define ICANON 0000002 #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K) -# define XCASE 0000004 +# define XCASE 0000004 #endif -#define ECHO 0000010 -#define ECHOE 0000020 -#define ECHOK 0000040 -#define ECHONL 0000100 -#define NOFLSH 0000200 -#define TOSTOP 0000400 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 #ifdef __USE_MISC -# define ECHOCTL 0001000 -# define ECHOPRT 0002000 -# define ECHOKE 0004000 -# define FLUSHO 0010000 -# define PENDIN 0040000 +# define ECHOCTL 0001000 +# define ECHOPRT 0002000 +# define ECHOKE 0004000 +# define FLUSHO 0010000 +# define PENDIN 0040000 #endif -#define IEXTEN 0100000 +#define IEXTEN 0100000 #ifdef __USE_MISC -# define EXTPROC 0200000 +# define EXTPROC 0200000 #endif /* tcflow() and TCXONC use these */ -#define TCOOFF 0 -#define TCOON 1 -#define TCIOFF 2 -#define TCION 3 +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 /* tcflush() and TCFLSH use these */ -#define TCIFLUSH 0 -#define TCOFLUSH 1 -#define TCIOFLUSH 2 +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 /* tcsetattr uses these */ -#define TCSANOW 0 -#define TCSADRAIN 1 -#define TCSAFLUSH 2 +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 __END_DECLS - diff --git a/LibC/time.h b/LibC/time.h index 29e55835129..0a720dadf4d 100644 --- a/LibC/time.h +++ b/LibC/time.h @@ -6,15 +6,15 @@ __BEGIN_DECLS struct tm { - int tm_sec; /* Seconds (0-60) */ - int tm_min; /* Minutes (0-59) */ - int tm_hour; /* Hours (0-23) */ - int tm_mday; /* Day of the month (1-31) */ - int tm_mon; /* Month (0-11) */ - int tm_year; /* Year - 1900 */ - int tm_wday; /* Day of the week (0-6, Sunday = 0) */ - int tm_yday; /* Day in the year (0-365, 1 Jan = 0) */ - int tm_isdst; /* Daylight saving time */ + int tm_sec; /* Seconds (0-60) */ + int tm_min; /* Minutes (0-59) */ + int tm_hour; /* Hours (0-23) */ + int tm_mday; /* Day of the month (1-31) */ + int tm_mon; /* Month (0-11) */ + int tm_year; /* Year - 1900 */ + int tm_wday; /* Day of the week (0-6, Sunday = 0) */ + int tm_yday; /* Day in the year (0-365, 1 Jan = 0) */ + int tm_isdst; /* Daylight saving time */ }; extern long timezone; @@ -26,12 +26,12 @@ typedef uint32_t clock_t; typedef uint32_t time_t; struct tm* localtime(const time_t*); -struct tm *gmtime(const time_t*); +struct tm* gmtime(const time_t*); time_t mktime(struct tm*); time_t time(time_t*); char* ctime(const time_t*); void tzset(); -char *asctime(const struct tm*); +char* asctime(const struct tm*); #define CLOCKS_PER_SEC 1000 clock_t clock(); @@ -39,7 +39,7 @@ clock_t clock(); double difftime(time_t, time_t); size_t strftime(char* s, size_t max, const char* format, const struct tm*); -#define difftime(t1,t0) (double)(t1 - t0) +#define difftime(t1, t0) (double)(t1 - t0) // This is c++11+, but we have no macro for that now. struct timespec { @@ -48,4 +48,3 @@ struct timespec { }; __END_DECLS - diff --git a/LibC/ulimit.h b/LibC/ulimit.h index ea0a35b06ff..6985bcf5908 100644 --- a/LibC/ulimit.h +++ b/LibC/ulimit.h @@ -7,4 +7,3 @@ __BEGIN_DECLS long ulimit(int cmd, long newlimit); __END_DECLS - diff --git a/LibC/unistd.h b/LibC/unistd.h index a9cacca3a49..994fde0c1ad 100644 --- a/LibC/unistd.h +++ b/LibC/unistd.h @@ -1,9 +1,9 @@ #pragma once +#include +#include #include #include -#include -#include __BEGIN_DECLS @@ -19,7 +19,7 @@ void sysbeep(); int systrace(pid_t); int gettid(); int donate(int tid); -int create_thread(int(*)(void*), void*); +int create_thread(int (*)(void*), void*); void exit_thread(int); int create_shared_buffer(pid_t peer_pid, int, void** buffer); void* get_shared_buffer(int shared_buffer_id); @@ -85,19 +85,20 @@ int access(const char* pathname, int mode); int isatty(int fd); int mknod(const char* pathname, mode_t, dev_t); long fpathconf(int fd, int name); -long pathconf(const char *path, int name); +long pathconf(const char* path, int name); char* getlogin(); int chown(const char* pathname, uid_t, gid_t); int ftruncate(int fd, off_t length); -enum { +enum +{ _PC_NAME_MAX, }; -#define WEXITSTATUS(status) (((status) & 0xff00) >> 8) -#define WTERMSIG(status) ((status) & 0x7f) +#define WEXITSTATUS(status) (((status)&0xff00) >> 8) +#define WTERMSIG(status) ((status)&0x7f) #define WIFEXITED(status) (WTERMSIG(status) == 0) -#define WIFSIGNALED(status) (((char) (((status) & 0x7f) + 1) >> 1) > 0) +#define WIFSIGNALED(status) (((char)(((status)&0x7f) + 1) >> 1) > 0) #define HOST_NAME_MAX 64 @@ -107,4 +108,3 @@ enum { #define F_OK 0 __END_DECLS - diff --git a/LibC/utime.h b/LibC/utime.h index 96c26f6bb41..6ad7e3592a2 100644 --- a/LibC/utime.h +++ b/LibC/utime.h @@ -7,4 +7,3 @@ __BEGIN_DECLS int utime(const char* pathname, const struct utimbuf*); __END_DECLS - diff --git a/LibC/utmp.h b/LibC/utmp.h index 69e1167e82b..701e37d1dc5 100644 --- a/LibC/utmp.h +++ b/LibC/utmp.h @@ -4,9 +4,9 @@ __BEGIN_DECLS -struct exit_status { /* Type for ut_exit, below */ - short int e_termination; /* Process termination status */ - short int e_exit; /* Process exit status */ +struct exit_status { /* Type for ut_exit, below */ + short int e_termination; /* Process termination status */ + short int e_exit; /* Process exit status */ }; #define UT_NAMESIZE 32 @@ -14,27 +14,27 @@ struct exit_status { /* Type for ut_exit, below */ #define UT_HOSTSIZE 256 struct utmp { - short ut_type; /* Type of record */ - pid_t ut_pid; /* PID of login process */ - char ut_line[UT_LINESIZE]; /* Device name of tty - "/dev/" */ - char ut_id[4]; /* Terminal name suffix, + short ut_type; /* Type of record */ + pid_t ut_pid; /* PID of login process */ + char ut_line[UT_LINESIZE]; /* Device name of tty - "/dev/" */ + char ut_id[4]; /* Terminal name suffix, or inittab(5) ID */ - char ut_user[UT_NAMESIZE]; /* Username */ - char ut_host[UT_HOSTSIZE]; /* Hostname for remote login, or + char ut_user[UT_NAMESIZE]; /* Username */ + char ut_host[UT_HOSTSIZE]; /* Hostname for remote login, or kernel version for run-level messages */ - struct exit_status ut_exit; /* Exit status of a process + struct exit_status ut_exit; /* Exit status of a process marked as DEAD_PROCESS; not used by Linux init (1 */ - long ut_session; /* Session ID */ - struct timeval ut_tv; /* Time entry was made */ + long ut_session; /* Session ID */ + struct timeval ut_tv; /* Time entry was made */ - int32_t ut_addr_v6[4]; /* Internet address of remote + int32_t ut_addr_v6[4]; /* Internet address of remote host; IPv4 address uses just ut_addr_v6[0] */ - char __unused[20]; /* Reserved for future use */ + char __unused[20]; /* Reserved for future use */ }; __END_DECLS diff --git a/LibC/wchar.h b/LibC/wchar.h index e46806fcc5f..d28d0d4c7d4 100644 --- a/LibC/wchar.h +++ b/LibC/wchar.h @@ -1,12 +1,12 @@ #pragma once -#include #include +#include __BEGIN_DECLS #ifndef WEOF -#define WEOF (0xffffffffu) +# define WEOF (0xffffffffu) #endif __END_DECLS diff --git a/LibCore/CArgsParser.cpp b/LibCore/CArgsParser.cpp index ab4936d15de..55dc3507914 100644 --- a/LibCore/CArgsParser.cpp +++ b/LibCore/CArgsParser.cpp @@ -19,18 +19,27 @@ const Vector& CArgsParserResult::get_single_values() const } CArgsParser::Arg::Arg(const String& name, const String& description, bool required) - : name(name), description(description), required(required) -{} + : name(name) + , description(description) + , required(required) +{ +} CArgsParser::Arg::Arg(const String& name, const String& value_name, const String& description, bool required) - : name(name), description(description), value_name(value_name), required(required) -{} + : name(name) + , description(description) + , value_name(value_name) + , required(required) +{ +} CArgsParser::CArgsParser(const String& program_name) - : m_program_name(program_name), m_prefix("-") -{} + : m_program_name(program_name) + , m_prefix("-") +{ +} -CArgsParserResult CArgsParser::parse(const int argc, const char** argv) +CArgsParserResult CArgsParser::parse(const int argc, const char** argv) { CArgsParserResult res; @@ -48,7 +57,7 @@ CArgsParserResult CArgsParser::parse(const int argc, const char** argv) return res; } -int CArgsParser::parse_next_param(const int index, const char** argv, const int params_left, CArgsParserResult& res) +int CArgsParser::parse_next_param(const int index, const char** argv, const int params_left, CArgsParserResult& res) { if (params_left == 0) return 0; @@ -148,7 +157,7 @@ void CArgsParser::add_arg(const String& name, const String& value_name, const St void CArgsParser::add_single_value(const String& name) { - m_single_args.append(SingleArg{name, false}); + m_single_args.append(SingleArg { name, false }); } void CArgsParser::add_required_single_value(const String& name) @@ -157,7 +166,7 @@ void CArgsParser::add_required_single_value(const String& name) // adding required arguments after non-required arguments would be nonsensical ASSERT(m_single_args.last().required); } - m_single_args.append(SingleArg{name, true}); + m_single_args.append(SingleArg { name, true }); } String CArgsParser::get_usage() const @@ -226,4 +235,3 @@ void CArgsParser::print_usage() const { printf("%s\n", get_usage().characters()); } - diff --git a/LibCore/CArgsParser.h b/LibCore/CArgsParser.h index ab4078822eb..4c50aa23a9a 100644 --- a/LibCore/CArgsParser.h +++ b/LibCore/CArgsParser.h @@ -67,4 +67,3 @@ private: Vector m_single_args; HashMap m_args; }; - diff --git a/LibCore/CConfigFile.cpp b/LibCore/CConfigFile.cpp index 6b462145612..d39d4505a07 100644 --- a/LibCore/CConfigFile.cpp +++ b/LibCore/CConfigFile.cpp @@ -1,9 +1,9 @@ +#include #include #include #include -#include -#include #include +#include #include Retained CConfigFile::get_for_app(const String& app_name) @@ -24,17 +24,17 @@ Retained CConfigFile::get_for_system(const String& app_name) CConfigFile::CConfigFile(const String& file_name) : m_file_name(file_name) { - reparse(); + reparse(); } CConfigFile::~CConfigFile() { - sync(); + sync(); } void CConfigFile::reparse() { - m_groups.clear(); + m_groups.clear(); CFile file(m_file_name); if (!file.open(CIODevice::OpenMode::ReadOnly)) @@ -46,38 +46,38 @@ void CConfigFile::reparse() auto line = file.read_line(BUFSIZ); auto* cp = (const char*)line.pointer(); - while(*cp && (*cp == ' ' || *cp == '\t' || *cp == '\n')) - ++cp; + while (*cp && (*cp == ' ' || *cp == '\t' || *cp == '\n')) + ++cp; switch (*cp) { - case '\0':// EOL... - case '#': // Comment, skip entire line. - case ';': // -||- - continue; - case '[': { // Start of new group. - StringBuilder builder; - ++cp; // Skip the '[' - while (*cp && (*cp != ']')) - builder.append(*(cp++)); - current_group = &m_groups.ensure(builder.to_string()); - break; - } - default: { // Start of key{ - StringBuilder key_builder; - StringBuilder value_builder; - while (*cp && (*cp != '=')) - key_builder.append(*(cp++)); - ++cp; // Skip the '=' - while (*cp && (*cp != '\n')) - value_builder.append(*(cp++)); - if (!current_group) { - // We're not in a group yet, create one with the name ""... - current_group = &m_groups.ensure(""); - } - current_group->set(key_builder.to_string(), value_builder.to_string()); - } - } - } + case '\0': // EOL... + case '#': // Comment, skip entire line. + case ';': // -||- + continue; + case '[': { // Start of new group. + StringBuilder builder; + ++cp; // Skip the '[' + while (*cp && (*cp != ']')) + builder.append(*(cp++)); + current_group = &m_groups.ensure(builder.to_string()); + break; + } + default: { // Start of key{ + StringBuilder key_builder; + StringBuilder value_builder; + while (*cp && (*cp != '=')) + key_builder.append(*(cp++)); + ++cp; // Skip the '=' + while (*cp && (*cp != '\n')) + value_builder.append(*(cp++)); + if (!current_group) { + // We're not in a group yet, create one with the name ""... + current_group = &m_groups.ensure(""); + } + current_group->set(key_builder.to_string(), value_builder.to_string()); + } + } + } } String CConfigFile::read_entry(const String& group, const String& key, const String& default_value) const @@ -91,7 +91,7 @@ String CConfigFile::read_entry(const String& group, const String& key, const Str return jt->value; } -int CConfigFile::read_num_entry(const String& group, const String &key, int default_value) const +int CConfigFile::read_num_entry(const String& group, const String& key, int default_value) const { if (!has_key(group, key)) { const_cast(*this).write_num_entry(group, key, default_value); @@ -105,7 +105,7 @@ int CConfigFile::read_num_entry(const String& group, const String &key, int defa return value; } -Color CConfigFile::read_color_entry(const String& group, const String &key, Color default_value) const +Color CConfigFile::read_color_entry(const String& group, const String& key, Color default_value) const { if (!has_key(group, key)) { const_cast(*this).write_color_entry(group, key, default_value); @@ -116,26 +116,26 @@ Color CConfigFile::read_color_entry(const String& group, const String &key, Colo if (shades.size() < 3) return default_value; bool ok1 = true, - ok2 = true, - ok3 = true, - ok4 = true; + ok2 = true, + ok3 = true, + ok4 = true; Color value; if (shades.size() == 3) { value = Color(shades[0].to_uint(ok1), - shades[1].to_uint(ok2), - shades[2].to_uint(ok3)); + shades[1].to_uint(ok2), + shades[2].to_uint(ok3)); } else { value = Color(shades[0].to_uint(ok1), - shades[1].to_uint(ok2), - shades[2].to_uint(ok3), - shades[3].to_uint(ok4)); + shades[1].to_uint(ok2), + shades[2].to_uint(ok3), + shades[3].to_uint(ok4)); } if (!(ok1 && ok2 && ok3 && ok4)) return default_value; return value; } -bool CConfigFile::read_bool_entry(const String& group, const String &key, bool default_value) const +bool CConfigFile::read_bool_entry(const String& group, const String& key, bool default_value) const { return read_entry(group, key, default_value ? "1" : "0") == "1"; } @@ -143,7 +143,7 @@ bool CConfigFile::read_bool_entry(const String& group, const String &key, bool d void CConfigFile::write_entry(const String& group, const String& key, const String& value) { m_groups.ensure(group).ensure(key) = value; - m_dirty = true; + m_dirty = true; } void CConfigFile::write_num_entry(const String& group, const String& key, int value) @@ -152,32 +152,29 @@ void CConfigFile::write_num_entry(const String& group, const String& key, int va } void CConfigFile::write_color_entry(const String& group, const String& key, Color value) { - write_entry(group, key, String::format("%d,%d,%d,%d", value.red(), - value.green(), - value.blue(), - value.alpha())); + write_entry(group, key, String::format("%d,%d,%d,%d", value.red(), value.green(), value.blue(), value.alpha())); } bool CConfigFile::sync() { if (!m_dirty) - return true; + return true; - FILE *fp = fopen(m_file_name.characters(), "wb"); + FILE* fp = fopen(m_file_name.characters(), "wb"); if (!fp) - return false; + return false; for (auto& it : m_groups) { fprintf(fp, "[%s]\n", it.key.characters()); for (auto& jt : it.value) fprintf(fp, "%s=%s\n", jt.key.characters(), jt.value.characters()); fprintf(fp, "\n"); - } + } fclose(fp); - m_dirty = false; - return true; + m_dirty = false; + return true; } void CConfigFile::dump() const @@ -187,7 +184,7 @@ void CConfigFile::dump() const for (auto& jt : it.value) printf("%s=%s\n", jt.key.characters(), jt.value.characters()); printf("\n"); - } + } } Vector CConfigFile::groups() const @@ -199,7 +196,7 @@ Vector CConfigFile::keys(const String& group) const { auto it = m_groups.find(group); if (it == m_groups.end()) - return { }; + return {}; return it->value.keys(); } @@ -207,7 +204,7 @@ bool CConfigFile::has_key(const String& group, const String& key) const { auto it = m_groups.find(group); if (it == m_groups.end()) - return { }; + return {}; return it->value.contains(key); } @@ -219,7 +216,7 @@ bool CConfigFile::has_group(const String& group) const void CConfigFile::remove_group(const String& group) { m_groups.remove(group); - m_dirty = true; + m_dirty = true; } void CConfigFile::remove_entry(const String& group, const String& key) @@ -228,5 +225,5 @@ void CConfigFile::remove_entry(const String& group, const String& key) if (it == m_groups.end()) return; it->value.remove(key); - m_dirty = true; + m_dirty = true; } diff --git a/LibCore/CConfigFile.h b/LibCore/CConfigFile.h index ea71c9b367b..0f58b2b2a2b 100644 --- a/LibCore/CConfigFile.h +++ b/LibCore/CConfigFile.h @@ -1,11 +1,11 @@ #pragma once -#include -#include -#include #include -#include +#include #include +#include +#include +#include class CConfigFile : public Retainable { public: @@ -22,18 +22,18 @@ public: String read_entry(const String& group, const String& key, const String& default_vaule = String()) const; int read_num_entry(const String& group, const String& key, int default_value = 0) const; bool read_bool_entry(const String& group, const String& key, bool default_value = false) const; - Color read_color_entry(const String& group, const String &key, Color default_value) const; + Color read_color_entry(const String& group, const String& key, Color default_value) const; - void write_entry(const String& group, const String& key, const String &value); + void write_entry(const String& group, const String& key, const String& value); void write_num_entry(const String& group, const String& key, int value); void write_bool_entry(const String& group, const String& key, bool value); void write_color_entry(const String& group, const String& key, Color value); - void dump() const; + void dump() const; bool is_dirty() const { return m_dirty; } - bool sync(); + bool sync(); void remove_group(const String& group); void remove_entry(const String& group, const String& key); diff --git a/LibCore/CDirIterator.cpp b/LibCore/CDirIterator.cpp index c66b313e459..aa64ea8b719 100644 --- a/LibCore/CDirIterator.cpp +++ b/LibCore/CDirIterator.cpp @@ -65,4 +65,3 @@ String CDirIterator::next_path() m_next = String(); return tmp; } - diff --git a/LibCore/CDirIterator.h b/LibCore/CDirIterator.h index 03804aecf39..72920c2c1f1 100644 --- a/LibCore/CDirIterator.h +++ b/LibCore/CDirIterator.h @@ -1,11 +1,12 @@ #pragma once -#include #include +#include class CDirIterator { public: - enum Flags { + enum Flags + { NoFlags = 0x0, SkipDots = 0x1, }; @@ -27,4 +28,3 @@ private: bool advance_next(); }; - diff --git a/LibCore/CElapsedTimer.cpp b/LibCore/CElapsedTimer.cpp index aec3658fc44..e783f59b0d8 100644 --- a/LibCore/CElapsedTimer.cpp +++ b/LibCore/CElapsedTimer.cpp @@ -1,6 +1,6 @@ -#include #include #include +#include #include void CElapsedTimer::start() diff --git a/LibCore/CElapsedTimer.h b/LibCore/CElapsedTimer.h index bb8fa28ac63..76fa3044783 100644 --- a/LibCore/CElapsedTimer.h +++ b/LibCore/CElapsedTimer.h @@ -4,7 +4,7 @@ class CElapsedTimer { public: - CElapsedTimer() { } + CElapsedTimer() {} bool is_valid() const { return m_valid; } void start(); @@ -12,5 +12,7 @@ public: private: bool m_valid { false }; - struct timeval m_start_time { 0, 0 }; + struct timeval m_start_time { + 0, 0 + }; }; diff --git a/LibCore/CEvent.h b/LibCore/CEvent.h index 4010afe607a..1920df26881 100644 --- a/LibCore/CEvent.h +++ b/LibCore/CEvent.h @@ -1,15 +1,16 @@ #pragma once #include +#include #include #include -#include class CObject; class CEvent { public: - enum Type { + enum Type + { Invalid = 0, Quit, Timer, @@ -19,9 +20,12 @@ public: ChildRemoved, }; - CEvent() { } - explicit CEvent(unsigned type) : m_type(type) { } - virtual ~CEvent() { } + CEvent() {} + explicit CEvent(unsigned type) + : m_type(type) + { + } + virtual ~CEvent() {} unsigned type() const { return m_type; } @@ -31,6 +35,7 @@ private: class CDeferredInvocationEvent : public CEvent { friend class CEventLoop; + public: CDeferredInvocationEvent(Function invokee) : CEvent(CEvent::Type::DeferredInvoke) @@ -45,10 +50,11 @@ private: class CTimerEvent final : public CEvent { public: explicit CTimerEvent(int timer_id) - : CEvent(CEvent::Timer), m_timer_id(timer_id) + : CEvent(CEvent::Timer) + , m_timer_id(timer_id) { } - ~CTimerEvent() { } + ~CTimerEvent() {} int timer_id() const { return m_timer_id; } diff --git a/LibCore/CEventLoop.cpp b/LibCore/CEventLoop.cpp index 4537efb5afa..d84a45fe169 100644 --- a/LibCore/CEventLoop.cpp +++ b/LibCore/CEventLoop.cpp @@ -1,20 +1,19 @@ -#include -#include -#include -#include -#include -#include -#include +#include +#include #include +#include +#include #include -#include #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include //#define CEVENTLOOP_DEBUG //#define DEFERRED_INVOKE_DEBUG @@ -66,7 +65,8 @@ void CEventLoop::quit(int code) struct CEventLoopPusher { public: - CEventLoopPusher(CEventLoop& event_loop) : m_event_loop(event_loop) + CEventLoopPusher(CEventLoop& event_loop) + : m_event_loop(event_loop) { if (&m_event_loop != s_main_event_loop) { m_event_loop.take_pending_events_from(CEventLoop::current()); @@ -80,6 +80,7 @@ public: CEventLoop::current().take_pending_events_from(m_event_loop); } } + private: CEventLoop& m_event_loop; }; @@ -159,7 +160,7 @@ void CEventLoop::wait_for_event(WaitMode mode) FD_ZERO(&wfds); int max_fd = 0; - auto add_fd_to_set = [&max_fd] (int fd, fd_set& set){ + auto add_fd_to_set = [&max_fd](int fd, fd_set& set) { FD_SET(fd, &set); if (fd > max_fd) max_fd = fd; @@ -271,8 +272,8 @@ int CEventLoop::register_timer(CObject& object, int milliseconds, bool should_re gettimeofday(&now, nullptr); timer->reload(now); timer->should_reload = should_reload; - int timer_id = ++s_next_timer_id; // FIXME: This will eventually wrap around. - ASSERT(timer_id); // FIXME: Aforementioned wraparound. + int timer_id = ++s_next_timer_id; // FIXME: This will eventually wrap around. + ASSERT(timer_id); // FIXME: Aforementioned wraparound. timer->timer_id = timer_id; s_timers->set(timer->timer_id, move(timer)); return timer_id; diff --git a/LibCore/CEventLoop.h b/LibCore/CEventLoop.h index a44cc72486a..dbcc67ddb72 100644 --- a/LibCore/CEventLoop.h +++ b/LibCore/CEventLoop.h @@ -21,7 +21,8 @@ public: int exec(); - enum class WaitMode { + enum class WaitMode + { WaitForEvents, PollForEvents, }; @@ -52,8 +53,8 @@ public: protected: virtual void add_file_descriptors_for_select(fd_set&, int& max_fd) { UNUSED_PARAM(max_fd); } - virtual void process_file_descriptors_after_select(const fd_set&) { } - virtual void do_processing() { } + virtual void process_file_descriptors_after_select(const fd_set&) {} + virtual void do_processing() {} private: void wait_for_event(WaitMode); diff --git a/LibCore/CFile.cpp b/LibCore/CFile.cpp index 47cee94f15f..44813e1c971 100644 --- a/LibCore/CFile.cpp +++ b/LibCore/CFile.cpp @@ -1,7 +1,7 @@ #include -#include #include #include +#include CFile::CFile(const String& filename) : m_filename(filename) diff --git a/LibCore/CFile.h b/LibCore/CFile.h index a78c850fe38..fab396ac55d 100644 --- a/LibCore/CFile.h +++ b/LibCore/CFile.h @@ -1,11 +1,11 @@ #pragma once -#include #include +#include class CFile final : public CIODevice { public: - CFile() { } + CFile() {} explicit CFile(const String&); virtual ~CFile() override; @@ -14,7 +14,11 @@ public: virtual bool open(CIODevice::OpenMode) override; - enum class ShouldCloseFileDescriptor { No = 0, Yes }; + enum class ShouldCloseFileDescriptor + { + No = 0, + Yes + }; bool open(int fd, CIODevice::OpenMode, ShouldCloseFileDescriptor); virtual const char* class_name() const override { return "CFile"; } diff --git a/LibCore/CHttpJob.cpp b/LibCore/CHttpJob.cpp index f9a9a08f3b5..e580fd87c26 100644 --- a/LibCore/CHttpJob.cpp +++ b/LibCore/CHttpJob.cpp @@ -22,7 +22,7 @@ void CHttpJob::on_socket_connected() bool success = m_socket->send(raw_request); if (!success) - return deferred_invoke([this](auto&){ did_fail(CNetworkJob::Error::TransmissionFailed); }); + return deferred_invoke([this](auto&) { did_fail(CNetworkJob::Error::TransmissionFailed); }); Vector buffer; while (m_socket->is_connected()) { @@ -33,18 +33,18 @@ void CHttpJob::on_socket_connected() auto line = m_socket->read_line(PAGE_SIZE); if (line.is_null()) { printf("Expected HTTP status\n"); - return deferred_invoke([this](auto&){ did_fail(CNetworkJob::Error::TransmissionFailed); }); + return deferred_invoke([this](auto&) { did_fail(CNetworkJob::Error::TransmissionFailed); }); } auto parts = String::copy(line, Chomp).split(' '); if (parts.size() < 3) { printf("Expected 3-part HTTP status, got '%s'\n", line.pointer()); - return deferred_invoke([this](auto&){ did_fail(CNetworkJob::Error::ProtocolFailed); }); + return deferred_invoke([this](auto&) { did_fail(CNetworkJob::Error::ProtocolFailed); }); } bool ok; m_code = parts[1].to_uint(ok); if (!ok) { printf("Expected numeric HTTP status\n"); - return deferred_invoke([this](auto&){ did_fail(CNetworkJob::Error::ProtocolFailed); }); + return deferred_invoke([this](auto&) { did_fail(CNetworkJob::Error::ProtocolFailed); }); } m_state = State::InHeaders; continue; @@ -65,12 +65,12 @@ void CHttpJob::on_socket_connected() auto parts = chomped_line.split(':'); if (parts.is_empty()) { printf("Expected HTTP header with key/value\n"); - return deferred_invoke([this](auto&){ did_fail(CNetworkJob::Error::ProtocolFailed); }); + return deferred_invoke([this](auto&) { did_fail(CNetworkJob::Error::ProtocolFailed); }); } auto name = parts[0]; if (chomped_line.length() < name.length() + 2) { printf("Malformed HTTP header: '%s' (%d)\n", chomped_line.characters(), chomped_line.length()); - return deferred_invoke([this](auto&){ did_fail(CNetworkJob::Error::ProtocolFailed); }); + return deferred_invoke([this](auto&) { did_fail(CNetworkJob::Error::ProtocolFailed); }); } auto value = chomped_line.substring(name.length() + 2, chomped_line.length() - name.length() - 2); m_headers.set(name, value); @@ -84,13 +84,13 @@ void CHttpJob::on_socket_connected() m_state = State::Finished; break; } - return deferred_invoke([this](auto&){ did_fail(CNetworkJob::Error::ProtocolFailed); }); + return deferred_invoke([this](auto&) { did_fail(CNetworkJob::Error::ProtocolFailed); }); } buffer.append(payload.pointer(), payload.size()); } auto response = CHttpResponse::create(m_code, move(m_headers), ByteBuffer::copy(buffer.data(), buffer.size())); - deferred_invoke([this, response] (auto&) { + deferred_invoke([this, response](auto&) { did_finish(move(response)); }); } diff --git a/LibCore/CHttpJob.h b/LibCore/CHttpJob.h index e30e836b665..c8d2c8c361b 100644 --- a/LibCore/CHttpJob.h +++ b/LibCore/CHttpJob.h @@ -1,8 +1,8 @@ #pragma once -#include -#include #include +#include +#include class CTCPSocket; @@ -18,7 +18,8 @@ public: private: void on_socket_connected(); - enum class State { + enum class State + { InStatus, InHeaders, InBody, diff --git a/LibCore/CHttpRequest.cpp b/LibCore/CHttpRequest.cpp index 3f07fecaa1f..de62a8cd6dc 100644 --- a/LibCore/CHttpRequest.cpp +++ b/LibCore/CHttpRequest.cpp @@ -1,6 +1,6 @@ -#include -#include #include +#include +#include CHttpRequest::CHttpRequest() { diff --git a/LibCore/CHttpRequest.h b/LibCore/CHttpRequest.h index 5432baf4b53..8ab6fef4130 100644 --- a/LibCore/CHttpRequest.h +++ b/LibCore/CHttpRequest.h @@ -6,7 +6,13 @@ class CNetworkJob; class CHttpRequest { public: - enum Method { Invalid, HEAD, GET, POST }; + enum Method + { + Invalid, + HEAD, + GET, + POST + }; CHttpRequest(); ~CHttpRequest(); diff --git a/LibCore/CHttpResponse.h b/LibCore/CHttpResponse.h index 7cf46bc545d..851f77d3a08 100644 --- a/LibCore/CHttpResponse.h +++ b/LibCore/CHttpResponse.h @@ -1,8 +1,8 @@ #pragma once -#include #include #include +#include class CHttpResponse : public CNetworkResponse { public: diff --git a/LibCore/CIODevice.h b/LibCore/CIODevice.h index 79e589eb9f9..4977c3f33b8 100644 --- a/LibCore/CIODevice.h +++ b/LibCore/CIODevice.h @@ -1,18 +1,19 @@ #pragma once -#include #include +#include class CIODevice : public CObject { public: - enum OpenMode { - NotOpen = 0, - ReadOnly = 1, - WriteOnly = 2, - ReadWrite = 3, - Append = 4, - Truncate = 8, - MustBeNew = 16, + enum OpenMode + { + NotOpen = 0, + ReadOnly = 1, + WriteOnly = 2, + ReadWrite = 3, + Append = 4, + Truncate = 8, + MustBeNew = 16, }; virtual ~CIODevice() override; @@ -37,7 +38,8 @@ public: bool can_read() const; - enum class SeekMode { + enum class SeekMode + { SetPosition, FromCurrentPosition, FromEndPosition, diff --git a/LibCore/CLock.h b/LibCore/CLock.h index a9853f52152..02ab53fa827 100644 --- a/LibCore/CLock.h +++ b/LibCore/CLock.h @@ -4,23 +4,24 @@ #include #include -#define memory_barrier() asm volatile ("" ::: "memory") +#define memory_barrier() asm volatile("" :: \ + : "memory") static inline dword CAS(volatile dword* mem, dword newval, dword oldval) { dword ret; asm volatile( "cmpxchgl %2, %1" - :"=a"(ret), "+m"(*mem) - :"r"(newval), "0"(oldval) - :"cc", "memory"); + : "=a"(ret), "+m"(*mem) + : "r"(newval), "0"(oldval) + : "cc", "memory"); return ret; } class CLock { public: - CLock() { } - ~CLock() { } + CLock() {} + ~CLock() {} void lock(); void unlock(); @@ -33,7 +34,11 @@ private: class CLocker { public: - [[gnu::always_inline]] inline explicit CLocker(CLock& l) : m_lock(l) { lock(); } + [[gnu::always_inline]] inline explicit CLocker(CLock& l) + : m_lock(l) + { + lock(); + } [[gnu::always_inline]] inline ~CLocker() { unlock(); } [[gnu::always_inline]] inline void unlock() { m_lock.unlock(); } [[gnu::always_inline]] inline void lock() { m_lock.lock(); } @@ -86,8 +91,11 @@ inline void CLock::unlock() template class CLockable { public: - CLockable() { } - CLockable(T&& resource) : m_resource(move(resource)) { } + CLockable() {} + CLockable(T&& resource) + : m_resource(move(resource)) + { + } CLock& lock() { return m_lock; } T& resource() { return m_resource; } @@ -101,4 +109,3 @@ private: T m_resource; CLock m_lock; }; - diff --git a/LibCore/CNetworkJob.h b/LibCore/CNetworkJob.h index 4b6b479c8fb..3d8117c754a 100644 --- a/LibCore/CNetworkJob.h +++ b/LibCore/CNetworkJob.h @@ -1,13 +1,14 @@ #pragma once -#include #include +#include class CNetworkResponse; class CNetworkJob : public CObject { public: - enum class Error { + enum class Error + { None, ConnectionFailed, TransmissionFailed, diff --git a/LibCore/CNetworkResponse.h b/LibCore/CNetworkResponse.h index 1968590c793..70bc30de150 100644 --- a/LibCore/CNetworkResponse.h +++ b/LibCore/CNetworkResponse.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class CNetworkResponse : public Retainable { public: diff --git a/LibCore/CNotifier.cpp b/LibCore/CNotifier.cpp index a7e1344900c..000602a4a96 100644 --- a/LibCore/CNotifier.cpp +++ b/LibCore/CNotifier.cpp @@ -1,6 +1,6 @@ -#include -#include #include +#include +#include CNotifier::CNotifier(int fd, unsigned event_mask) : m_fd(fd) @@ -13,4 +13,3 @@ CNotifier::~CNotifier() { CEventLoop::unregister_notifier(Badge(), *this); } - diff --git a/LibCore/CNotifier.h b/LibCore/CNotifier.h index baa3532b927..736d78e04b3 100644 --- a/LibCore/CNotifier.h +++ b/LibCore/CNotifier.h @@ -4,10 +4,11 @@ class CNotifier { public: - enum Event { - None = 0, - Read = 1, - Write = 2, + enum Event + { + None = 0, + Read = 1, + Write = 2, Exceptional = 4, }; CNotifier(int fd, unsigned event_mask); diff --git a/LibCore/CObject.cpp b/LibCore/CObject.cpp index 93f7733c926..a5ea5e6977d 100644 --- a/LibCore/CObject.cpp +++ b/LibCore/CObject.cpp @@ -1,7 +1,7 @@ -#include +#include #include #include -#include +#include #include CObject::CObject(CObject* parent, bool is_widget) @@ -100,7 +100,7 @@ void CObject::dump_tree(int indent) } printf("%s{%p}\n", class_name(), this); - for_each_child([&] (auto& child) { + for_each_child([&](auto& child) { child.dump_tree(indent + 2); return IterationDecision::Continue; }); diff --git a/LibCore/CObject.h b/LibCore/CObject.h index a4eac52eec2..fda00cd9760 100644 --- a/LibCore/CObject.h +++ b/LibCore/CObject.h @@ -29,7 +29,8 @@ public: } } - template void for_each_child_of_type(Callback callback); + template + void for_each_child_of_type(Callback callback); CObject* parent() { return m_parent; } const CObject* parent() const { return m_parent; } @@ -61,7 +62,8 @@ private: Vector m_children; }; -template inline bool is(const CObject&) { return true; } +template +inline bool is(const CObject&) { return true; } template inline T& to(CObject& object) @@ -80,7 +82,7 @@ inline const T& to(const CObject& object) template inline void CObject::for_each_child_of_type(Callback callback) { - for_each_child([&] (auto& child) { + for_each_child([&](auto& child) { if (is(child)) return callback(to(child)); return IterationDecision::Continue; diff --git a/LibCore/CProcessStatisticsReader.cpp b/LibCore/CProcessStatisticsReader.cpp index 1a80f306c30..439ec36e134 100644 --- a/LibCore/CProcessStatisticsReader.cpp +++ b/LibCore/CProcessStatisticsReader.cpp @@ -1,8 +1,8 @@ #include "CProcessStatisticsReader.h" #include "CFile.h" -#include #include +#include CProcessStatisticsReader::CProcessStatisticsReader() { @@ -64,7 +64,7 @@ void CProcessStatisticsReader::update_map(HashMap& ma process.username = get_username_from_uid(uid); process.priority = parts[16]; - + process.syscalls = parts[17].to_uint(ok); if (!ok) { fprintf(stderr, "CProcessHelper : couldn't convert %s to a valid syscalls count value\n", parts[17].characters()); diff --git a/LibCore/CProcessStatisticsReader.h b/LibCore/CProcessStatisticsReader.h index 2ce97e9f688..df9b788ea22 100644 --- a/LibCore/CProcessStatisticsReader.h +++ b/LibCore/CProcessStatisticsReader.h @@ -24,6 +24,6 @@ public: private: void update_map(HashMap& map); String get_username_from_uid(const uid_t uid); - + HashMap m_usernames; }; diff --git a/LibCore/CSocket.cpp b/LibCore/CSocket.cpp index e29caefe299..ea9a7135ecd 100644 --- a/LibCore/CSocket.cpp +++ b/LibCore/CSocket.cpp @@ -1,12 +1,12 @@ -#include #include -#include -#include +#include #include -#include -#include -#include #include +#include +#include +#include +#include +#include CSocket::CSocket(Type type, CObject* parent) : CIODevice(parent) diff --git a/LibCore/CSocket.h b/LibCore/CSocket.h index b02133f0502..0de7872fb29 100644 --- a/LibCore/CSocket.h +++ b/LibCore/CSocket.h @@ -7,7 +7,12 @@ class CNotifier; class CSocket : public CIODevice { public: - enum class Type { Invalid, TCP, UDP }; + enum class Type + { + Invalid, + TCP, + UDP + }; virtual ~CSocket() override; bool connect(const String& hostname, int port); diff --git a/LibCore/CSocketAddress.h b/LibCore/CSocketAddress.h index 5de064dd95b..efa545f24c6 100644 --- a/LibCore/CSocketAddress.h +++ b/LibCore/CSocketAddress.h @@ -4,9 +4,14 @@ class CSocketAddress { public: - enum class Type { Invalid, IPv4, Local }; + enum class Type + { + Invalid, + IPv4, + Local + }; - CSocketAddress() { } + CSocketAddress() {} CSocketAddress(const IPv4Address& address) : m_type(Type::IPv4) , m_ipv4_address(address) @@ -20,8 +25,10 @@ public: String to_string() const { switch (m_type) { - case Type::IPv4: return m_ipv4_address.to_string(); - default: return "[CSocketAddress]"; + case Type::IPv4: + return m_ipv4_address.to_string(); + default: + return "[CSocketAddress]"; } } diff --git a/LibCore/CTCPSocket.h b/LibCore/CTCPSocket.h index c48331f9ee3..fe4f3ffb3a0 100644 --- a/LibCore/CTCPSocket.h +++ b/LibCore/CTCPSocket.h @@ -7,4 +7,3 @@ public: private: }; - diff --git a/LibCore/CTimer.h b/LibCore/CTimer.h index 4d0507512fc..b6c1c2005f3 100644 --- a/LibCore/CTimer.h +++ b/LibCore/CTimer.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class CTimer final : public CObject { public: diff --git a/LibCore/CUserInfo.cpp b/LibCore/CUserInfo.cpp index 9efe1604893..d5308d454e7 100644 --- a/LibCore/CUserInfo.cpp +++ b/LibCore/CUserInfo.cpp @@ -1,7 +1,7 @@ #include "CUserInfo.h" +#include #include #include -#include const char* get_current_user_home_path() { diff --git a/LibCore/CUserInfo.h b/LibCore/CUserInfo.h index 22ef0a8fb49..b47cec4af1c 100644 --- a/LibCore/CUserInfo.h +++ b/LibCore/CUserInfo.h @@ -1 +1 @@ -const char *get_current_user_home_path(); +const char* get_current_user_home_path(); diff --git a/LibGUI/GAbstractView.h b/LibGUI/GAbstractView.h index 1660e40dffd..7709c0cae8d 100644 --- a/LibGUI/GAbstractView.h +++ b/LibGUI/GAbstractView.h @@ -1,13 +1,14 @@ #pragma once +#include #include #include -#include class GTextBox; class GAbstractView : public GScrollableWidget { friend class GModel; + public: explicit GAbstractView(GWidget* parent); virtual ~GAbstractView() override; @@ -23,7 +24,7 @@ public: virtual void did_update_model(); virtual void did_update_selection(); - virtual Rect content_rect(const GModelIndex&) const { return { }; } + virtual Rect content_rect(const GModelIndex&) const { return {}; } void begin_editing(const GModelIndex&); void stop_editing(); diff --git a/LibGUI/GAction.h b/LibGUI/GAction.h index 4d9445fc961..5770693a8ca 100644 --- a/LibGUI/GAction.h +++ b/LibGUI/GAction.h @@ -1,23 +1,25 @@ #pragma once #include +#include #include +#include #include #include -#include #include -#include -#include -#include +#include #include +#include class GButton; class GMenuItem; class GWidget; -class GAction : public Retainable, public Weakable { +class GAction : public Retainable + , public Weakable { public: - enum class ShortcutScope { + enum class ShortcutScope + { None, ApplicationGlobal, WidgetLocal, @@ -62,7 +64,11 @@ public: bool is_checkable() const { return m_checkable; } void set_checkable(bool checkable) { m_checkable = checkable; } - bool is_checked() const { ASSERT(is_checkable()); return m_checked; } + bool is_checked() const + { + ASSERT(is_checkable()); + return m_checked; + } void set_checked(bool); void register_button(Badge, GButton&); @@ -77,8 +83,10 @@ private: GAction(const String& text, RetainPtr&& icon, Function = nullptr, GWidget* = nullptr); GAction(const String& text, const String& custom_data = String(), Function = nullptr, GWidget* = nullptr); - template void for_each_toolbar_button(Callback); - template void for_each_menu_item(Callback); + template + void for_each_toolbar_button(Callback); + template + void for_each_menu_item(Callback); String m_text; String m_custom_data; diff --git a/LibGUI/GApplication.h b/LibGUI/GApplication.h index 4242204cbfd..14b9d65f594 100644 --- a/LibGUI/GApplication.h +++ b/LibGUI/GApplication.h @@ -1,8 +1,8 @@ #pragma once #include -#include #include +#include #include class GAction; diff --git a/LibGUI/GBoxLayout.h b/LibGUI/GBoxLayout.h index 605c7d5d625..b16cca03011 100644 --- a/LibGUI/GBoxLayout.h +++ b/LibGUI/GBoxLayout.h @@ -15,4 +15,3 @@ public: private: Orientation m_orientation; }; - diff --git a/LibGUI/GButton.h b/LibGUI/GButton.h index c0d185a21e4..1f62dc8d39e 100644 --- a/LibGUI/GButton.h +++ b/LibGUI/GButton.h @@ -43,4 +43,3 @@ private: TextAlignment m_text_alignment { TextAlignment::Center }; WeakPtr m_action; }; - diff --git a/LibGUI/GCheckBox.h b/LibGUI/GCheckBox.h index 57e644aa9be..26116817e5c 100644 --- a/LibGUI/GCheckBox.h +++ b/LibGUI/GCheckBox.h @@ -17,4 +17,3 @@ public: private: virtual void paint_event(GPaintEvent&) override; }; - diff --git a/LibGUI/GDialog.h b/LibGUI/GDialog.h index 007f07cc599..7244db5aa09 100644 --- a/LibGUI/GDialog.h +++ b/LibGUI/GDialog.h @@ -1,11 +1,16 @@ #pragma once -#include #include +#include class GDialog : public GWindow { public: - enum ExecResult { ExecOK = 0, ExecCancel = 1, ExecAborted = 2 }; + enum ExecResult + { + ExecOK = 0, + ExecCancel = 1, + ExecAborted = 2 + }; virtual ~GDialog() override; diff --git a/LibGUI/GDirectoryModel.h b/LibGUI/GDirectoryModel.h index e33693ed455..d4f0e310738 100644 --- a/LibGUI/GDirectoryModel.h +++ b/LibGUI/GDirectoryModel.h @@ -1,16 +1,18 @@ #pragma once -#include #include +#include #include class GDirectoryModel final : public GModel { friend int thumbnail_thread(void*); + public: static Retained create() { return adopt(*new GDirectoryModel); } virtual ~GDirectoryModel() override; - enum Column { + enum Column + { Icon = 0, Name, Size, diff --git a/LibGUI/GEvent.h b/LibGUI/GEvent.h index bdb4c0e5d5a..54e111dfe3c 100644 --- a/LibGUI/GEvent.h +++ b/LibGUI/GEvent.h @@ -1,16 +1,17 @@ #pragma once +#include #include +#include #include #include -#include -#include class CObject; -class GEvent : public CEvent{ +class GEvent : public CEvent { public: - enum Type { + enum Type + { Show = 1000, Hide, Paint, @@ -43,9 +44,12 @@ public: __End_WM_Events, }; - GEvent() { } - explicit GEvent(Type type) : CEvent(type) { } - virtual ~GEvent() { } + GEvent() {} + explicit GEvent(Type type) + : CEvent(type) + { + } + virtual ~GEvent() {} bool is_key_event() const { return type() == KeyUp || type() == KeyDown; } bool is_paint_event() const { return type() == Paint; } @@ -175,6 +179,7 @@ public: const Size& old_size() const { return m_old_size; } const Size& size() const { return m_size; } + private: Size m_old_size; Size m_size; @@ -213,7 +218,8 @@ public: } }; -enum GMouseButton : byte { +enum GMouseButton : byte +{ None = 0, Left = 1, Right = 2, diff --git a/LibGUI/GEventLoop.h b/LibGUI/GEventLoop.h index 9d8b5b7e868..aa546825459 100644 --- a/LibGUI/GEventLoop.h +++ b/LibGUI/GEventLoop.h @@ -1,8 +1,8 @@ #pragma once #include -#include #include +#include class GAction; class CObject; @@ -16,7 +16,7 @@ public: static GEventLoop& current() { return static_cast(CEventLoop::current()); } - static bool post_message_to_server(const WSAPI_ClientMessage&, const ByteBuffer& extra_data = { }); + static bool post_message_to_server(const WSAPI_ClientMessage&, const ByteBuffer& extra_data = {}); bool wait_for_specific_event(WSAPI_ServerMessage::Type, WSAPI_ServerMessage&); WSAPI_ServerMessage sync_request(const WSAPI_ClientMessage& request, WSAPI_ServerMessage::Type response_type); diff --git a/LibGUI/GFileSystemModel.h b/LibGUI/GFileSystemModel.h index 7eb7f5ef0c3..7f21ca7794e 100644 --- a/LibGUI/GFileSystemModel.h +++ b/LibGUI/GFileSystemModel.h @@ -4,8 +4,14 @@ class GFileSystemModel : public GModel { friend class Node; + public: - enum Mode { Invalid, DirectoriesOnly, FilesAndDirectories }; + enum Mode + { + Invalid, + DirectoriesOnly, + FilesAndDirectories + }; static Retained create(const String& root_path = "/", Mode mode = Mode::FilesAndDirectories) { diff --git a/LibGUI/GFontDatabase.h b/LibGUI/GFontDatabase.h index e1de0baec56..af49e688750 100644 --- a/LibGUI/GFontDatabase.h +++ b/LibGUI/GFontDatabase.h @@ -1,8 +1,8 @@ #pragma once #include -#include #include +#include class Font; @@ -20,7 +20,8 @@ public: void for_each_font(Function); void for_each_fixed_width_font(Function); - Metadata get_metadata_by_name(const String& name) const { + Metadata get_metadata_by_name(const String& name) const + { return m_name_to_metadata.get(name); }; diff --git a/LibGUI/GIcon.h b/LibGUI/GIcon.h index c0b3d15cdf5..61d928127f6 100644 --- a/LibGUI/GIcon.h +++ b/LibGUI/GIcon.h @@ -1,18 +1,18 @@ #pragma once -#include #include +#include class GIconImpl : public Retainable { public: static Retained create() { return adopt(*new GIconImpl); } - ~GIconImpl() { } + ~GIconImpl() {} const GraphicsBitmap* bitmap_for_size(int) const; void set_bitmap_for_size(int, RetainPtr&&); private: - GIconImpl() { } + GIconImpl() {} HashMap> m_bitmaps; }; @@ -23,7 +23,7 @@ public: explicit GIcon(RetainPtr&&, RetainPtr&&); explicit GIcon(const GIconImpl&); GIcon(const GIcon&); - ~GIcon() { } + ~GIcon() {} static GIcon default_icon(const String&); diff --git a/LibGUI/GItemView.h b/LibGUI/GItemView.h index 19f9e30f922..ca50019ce4b 100644 --- a/LibGUI/GItemView.h +++ b/LibGUI/GItemView.h @@ -1,9 +1,9 @@ #pragma once -#include -#include #include #include +#include +#include class GScrollBar; class Painter; diff --git a/LibGUI/GLabel.h b/LibGUI/GLabel.h index f9097a28c25..a67b50b90c0 100644 --- a/LibGUI/GLabel.h +++ b/LibGUI/GLabel.h @@ -36,4 +36,3 @@ private: TextAlignment m_text_alignment { TextAlignment::Center }; bool m_should_stretch_icon { false }; }; - diff --git a/LibGUI/GLayout.h b/LibGUI/GLayout.h index 4d07f735463..498f0efc6af 100644 --- a/LibGUI/GLayout.h +++ b/LibGUI/GLayout.h @@ -32,7 +32,8 @@ public: protected: struct Entry { - enum class Type { + enum class Type + { Invalid = 0, Widget, Layout, @@ -51,4 +52,3 @@ protected: GMargins m_margins; int m_spacing { 4 }; }; - diff --git a/LibGUI/GListView.h b/LibGUI/GListView.h index 8cf1c4cb0fc..d32f7b51f90 100644 --- a/LibGUI/GListView.h +++ b/LibGUI/GListView.h @@ -1,9 +1,9 @@ #pragma once -#include -#include #include #include +#include +#include class GScrollBar; class Painter; diff --git a/LibGUI/GMargins.h b/LibGUI/GMargins.h index 730923bf2bc..cdfb5906545 100644 --- a/LibGUI/GMargins.h +++ b/LibGUI/GMargins.h @@ -2,7 +2,7 @@ class GMargins { public: - GMargins() { } + GMargins() {} GMargins(int left, int top, int right, int bottom) : m_left(left) , m_top(top) @@ -10,7 +10,7 @@ public: , m_bottom(bottom) { } - ~GMargins() { } + ~GMargins() {} bool is_null() const { return !m_left && !m_top && !m_right && !m_bottom; } diff --git a/LibGUI/GMenu.h b/LibGUI/GMenu.h index 1eb741de4b6..97a8ed51c98 100644 --- a/LibGUI/GMenu.h +++ b/LibGUI/GMenu.h @@ -1,10 +1,10 @@ #pragma once -#include #include #include #include #include +#include class GAction; class Point; diff --git a/LibGUI/GMenuBar.h b/LibGUI/GMenuBar.h index 4fc4d905546..88f98eed7b5 100644 --- a/LibGUI/GMenuBar.h +++ b/LibGUI/GMenuBar.h @@ -1,8 +1,8 @@ #pragma once -#include #include #include +#include class GApplication; diff --git a/LibGUI/GMenuItem.h b/LibGUI/GMenuItem.h index 29875281216..6cb1df8e538 100644 --- a/LibGUI/GMenuItem.h +++ b/LibGUI/GMenuItem.h @@ -8,7 +8,12 @@ class GMenu; class GMenuItem { public: - enum Type { Invalid, Action, Separator }; + enum Type + { + Invalid, + Action, + Separator + }; GMenuItem(unsigned menu_id, Type); GMenuItem(unsigned menu_id, Retained&&); @@ -43,4 +48,3 @@ private: bool m_checked { false }; RetainPtr m_action; }; - diff --git a/LibGUI/GMessageBox.h b/LibGUI/GMessageBox.h index 5ccfcc46aa6..31f4983ae35 100644 --- a/LibGUI/GMessageBox.h +++ b/LibGUI/GMessageBox.h @@ -4,7 +4,8 @@ class GMessageBox : public GDialog { public: - enum class Type { + enum class Type + { None, Information, Warning, diff --git a/LibGUI/GModel.h b/LibGUI/GModel.h index 9f3e087c3cc..0aba8900cd6 100644 --- a/LibGUI/GModel.h +++ b/LibGUI/GModel.h @@ -12,11 +12,17 @@ class Font; class GAbstractView; -enum class GSortOrder { None, Ascending, Descending }; +enum class GSortOrder +{ + None, + Ascending, + Descending +}; class GModelNotification { public: - enum Type { + enum Type + { Invalid = 0, ModelUpdated, }; @@ -43,22 +49,30 @@ public: const Font* font { nullptr }; }; - enum class Role { Display, Sort, Custom, ForegroundColor, BackgroundColor, Icon }; + enum class Role + { + Display, + Sort, + Custom, + ForegroundColor, + BackgroundColor, + Icon + }; virtual ~GModel(); virtual int row_count(const GModelIndex& = GModelIndex()) const = 0; virtual int column_count(const GModelIndex& = GModelIndex()) const = 0; - virtual String row_name(int) const { return { }; } - virtual String column_name(int) const { return { }; } - virtual ColumnMetadata column_metadata(int) const { return { }; } + virtual String row_name(int) const { return {}; } + virtual String column_name(int) const { return {}; } + virtual ColumnMetadata column_metadata(int) const { return {}; } virtual GVariant data(const GModelIndex&, Role = Role::Display) const = 0; virtual void update() = 0; - virtual GModelIndex parent_index(const GModelIndex&) const { return { }; } + virtual GModelIndex parent_index(const GModelIndex&) const { return {}; } virtual GModelIndex index(int row, int column = 0, const GModelIndex& = GModelIndex()) const { return create_index(row, column); } virtual GModelIndex sibling(int row, int column, const GModelIndex& parent) const; virtual bool is_editable(const GModelIndex&) const { return false; } - virtual void set_data(const GModelIndex&, const GVariant&) { } + virtual void set_data(const GModelIndex&, const GVariant&) {} bool is_valid(const GModelIndex& index) const { @@ -70,7 +84,7 @@ public: virtual int key_column() const { return -1; } virtual GSortOrder sort_order() const { return GSortOrder::None; } - virtual void set_key_column_and_sort_order(int, GSortOrder) { } + virtual void set_key_column_and_sort_order(int, GSortOrder) {} void register_view(Badge, GAbstractView&); void unregister_view(Badge, GAbstractView&); diff --git a/LibGUI/GModelIndex.h b/LibGUI/GModelIndex.h index a568f1f63a7..6817270a663 100644 --- a/LibGUI/GModelIndex.h +++ b/LibGUI/GModelIndex.h @@ -4,8 +4,9 @@ class GModel; class GModelIndex { friend class GModel; + public: - GModelIndex() { } + GModelIndex() {} bool is_valid() const { return m_row != -1 && m_column != -1; } int row() const { return m_row; } diff --git a/LibGUI/GProgressBar.h b/LibGUI/GProgressBar.h index 2429dcf0aed..42e38434038 100644 --- a/LibGUI/GProgressBar.h +++ b/LibGUI/GProgressBar.h @@ -19,7 +19,12 @@ public: String caption() const { return m_caption; } void set_caption(const String& caption) { m_caption = caption; } - enum Format { NoText, Percentage, ValueSlashMax }; + enum Format + { + NoText, + Percentage, + ValueSlashMax + }; Format format() const { return m_format; } void set_format(Format format) { m_format = format; } diff --git a/LibGUI/GRadioButton.h b/LibGUI/GRadioButton.h index 95897f5b47e..410f0e4556f 100644 --- a/LibGUI/GRadioButton.h +++ b/LibGUI/GRadioButton.h @@ -17,11 +17,13 @@ protected: private: virtual bool is_radio_button() const final { return true; } - template void for_each_in_group(Callback); + template + void for_each_in_group(Callback); static Size circle_size(); }; -template<> inline bool is(const CObject& object) +template<> +inline bool is(const CObject& object) { if (!is(object)) return false; diff --git a/LibGUI/GScrollBar.h b/LibGUI/GScrollBar.h index cfc9fbc7a28..7878a9b6274 100644 --- a/LibGUI/GScrollBar.h +++ b/LibGUI/GScrollBar.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class GScrollBar final : public GWidget { public: @@ -28,7 +28,8 @@ public: virtual const char* class_name() const override { return "GScrollBar"; } - enum Component { + enum Component + { Invalid, DecrementButton, IncrementButton, diff --git a/LibGUI/GScrollableWidget.h b/LibGUI/GScrollableWidget.h index f2b0c17a868..f645a8bf473 100644 --- a/LibGUI/GScrollableWidget.h +++ b/LibGUI/GScrollableWidget.h @@ -40,7 +40,7 @@ protected: explicit GScrollableWidget(GWidget* parent); virtual void resize_event(GResizeEvent&) override; virtual void mousewheel_event(GMouseEvent&) override; - virtual void did_scroll() { } + virtual void did_scroll() {} void set_content_size(const Size&); void set_size_occupied_by_fixed_elements(const Size&); diff --git a/LibGUI/GShortcut.h b/LibGUI/GShortcut.h index bae66dc4d50..20713eb0f50 100644 --- a/LibGUI/GShortcut.h +++ b/LibGUI/GShortcut.h @@ -1,12 +1,12 @@ #pragma once -#include #include #include +#include class GShortcut { public: - GShortcut() { } + GShortcut() {} GShortcut(byte modifiers, KeyCode key) : m_modifiers(modifiers) , m_key(key) diff --git a/LibGUI/GTableView.h b/LibGUI/GTableView.h index 4838b4f0488..9db2e68eaa7 100644 --- a/LibGUI/GTableView.h +++ b/LibGUI/GTableView.h @@ -1,9 +1,9 @@ #pragma once -#include -#include #include #include +#include +#include class GScrollBar; class Painter; diff --git a/LibGUI/GTextBox.h b/LibGUI/GTextBox.h index fd05d885b2d..6673e09fefe 100644 --- a/LibGUI/GTextBox.h +++ b/LibGUI/GTextBox.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class GTextBox final : public GTextEditor { public: @@ -10,4 +10,3 @@ public: virtual const char* class_name() const override { return "GTextBox"; } }; - diff --git a/LibGUI/GTextEditor.h b/LibGUI/GTextEditor.h index a1bfe0c33fc..648bf9d80de 100644 --- a/LibGUI/GTextEditor.h +++ b/LibGUI/GTextEditor.h @@ -1,8 +1,8 @@ #pragma once -#include #include #include +#include #include class GAction; @@ -12,7 +12,7 @@ class Painter; class GTextPosition { public: - GTextPosition() { } + GTextPosition() {} GTextPosition(int line, int column) : m_line(line) , m_column(column) @@ -38,11 +38,19 @@ private: class GTextRange { public: - GTextRange() { } - GTextRange(const GTextPosition& start, const GTextPosition& end) : m_start(start) , m_end(end) { } + GTextRange() {} + GTextRange(const GTextPosition& start, const GTextPosition& end) + : m_start(start) + , m_end(end) + { + } bool is_valid() const { return m_start.is_valid() && m_end.is_valid(); } - void clear() { m_start = { }; m_end = { }; } + void clear() + { + m_start = {}; + m_end = {}; + } GTextPosition& start() { return m_start; } GTextPosition& end() { return m_end; } @@ -54,7 +62,11 @@ public: void set_start(const GTextPosition& position) { m_start = position; } void set_end(const GTextPosition& position) { m_end = position; } - void set(const GTextPosition& start, const GTextPosition& end) { m_start = start; m_end = end; } + void set(const GTextPosition& start, const GTextPosition& end) + { + m_start = start; + m_end = end; + } private: GTextPosition normalized_start() const { return m_start < m_end ? m_start : m_end; } @@ -66,7 +78,11 @@ private: class GTextEditor : public GScrollableWidget { public: - enum Type { MultiLine, SingleLine }; + enum Type + { + MultiLine, + SingleLine + }; GTextEditor(Type, GWidget* parent); virtual ~GTextEditor() override; @@ -149,6 +165,7 @@ private: class Line { friend class GTextEditor; + public: Line(); explicit Line(const String&); diff --git a/LibGUI/GToolBar.h b/LibGUI/GToolBar.h index 4660001c1c6..5dac448e746 100644 --- a/LibGUI/GToolBar.h +++ b/LibGUI/GToolBar.h @@ -21,7 +21,12 @@ private: virtual void paint_event(GPaintEvent&) override; struct Item { - enum Type { Invalid, Separator, Action }; + enum Type + { + Invalid, + Separator, + Action + }; Type type { Invalid }; RetainPtr action; }; diff --git a/LibGUI/GVariant.h b/LibGUI/GVariant.h index 38cdfd713b7..83193e82ad2 100644 --- a/LibGUI/GVariant.h +++ b/LibGUI/GVariant.h @@ -27,7 +27,8 @@ public: void clear(); ~GVariant(); - enum class Type { + enum class Type + { Invalid, Bool, Int, diff --git a/LibGUI/GWidget.h b/LibGUI/GWidget.h index 6416145672a..6e73c7e4c1c 100644 --- a/LibGUI/GWidget.h +++ b/LibGUI/GWidget.h @@ -1,15 +1,15 @@ #pragma once +#include +#include +#include #include +#include #include #include -#include -#include #include #include -#include -#include -#include +#include class GraphicsBitmap; class GAction; @@ -17,10 +17,26 @@ class GLayout; class GMenu; class GWindow; -enum class SizePolicy { Fixed, Fill }; -enum class Orientation { Horizontal, Vertical }; -enum class HorizontalDirection { Left, Right }; -enum class VerticalDirection { Up, Down }; +enum class SizePolicy +{ + Fixed, + Fill +}; +enum class Orientation +{ + Horizontal, + Vertical +}; +enum class HorizontalDirection +{ + Left, + Right +}; +enum class VerticalDirection +{ + Up, + Down +}; class GWidget : public CObject { public: @@ -178,7 +194,7 @@ public: template void for_each_child_widget(Callback callback) { - for_each_child([&] (auto& child) { + for_each_child([&](auto& child) { if (is(child)) return callback(to(child)); return IterationDecision::Continue; @@ -224,7 +240,8 @@ private: HashMap m_local_shortcut_actions; }; -template<> inline bool is(const CObject& object) +template<> +inline bool is(const CObject& object) { return object.is_widget(); } diff --git a/LibGUI/GWindow.h b/LibGUI/GWindow.h index c1b3d10cd33..200bec1a77a 100644 --- a/LibGUI/GWindow.h +++ b/LibGUI/GWindow.h @@ -1,16 +1,17 @@ #pragma once -#include -#include -#include -#include #include #include +#include +#include +#include +#include class GWidget; class GWMEvent; -enum class GStandardCursor { +enum class GStandardCursor +{ None = 0, Arrow, IBeam, diff --git a/LibGUI/GWindowType.h b/LibGUI/GWindowType.h index d6208892492..a399dec4a3a 100644 --- a/LibGUI/GWindowType.h +++ b/LibGUI/GWindowType.h @@ -1,6 +1,7 @@ #pragma once -enum class GWindowType { +enum class GWindowType +{ Invalid = 0, Normal, Menu, diff --git a/LibM/math.h b/LibM/math.h index 2c3771a9abf..70f95efe34f 100644 --- a/LibM/math.h +++ b/LibM/math.h @@ -54,4 +54,3 @@ float ldexpf(float, int exp); double pow(double x, double y); __END_DECLS - diff --git a/Servers/LookupServer/DNSPacket.h b/Servers/LookupServer/DNSPacket.h index d1ba5c0fb9f..fddf35a5b17 100644 --- a/Servers/LookupServer/DNSPacket.h +++ b/Servers/LookupServer/DNSPacket.h @@ -3,7 +3,8 @@ #include #include -class [[gnu::packed]] DNSPacket { +class [[gnu::packed]] DNSPacket +{ public: DNSPacket() : m_recursion_desired(false) diff --git a/Servers/LookupServer/DNSRecord.h b/Servers/LookupServer/DNSRecord.h index 954fbd036ad..5989f8c99a3 100644 --- a/Servers/LookupServer/DNSRecord.h +++ b/Servers/LookupServer/DNSRecord.h @@ -3,9 +3,10 @@ #include #include -class [[gnu::packed]] DNSRecord { +class [[gnu::packed]] DNSRecord +{ public: - DNSRecord() { } + DNSRecord() {} word name() const { return m_name; } word type() const { return m_type; } diff --git a/Servers/WindowServer/WSAPITypes.h b/Servers/WindowServer/WSAPITypes.h index 9d2d9b6285b..fe3a194cd50 100644 --- a/Servers/WindowServer/WSAPITypes.h +++ b/Servers/WindowServer/WSAPITypes.h @@ -20,7 +20,8 @@ struct WSAPI_Rect { WSAPI_Size size; }; -enum WSAPI_WindowType { +enum WSAPI_WindowType +{ Invalid = 0, Normal, Menu, @@ -36,20 +37,25 @@ struct WSAPI_WindowBackingStoreInfo { RGBA32* pixels; }; -enum class WSAPI_MouseButton : unsigned char { +enum class WSAPI_MouseButton : unsigned char +{ NoButton = 0, - Left = 1, - Right = 2, - Middle = 4, + Left = 1, + Right = 2, + Middle = 4, }; -struct WSAPI_KeyModifiers { enum { - Shift = 1 << 0, - Alt = 1 << 1, - Ctrl = 1 << 2, -}; }; +struct WSAPI_KeyModifiers { + enum + { + Shift = 1 << 0, + Alt = 1 << 1, + Ctrl = 1 << 2, + }; +}; -enum class WSAPI_StandardCursor : unsigned char { +enum class WSAPI_StandardCursor : unsigned char +{ None = 0, Arrow, IBeam, @@ -59,7 +65,8 @@ enum class WSAPI_StandardCursor : unsigned char { ResizeDiagonalBLTR, }; -enum WSAPI_WMEventMask : unsigned { +enum WSAPI_WMEventMask : unsigned +{ WindowRectChanges = 1 << 0, WindowStateChanges = 1 << 1, WindowIconChanges = 1 << 2, @@ -67,7 +74,8 @@ enum WSAPI_WMEventMask : unsigned { }; struct WSAPI_ServerMessage { - enum Type : unsigned { + enum Type : unsigned + { Invalid, Error, Paint, @@ -187,7 +195,8 @@ struct WSAPI_ServerMessage { }; struct WSAPI_ClientMessage { - enum Type : unsigned { + enum Type : unsigned + { Invalid, CreateMenubar, DestroyMenubar, @@ -290,9 +299,18 @@ struct WSAPI_ClientMessage { }; }; -inline Rect::Rect(const WSAPI_Rect& r) : Rect(r.location, r.size) { } -inline Point::Point(const WSAPI_Point& p) : Point(p.x, p.y) { } -inline Size::Size(const WSAPI_Size& s) : Size(s.width, s.height) { } +inline Rect::Rect(const WSAPI_Rect& r) + : Rect(r.location, r.size) +{ +} +inline Point::Point(const WSAPI_Point& p) + : Point(p.x, p.y) +{ +} +inline Size::Size(const WSAPI_Size& s) + : Size(s.width, s.height) +{ +} inline Rect::operator WSAPI_Rect() const { return { m_location, m_size }; } inline Point::operator WSAPI_Point() const { return { m_x, m_y }; } inline Size::operator WSAPI_Size() const { return { m_width, m_height }; } diff --git a/Servers/WindowServer/WSButton.h b/Servers/WindowServer/WSButton.h index bd87932e6f5..780e55aaa34 100644 --- a/Servers/WindowServer/WSButton.h +++ b/Servers/WindowServer/WSButton.h @@ -1,9 +1,9 @@ #pragma once -#include #include #include #include +#include class CharacterBitmap; class Painter; @@ -18,7 +18,7 @@ public: Rect relative_rect() const { return m_relative_rect; } void set_relative_rect(const Rect& rect) { m_relative_rect = rect; } - Rect rect() const { return { { }, m_relative_rect.size() }; } + Rect rect() const { return { {}, m_relative_rect.size() }; } Rect screen_rect() const; void paint(Painter&); diff --git a/Servers/WindowServer/WSClientConnection.h b/Servers/WindowServer/WSClientConnection.h index da5eeb94b01..e2d1025e8cf 100644 --- a/Servers/WindowServer/WSClientConnection.h +++ b/Servers/WindowServer/WSClientConnection.h @@ -1,11 +1,11 @@ #pragma once +#include #include #include #include -#include -#include #include +#include #include class WSWindow; @@ -21,7 +21,7 @@ public: static WSClientConnection* from_client_id(int client_id); static void for_each_client(Function); - void post_message(const WSAPI_ServerMessage&, const ByteBuffer& = { }); + void post_message(const WSAPI_ServerMessage&, const ByteBuffer& = {}); int client_id() const { return m_client_id; } WSMenuBar* app_menubar() { return m_app_menubar.ptr(); } @@ -33,8 +33,10 @@ public: void set_client_pid(pid_t pid) { m_pid = pid; } - template void for_each_window_matching(Matching, Callback); - template void for_each_window(Callback); + template + void for_each_window_matching(Matching, Callback); + template + void for_each_window(Callback); void notify_about_new_screen_rect(const Rect&); void post_paint_message(WSWindow&); diff --git a/Servers/WindowServer/WSCompositor.h b/Servers/WindowServer/WSCompositor.h index 02440ab553d..eb217d88a86 100644 --- a/Servers/WindowServer/WSCompositor.h +++ b/Servers/WindowServer/WSCompositor.h @@ -10,7 +10,14 @@ class Painter; class WSCursor; -enum class WallpaperMode { Simple, Tile, Center, Scaled, Unchecked }; +enum class WallpaperMode +{ + Simple, + Tile, + Center, + Scaled, + Unchecked +}; class WSCompositor final : public CObject { public: diff --git a/Servers/WindowServer/WSCursor.h b/Servers/WindowServer/WSCursor.h index 889fdcdef1c..e16eada5c74 100644 --- a/Servers/WindowServer/WSCursor.h +++ b/Servers/WindowServer/WSCursor.h @@ -2,7 +2,8 @@ #include -enum class WSStandardCursor { +enum class WSStandardCursor +{ None = 0, Arrow, IBeam, diff --git a/Servers/WindowServer/WSEvent.h b/Servers/WindowServer/WSEvent.h index 635f7bb6e6c..95276d642a6 100644 --- a/Servers/WindowServer/WSEvent.h +++ b/Servers/WindowServer/WSEvent.h @@ -1,17 +1,18 @@ #pragma once -#include -#include #include #include #include +#include +#include +#include #include #include -#include class WSEvent : public CEvent { public: - enum Type { + enum Type + { Invalid = 2000, WM_DeferredCompose, WM_ClientDisconnected, @@ -71,9 +72,12 @@ public: __End_API_Client_Requests, }; - WSEvent() { } - explicit WSEvent(Type type) : CEvent(type) { } - virtual ~WSEvent() { } + WSEvent() {} + explicit WSEvent(Type type) + : CEvent(type) + { + } + virtual ~WSEvent() {} bool is_client_request() const { return type() > __Begin_API_Client_Requests && type() < __End_API_Client_Requests; } bool is_mouse_event() const { return type() == MouseMove || type() == MouseDown || type() == MouseDoubleClick || type() == MouseUp || type() == MouseWheel; } @@ -162,7 +166,6 @@ private: bool m_minimized; }; - class WSAPISetGlobalCursorTrackingRequest : public WSAPIClientRequest { public: WSAPISetGlobalCursorTrackingRequest(int client_id, int window_id, bool value) @@ -688,7 +691,8 @@ private: Vector m_rects; }; -enum class MouseButton : byte { +enum class MouseButton : byte +{ None = 0, Left = 1, Right = 2, diff --git a/Servers/WindowServer/WSEventLoop.h b/Servers/WindowServer/WSEventLoop.h index a45a9eb9d44..8c76a17efb5 100644 --- a/Servers/WindowServer/WSEventLoop.h +++ b/Servers/WindowServer/WSEventLoop.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class WSClientConnection; struct WSAPI_ClientMessage; diff --git a/Servers/WindowServer/WSMenu.h b/Servers/WindowServer/WSMenu.h index b9a97132566..25d27179e34 100644 --- a/Servers/WindowServer/WSMenu.h +++ b/Servers/WindowServer/WSMenu.h @@ -3,9 +3,9 @@ #include #include #include +#include #include #include -#include class WSClientConnection; class WSMenuBar; @@ -91,4 +91,3 @@ private: Vector> m_items; OwnPtr m_menu_window; }; - diff --git a/Servers/WindowServer/WSMenuBar.h b/Servers/WindowServer/WSMenuBar.h index 08fc527e59d..c26a3447b02 100644 --- a/Servers/WindowServer/WSMenuBar.h +++ b/Servers/WindowServer/WSMenuBar.h @@ -2,8 +2,8 @@ #include "WSMenu.h" #include -#include #include +#include class WSMenuBar : public Weakable { public: diff --git a/Servers/WindowServer/WSMenuItem.h b/Servers/WindowServer/WSMenuItem.h index c725a43c145..7b381386e77 100644 --- a/Servers/WindowServer/WSMenuItem.h +++ b/Servers/WindowServer/WSMenuItem.h @@ -8,13 +8,14 @@ class WSMenu; class WSMenuItem { public: - enum Type { + enum Type + { None, Text, Separator, }; - WSMenuItem(WSMenu&, unsigned identifier, const String& text, const String& shortcut_text = { }, bool enabled = true, bool checkable = false, bool checked = false); + WSMenuItem(WSMenu&, unsigned identifier, const String& text, const String& shortcut_text = {}, bool enabled = true, bool checkable = false, bool checked = false); WSMenuItem(WSMenu&, Type); ~WSMenuItem(); @@ -51,4 +52,3 @@ private: String m_shortcut_text; Rect m_rect; }; - diff --git a/Servers/WindowServer/WSScreen.h b/Servers/WindowServer/WSScreen.h index 891ac527b0a..77fb5880a2b 100644 --- a/Servers/WindowServer/WSScreen.h +++ b/Servers/WindowServer/WSScreen.h @@ -1,9 +1,9 @@ #pragma once +#include +#include #include #include -#include -#include class WSScreen { public: diff --git a/Servers/WindowServer/WSWindow.h b/Servers/WindowServer/WSWindow.h index 1f76a25c8a2..4e938b44a0f 100644 --- a/Servers/WindowServer/WSWindow.h +++ b/Servers/WindowServer/WSWindow.h @@ -1,20 +1,21 @@ #pragma once -#include -#include #include #include #include -#include -#include #include +#include +#include +#include +#include class WSClientConnection; class WSCursor; class WSMenu; class WSMouseEvent; -class WSWindow final : public CObject, public InlineLinkedListNode { +class WSWindow final : public CObject + , public InlineLinkedListNode { public: WSWindow(WSClientConnection&, WSWindowType, int window_id, bool modal, bool resizable, bool fullscreen); WSWindow(CObject&, WSWindowType); diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h index 9192a35860d..6c2fde241f4 100644 --- a/Servers/WindowServer/WSWindowManager.h +++ b/Servers/WindowServer/WSWindowManager.h @@ -1,22 +1,22 @@ #pragma once -#include -#include -#include -#include +#include "WSMenuBar.h" +#include #include #include #include -#include -#include "WSMenuBar.h" -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include +#include +#include +#include class WSAPIClientRequest; class WSScreen; @@ -29,12 +29,24 @@ class WSWindowSwitcher; class GraphicsBitmap; class WSButton; -enum class ResizeDirection { None, Left, UpLeft, Up, UpRight, Right, DownRight, Down, DownLeft }; +enum class ResizeDirection +{ + None, + Left, + UpLeft, + Up, + UpRight, + Right, + DownRight, + Down, + DownLeft +}; class WSWindowManager : public CObject { friend class WSCompositor; friend class WSWindowFrame; friend class WSWindowSwitcher; + public: static WSWindowManager& the(); @@ -135,12 +147,18 @@ private: void start_window_drag(WSWindow&, const WSMouseEvent&); void handle_client_request(const WSAPIClientRequest&); void set_hovered_window(WSWindow*); - template IterationDecision for_each_visible_window_of_type_from_back_to_front(WSWindowType, Callback, bool ignore_highlight = false); - template IterationDecision for_each_visible_window_of_type_from_front_to_back(WSWindowType, Callback, bool ignore_highlight = false); - template IterationDecision for_each_visible_window_from_front_to_back(Callback); - template IterationDecision for_each_visible_window_from_back_to_front(Callback); - template void for_each_window_listening_to_wm_events(Callback); - template void for_each_window(Callback); + template + IterationDecision for_each_visible_window_of_type_from_back_to_front(WSWindowType, Callback, bool ignore_highlight = false); + template + IterationDecision for_each_visible_window_of_type_from_front_to_back(WSWindowType, Callback, bool ignore_highlight = false); + template + IterationDecision for_each_visible_window_from_front_to_back(Callback); + template + IterationDecision for_each_visible_window_from_back_to_front(Callback); + template + void for_each_window_listening_to_wm_events(Callback); + template + void for_each_window(Callback); template void for_each_active_menubar_menu(Callback callback) @@ -185,10 +203,10 @@ private: HashTable m_windows; InlineLinkedList m_windows_in_order; - struct DoubleClickInfo - { + struct DoubleClickInfo { CElapsedTimer& click_clock(MouseButton); - void reset() { + void reset() + { m_left_click_clock = CElapsedTimer(); m_right_click_clock = CElapsedTimer(); m_middle_click_clock = CElapsedTimer(); diff --git a/Servers/WindowServer/WSWindowSwitcher.h b/Servers/WindowServer/WSWindowSwitcher.h index e3d50160800..1feed2625c4 100644 --- a/Servers/WindowServer/WSWindowSwitcher.h +++ b/Servers/WindowServer/WSWindowSwitcher.h @@ -1,9 +1,9 @@ #pragma once -#include #include #include #include +#include class Painter; class WSKeyEvent; diff --git a/Servers/WindowServer/WSWindowType.h b/Servers/WindowServer/WSWindowType.h index 897e81f74e8..5197046f2c9 100644 --- a/Servers/WindowServer/WSWindowType.h +++ b/Servers/WindowServer/WSWindowType.h @@ -1,6 +1,7 @@ #pragma once -enum class WSWindowType { +enum class WSWindowType +{ Invalid = 0, Normal, Menu, diff --git a/Shell/LineEditor.h b/Shell/LineEditor.h index da01c435af6..2de7d52e14c 100644 --- a/Shell/LineEditor.h +++ b/Shell/LineEditor.h @@ -28,7 +28,8 @@ private: int m_history_cursor { 0 }; int m_history_capacity { 100 }; - enum class InputState { + enum class InputState + { Free, ExpectBracket, ExpectFinal, diff --git a/Shell/Parser.h b/Shell/Parser.h index ed94a888dcb..4f3bde4a7fe 100644 --- a/Shell/Parser.h +++ b/Shell/Parser.h @@ -4,11 +4,18 @@ #include struct Redirection { - enum Type { Pipe, FileWrite, FileWriteAppend, FileRead, Rewire }; + enum Type + { + Pipe, + FileWrite, + FileWriteAppend, + FileRead, + Rewire + }; Type type; int fd { -1 }; int rewire_fd { -1 }; - String path { }; + String path {}; }; struct Subcommand { @@ -18,7 +25,10 @@ struct Subcommand { class Parser { public: - explicit Parser(const String& input) : m_input(input) { } + explicit Parser(const String& input) + : m_input(input) + { + } Vector parse(); @@ -29,7 +39,8 @@ private: void begin_redirect_read(int fd); void begin_redirect_write(int fd); - enum State { + enum State + { Free, InSingleQuotes, InDoubleQuotes, @@ -44,4 +55,3 @@ private: Vector m_redirections; Vector m_token; }; -