diff options
286 files changed, 3242 insertions, 2422 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..d2314f72ac --- /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 80014ac8e1..b93843b719 100644 --- a/AK/AKString.h +++ b/AK/AKString.h @@ -3,18 +3,18 @@ #include <AK/ByteBuffer.h> #include <AK/RetainPtr.h> #include <AK/StringImpl.h> +#include <AK/StringView.h> #include <AK/Traits.h> #include <AK/Vector.h> -#include <AK/StringView.h> #include <AK/kstdio.h> 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 bd2404cd68..35c92442b2 100644 --- a/AK/Assertions.h +++ b/AK/Assertions.h @@ -1,13 +1,13 @@ #pragma once #ifdef KERNEL -#include <Kernel/Assertions.h> +# include <Kernel/Assertions.h> #else -#include <assert.h> -#ifndef __serenity__ -#define ASSERT assert -#define ASSERT_NOT_REACHED assert(false) -#endif +# include <assert.h> +# 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 46ae8fbce9..0bcb62de4c 100644 --- a/AK/Badge.h +++ b/AK/Badge.h @@ -3,5 +3,5 @@ template<typename T> class Badge { friend T; - Badge() { } + Badge() {} }; diff --git a/AK/Bitmap.h b/AK/Bitmap.h index ad7c304e0c..1c013cc3c0 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 45b213713d..c472e94022 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -1,9 +1,9 @@ #pragma once -#include "Types.h" #include "StdLibExtras.h" -#include <AK/Retainable.h> +#include "Types.h" #include <AK/RetainPtr.h> +#include <AK/Retainable.h> #include <AK/kmalloc.h> 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> ByteBufferImpl::adopt(void* data, int size) } using AK::ByteBuffer; - diff --git a/AK/CircularQueue.h b/AK/CircularQueue.h index 605402e0c1..7f1ce3ccf9 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 2aa804175b..b3135f6206 100644 --- a/AK/DoublyLinkedList.h +++ b/AK/DoublyLinkedList.h @@ -9,22 +9,28 @@ template<typename T> 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 e094c1de3d..07d8d5ea82 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<String> canonical_parts; diff --git a/AK/FileSystemPath.h b/AK/FileSystemPath.h index 3e56523269..b62160a526 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 b2d10aa0fe..bea6708ca5 100644 --- a/AK/Function.h +++ b/AK/Function.h @@ -31,13 +31,14 @@ namespace AK { -template<typename> class Function; +template<typename> +class Function; -template <typename Out, typename... In> +template<typename Out, typename... In> class Function<Out(In...)> { public: Function() = default; - Function(std::nullptr_t) { } + Function(std::nullptr_t) {} template<typename CallableType, class = typename EnableIf<!(IsPointer<CallableType>::value && IsFunction<typename RemovePointer<CallableType>::Type>::value) && IsRvalueReference<CallableType&&>::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 21bfaff94e..4155d23c67 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 828a9017e1..bd58a5a8e6 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<typename K, typename V> void HashMap<K, V>::set(const K& key, V&& value) { - m_table.set(Entry{key, move(value)}); + m_table.set(Entry { key, move(value) }); } template<typename K, typename V> void HashMap<K, V>::set(const K& key, const V& value) { - m_table.set(Entry{key, value}); + m_table.set(Entry { key, value }); } template<typename K, typename V> @@ -148,4 +148,3 @@ auto HashMap<K, V>::find(const K& key) const -> ConstIteratorType } using AK::HashMap; - diff --git a/AK/HashTable.h b/AK/HashTable.h index 8a4b5f847d..7720a38f86 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<typename T, typename = Traits<T>> class HashTable; +template<typename T, typename = Traits<T>> +class HashTable; template<typename T, typename TraitsForT> 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<T>::Iterator bucket_iterator = DoublyLinkedList<T>::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<T>::ConstIterator bucket_iterator = DoublyLinkedList<T>::ConstIterator::universal_end(), int bucket_index = 0) @@ -285,7 +288,6 @@ void HashTable<T, TraitsForT>::set(const T& value) m_size++; } - template<typename T, typename TraitsForT> void HashTable<T, TraitsForT>::rehash(int new_capacity) { @@ -308,14 +310,14 @@ void HashTable<T, TraitsForT>::rehash(int new_capacity) } } - delete [] old_buckets; + delete[] old_buckets; } template<typename T, typename TraitsForT> void HashTable<T, TraitsForT>::clear() { if (m_buckets) { - delete [] m_buckets; + delete[] m_buckets; m_buckets = nullptr; } m_capacity = 0; @@ -429,4 +431,3 @@ void HashTable<T, TraitsForT>::dump() const } using AK::HashTable; - diff --git a/AK/InlineLinkedList.h b/AK/InlineLinkedList.h index a6156c4284..08e4fbdb26 100644 --- a/AK/InlineLinkedList.h +++ b/AK/InlineLinkedList.h @@ -5,47 +5,54 @@ namespace AK { -template<typename T> class InlineLinkedListNode { +template<typename T> +class InlineLinkedListNode { public: InlineLinkedListNode(); - + void set_prev(T*); void set_next(T*); - + T* prev() const; T* next() const; }; -template<typename T> inline InlineLinkedListNode<T>::InlineLinkedListNode() +template<typename T> +inline InlineLinkedListNode<T>::InlineLinkedListNode() { set_prev(0); set_next(0); } -template<typename T> inline void InlineLinkedListNode<T>::set_prev(T* prev) +template<typename T> +inline void InlineLinkedListNode<T>::set_prev(T* prev) { static_cast<T*>(this)->m_prev = prev; } -template<typename T> inline void InlineLinkedListNode<T>::set_next(T* next) +template<typename T> +inline void InlineLinkedListNode<T>::set_next(T* next) { static_cast<T*>(this)->m_next = next; } -template<typename T> inline T* InlineLinkedListNode<T>::prev() const +template<typename T> +inline T* InlineLinkedListNode<T>::prev() const { return static_cast<const T*>(this)->m_prev; } -template<typename T> inline T* InlineLinkedListNode<T>::next() const +template<typename T> +inline T* InlineLinkedListNode<T>::next() const { return static_cast<const T*>(this)->m_next; } -template<typename T> class InlineLinkedList { +template<typename T> +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<typename T> inline size_t InlineLinkedList<T>::size_slow() const +template<typename T> +inline size_t InlineLinkedList<T>::size_slow() const { size_t size = 0; for (T* node = m_head; node; node = node->next()) @@ -83,13 +91,15 @@ template<typename T> inline size_t InlineLinkedList<T>::size_slow() const return size; } -template<typename T> inline void InlineLinkedList<T>::clear() +template<typename T> +inline void InlineLinkedList<T>::clear() { m_head = 0; m_tail = 0; } -template<typename T> inline void InlineLinkedList<T>::prepend(T* node) +template<typename T> +inline void InlineLinkedList<T>::prepend(T* node) { if (!m_head) { ASSERT(!m_tail); @@ -107,7 +117,8 @@ template<typename T> inline void InlineLinkedList<T>::prepend(T* node) m_head = node; } -template<typename T> inline void InlineLinkedList<T>::append(T* node) +template<typename T> +inline void InlineLinkedList<T>::append(T* node) { if (!m_tail) { ASSERT(!m_head); @@ -125,7 +136,8 @@ template<typename T> inline void InlineLinkedList<T>::append(T* node) m_tail = node; } -template<typename T> inline void InlineLinkedList<T>::remove(T* node) +template<typename T> +inline void InlineLinkedList<T>::remove(T* node) { if (node->prev()) { ASSERT(node != m_head); @@ -144,7 +156,8 @@ template<typename T> inline void InlineLinkedList<T>::remove(T* node) } } -template<typename T> inline T* InlineLinkedList<T>::remove_head() +template<typename T> +inline T* InlineLinkedList<T>::remove_head() { T* node = head(); if (node) @@ -152,7 +165,8 @@ template<typename T> inline T* InlineLinkedList<T>::remove_head() return node; } -template<typename T> inline T* InlineLinkedList<T>::remove_tail() +template<typename T> +inline T* InlineLinkedList<T>::remove_tail() { T* node = tail(); if (node) @@ -160,7 +174,8 @@ template<typename T> inline T* InlineLinkedList<T>::remove_tail() return node; } -template<typename T> inline void InlineLinkedList<T>::append(InlineLinkedList<T>& other) +template<typename T> +inline void InlineLinkedList<T>::append(InlineLinkedList<T>& other) { if (!other.head()) return; diff --git a/AK/MappedFile.cpp b/AK/MappedFile.cpp index a65f76b9ab..b234fa19c6 100644 --- a/AK/MappedFile.cpp +++ b/AK/MappedFile.cpp @@ -1,9 +1,9 @@ #include <AK/MappedFile.h> +#include <fcntl.h> +#include <stdio.h> #include <sys/mman.h> #include <sys/stat.h> -#include <fcntl.h> #include <unistd.h> -#include <stdio.h> //#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 0398bff7bd..513fd28e5e 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 22805bdf50..4c5aa273cd 100644 --- a/AK/NetworkOrdered.h +++ b/AK/NetworkOrdered.h @@ -18,7 +18,8 @@ template<typename T> } template<typename T> -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 ff7df2346b..2e2b9d0cbc 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 828aca3110..64168e8596 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<typename T> class OwnPtr { public: - OwnPtr() { } - explicit OwnPtr(T* ptr) : m_ptr(ptr) { } - OwnPtr(OwnPtr&& other) : m_ptr(other.leak_ptr()) { } - template<typename U> OwnPtr(OwnPtr<U>&& other) : m_ptr(static_cast<T*>(other.leak_ptr())) { } - OwnPtr(std::nullptr_t) { }; + OwnPtr() {} + explicit OwnPtr(T* ptr) + : m_ptr(ptr) + { + } + OwnPtr(OwnPtr&& other) + : m_ptr(other.leak_ptr()) + { + } + template<typename U> + OwnPtr(OwnPtr<U>&& other) + : m_ptr(static_cast<T*>(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<class T, class... Args> inline OwnPtr<T> +template<class T, class... Args> +inline OwnPtr<T> make(Args&&... args) { return OwnPtr<T>(new T(AK::forward<Args>(args)...)); @@ -105,6 +116,5 @@ struct Traits<OwnPtr<T>> { } -using AK::OwnPtr; using AK::make; - +using AK::OwnPtr; diff --git a/AK/QuickSort.h b/AK/QuickSort.h index 790c25786c..2d196d2977 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 <typename Iterator, typename LessThan> +template<typename Iterator, typename LessThan> 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 d7140ab1c7..0044202dee 100644 --- a/AK/RetainPtr.h +++ b/AK/RetainPtr.h @@ -1,38 +1,80 @@ #pragma once -#include <AK/Types.h> #include <AK/Retained.h> +#include <AK/Types.h> namespace AK { template<typename T> class RetainPtr { public: - enum AdoptTag { Adopt }; - - RetainPtr() { } - RetainPtr(const T* ptr) : m_ptr(const_cast<T*>(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<T*>(&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<typename U> RetainPtr(Retained<U>&& other) : m_ptr(static_cast<T*>(&other.leak_ref())) { } - template<typename U> RetainPtr(RetainPtr<U>&& other) : m_ptr(static_cast<T*>(other.leak_ref())) { } - RetainPtr(const RetainPtr& other) : m_ptr(const_cast<RetainPtr&>(other).copy_ref().leak_ref()) { } - template<typename U> RetainPtr(const RetainPtr<U>& other) : m_ptr(const_cast<RetainPtr<U>&>(other).copy_ref().leak_ref()) { } + enum AdoptTag { + Adopt + }; + + RetainPtr() {} + RetainPtr(const T* ptr) + : m_ptr(const_cast<T*>(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<T*>(&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<typename U> + RetainPtr(Retained<U>&& other) + : m_ptr(static_cast<T*>(&other.leak_ref())) + { + } + template<typename U> + RetainPtr(RetainPtr<U>&& other) + : m_ptr(static_cast<T*>(other.leak_ref())) + { + } + RetainPtr(const RetainPtr& other) + : m_ptr(const_cast<RetainPtr&>(other).copy_ref().leak_ref()) + { + } + template<typename U> + RetainPtr(const RetainPtr<U>& other) + : m_ptr(const_cast<RetainPtr<U>&>(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 fb6a06c4ad..be928f8521 100644 --- a/AK/Retainable.h +++ b/AK/Retainable.h @@ -6,27 +6,27 @@ namespace AK { template<class T> -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<class T> -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 f583576c42..e1aa22f8ec 100644 --- a/AK/Retained.h +++ b/AK/Retained.h @@ -4,15 +4,15 @@ #include <AK/Types.h> #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<typename T> class CONSUMABLE(unconsumed) Retained { public: - enum AdoptTag { Adopt }; - - RETURN_TYPESTATE(unconsumed) Retained(const T& object) : m_ptr(const_cast<T*>(&object)) { m_ptr->retain(); } - RETURN_TYPESTATE(unconsumed) Retained(T& object) : m_ptr(&object) { m_ptr->retain(); } - template<typename U> RETURN_TYPESTATE(unconsumed) Retained(U& object) : m_ptr(&static_cast<T&>(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<typename U> RETURN_TYPESTATE(unconsumed) Retained(Retained<U>&& other) : m_ptr(static_cast<T*>(&other.leak_ref())) { } - RETURN_TYPESTATE(unconsumed) Retained(const Retained& other) : m_ptr(&const_cast<Retained&>(other).copy_ref().leak_ref()) { } - template<typename U> RETURN_TYPESTATE(unconsumed) Retained(const Retained<U>& other) : m_ptr(&const_cast<Retained<U>&>(other).copy_ref().leak_ref()) { } + enum AdoptTag { + Adopt + }; + + RETURN_TYPESTATE(unconsumed) + Retained(const T& object) + : m_ptr(const_cast<T*>(&object)) + { + m_ptr->retain(); + } + RETURN_TYPESTATE(unconsumed) + Retained(T& object) + : m_ptr(&object) + { + m_ptr->retain(); + } + template<typename U> + RETURN_TYPESTATE(unconsumed) + Retained(U& object) + : m_ptr(&static_cast<T&>(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<typename U> + RETURN_TYPESTATE(unconsumed) + Retained(Retained<U>&& other) + : m_ptr(static_cast<T*>(&other.leak_ref())) + { + } + RETURN_TYPESTATE(unconsumed) + Retained(const Retained& other) + : m_ptr(&const_cast<Retained&>(other).copy_ref().leak_ref()) + { + } + template<typename U> + RETURN_TYPESTATE(unconsumed) + Retained(const Retained<U>& other) + : m_ptr(&const_cast<Retained<U>&>(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<typename U> - CALLABLE_WHEN(unconsumed) Retained& operator=(Retained<U>&& other) + CALLABLE_WHEN(unconsumed) + Retained& operator=(Retained<U>&& other) { if (this != static_cast<void*>(&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<T> adopt(T& object) } -using AK::Retained; using AK::adopt; +using AK::Retained; diff --git a/AK/SinglyLinkedList.h b/AK/SinglyLinkedList.h index 022b6f9571..c14fe97b45 100644 --- a/AK/SinglyLinkedList.h +++ b/AK/SinglyLinkedList.h @@ -8,13 +8,16 @@ template<typename T> 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 ee8aa862d9..491fe645ed 100644 --- a/AK/StdLibExtras.cpp +++ b/AK/StdLibExtras.cpp @@ -1,5 +1,5 @@ -#include <AK/StdLibExtras.h> #include <AK/Assertions.h> +#include <AK/StdLibExtras.h> #include <AK/Types.h> #include <AK/kstdio.h> @@ -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 d090ad861d..f233ab4219 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -1,10 +1,10 @@ #pragma once #ifdef KERNEL -#include <Kernel/StdLib.h> +# include <Kernel/StdLib.h> #else -#include <stdlib.h> -#include <string.h> +# include <stdlib.h> +# include <string.h> #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<typename T, typename U> 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 <typename T> +template<typename T> T&& move(T& arg) { return static_cast<T&&>(arg); } #ifdef __clang__ -#pragma clang diagnostic pop +# pragma clang diagnostic pop #endif template<typename T> @@ -107,26 +104,37 @@ template<typename T, typename U> void swap(T& a, U& b) { U tmp = move((U&)a); - a = (T&&)move(b); + a = (T &&) move(b); b = move(tmp); } template<bool B, class T = void> -struct EnableIf -{ +struct EnableIf { }; template<class T> -struct EnableIf<true, T> -{ +struct EnableIf<true, T> { typedef T Type; }; -template<class T> struct RemoveConst { typedef T Type; }; -template<class T> struct RemoveConst<const T> { typedef T Type; }; -template<class T> struct RemoveVolatile { typedef T Type; }; -template<class T> struct RemoveVolatile<const T> { typedef T Type; }; -template<class T> struct RemoveCV { +template<class T> +struct RemoveConst { + typedef T Type; +}; +template<class T> +struct RemoveConst<const T> { + typedef T Type; +}; +template<class T> +struct RemoveVolatile { + typedef T Type; +}; +template<class T> +struct RemoveVolatile<const T> { + typedef T Type; +}; +template<class T> +struct RemoveCV { typedef typename RemoveVolatile<typename RemoveConst<T>::Type>::Type Type; }; @@ -143,69 +151,145 @@ typedef IntegralConstant<bool, false> FalseType; typedef IntegralConstant<bool, true> TrueType; template<class T> -struct __IsPointerHelper : FalseType { }; +struct __IsPointerHelper : FalseType { +}; template<class T> -struct __IsPointerHelper<T*> : TrueType { }; +struct __IsPointerHelper<T*> : TrueType { +}; template<class T> -struct IsPointer : __IsPointerHelper<typename RemoveCV<T>::Type> { }; +struct IsPointer : __IsPointerHelper<typename RemoveCV<T>::Type> { +}; -template<class> struct IsFunction : FalseType { }; +template<class> +struct IsFunction : FalseType { +}; -template<class Ret, class... Args> struct IsFunction<Ret(Args...)> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...)> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...) const> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...) volatile> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) volatile> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...) const volatile> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const volatile> : TrueType { }; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...)> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...)> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...) const> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...) const> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...) volatile> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...) volatile> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...) const volatile> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...) const volatile> : TrueType { +}; -template<class Ret, class... Args> struct IsFunction<Ret(Args...) &> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) &> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...) const &> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const &> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...) volatile &> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) volatile &> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...) const volatile &> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const volatile &> : TrueType { }; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...)&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...)&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...) const&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...) const&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...) volatile&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...) volatile&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...) const volatile&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...) const volatile&> : TrueType { +}; -template<class Ret, class... Args> struct IsFunction<Ret(Args...) &&> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) &&> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...) const &&> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const &&> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...) volatile &&> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) volatile &&> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...) const volatile &&> : TrueType { }; -template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const volatile &&> : TrueType { }; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...) &&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...) &&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...) const&&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...) const&&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...) volatile&&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...) volatile&&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args...) const volatile&&> : TrueType { +}; +template<class Ret, class... Args> +struct IsFunction<Ret(Args..., ...) const volatile&&> : TrueType { +}; -template<class T> struct IsRvalueReference : FalseType { }; -template<class T> struct IsRvalueReference<T&&> : TrueType { }; +template<class T> +struct IsRvalueReference : FalseType { +}; +template<class T> +struct IsRvalueReference<T&&> : TrueType { +}; -template<class T> struct RemovePointer { typedef T Type; }; -template<class T> struct RemovePointer<T*> { typedef T Type; }; -template<class T> struct RemovePointer<T* const> { typedef T Type; }; -template<class T> struct RemovePointer<T* volatile> { typedef T Type; }; -template<class T> struct RemovePointer<T* const volatile> { typedef T Type; }; +template<class T> +struct RemovePointer { + typedef T Type; +}; +template<class T> +struct RemovePointer<T*> { + typedef T Type; +}; +template<class T> +struct RemovePointer<T* const> { + typedef T Type; +}; +template<class T> +struct RemovePointer<T* volatile> { + typedef T Type; +}; +template<class T> +struct RemovePointer<T* const volatile> { + typedef T Type; +}; template<typename T, typename U> struct IsSame { - enum { value = 0 }; + enum { + value = 0 + }; }; template<typename T> struct IsSame<T, T> { - enum { value = 1 }; + enum { + value = 1 + }; }; } -using AK::min; +using AK::ceil_div; +using AK::exchange; +using AK::forward; +using AK::IsSame; using AK::max; +using AK::min; using AK::move; -using AK::forward; -using AK::exchange; using AK::swap; -using AK::ceil_div; -using AK::IsSame; diff --git a/AK/String.cpp b/AK/String.cpp index 8544e4c98a..5ec6f355ee 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> String::split(const char separator) const { if (is_empty()) - return { }; + return {}; Vector<String> v; ssize_t substart = 0; @@ -94,7 +94,7 @@ Vector<String> String::split(const char separator) const Vector<StringView> String::split_view(const char separator) const { if (is_empty()) - return { }; + return {}; Vector<StringView> 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 08776dd3f3..0fe550242e 100644 --- a/AK/StringBuilder.cpp +++ b/AK/StringBuilder.cpp @@ -1,7 +1,7 @@ #include "StringBuilder.h" -#include <LibC/stdarg.h> #include "printf.cpp" #include <AK/StdLibExtras.h> +#include <LibC/stdarg.h> 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 f6c17dbf85..700540942a 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 5b8e6c742f..2799e237d6 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 c7ecfd3c24..babca34e10 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<StringImpl> { 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 06fe6752e5..77fc057c39 100644 --- a/AK/StringView.cpp +++ b/AK/StringView.cpp @@ -1,12 +1,12 @@ -#include <AK/StringView.h> #include <AK/AKString.h> +#include <AK/StringView.h> namespace AK { Vector<StringView> StringView::split_view(const char separator) const { if (is_empty()) - return { }; + return {}; Vector<StringView> v; ssize_t substart = 0; @@ -30,7 +30,7 @@ Vector<StringView> 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 51ccd2f67c..ced68488a0 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 274672a490..6248bb865b 100644 --- a/AK/TemporaryChange.h +++ b/AK/TemporaryChange.h @@ -5,7 +5,12 @@ namespace AK { template<typename T> 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 7c88a2e7cb..c147fa3cbd 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<typename T> -struct Traits -{ +struct Traits { }; template<> @@ -38,4 +37,3 @@ struct Traits<T*> { }; } - diff --git a/AK/Types.h b/AK/Types.h index fb8501d21d..6764995430 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 <stdint.h> -#include <sys/types.h> +# include <stdint.h> +# include <sys/types.h> 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 2ebe8f92b1..c1b9c5622f 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<T*>(m_inline_buffer_storage); } - const T* inline_buffer() const { static_assert(inline_capacity > 0); return reinterpret_cast<const T*>(m_inline_buffer_storage); } + T* inline_buffer() + { + static_assert(inline_capacity > 0); + return reinterpret_cast<T*>(m_inline_buffer_storage); + } + const T* inline_buffer() const + { + static_assert(inline_capacity > 0); + return reinterpret_cast<const T*>(m_inline_buffer_storage); + } int m_size { 0 }; int m_capacity { 0 }; diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index 89dbcd93f4..30d118e178 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -4,14 +4,16 @@ namespace AK { -template<typename T> class OwnPtr; +template<typename T> +class OwnPtr; template<typename T> class WeakPtr { friend class Weakable<T>; + public: - WeakPtr() { } - WeakPtr(std::nullptr_t) { } + WeakPtr() {} + WeakPtr(std::nullptr_t) {} template<typename U> WeakPtr(WeakPtr<U>&& other) @@ -48,7 +50,10 @@ public: bool operator==(const OwnPtr<T>& other) const { return ptr() == other.ptr(); } private: - WeakPtr(RetainPtr<WeakLink<T>>&& link) : m_link(move(link)) { } + WeakPtr(RetainPtr<WeakLink<T>>&& link) + : m_link(move(link)) + { + } RetainPtr<WeakLink<T>> m_link; }; @@ -64,4 +69,3 @@ inline WeakPtr<T> Weakable<T>::make_weak_ptr() } using AK::WeakPtr; - diff --git a/AK/Weakable.h b/AK/Weakable.h index c9590c2be1..d5b55050d3 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<typename T> class Weakable; -template<typename T> class WeakPtr; +template<typename T> +class Weakable; +template<typename T> +class WeakPtr; template<typename T> class WeakLink : public Retainable<WeakLink<T>> { friend class Weakable<T>; + public: T* ptr() { return static_cast<T*>(m_ptr); } const T* ptr() const { return static_cast<const T*>(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<typename T> class Weakable { private: class Link; + public: WeakPtr<T> make_weak_ptr(); protected: - Weakable() { } + Weakable() {} ~Weakable() { diff --git a/AK/kmalloc.h b/AK/kmalloc.h index c31352ec01..c1068d7f67 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 <Kernel/kmalloc.h> +# include <Kernel/kmalloc.h> #else -#include <stdlib.h> +# include <stdlib.h> -#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 68d29e5dc6..0b5ee149ad 100644 --- a/AK/printf.cpp +++ b/AK/printf.cpp @@ -169,7 +169,6 @@ template<typename PutChFunc> return fieldWidth; } - template<typename PutChFunc> [[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<typename PutChFunc> template<typename PutChFunc> [[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<typename PutChFunc> 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; - - 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 '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; + 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 '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_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)); - ++ret; - break; - - case '%': - putch(bufptr, '%'); + 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 '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 58ff16d628..c494419e5d 100644 --- a/Applications/FileManager/DirectoryView.h +++ b/Applications/FileManager/DirectoryView.h @@ -1,10 +1,10 @@ #pragma once #include <AK/Vector.h> -#include <LibGUI/GTableView.h> +#include <LibGUI/GDirectoryModel.h> #include <LibGUI/GItemView.h> #include <LibGUI/GStackWidget.h> -#include <LibGUI/GDirectoryModel.h> +#include <LibGUI/GTableView.h> #include <sys/stat.h> class DirectoryView final : public GStackWidget { @@ -26,7 +26,12 @@ public: Function<void(String)> on_status_message; Function<void(int done, int total)> 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<GDirectoryModel> m_model; - int m_path_history_position{ 0 }; + int m_path_history_position { 0 }; Vector<String> m_path_history; void add_path_to_history(const String& path); diff --git a/Applications/FontEditor/FontEditor.h b/Applications/FontEditor/FontEditor.h index 3d41d6b768..9132c5029a 100644 --- a/Applications/FontEditor/FontEditor.h +++ b/Applications/FontEditor/FontEditor.h @@ -1,7 +1,7 @@ #pragma once -#include <LibGUI/GWidget.h> #include <AK/Function.h> +#include <LibGUI/GWidget.h> class GlyphEditorWidget; class GlyphMapWidget; diff --git a/Applications/FontEditor/GlyphEditorWidget.h b/Applications/FontEditor/GlyphEditorWidget.h index 2e9c311ccd..3784c054b5 100644 --- a/Applications/FontEditor/GlyphEditorWidget.h +++ b/Applications/FontEditor/GlyphEditorWidget.h @@ -1,5 +1,5 @@ -#include <LibGUI/GFrame.h> #include <AK/Function.h> +#include <LibGUI/GFrame.h> class GlyphEditorWidget final : public GFrame { public: diff --git a/Applications/FontEditor/GlyphMapWidget.h b/Applications/FontEditor/GlyphMapWidget.h index 07aafbe2e1..e5746aff0b 100644 --- a/Applications/FontEditor/GlyphMapWidget.h +++ b/Applications/FontEditor/GlyphMapWidget.h @@ -1,7 +1,7 @@ #pragma once -#include <LibGUI/GFrame.h> #include <AK/Function.h> +#include <LibGUI/GFrame.h> class GlyphMapWidget final : public GFrame { public: diff --git a/Applications/IRCClient/IRCAppWindow.h b/Applications/IRCClient/IRCAppWindow.h index e34c281f2e..96e0867a67 100644 --- a/Applications/IRCClient/IRCAppWindow.h +++ b/Applications/IRCClient/IRCAppWindow.h @@ -1,9 +1,9 @@ #pragma once -#include <LibGUI/GWindow.h> -#include <LibGUI/GWidget.h> #include "IRCClient.h" #include "IRCWindow.h" +#include <LibGUI/GWidget.h> +#include <LibGUI/GWindow.h> class GAction; class GStackWidget; diff --git a/Applications/IRCClient/IRCChannel.h b/Applications/IRCClient/IRCChannel.h index 8770dd181d..de9132639a 100644 --- a/Applications/IRCClient/IRCChannel.h +++ b/Applications/IRCClient/IRCChannel.h @@ -1,11 +1,11 @@ #pragma once +#include "IRCLogBuffer.h" #include <AK/AKString.h> #include <AK/CircularQueue.h> -#include <AK/Vector.h> -#include <AK/Retainable.h> #include <AK/RetainPtr.h> -#include "IRCLogBuffer.h" +#include <AK/Retainable.h> +#include <AK/Vector.h> class IRCClient; class IRCChannelMemberListModel; diff --git a/Applications/IRCClient/IRCChannelMemberListModel.h b/Applications/IRCClient/IRCChannelMemberListModel.h index 2f67cf15ca..ac380ec62d 100644 --- a/Applications/IRCClient/IRCChannelMemberListModel.h +++ b/Applications/IRCClient/IRCChannelMemberListModel.h @@ -1,13 +1,16 @@ #pragma once -#include <LibGUI/GModel.h> #include <AK/Function.h> +#include <LibGUI/GModel.h> class IRCChannel; class IRCChannelMemberListModel final : public GModel { public: - enum Column { Name }; + enum Column + { + Name + }; static Retained<IRCChannelMemberListModel> create(IRCChannel& channel) { return adopt(*new IRCChannelMemberListModel(channel)); } virtual ~IRCChannelMemberListModel() override; diff --git a/Applications/IRCClient/IRCClient.h b/Applications/IRCClient/IRCClient.h index 2ae4c348fa..ac02b9e9fc 100644 --- a/Applications/IRCClient/IRCClient.h +++ b/Applications/IRCClient/IRCClient.h @@ -1,13 +1,13 @@ #pragma once +#include "IRCLogBuffer.h" +#include "IRCWindow.h" #include <AK/AKString.h> -#include <AK/HashMap.h> #include <AK/CircularQueue.h> #include <AK/Function.h> -#include <LibCore/CTCPSocket.h> +#include <AK/HashMap.h> #include <LibCore/CConfigFile.h> -#include "IRCLogBuffer.h" -#include "IRCWindow.h" +#include <LibCore/CTCPSocket.h> 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 e1b6b472dd..7d2bdff220 100644 --- a/Applications/IRCClient/IRCLogBuffer.h +++ b/Applications/IRCClient/IRCLogBuffer.h @@ -2,8 +2,8 @@ #include <AK/AKString.h> #include <AK/CircularQueue.h> -#include <AK/Retainable.h> #include <AK/RetainPtr.h> +#include <AK/Retainable.h> #include <SharedGraphics/Color.h> class IRCLogBufferModel; diff --git a/Applications/IRCClient/IRCLogBufferModel.h b/Applications/IRCClient/IRCLogBufferModel.h index 5be8237d07..d5479da887 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 8d26d92881..88f941fbdf 100644 --- a/Applications/IRCClient/IRCQuery.h +++ b/Applications/IRCClient/IRCQuery.h @@ -1,11 +1,11 @@ #pragma once +#include "IRCLogBuffer.h" #include <AK/AKString.h> #include <AK/CircularQueue.h> -#include <AK/Vector.h> -#include <AK/Retainable.h> #include <AK/RetainPtr.h> -#include "IRCLogBuffer.h" +#include <AK/Retainable.h> +#include <AK/Vector.h> class IRCClient; class IRCWindow; diff --git a/Applications/IRCClient/IRCWindow.h b/Applications/IRCClient/IRCWindow.h index 2fce542fe5..f8fe692542 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 d565eb78e3..93fa6b6abd 100644 --- a/Applications/IRCClient/IRCWindowListModel.h +++ b/Applications/IRCClient/IRCWindowListModel.h @@ -1,14 +1,15 @@ #pragma once -#include <LibGUI/GModel.h> #include <AK/Function.h> +#include <LibGUI/GModel.h> 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 83971c20bc..1d39beb1f1 100644 --- a/Applications/ProcessManager/GraphWidget.h +++ b/Applications/ProcessManager/GraphWidget.h @@ -1,5 +1,5 @@ -#include <LibGUI/GFrame.h> #include <AK/CircularQueue.h> +#include <LibGUI/GFrame.h> class GraphWidget final : public GFrame { public: diff --git a/Applications/ProcessManager/MemoryStatsWidget.h b/Applications/ProcessManager/MemoryStatsWidget.h index 2f6b1dc183..e3912b9b94 100644 --- a/Applications/ProcessManager/MemoryStatsWidget.h +++ b/Applications/ProcessManager/MemoryStatsWidget.h @@ -1,7 +1,7 @@ #pragma once -#include <LibGUI/GWidget.h> #include <LibCore/CFile.h> +#include <LibGUI/GWidget.h> class GLabel; class GraphWidget; diff --git a/Applications/ProcessManager/ProcessModel.h b/Applications/ProcessManager/ProcessModel.h index 92ff292a0b..3f6b18b111 100644 --- a/Applications/ProcessManager/ProcessModel.h +++ b/Applications/ProcessManager/ProcessModel.h @@ -3,15 +3,16 @@ #include <AK/AKString.h> #include <AK/HashMap.h> #include <AK/Vector.h> -#include <LibGUI/GModel.h> #include <LibCore/CFile.h> +#include <LibGUI/GModel.h> #include <unistd.h> 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 28aef8ce0e..24c45e3365 100644 --- a/Applications/ProcessManager/ProcessTableView.h +++ b/Applications/ProcessManager/ProcessTableView.h @@ -1,7 +1,7 @@ #pragma once -#include <LibGUI/GTableView.h> #include <AK/Function.h> +#include <LibGUI/GTableView.h> #include <unistd.h> 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 6cb790521a..2a84b0b410 100644 --- a/Applications/Taskbar/TaskbarButton.h +++ b/Applications/Taskbar/TaskbarButton.h @@ -1,7 +1,7 @@ #pragma once -#include <LibGUI/GButton.h> #include "WindowIdentifier.h" +#include <LibGUI/GButton.h> class TaskbarButton final : public GButton { public: diff --git a/Applications/Taskbar/TaskbarWindow.h b/Applications/Taskbar/TaskbarWindow.h index 856185343f..fbfd4a50c4 100644 --- a/Applications/Taskbar/TaskbarWindow.h +++ b/Applications/Taskbar/TaskbarWindow.h @@ -1,6 +1,6 @@ -#include <LibGUI/GWindow.h> -#include <LibGUI/GWidget.h> #include "WindowList.h" +#include <LibGUI/GWidget.h> +#include <LibGUI/GWindow.h> class TaskbarWindow final : public GWindow { public: diff --git a/Applications/Taskbar/WindowIdentifier.h b/Applications/Taskbar/WindowIdentifier.h index afed91a288..f5fcd65bfc 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 6ebaaa5328..12cefb52ab 100644 --- a/Applications/Taskbar/WindowList.h +++ b/Applications/Taskbar/WindowList.h @@ -1,10 +1,10 @@ #pragma once +#include "WindowIdentifier.h" #include <AK/AKString.h> #include <AK/HashMap.h> -#include <SharedGraphics/Rect.h> #include <LibGUI/GButton.h> -#include "WindowIdentifier.h" +#include <SharedGraphics/Rect.h> class Window { public: @@ -64,7 +64,8 @@ class WindowList { public: static WindowList& the(); - template<typename Callback> void for_each_window(Callback callback) + template<typename Callback> + 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 52484080d7..4a84165256 100644 --- a/Applications/Terminal/Terminal.h +++ b/Applications/Terminal/Terminal.h @@ -3,12 +3,12 @@ #include <AK/AKString.h> #include <AK/Types.h> #include <AK/Vector.h> -#include <SharedGraphics/GraphicsBitmap.h> -#include <SharedGraphics/Rect.h> -#include <LibGUI/GFrame.h> +#include <LibCore/CConfigFile.h> #include <LibCore/CNotifier.h> #include <LibCore/CTimer.h> -#include <LibCore/CConfigFile.h> +#include <LibGUI/GFrame.h> +#include <SharedGraphics/GraphicsBitmap.h> +#include <SharedGraphics/Rect.h> 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 bae9553233..37ced0a651 100644 --- a/DevTools/VisualBuilder/VBForm.h +++ b/DevTools/VisualBuilder/VBForm.h @@ -1,11 +1,12 @@ #pragma once -#include <LibGUI/GWidget.h> -#include <AK/Vector.h> #include "VBWidget.h" +#include <AK/Vector.h> +#include <LibGUI/GWidget.h> 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<typename Callback> void for_each_selected_widget(Callback); + template<typename Callback> + void for_each_selected_widget(Callback); VBWidget* single_selected_widget(); diff --git a/DevTools/VisualBuilder/VBProperty.h b/DevTools/VisualBuilder/VBProperty.h index 9d70c66c8e..57a8bab87a 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<GVariant(const GWidget&)>&& getter, Function<void(GWidget&, const GVariant&)>&& setter); diff --git a/DevTools/VisualBuilder/VBWidget.h b/DevTools/VisualBuilder/VBWidget.h index afd240b081..7395157098 100644 --- a/DevTools/VisualBuilder/VBWidget.h +++ b/DevTools/VisualBuilder/VBWidget.h @@ -1,12 +1,12 @@ #pragma once -#include <SharedGraphics/Rect.h> +#include "VBWidgetType.h" +#include <AK/Function.h> +#include <AK/HashMap.h> #include <AK/Retainable.h> #include <AK/Retained.h> #include <AK/Weakable.h> -#include <AK/HashMap.h> -#include <AK/Function.h> -#include "VBWidgetType.h" +#include <SharedGraphics/Rect.h> 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<typename Callback> 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<VBWidget>, public Weakable<VBWidget> { +class VBWidget : public Retainable<VBWidget> + , public Weakable<VBWidget> { friend class VBWidgetPropertyModel; + public: static Retained<VBWidget> 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 b84bffc697..2aa4542424 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 d2af1f941e..bd08a1d574 100644 --- a/DevTools/VisualBuilder/VBWidgetRegistry.h +++ b/DevTools/VisualBuilder/VBWidgetRegistry.h @@ -1,9 +1,9 @@ #pragma once #include "VBWidgetType.h" +#include <AK/AKString.h> #include <AK/HashMap.h> #include <AK/OwnPtr.h> -#include <AK/AKString.h> class GWidget; class VBProperty; @@ -11,7 +11,8 @@ class VBWidget; class VBWidgetRegistry { public: - template<typename Callback> static void for_each_widget_type(Callback callback) + template<typename Callback> + 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 1d0487a478..a816a7cf52 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 3d033b8f81..5af284a466 100644 --- a/Games/Minesweeper/Field.h +++ b/Games/Minesweeper/Field.h @@ -1,8 +1,8 @@ #pragma once -#include <LibGUI/GFrame.h> -#include <LibCore/CTimer.h> #include <AK/Noncopyable.h> +#include <LibCore/CTimer.h> +#include <LibGUI/GFrame.h> 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<typename Callback> void for_each_neighbor(Callback); + template<typename Callback> + 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<typename Callback> void for_each_square(Callback); + template<typename Callback> + 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 8f8a67c9a9..704e80c0d3 100644 --- a/Games/Snake/SnakeGame.h +++ b/Games/Snake/SnakeGame.h @@ -1,7 +1,7 @@ #pragma once -#include <LibGUI/GWidget.h> #include <AK/CircularQueue.h> +#include <LibGUI/GWidget.h> class SnakeGame : public GWidget { public: diff --git a/Kernel/Alarm.h b/Kernel/Alarm.h index a724a06ec1..ba8fb6211f 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 8eada59219..de744bf11f 100644 --- a/Kernel/Assertions.h +++ b/Kernel/Assertions.h @@ -1,17 +1,24 @@ #pragma once -#include <Kernel/kstdio.h> #include <Kernel/i386.h> +#include <Kernel/kstdio.h> #ifdef DEBUG [[noreturn]] void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func); -#define ASSERT(expr) (static_cast<bool>(expr) ? (void)0 : __assertion_failed(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__)) -#define ASSERT_NOT_REACHED() ASSERT(false) +# define ASSERT(expr) (static_cast<bool>(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 45101a8d0d..59fe006c4e 100644 --- a/Kernel/Console.h +++ b/Kernel/Console.h @@ -35,4 +35,3 @@ private: ConsoleImplementation* m_implementation { nullptr }; CircularQueue<char, 16384> m_logbuffer; }; - diff --git a/Kernel/Devices/BXVGADevice.h b/Kernel/Devices/BXVGADevice.h index 96207d400d..d797724475 100644 --- a/Kernel/Devices/BXVGADevice.h +++ b/Kernel/Devices/BXVGADevice.h @@ -1,10 +1,10 @@ #pragma once -#include <AK/Types.h> #include <AK/AKString.h> -#include <SharedGraphics/Size.h> -#include <Kernel/PhysicalAddress.h> +#include <AK/Types.h> #include <Kernel/Devices/BlockDevice.h> +#include <Kernel/PhysicalAddress.h> +#include <SharedGraphics/Size.h> class BXVGADevice final : public BlockDevice { AK_MAKE_ETERNAL diff --git a/Kernel/Devices/BlockDevice.h b/Kernel/Devices/BlockDevice.h index c96d4d3185..d76d90614d 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 6dedf20743..3e4778b260 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 badf92b0ca..66a51a8f41 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 c16c848f8b..667f3af427 100644 --- a/Kernel/Devices/FileBackedDiskDevice.h +++ b/Kernel/Devices/FileBackedDiskDevice.h @@ -1,9 +1,9 @@ #pragma once -#include <Kernel/Devices/DiskDevice.h> -#include <AK/RetainPtr.h> #include <AK/AKString.h> +#include <AK/RetainPtr.h> #include <AK/Types.h> +#include <Kernel/Devices/DiskDevice.h> #include <stdio.h> 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 c88e6f6857..9974e47c4d 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 d87ab9e690..7f5cfbd99e 100644 --- a/Kernel/Devices/IDEDiskDevice.h +++ b/Kernel/Devices/IDEDiskDevice.h @@ -1,9 +1,9 @@ #pragma once -#include <Kernel/Lock.h> #include <AK/RetainPtr.h> #include <Kernel/Devices/DiskDevice.h> #include <Kernel/IRQHandler.h> +#include <Kernel/Lock.h> #include <Kernel/PCI.h> #include <Kernel/PhysicalAddress.h> #include <Kernel/VM/PhysicalPage.h> @@ -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<IDEDiskDevice> create(); @@ -58,4 +59,3 @@ private: word m_bus_master_base { 0 }; Lockable<bool> m_dma_enabled; }; - diff --git a/Kernel/Devices/KeyboardDevice.h b/Kernel/Devices/KeyboardDevice.h index c6e9fa972e..16f134b2a7 100644 --- a/Kernel/Devices/KeyboardDevice.h +++ b/Kernel/Devices/KeyboardDevice.h @@ -1,15 +1,16 @@ #pragma once -#include <AK/Types.h> -#include <AK/DoublyLinkedList.h> -#include <AK/CircularQueue.h> -#include <Kernel/Devices/CharacterDevice.h> #include "IRQHandler.h" #include "KeyCode.h" +#include <AK/CircularQueue.h> +#include <AK/DoublyLinkedList.h> +#include <AK/Types.h> +#include <Kernel/Devices/CharacterDevice.h> 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 b00cfeed67..47ba7baf5a 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 6a04ab672c..de97cfe4e1 100644 --- a/Kernel/Devices/PS2MouseDevice.h +++ b/Kernel/Devices/PS2MouseDevice.h @@ -1,11 +1,12 @@ #pragma once +#include <AK/CircularQueue.h> #include <Kernel/Devices/CharacterDevice.h> -#include <Kernel/MousePacket.h> #include <Kernel/IRQHandler.h> -#include <AK/CircularQueue.h> +#include <Kernel/MousePacket.h> -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 fe7fd1a439..ecce3c6bfb 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 74cfb60361..930f3adec2 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 9898ea0786..fc638bd580 100644 --- a/Kernel/FileSystem/DevPtsFS.h +++ b/Kernel/FileSystem/DevPtsFS.h @@ -26,4 +26,3 @@ private: HashTable<SlavePTY*> m_slave_ptys; }; - diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h index c958bac411..21e4e856b3 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -1,9 +1,9 @@ #pragma once -#include <Kernel/UnixTypes.h> +#include <Kernel/FileSystem/DiskBackedFileSystem.h> #include <Kernel/FileSystem/Inode.h> #include <Kernel/FileSystem/ext2_fs.h> -#include <Kernel/FileSystem/DiskBackedFileSystem.h> +#include <Kernel/UnixTypes.h> 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 <Ext2FS> create(Retained<DiskDevice>&&); + static Retained<Ext2FS> create(Retained<DiskDevice>&&); virtual ~Ext2FS() override; virtual bool initialize() override; diff --git a/Kernel/FileSystem/FIFO.h b/Kernel/FileSystem/FIFO.h index b9eea984cb..72faae428d 100644 --- a/Kernel/FileSystem/FIFO.h +++ b/Kernel/FileSystem/FIFO.h @@ -1,15 +1,18 @@ #pragma once #include <Kernel/DoubleBuffer.h> -#include <Kernel/UnixTypes.h> #include <Kernel/File.h> +#include <Kernel/UnixTypes.h> class FileDescriptor; class FIFO final : public File { public: - enum class Direction : byte { - Neither, Reader, Writer + enum class Direction : byte + { + Neither, + Reader, + Writer }; static RetainPtr<FIFO> from_fifo_id(dword); diff --git a/Kernel/FileSystem/FileDescriptor.h b/Kernel/FileSystem/FileDescriptor.h index 2f9b98c42b..30ebbce559 100644 --- a/Kernel/FileSystem/FileDescriptor.h +++ b/Kernel/FileSystem/FileDescriptor.h @@ -1,14 +1,14 @@ #pragma once -#include <Kernel/FileSystem/VirtualFileSystem.h> -#include <Kernel/FileSystem/InodeMetadata.h> -#include <Kernel/FileSystem/Inode.h> -#include <Kernel/FileSystem/FIFO.h> -#include <Kernel/LinearAddress.h> +#include <AK/Badge.h> #include <AK/ByteBuffer.h> #include <AK/CircularQueue.h> #include <AK/Retainable.h> -#include <AK/Badge.h> +#include <Kernel/FileSystem/FIFO.h> +#include <Kernel/FileSystem/Inode.h> +#include <Kernel/FileSystem/InodeMetadata.h> +#include <Kernel/FileSystem/VirtualFileSystem.h> +#include <Kernel/LinearAddress.h> #include <Kernel/Net/Socket.h> 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 800391036d..097d479b00 100644 --- a/Kernel/FileSystem/FileSystem.h +++ b/Kernel/FileSystem/FileSystem.h @@ -1,20 +1,20 @@ #pragma once -#include <Kernel/Devices/DiskDevice.h> #include "InodeIdentifier.h" #include "InodeMetadata.h" #include "UnixTypes.h" +#include <AK/AKString.h> #include <AK/ByteBuffer.h> +#include <AK/Function.h> #include <AK/HashMap.h> #include <AK/OwnPtr.h> -#include <AK/Retainable.h> #include <AK/RetainPtr.h> -#include <AK/AKString.h> -#include <AK/Function.h> -#include <AK/kstdio.h> -#include <Kernel/Lock.h> +#include <AK/Retainable.h> #include <AK/WeakPtr.h> +#include <AK/kstdio.h> +#include <Kernel/Devices/DiskDevice.h> #include <Kernel/KResult.h> +#include <Kernel/Lock.h> static const dword mepoch = 476763780; @@ -25,6 +25,7 @@ class VMObject; class FS : public Retainable<FS> { friend class Inode; + public: virtual ~FS(); @@ -57,7 +58,7 @@ public: virtual RetainPtr<Inode> get_inode(InodeIdentifier) const = 0; - virtual void flush_writes() { } + virtual void flush_writes() {} protected: FS(); @@ -93,4 +94,3 @@ struct Traits<InodeIdentifier> { }; } - diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index 520b271f88..f7f560ce37 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -1,12 +1,12 @@ #pragma once -#include <AK/Retainable.h> #include <AK/AKString.h> #include <AK/Function.h> +#include <AK/Retainable.h> #include <AK/WeakPtr.h> +#include <Kernel/FileSystem/FileSystem.h> #include <Kernel/FileSystem/InodeIdentifier.h> #include <Kernel/FileSystem/InodeMetadata.h> -#include <Kernel/FileSystem/FileSystem.h> #include <Kernel/KResult.h> #include <Kernel/Lock.h> @@ -17,10 +17,11 @@ class VMObject; class Inode : public Retainable<Inode> { 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<LocalSocket> m_socket; bool m_metadata_dirty { false }; }; - diff --git a/Kernel/FileSystem/InodeIdentifier.h b/Kernel/FileSystem/InodeIdentifier.h index cb0c24f8c3..95c1bc6226 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 ee24330f9d..f151fbe048 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 5693806d4e..a8e27a35ac 100644 --- a/Kernel/FileSystem/ProcFS.h +++ b/Kernel/FileSystem/ProcFS.h @@ -1,9 +1,9 @@ #pragma once -#include <Kernel/Lock.h> #include <AK/Types.h> #include <Kernel/FileSystem/FileSystem.h> #include <Kernel/FileSystem/Inode.h> +#include <Kernel/Lock.h> 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<ByteBuffer(InodeIdentifier)>&& a_read_callback = nullptr, Function<ssize_t(InodeIdentifier, const ByteBuffer&)>&& a_write_callback = nullptr, RetainPtr<ProcFSInode>&& 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 2e1cfc2254..291d8918dc 100644 --- a/Kernel/FileSystem/SyntheticFileSystem.h +++ b/Kernel/FileSystem/SyntheticFileSystem.h @@ -1,9 +1,9 @@ #pragma once +#include <AK/HashMap.h> #include <Kernel/FileSystem/FileSystem.h> #include <Kernel/FileSystem/Inode.h> #include <Kernel/UnixTypes.h> -#include <AK/HashMap.h> 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 16b0dafbad..04ef61a432 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 <AK/AKString.h> +#include <AK/Function.h> #include <AK/HashMap.h> #include <AK/OwnPtr.h> #include <AK/RetainPtr.h> -#include <AK/AKString.h> #include <AK/Vector.h> -#include <AK/Function.h> -#include "InodeIdentifier.h" -#include "InodeMetadata.h" -#include "FileSystem.h" #include <Kernel/KResult.h> #define O_RDONLY 0 @@ -116,4 +116,3 @@ private: Vector<OwnPtr<Mount>> m_mounts; HashMap<dword, Device*> m_devices; }; - diff --git a/Kernel/FileSystem/ext2_fs.h b/Kernel/FileSystem/ext2_fs.h index 4f0856acf1..372423f0ec 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 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 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_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 27277fa3fe..10160466cf 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 5453b98494..259911264c 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 e856b84e46..4abadf6b20 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 1cc740bc74..291e9ea2ea 100644 --- a/Kernel/KResult.h +++ b/Kernel/KResult.h @@ -3,20 +3,31 @@ #include <AK/Assertions.h> #include <LibC/errno_numbers.h> -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<typename T> friend class KResultOr; - KResult() { } + template<typename T> + 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<T*>(&m_storage); } - const T& value() const { ASSERT(!m_is_error); return *reinterpret_cast<T*>(&m_storage); } + KResult error() const + { + ASSERT(m_is_error); + return m_error; + } + T& value() + { + ASSERT(!m_is_error); + return *reinterpret_cast<T*>(&m_storage); + } + const T& value() const + { + ASSERT(!m_is_error); + return *reinterpret_cast<T*>(&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 310c950ca9..67c065625f 100644 --- a/Kernel/KeyCode.h +++ b/Kernel/KeyCode.h @@ -2,7 +2,8 @@ #include <AK/Types.h> -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 c3064a9af4..3b0eecea02 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 c61df5f647..fcd9a69a94 100644 --- a/Kernel/Lock.h +++ b/Kernel/Lock.h @@ -2,9 +2,9 @@ #include <AK/Assertions.h> #include <AK/Types.h> -#include <Kernel/i386.h> -#include <Kernel/Scheduler.h> #include <Kernel/KSyms.h> +#include <Kernel/Scheduler.h> +#include <Kernel/i386.h> 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<typename T> 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 ddfcd54f63..2fecc2b0a0 100644 --- a/Kernel/Net/ARP.h +++ b/Kernel/Net/ARP.h @@ -1,23 +1,26 @@ #pragma once -#include <Kernel/Net/MACAddress.h> -#include <Kernel/Net/IPv4.h> #include <Kernel/Net/EtherType.h> +#include <Kernel/Net/IPv4.h> +#include <Kernel/Net/MACAddress.h> 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 cf9bdb3ba5..e2050853d5 100644 --- a/Kernel/Net/E1000NetworkAdapter.h +++ b/Kernel/Net/E1000NetworkAdapter.h @@ -1,12 +1,13 @@ #pragma once +#include <AK/OwnPtr.h> +#include <Kernel/IRQHandler.h> #include <Kernel/Net/NetworkAdapter.h> #include <Kernel/PCI.h> #include <Kernel/VM/MemoryManager.h> -#include <Kernel/IRQHandler.h> -#include <AK/OwnPtr.h> -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 027967ff77..42edc16427 100644 --- a/Kernel/Net/EtherType.h +++ b/Kernel/Net/EtherType.h @@ -3,8 +3,9 @@ #include <AK/Types.h> 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 18afc9242b..137285230e 100644 --- a/Kernel/Net/EthernetFrameHeader.h +++ b/Kernel/Net/EthernetFrameHeader.h @@ -1,12 +1,13 @@ #pragma once -#include <Kernel/Net/MACAddress.h> #include <AK/NetworkOrdered.h> +#include <Kernel/Net/MACAddress.h> -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 efc6cf4ca6..2433626a64 100644 --- a/Kernel/Net/ICMP.h +++ b/Kernel/Net/ICMP.h @@ -1,19 +1,21 @@ #pragma once -#include <Kernel/Net/MACAddress.h> #include <Kernel/Net/IPv4.h> +#include <Kernel/Net/MACAddress.h> 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<word> identifier; NetworkOrdered<word> sequence_number; diff --git a/Kernel/Net/IPv4.h b/Kernel/Net/IPv4.h index 61232b78e2..0c858d94d0 100644 --- a/Kernel/Net/IPv4.h +++ b/Kernel/Net/IPv4.h @@ -5,7 +5,8 @@ #include <AK/NetworkOrdered.h> #include <AK/Types.h> -enum class IPv4Protocol : word { +enum class IPv4Protocol : word +{ ICMP = 1, TCP = 6, UDP = 17, @@ -13,9 +14,10 @@ enum class IPv4Protocol : word { NetworkOrdered<word> 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<IPv4Address> { } -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 33b4f9d420..4f18d63113 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -1,11 +1,11 @@ #pragma once -#include <Kernel/Net/Socket.h> -#include <Kernel/DoubleBuffer.h> -#include <Kernel/Net/IPv4.h> #include <AK/HashMap.h> -#include <Kernel/Lock.h> #include <AK/SinglyLinkedList.h> +#include <Kernel/DoubleBuffer.h> +#include <Kernel/Lock.h> +#include <Kernel/Net/IPv4.h> +#include <Kernel/Net/Socket.h> class IPv4SocketHandle; class TCPSocketHandle; @@ -86,7 +86,7 @@ private: class IPv4SocketHandle : public SocketHandle { public: - IPv4SocketHandle() { } + IPv4SocketHandle() {} IPv4SocketHandle(RetainPtr<IPv4Socket>&& socket) : SocketHandle(move(socket)) diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h index db481912f2..3328fd4eba 100644 --- a/Kernel/Net/LocalSocket.h +++ b/Kernel/Net/LocalSocket.h @@ -1,7 +1,7 @@ #pragma once -#include <Kernel/Net/Socket.h> #include <Kernel/DoubleBuffer.h> +#include <Kernel/Net/Socket.h> 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 0c2de93b27..3cf906decb 100644 --- a/Kernel/Net/MACAddress.h +++ b/Kernel/Net/MACAddress.h @@ -1,18 +1,19 @@ #pragma once -#include <AK/Assertions.h> #include <AK/AKString.h> +#include <AK/Assertions.h> #include <AK/Types.h> #include <Kernel/StdLib.h> -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 3a7d0755c7..fd24d7ca41 100644 --- a/Kernel/Net/NetworkAdapter.h +++ b/Kernel/Net/NetworkAdapter.h @@ -3,19 +3,23 @@ #include <AK/ByteBuffer.h> #include <AK/SinglyLinkedList.h> #include <AK/Types.h> -#include <Kernel/Net/MACAddress.h> -#include <Kernel/Net/IPv4.h> +#include <Kernel/Alarm.h> #include <Kernel/Net/ARP.h> #include <Kernel/Net/ICMP.h> -#include <Kernel/Alarm.h> +#include <Kernel/Net/IPv4.h> +#include <Kernel/Net/MACAddress.h> 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 0fb9544cbb..45693a2ffc 100644 --- a/Kernel/Net/Socket.h +++ b/Kernel/Net/Socket.h @@ -1,16 +1,27 @@ #pragma once -#include <Kernel/Lock.h> -#include <AK/Retainable.h> -#include <AK/RetainPtr.h> #include <AK/HashTable.h> +#include <AK/RetainPtr.h> +#include <AK/Retainable.h> #include <AK/Vector.h> #include <Kernel/File.h> -#include <Kernel/UnixTypes.h> #include <Kernel/KResult.h> +#include <Kernel/Lock.h> +#include <Kernel/UnixTypes.h> -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>&& socket) : m_socket(move(socket)) diff --git a/Kernel/Net/TCP.h b/Kernel/Net/TCP.h index e2eac61449..8138ed3d52 100644 --- a/Kernel/Net/TCP.h +++ b/Kernel/Net/TCP.h @@ -3,20 +3,22 @@ #include <Kernel/Net/IPv4.h> 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 c248b9d9ba..35856d7ae8 100644 --- a/Kernel/Net/TCPSocket.h +++ b/Kernel/Net/TCPSocket.h @@ -7,7 +7,8 @@ public: static Retained<TCPSocket> 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<TCPSocket>&& socket) : SocketHandle(move(socket)) diff --git a/Kernel/Net/UDP.h b/Kernel/Net/UDP.h index ba6d02af37..7ec39719cd 100644 --- a/Kernel/Net/UDP.h +++ b/Kernel/Net/UDP.h @@ -2,10 +2,11 @@ #include <Kernel/Net/IPv4.h> -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 ea94887754..a76eaa7fe7 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<UDPSocket>&& socket) : SocketHandle(move(socket)) @@ -46,4 +46,3 @@ public: UDPSocket& socket() { return static_cast<UDPSocket&>(SocketHandle::socket()); } const UDPSocket& socket() const { return static_cast<const UDPSocket&>(SocketHandle::socket()); } }; - diff --git a/Kernel/PCI.h b/Kernel/PCI.h index e8330d4245..f295fb8f4d 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 2f6304139c..7b0dcbe6a5 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 1f8ff12b4f..6fd869dca6 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 328cb3a788..242219d889 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -1,18 +1,18 @@ #pragma once -#include <AK/Types.h> -#include <AK/InlineLinkedList.h> #include <AK/AKString.h> +#include <AK/InlineLinkedList.h> +#include <AK/Types.h> #include <AK/Vector.h> #include <AK/WeakPtr.h> #include <AK/Weakable.h> #include <Kernel/FileSystem/VirtualFileSystem.h> -#include <Kernel/VM/RangeAllocator.h> -#include <Kernel/TTY/TTY.h> +#include <Kernel/Lock.h> #include <Kernel/Syscall.h> -#include <Kernel/UnixTypes.h> +#include <Kernel/TTY/TTY.h> #include <Kernel/Thread.h> -#include <Kernel/Lock.h> +#include <Kernel/UnixTypes.h> +#include <Kernel/VM/RangeAllocator.h> #include <LibC/signal_numbers.h> class ELFLoader; @@ -24,9 +24,11 @@ class ProcessTracer; void kgettimeofday(timeval&); -class Process : public InlineLinkedListNode<Process>, public Weakable<Process> { +class Process : public InlineLinkedListNode<Process> + , public Weakable<Process> { friend class InlineLinkedListNode<Process>; 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<String>&& arguments = Vector<String>(), Vector<String>&& environment = Vector<String>(), TTY* = nullptr); @@ -35,14 +37,16 @@ public: static Vector<pid_t> all_pids(); static Vector<Process*> 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<typename Callback> static void for_each(Callback); - template<typename Callback> static void for_each_in_pgrp(pid_t, Callback); - template<typename Callback> void for_each_child(Callback); - template<typename Callback> void for_each_thread(Callback) const; + template<typename Callback> + static void for_each(Callback); + template<typename Callback> + static void for_each_in_pgrp(pid_t, Callback); + template<typename Callback> + void for_each_child(Callback); + template<typename Callback> + 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<typename T> bool validate_read_typed(T* value, size_t count = 1) { return validate_read(value, sizeof(T) * count); } - template<typename T> bool validate_write_typed(T* value, size_t count = 1) { return validate_write(value, sizeof(T) * count); } + template<typename T> + bool validate_read_typed(T* value, size_t count = 1) { return validate_read(value, sizeof(T) * count); } + template<typename T> + 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 9db8aa60a4..b0b0321b67 100644 --- a/Kernel/ProcessTracer.h +++ b/Kernel/ProcessTracer.h @@ -1,7 +1,7 @@ #pragma once -#include <Kernel/File.h> #include <AK/CircularQueue.h> +#include <Kernel/File.h> #include <Kernel/UnixTypes.h> class ProcessTracer : public File { diff --git a/Kernel/RTC.h b/Kernel/RTC.h index 7fe25b3392..3ae5a441a5 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 da3c5c8e3e..76b4a8d070 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 ffbb7ac468..4c8520ce12 100644 --- a/Kernel/SharedMemory.h +++ b/Kernel/SharedMemory.h @@ -1,11 +1,11 @@ #pragma once -#include <AK/Retainable.h> -#include <AK/RetainPtr.h> #include <AK/AKString.h> +#include <AK/RetainPtr.h> +#include <AK/Retainable.h> +#include <Kernel/File.h> #include <Kernel/KResult.h> #include <Kernel/UnixTypes.h> -#include <Kernel/File.h> class VMObject; diff --git a/Kernel/StdLib.h b/Kernel/StdLib.h index 3f32de4797..6fa43e3563 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 2d093f6a74..c6ff1bc686 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -3,116 +3,116 @@ #include <AK/Types.h> #include <LibC/fd_set.h> -#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<typename T1> 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<typename T1, typename T2> 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<typename T1, typename T2, typename T3> 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 c5979ba991..1d06d6f4d8 100644 --- a/Kernel/TTY/PTYMultiplexer.h +++ b/Kernel/TTY/PTYMultiplexer.h @@ -1,7 +1,7 @@ #pragma once -#include <Kernel/Devices/CharacterDevice.h> #include <AK/Badge.h> +#include <Kernel/Devices/CharacterDevice.h> #include <Kernel/Lock.h> class MasterPTY; diff --git a/Kernel/TTY/SlavePTY.h b/Kernel/TTY/SlavePTY.h index f764c43649..ffe7ebd8b1 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 56fbcb3c6f..e6d489579c 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 eb0c11b3fe..8e89fac853 100644 --- a/Kernel/TTY/VirtualConsole.h +++ b/Kernel/TTY/VirtualConsole.h @@ -1,13 +1,19 @@ #pragma once -#include <Kernel/TTY/TTY.h> -#include <Kernel/Devices/KeyboardDevice.h> #include "Console.h" +#include <Kernel/Devices/KeyboardDevice.h> +#include <Kernel/TTY/TTY.h> -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 11091f6d3b..40f7abba11 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -1,15 +1,15 @@ #pragma once -#include <Kernel/i386.h> -#include <Kernel/KResult.h> -#include <Kernel/LinearAddress.h> -#include <Kernel/UnixTypes.h> -#include <Kernel/VM/Region.h> #include <AK/AKString.h> #include <AK/InlineLinkedList.h> #include <AK/OwnPtr.h> #include <AK/RetainPtr.h> #include <AK/Vector.h> +#include <Kernel/KResult.h> +#include <Kernel/LinearAddress.h> +#include <Kernel/UnixTypes.h> +#include <Kernel/VM/Region.h> +#include <Kernel/i386.h> 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<Thread>* g_nonrunnable_threads; class Thread : public InlineLinkedListNode<Thread> { 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>* thread_list() { return m_thread_list; } void set_thread_list(InlineLinkedList<Thread>*); - template<typename Callback> static void for_each_in_state(State, Callback); - template<typename Callback> static void for_each_living(Callback); - template<typename Callback> static void for_each_runnable(Callback); - template<typename Callback> static void for_each_nonrunnable(Callback); - template<typename Callback> static void for_each(Callback); + template<typename Callback> + static void for_each_in_state(State, Callback); + template<typename Callback> + static void for_each_living(Callback); + template<typename Callback> + static void for_each_runnable(Callback); + template<typename Callback> + static void for_each_nonrunnable(Callback); + template<typename Callback> + static void for_each(Callback); static bool is_runnable_state(Thread::State state) { diff --git a/Kernel/UnixTypes.h b/Kernel/UnixTypes.h index 62ed18d1c6..4e092e8e88 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 3615826fb3..b45cfcbf00 100644 --- a/Kernel/VM/MemoryManager.h +++ b/Kernel/VM/MemoryManager.h @@ -1,27 +1,28 @@ #pragma once -#include <AK/Types.h> #include "i386.h" +#include <AK/AKString.h> +#include <AK/Badge.h> #include <AK/Bitmap.h> #include <AK/ByteBuffer.h> -#include <AK/Retainable.h> +#include <AK/HashTable.h> #include <AK/RetainPtr.h> +#include <AK/Retainable.h> +#include <AK/Types.h> #include <AK/Vector.h> -#include <AK/HashTable.h> -#include <AK/AKString.h> -#include <AK/Badge.h> #include <AK/Weakable.h> +#include <Kernel/FileSystem/InodeIdentifier.h> #include <Kernel/LinearAddress.h> #include <Kernel/VM/PhysicalPage.h> #include <Kernel/VM/Region.h> #include <Kernel/VM/VMObject.h> -#include <Kernel/FileSystem/InodeIdentifier.h> -#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<PhysicalPage> allocate_physical_page(ShouldZeroFill); RetainPtr<PhysicalPage> 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<dword*>(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<dword*>(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 409a5f919c..8207389ab7 100644 --- a/Kernel/VM/PageDirectory.h +++ b/Kernel/VM/PageDirectory.h @@ -1,13 +1,14 @@ #pragma once -#include <Kernel/VM/PhysicalPage.h> -#include <Kernel/VM/RangeAllocator.h> #include <AK/HashMap.h> -#include <AK/Retainable.h> #include <AK/RetainPtr.h> +#include <AK/Retainable.h> +#include <Kernel/VM/PhysicalPage.h> +#include <Kernel/VM/RangeAllocator.h> class PageDirectory : public Retainable<PageDirectory> { friend class MemoryManager; + public: static Retained<PageDirectory> create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr) { return adopt(*new PageDirectory(parent_range_allocator)); } static Retained<PageDirectory> create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); } diff --git a/Kernel/VM/PhysicalPage.h b/Kernel/VM/PhysicalPage.h index 2d9cd88677..bf2726bcef 100644 --- a/Kernel/VM/PhysicalPage.h +++ b/Kernel/VM/PhysicalPage.h @@ -1,13 +1,14 @@ #pragma once +#include <AK/Retained.h> #include <Kernel/Assertions.h> #include <Kernel/PhysicalAddress.h> -#include <AK/Retained.h> 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 e80e1278ca..7381aa5db7 100644 --- a/Kernel/VM/RangeAllocator.h +++ b/Kernel/VM/RangeAllocator.h @@ -1,12 +1,13 @@ #pragma once -#include <Kernel/LinearAddress.h> #include <AK/Vector.h> +#include <Kernel/LinearAddress.h> 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 806fa6460c..254469cf1d 100644 --- a/Kernel/VM/Region.h +++ b/Kernel/VM/Region.h @@ -10,6 +10,7 @@ class VMObject; class Region : public Retainable<Region> { friend class MemoryManager; + public: Region(const Range&, String&&, bool r, bool w, bool cow = false); Region(const Range&, Retained<VMObject>&&, 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 4a0fee7436..0f7b9c4fea 100644 --- a/Kernel/VM/VMObject.h +++ b/Kernel/VM/VMObject.h @@ -1,11 +1,11 @@ #pragma once +#include <AK/AKString.h> #include <AK/Badge.h> -#include <AK/Retainable.h> -#include <AK/Weakable.h> #include <AK/RetainPtr.h> +#include <AK/Retainable.h> #include <AK/Vector.h> -#include <AK/AKString.h> +#include <AK/Weakable.h> #include <Kernel/Lock.h> #include <Kernel/PhysicalAddress.h> #include <Kernel/UnixTypes.h> @@ -13,8 +13,10 @@ class Inode; class PhysicalPage; -class VMObject : public Retainable<VMObject>, public Weakable<VMObject> { +class VMObject : public Retainable<VMObject> + , public Weakable<VMObject> { friend class MemoryManager; + public: static Retained<VMObject> create_file_backed(RetainPtr<Inode>&&); static Retained<VMObject> create_anonymous(size_t); @@ -46,7 +48,8 @@ private: explicit VMObject(size_t); VMObject(PhysicalAddress, size_t); - template<typename Callback> void for_each_region(Callback); + template<typename Callback> + 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 c770d45286..a323947d03 100644 --- a/Kernel/i386.h +++ b/Kernel/i386.h @@ -1,12 +1,13 @@ #pragma once -#include <Kernel/kstdio.h> #include <Kernel/LinearAddress.h> +#include <Kernel/kstdio.h> #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 c537036f2a..573399d1a1 100644 --- a/Kernel/i8253.h +++ b/Kernel/i8253.h @@ -2,26 +2,26 @@ #include <AK/Types.h> -#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 d44d215f64..00509e320c 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 09dbc40463..fc2fa28cad 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 33de7c7a6e..24fd371516 100644 --- a/LibC/SharedBuffer.h +++ b/LibC/SharedBuffer.h @@ -1,7 +1,7 @@ #pragma once -#include <AK/Retainable.h> #include <AK/RetainPtr.h> +#include <AK/Retainable.h> class SharedBuffer : public Retainable<SharedBuffer> { public: diff --git a/LibC/alloca.h b/LibC/alloca.h index 0813019304..db619d9b43 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 ec2292ef67..0c0c966a68 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 21e380fe4e..9c86d09f0f 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 17ab57c471..c551c3fc8e 100644 --- a/LibC/ctype.h +++ b/LibC/ctype.h @@ -1,7 +1,7 @@ #pragma once -#include <sys/cdefs.h> #include <string.h> +#include <sys/cdefs.h> __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 9b0e77cdb3..27164519bf 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 0b9505fe62..f07144a915 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 967cc18b37..3d3bf85029 100644 --- a/LibC/errno.h +++ b/LibC/errno.h @@ -1,18 +1,18 @@ #pragma once -#include <sys/cdefs.h> #include <errno_numbers.h> +#include <sys/cdefs.h> #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 2527d44e97..7421967c92 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 5f67104bf3..b49d3ef372 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 4f5b9ae2bc..70831a2565 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 b1c4e94275..0f5c52e668 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 73ea753fd9..f8b408026d 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 5627cb121a..91406bbb8e 100644 --- a/LibC/mntent.h +++ b/LibC/mntent.h @@ -1,7 +1,7 @@ #pragma once -#include <sys/cdefs.h> #include <stdio.h> +#include <sys/cdefs.h> __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 492802f59b..ed75e48240 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 f0a59de8be..7a43b59b85 100644 --- a/LibC/netinet/in.h +++ b/LibC/netinet/in.h @@ -1,7 +1,7 @@ #pragma once -#include <sys/cdefs.h> #include <stdint.h> +#include <sys/cdefs.h> __BEGIN_DECLS diff --git a/LibC/netinet/ip_icmp.h b/LibC/netinet/ip_icmp.h index 7f18bea110..7b278aac90 100644 --- a/LibC/netinet/ip_icmp.h +++ b/LibC/netinet/ip_icmp.h @@ -1,7 +1,7 @@ #pragma once -#include <sys/cdefs.h> #include <stdint.h> +#include <sys/cdefs.h> __BEGIN_DECLS @@ -19,4 +19,3 @@ struct icmphdr { }; __END_DECLS - diff --git a/LibC/poll.h b/LibC/poll.h index 1a52049c82..02d3e66059 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 b98717b224..d5848d0821 100644 --- a/LibC/pthread.h +++ b/LibC/pthread.h @@ -1,7 +1,7 @@ #pragma once -#include <sys/cdefs.h> #include <sched.h> +#include <sys/cdefs.h> __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 d753063d7a..aa8aa26c74 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 01980ac8b5..a6511a38f6 100644 --- a/LibC/setjmp.h +++ b/LibC/setjmp.h @@ -1,10 +1,10 @@ #pragma once -#include <sys/cdefs.h> -#include <sys/types.h> -#include <stdint.h> #include <signal.h> #include <stdbool.h> +#include <stdint.h> +#include <sys/cdefs.h> +#include <sys/types.h> __BEGIN_DECLS diff --git a/LibC/signal.h b/LibC/signal.h index 77ee536512..798f5dad13 100644 --- a/LibC/signal.h +++ b/LibC/signal.h @@ -1,7 +1,7 @@ #pragma once -#include <sys/types.h> #include <signal_numbers.h> +#include <sys/types.h> __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 5c974cbf1c..3ce9ec0427 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 366964cb27..facdcd67e2 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 <sys/cdefs.h> +# include <sys/cdefs.h> #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 96d0d4dd92..6b4e36f93b 100644 --- a/LibC/stdbool.h +++ b/LibC/stdbool.h @@ -2,14 +2,14 @@ #ifndef __cplusplus -#include <sys/cdefs.h> +# include <sys/cdefs.h> __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 61a20c763a..73f82c1489 100644 --- a/LibC/stddef.h +++ b/LibC/stddef.h @@ -4,9 +4,9 @@ #include <sys/types.h> #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 4d0dc2bdfc..8dfe120712 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 8f41e74636..54f64173d8 100644 --- a/LibC/stdio.h +++ b/LibC/stdio.h @@ -2,16 +2,16 @@ #define _STDIO_H // Make GMP believe we exist. +#include <limits.h> +#include <stdarg.h> #include <sys/cdefs.h> #include <sys/types.h> -#include <stdarg.h> -#include <limits.h> #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 25e9a585dd..22493e5e98 100644 --- a/LibC/stdlib.h +++ b/LibC/stdlib.h @@ -1,8 +1,8 @@ #pragma once +#include <stddef.h> #include <sys/cdefs.h> #include <sys/types.h> -#include <stddef.h> __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 b71f6c602c..9d02da28b3 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 f74a8541f5..8f05740393 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 85edc5dbfe..f8ac61aeda 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 7b21cf8e55..cce5dc6969 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 9cc8abae4c..55bad8e20b 100644 --- a/LibC/sys/select.h +++ b/LibC/sys/select.h @@ -1,13 +1,12 @@ #pragma once +#include <fd_set.h> +#include <string.h> #include <sys/cdefs.h> #include <sys/types.h> -#include <string.h> -#include <fd_set.h> __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 b1dc322e1b..6923965652 100644 --- a/LibC/sys/socket.h +++ b/LibC/sys/socket.h @@ -1,8 +1,8 @@ #pragma once +#include <stdint.h> #include <sys/cdefs.h> #include <sys/types.h> -#include <stdint.h> #include <sys/un.h> __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 d337dfc294..fc6a36a33c 100644 --- a/LibC/sys/stat.h +++ b/LibC/sys/stat.h @@ -1,18 +1,18 @@ #pragma once +#include <fcntl.h> #include <sys/cdefs.h> #include <sys/types.h> -#include <fcntl.h> __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 fef0236f82..a28472f842 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 9f806759dc..4c4a20e7e4 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 e617b2e34d..6e903dfb4b 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 e9136d9c2b..d160b8aff5 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 01529f3df9..d408ea1700 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 29e5583512..0a720dadf4 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 ea0a35b06f..6985bcf590 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 a9cacca3a4..994fde0c1a 100644 --- a/LibC/unistd.h +++ b/LibC/unistd.h @@ -1,9 +1,9 @@ #pragma once +#include <errno.h> +#include <limits.h> #include <sys/cdefs.h> #include <sys/types.h> -#include <limits.h> -#include <errno.h> __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 96c26f6bb4..6ad7e3592a 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 69e1167e82..701e37d1dc 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 e46806fcc5..d28d0d4c7d 100644 --- a/LibC/wchar.h +++ b/LibC/wchar.h @@ -1,12 +1,12 @@ #pragma once -#include <sys/cdefs.h> #include <stddef.h> +#include <sys/cdefs.h> __BEGIN_DECLS #ifndef WEOF -#define WEOF (0xffffffffu) +# define WEOF (0xffffffffu) #endif __END_DECLS diff --git a/LibCore/CArgsParser.cpp b/LibCore/CArgsParser.cpp index ab4936d15d..55dc350791 100644 --- a/LibCore/CArgsParser.cpp +++ b/LibCore/CArgsParser.cpp @@ -19,18 +19,27 @@ const Vector<String>& 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 ab4078822e..4c50aa23a9 100644 --- a/LibCore/CArgsParser.h +++ b/LibCore/CArgsParser.h @@ -67,4 +67,3 @@ private: Vector<SingleArg> m_single_args; HashMap<String, Arg> m_args; }; - diff --git a/LibCore/CConfigFile.cpp b/LibCore/CConfigFile.cpp index 6b46214561..d39d4505a0 100644 --- a/LibCore/CConfigFile.cpp +++ b/LibCore/CConfigFile.cpp @@ -1,9 +1,9 @@ +#include <AK/StringBuilder.h> #include <LibCore/CConfigFile.h> #include <LibCore/CFile.h> #include <LibCore/CUserInfo.h> -#include <AK/StringBuilder.h> -#include <stdio.h> #include <pwd.h> +#include <stdio.h> #include <unistd.h> Retained<CConfigFile> CConfigFile::get_for_app(const String& app_name) @@ -24,17 +24,17 @@ Retained<CConfigFile> 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<CConfigFile&>(*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<CConfigFile&>(*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<String> CConfigFile::groups() const @@ -199,7 +196,7 @@ Vector<String> 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 ea71c9b367..0f58b2b2a2 100644 --- a/LibCore/CConfigFile.h +++ b/LibCore/CConfigFile.h @@ -1,11 +1,11 @@ #pragma once -#include <SharedGraphics/Color.h> -#include <AK/Vector.h> -#include <AK/HashMap.h> #include <AK/AKString.h> -#include <AK/Retainable.h> +#include <AK/HashMap.h> #include <AK/RetainPtr.h> +#include <AK/Retainable.h> +#include <AK/Vector.h> +#include <SharedGraphics/Color.h> class CConfigFile : public Retainable<CConfigFile> { 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 c66b313e45..aa64ea8b71 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 03804aecf3..72920c2c1f 100644 --- a/LibCore/CDirIterator.h +++ b/LibCore/CDirIterator.h @@ -1,11 +1,12 @@ #pragma once -#include <dirent.h> #include <AK/AKString.h> +#include <dirent.h> 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 aec3658fc4..e783f59b0d 100644 --- a/LibCore/CElapsedTimer.cpp +++ b/LibCore/CElapsedTimer.cpp @@ -1,6 +1,6 @@ -#include <LibCore/CElapsedTimer.h> #include <AK/Assertions.h> #include <AK/Time.h> +#include <LibCore/CElapsedTimer.h> #include <sys/time.h> void CElapsedTimer::start() diff --git a/LibCore/CElapsedTimer.h b/LibCore/CElapsedTimer.h index bb8fa28ac6..76fa304478 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 4010afe607..1920df2688 100644 --- a/LibCore/CEvent.h +++ b/LibCore/CEvent.h @@ -1,15 +1,16 @@ #pragma once #include <AK/AKString.h> +#include <AK/Function.h> #include <AK/Types.h> #include <AK/WeakPtr.h> -#include <AK/Function.h> 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<void(CObject&)> 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 4537efb5af..d84a45fe16 100644 --- a/LibCore/CEventLoop.cpp +++ b/LibCore/CEventLoop.cpp @@ -1,20 +1,19 @@ -#include <LibCore/CObject.h> -#include <LibCore/CEventLoop.h> -#include <LibCore/CEvent.h> -#include <LibCore/CLock.h> -#include <LibCore/CNotifier.h> -#include <LibC/unistd.h> -#include <LibC/stdio.h> +#include <AK/Time.h> +#include <LibC/errno.h> #include <LibC/fcntl.h> +#include <LibC/stdio.h> +#include <LibC/stdlib.h> #include <LibC/string.h> -#include <LibC/time.h> #include <LibC/sys/select.h> #include <LibC/sys/socket.h> #include <LibC/sys/time.h> -#include <LibC/errno.h> -#include <LibC/string.h> -#include <LibC/stdlib.h> -#include <AK/Time.h> +#include <LibC/time.h> +#include <LibC/unistd.h> +#include <LibCore/CEvent.h> +#include <LibCore/CEventLoop.h> +#include <LibCore/CLock.h> +#include <LibCore/CNotifier.h> +#include <LibCore/CObject.h> //#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 a44cc72486..dbcc67ddb7 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 47cee94f15..44813e1c97 100644 --- a/LibCore/CFile.cpp +++ b/LibCore/CFile.cpp @@ -1,7 +1,7 @@ #include <LibCore/CFile.h> -#include <unistd.h> #include <fcntl.h> #include <stdio.h> +#include <unistd.h> CFile::CFile(const String& filename) : m_filename(filename) diff --git a/LibCore/CFile.h b/LibCore/CFile.h index a78c850fe3..fab396ac55 100644 --- a/LibCore/CFile.h +++ b/LibCore/CFile.h @@ -1,11 +1,11 @@ #pragma once -#include <LibCore/CIODevice.h> #include <AK/AKString.h> +#include <LibCore/CIODevice.h> 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 f9a9a08f3b..e580fd87c2 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<byte> 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 e30e836b66..c8d2c8c361 100644 --- a/LibCore/CHttpJob.h +++ b/LibCore/CHttpJob.h @@ -1,8 +1,8 @@ #pragma once -#include <LibCore/CNetworkJob.h> -#include <LibCore/CHttpRequest.h> #include <AK/HashMap.h> +#include <LibCore/CHttpRequest.h> +#include <LibCore/CNetworkJob.h> 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 3f07fecaa1..de62a8cd6d 100644 --- a/LibCore/CHttpRequest.cpp +++ b/LibCore/CHttpRequest.cpp @@ -1,6 +1,6 @@ -#include <LibCore/CHttpRequest.h> -#include <LibCore/CHttpJob.h> #include <AK/StringBuilder.h> +#include <LibCore/CHttpJob.h> +#include <LibCore/CHttpRequest.h> CHttpRequest::CHttpRequest() { diff --git a/LibCore/CHttpRequest.h b/LibCore/CHttpRequest.h index 5432baf4b5..8ab6fef413 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 7cf46bc545..851f77d3a0 100644 --- a/LibCore/CHttpResponse.h +++ b/LibCore/CHttpResponse.h @@ -1,8 +1,8 @@ #pragma once -#include <LibCore/CNetworkResponse.h> #include <AK/AKString.h> #include <AK/HashMap.h> +#include <LibCore/CNetworkResponse.h> class CHttpResponse : public CNetworkResponse { public: diff --git a/LibCore/CIODevice.h b/LibCore/CIODevice.h index 79e589eb9f..4977c3f33b 100644 --- a/LibCore/CIODevice.h +++ b/LibCore/CIODevice.h @@ -1,18 +1,19 @@ #pragma once -#include <LibCore/CObject.h> #include <AK/ByteBuffer.h> +#include <LibCore/CObject.h> 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 a9853f5215..02ab53fa82 100644 --- a/LibCore/CLock.h +++ b/LibCore/CLock.h @@ -4,23 +4,24 @@ #include <AK/Types.h> #include <unistd.h> -#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<typename T> 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 4b6b479c8f..3d8117c754 100644 --- a/LibCore/CNetworkJob.h +++ b/LibCore/CNetworkJob.h @@ -1,13 +1,14 @@ #pragma once -#include <LibCore/CObject.h> #include <AK/Function.h> +#include <LibCore/CObject.h> 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 1968590c79..70bc30de15 100644 --- a/LibCore/CNetworkResponse.h +++ b/LibCore/CNetworkResponse.h @@ -1,7 +1,7 @@ #pragma once -#include <AK/Retainable.h> #include <AK/ByteBuffer.h> +#include <AK/Retainable.h> class CNetworkResponse : public Retainable<CNetworkResponse> { public: diff --git a/LibCore/CNotifier.cpp b/LibCore/CNotifier.cpp index a7e1344900..000602a4a9 100644 --- a/LibCore/CNotifier.cpp +++ b/LibCore/CNotifier.cpp @@ -1,6 +1,6 @@ -#include <LibCore/CNotifier.h> -#include <LibCore/CEventLoop.h> #include <LibCore/CEvent.h> +#include <LibCore/CEventLoop.h> +#include <LibCore/CNotifier.h> CNotifier::CNotifier(int fd, unsigned event_mask) : m_fd(fd) @@ -13,4 +13,3 @@ CNotifier::~CNotifier() { CEventLoop::unregister_notifier(Badge<CNotifier>(), *this); } - diff --git a/LibCore/CNotifier.h b/LibCore/CNotifier.h index baa3532b92..736d78e04b 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 93f7733c92..a5ea5e6977 100644 --- a/LibCore/CObject.cpp +++ b/LibCore/CObject.cpp @@ -1,7 +1,7 @@ -#include <LibCore/CObject.h> +#include <AK/Assertions.h> #include <LibCore/CEvent.h> #include <LibCore/CEventLoop.h> -#include <AK/Assertions.h> +#include <LibCore/CObject.h> #include <stdio.h> 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 a4eac52eec..fda00cd976 100644 --- a/LibCore/CObject.h +++ b/LibCore/CObject.h @@ -29,7 +29,8 @@ public: } } - template<typename T, typename Callback> void for_each_child_of_type(Callback callback); + template<typename T, typename Callback> + 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<CObject*> m_children; }; -template<typename T> inline bool is(const CObject&) { return true; } +template<typename T> +inline bool is(const CObject&) { return true; } template<typename T> inline T& to(CObject& object) @@ -80,7 +82,7 @@ inline const T& to(const CObject& object) template<typename T, typename Callback> inline void CObject::for_each_child_of_type(Callback callback) { - for_each_child([&] (auto& child) { + for_each_child([&](auto& child) { if (is<T>(child)) return callback(to<T>(child)); return IterationDecision::Continue; diff --git a/LibCore/CProcessStatisticsReader.cpp b/LibCore/CProcessStatisticsReader.cpp index 1a80f306c3..439ec36e13 100644 --- a/LibCore/CProcessStatisticsReader.cpp +++ b/LibCore/CProcessStatisticsReader.cpp @@ -1,8 +1,8 @@ #include "CProcessStatisticsReader.h" #include "CFile.h" -#include <stdio.h> #include <pwd.h> +#include <stdio.h> CProcessStatisticsReader::CProcessStatisticsReader() { @@ -64,7 +64,7 @@ void CProcessStatisticsReader::update_map(HashMap<pid_t, CProcessStatistics>& 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 2ce97e9f68..df9b788ea2 100644 --- a/LibCore/CProcessStatisticsReader.h +++ b/LibCore/CProcessStatisticsReader.h @@ -24,6 +24,6 @@ public: private: void update_map(HashMap<pid_t, CProcessStatistics>& map); String get_username_from_uid(const uid_t uid); - + HashMap<uid_t, String> m_usernames; }; diff --git a/LibCore/CSocket.cpp b/LibCore/CSocket.cpp index e29caefe29..ea9a7135ec 100644 --- a/LibCore/CSocket.cpp +++ b/LibCore/CSocket.cpp @@ -1,12 +1,12 @@ -#include <LibCore/CSocket.h> #include <LibCore/CNotifier.h> -#include <sys/socket.h> -#include <netinet/in.h> +#include <LibCore/CSocket.h> #include <arpa/inet.h> -#include <stdlib.h> -#include <stdio.h> -#include <netdb.h> #include <errno.h> +#include <netdb.h> +#include <netinet/in.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/socket.h> CSocket::CSocket(Type type, CObject* parent) : CIODevice(parent) diff --git a/LibCore/CSocket.h b/LibCore/CSocket.h index b02133f050..0de7872fb2 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 5de064dd95..efa545f24c 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 c48331f9ee..fe4f3ffb3a 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 4d0507512f..b6c1c2005f 100644 --- a/LibCore/CTimer.h +++ b/LibCore/CTimer.h @@ -1,7 +1,7 @@ #pragma once -#include <LibCore/CObject.h> #include <AK/Function.h> +#include <LibCore/CObject.h> class CTimer final : public CObject { public: diff --git a/LibCore/CUserInfo.cpp b/LibCore/CUserInfo.cpp index 9efe160489..d5308d454e 100644 --- a/LibCore/CUserInfo.cpp +++ b/LibCore/CUserInfo.cpp @@ -1,7 +1,7 @@ #include "CUserInfo.h" +#include <pwd.h> #include <stdlib.h> #include <unistd.h> -#include <pwd.h> const char* get_current_user_home_path() { diff --git a/LibCore/CUserInfo.h b/LibCore/CUserInfo.h index 22ef0a8fb4..b47cec4af1 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 1660e40dff..7709c0cae8 100644 --- a/LibGUI/GAbstractView.h +++ b/LibGUI/GAbstractView.h @@ -1,13 +1,14 @@ #pragma once +#include <AK/Function.h> #include <LibGUI/GModel.h> #include <LibGUI/GScrollableWidget.h> -#include <AK/Function.h> 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 4d9445fc96..5770693a8c 100644 --- a/LibGUI/GAction.h +++ b/LibGUI/GAction.h @@ -1,23 +1,25 @@ #pragma once #include <AK/AKString.h> +#include <AK/Badge.h> #include <AK/Function.h> +#include <AK/HashTable.h> #include <AK/Retainable.h> #include <AK/Retained.h> -#include <AK/Weakable.h> #include <AK/WeakPtr.h> -#include <AK/Badge.h> -#include <AK/HashTable.h> -#include <SharedGraphics/GraphicsBitmap.h> +#include <AK/Weakable.h> #include <LibGUI/GShortcut.h> +#include <SharedGraphics/GraphicsBitmap.h> class GButton; class GMenuItem; class GWidget; -class GAction : public Retainable<GAction>, public Weakable<GAction> { +class GAction : public Retainable<GAction> + , public Weakable<GAction> { 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>, GButton&); @@ -77,8 +83,10 @@ private: GAction(const String& text, RetainPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> = nullptr, GWidget* = nullptr); GAction(const String& text, const String& custom_data = String(), Function<void(GAction&)> = nullptr, GWidget* = nullptr); - template<typename Callback> void for_each_toolbar_button(Callback); - template<typename Callback> void for_each_menu_item(Callback); + template<typename Callback> + void for_each_toolbar_button(Callback); + template<typename Callback> + void for_each_menu_item(Callback); String m_text; String m_custom_data; diff --git a/LibGUI/GApplication.h b/LibGUI/GApplication.h index 4242204cbf..14b9d65f59 100644 --- a/LibGUI/GApplication.h +++ b/LibGUI/GApplication.h @@ -1,8 +1,8 @@ #pragma once #include <AK/Badge.h> -#include <AK/OwnPtr.h> #include <AK/HashMap.h> +#include <AK/OwnPtr.h> #include <LibGUI/GShortcut.h> class GAction; diff --git a/LibGUI/GBoxLayout.h b/LibGUI/GBoxLayout.h index 605c7d5d62..b16cca0301 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 c0d185a21e..1f62dc8d39 100644 --- a/LibGUI/GButton.h +++ b/LibGUI/GButton.h @@ -43,4 +43,3 @@ private: TextAlignment m_text_alignment { TextAlignment::Center }; WeakPtr<GAction> m_action; }; - diff --git a/LibGUI/GCheckBox.h b/LibGUI/GCheckBox.h index 57e644aa9b..26116817e5 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 007f07cc59..7244db5aa0 100644 --- a/LibGUI/GDialog.h +++ b/LibGUI/GDialog.h @@ -1,11 +1,16 @@ #pragma once -#include <LibGUI/GWindow.h> #include <LibGUI/GEventLoop.h> +#include <LibGUI/GWindow.h> 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 e33693ed45..d4f0e31073 100644 --- a/LibGUI/GDirectoryModel.h +++ b/LibGUI/GDirectoryModel.h @@ -1,16 +1,18 @@ #pragma once -#include <LibGUI/GModel.h> #include <AK/HashMap.h> +#include <LibGUI/GModel.h> #include <sys/stat.h> class GDirectoryModel final : public GModel { friend int thumbnail_thread(void*); + public: static Retained<GDirectoryModel> 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 bdb4c0e5d5..54e111dfe3 100644 --- a/LibGUI/GEvent.h +++ b/LibGUI/GEvent.h @@ -1,16 +1,17 @@ #pragma once +#include <Kernel/KeyCode.h> #include <LibCore/CEvent.h> +#include <LibGUI/GWindowType.h> #include <SharedGraphics/Point.h> #include <SharedGraphics/Rect.h> -#include <Kernel/KeyCode.h> -#include <LibGUI/GWindowType.h> 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 9d8b5b7e86..aa54682545 100644 --- a/LibGUI/GEventLoop.h +++ b/LibGUI/GEventLoop.h @@ -1,8 +1,8 @@ #pragma once #include <LibCore/CEventLoop.h> -#include <WindowServer/WSAPITypes.h> #include <LibGUI/GEvent.h> +#include <WindowServer/WSAPITypes.h> class GAction; class CObject; @@ -16,7 +16,7 @@ public: static GEventLoop& current() { return static_cast<GEventLoop&>(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 7eb7f5ef0c..7f21ca7794 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<GFileSystemModel> create(const String& root_path = "/", Mode mode = Mode::FilesAndDirectories) { diff --git a/LibGUI/GFontDatabase.h b/LibGUI/GFontDatabase.h index e1de0baec5..af49e68875 100644 --- a/LibGUI/GFontDatabase.h +++ b/LibGUI/GFontDatabase.h @@ -1,8 +1,8 @@ #pragma once #include <AK/AKString.h> -#include <AK/HashMap.h> #include <AK/Function.h> +#include <AK/HashMap.h> class Font; @@ -20,7 +20,8 @@ public: void for_each_font(Function<void(const String&)>); void for_each_fixed_width_font(Function<void(const String&)>); - 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 c0b3d15cdf..61d928127f 100644 --- a/LibGUI/GIcon.h +++ b/LibGUI/GIcon.h @@ -1,18 +1,18 @@ #pragma once -#include <SharedGraphics/GraphicsBitmap.h> #include <AK/HashMap.h> +#include <SharedGraphics/GraphicsBitmap.h> class GIconImpl : public Retainable<GIconImpl> { public: static Retained<GIconImpl> create() { return adopt(*new GIconImpl); } - ~GIconImpl() { } + ~GIconImpl() {} const GraphicsBitmap* bitmap_for_size(int) const; void set_bitmap_for_size(int, RetainPtr<GraphicsBitmap>&&); private: - GIconImpl() { } + GIconImpl() {} HashMap<int, RetainPtr<GraphicsBitmap>> m_bitmaps; }; @@ -23,7 +23,7 @@ public: explicit GIcon(RetainPtr<GraphicsBitmap>&&, RetainPtr<GraphicsBitmap>&&); 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 19f9e30f92..ca50019ce4 100644 --- a/LibGUI/GItemView.h +++ b/LibGUI/GItemView.h @@ -1,9 +1,9 @@ #pragma once -#include <LibGUI/GModel.h> -#include <LibGUI/GAbstractView.h> #include <AK/Function.h> #include <AK/HashMap.h> +#include <LibGUI/GAbstractView.h> +#include <LibGUI/GModel.h> class GScrollBar; class Painter; diff --git a/LibGUI/GLabel.h b/LibGUI/GLabel.h index f9097a28c2..a67b50b90c 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 4d07f73546..498f0efc6a 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 8cf1c4cb0f..d32f7b51f9 100644 --- a/LibGUI/GListView.h +++ b/LibGUI/GListView.h @@ -1,9 +1,9 @@ #pragma once -#include <LibGUI/GModel.h> -#include <LibGUI/GAbstractView.h> #include <AK/Function.h> #include <AK/HashMap.h> +#include <LibGUI/GAbstractView.h> +#include <LibGUI/GModel.h> class GScrollBar; class Painter; diff --git a/LibGUI/GMargins.h b/LibGUI/GMargins.h index 730923bf2b..cdfb590654 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 1eb741de4b..97a8ed51c9 100644 --- a/LibGUI/GMenu.h +++ b/LibGUI/GMenu.h @@ -1,10 +1,10 @@ #pragma once -#include <LibGUI/GMenuItem.h> #include <AK/Function.h> #include <AK/Retainable.h> #include <AK/Retained.h> #include <AK/Vector.h> +#include <LibGUI/GMenuItem.h> class GAction; class Point; diff --git a/LibGUI/GMenuBar.h b/LibGUI/GMenuBar.h index 4fc4d90554..88f98eed7b 100644 --- a/LibGUI/GMenuBar.h +++ b/LibGUI/GMenuBar.h @@ -1,8 +1,8 @@ #pragma once -#include <LibGUI/GMenu.h> #include <AK/Badge.h> #include <AK/Vector.h> +#include <LibGUI/GMenu.h> class GApplication; diff --git a/LibGUI/GMenuItem.h b/LibGUI/GMenuItem.h index 2987528121..6cb1df8e53 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<GAction>&&); @@ -43,4 +48,3 @@ private: bool m_checked { false }; RetainPtr<GAction> m_action; }; - diff --git a/LibGUI/GMessageBox.h b/LibGUI/GMessageBox.h index 5ccfcc46aa..31f4983ae3 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 9f3e087c3c..0aba8900cd 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>, GAbstractView&); void unregister_view(Badge<GAbstractView>, GAbstractView&); diff --git a/LibGUI/GModelIndex.h b/LibGUI/GModelIndex.h index a568f1f63a..6817270a66 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 2429dcf0ae..42e3843403 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 95897f5b47..410f0e4556 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<typename Callback> void for_each_in_group(Callback); + template<typename Callback> + void for_each_in_group(Callback); static Size circle_size(); }; -template<> inline bool is<GRadioButton>(const CObject& object) +template<> +inline bool is<GRadioButton>(const CObject& object) { if (!is<GWidget>(object)) return false; diff --git a/LibGUI/GScrollBar.h b/LibGUI/GScrollBar.h index cfc9fbc7a2..7878a9b627 100644 --- a/LibGUI/GScrollBar.h +++ b/LibGUI/GScrollBar.h @@ -1,7 +1,7 @@ #pragma once -#include <LibGUI/GWidget.h> #include <AK/Function.h> +#include <LibGUI/GWidget.h> 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 f2b0c17a86..f645a8bf47 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 bae66dc4d5..20713eb0f5 100644 --- a/LibGUI/GShortcut.h +++ b/LibGUI/GShortcut.h @@ -1,12 +1,12 @@ #pragma once -#include <Kernel/KeyCode.h> #include <AK/AKString.h> #include <AK/Traits.h> +#include <Kernel/KeyCode.h> 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 4838b4f048..9db2e68eaa 100644 --- a/LibGUI/GTableView.h +++ b/LibGUI/GTableView.h @@ -1,9 +1,9 @@ #pragma once -#include <LibGUI/GModel.h> -#include <LibGUI/GAbstractView.h> #include <AK/Function.h> #include <AK/HashMap.h> +#include <LibGUI/GAbstractView.h> +#include <LibGUI/GModel.h> class GScrollBar; class Painter; diff --git a/LibGUI/GTextBox.h b/LibGUI/GTextBox.h index fd05d885b2..6673e09fef 100644 --- a/LibGUI/GTextBox.h +++ b/LibGUI/GTextBox.h @@ -1,7 +1,7 @@ #pragma once -#include <LibGUI/GTextEditor.h> #include <AK/Function.h> +#include <LibGUI/GTextEditor.h> 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 a1bfe0c33f..648bf9d80d 100644 --- a/LibGUI/GTextEditor.h +++ b/LibGUI/GTextEditor.h @@ -1,8 +1,8 @@ #pragma once -#include <LibGUI/GScrollableWidget.h> #include <AK/Function.h> #include <AK/HashMap.h> +#include <LibGUI/GScrollableWidget.h> #include <SharedGraphics/TextAlignment.h> 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 4660001c1c..5dac448e74 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<GAction> action; }; diff --git a/LibGUI/GVariant.h b/LibGUI/GVariant.h index 38cdfd713b..83193e82ad 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 6416145672..6e73c7e4c1 100644 --- a/LibGUI/GWidget.h +++ b/LibGUI/GWidget.h @@ -1,15 +1,15 @@ #pragma once +#include <AK/AKString.h> +#include <AK/Badge.h> +#include <AK/HashMap.h> #include <LibCore/CElapsedTimer.h> +#include <LibCore/CObject.h> #include <LibGUI/GEvent.h> #include <LibGUI/GShortcut.h> -#include <LibCore/CObject.h> -#include <SharedGraphics/Rect.h> #include <SharedGraphics/Color.h> #include <SharedGraphics/Font.h> -#include <AK/Badge.h> -#include <AK/AKString.h> -#include <AK/HashMap.h> +#include <SharedGraphics/Rect.h> 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<typename Callback> void for_each_child_widget(Callback callback) { - for_each_child([&] (auto& child) { + for_each_child([&](auto& child) { if (is<GWidget>(child)) return callback(to<GWidget>(child)); return IterationDecision::Continue; @@ -224,7 +240,8 @@ private: HashMap<GShortcut, GAction*> m_local_shortcut_actions; }; -template<> inline bool is<GWidget>(const CObject& object) +template<> +inline bool is<GWidget>(const CObject& object) { return object.is_widget(); } diff --git a/LibGUI/GWindow.h b/LibGUI/GWindow.h index c1b3d10cd3..200bec1a77 100644 --- a/LibGUI/GWindow.h +++ b/LibGUI/GWindow.h @@ -1,16 +1,17 @@ #pragma once +#include <AK/AKString.h> +#include <AK/WeakPtr.h> #include <LibCore/CObject.h> #include <LibGUI/GWindowType.h> -#include <SharedGraphics/Rect.h> #include <SharedGraphics/GraphicsBitmap.h> -#include <AK/AKString.h> -#include <AK/WeakPtr.h> +#include <SharedGraphics/Rect.h> 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 d620889249..a399dec4a3 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 2c3771a9ab..70f95efe34 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 d1ba5c0fb9..fddf35a5b1 100644 --- a/Servers/LookupServer/DNSPacket.h +++ b/Servers/LookupServer/DNSPacket.h @@ -3,7 +3,8 @@ #include <AK/NetworkOrdered.h> #include <AK/Types.h> -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 954fbd036a..5989f8c99a 100644 --- a/Servers/LookupServer/DNSRecord.h +++ b/Servers/LookupServer/DNSRecord.h @@ -3,9 +3,10 @@ #include <AK/NetworkOrdered.h> #include <AK/Types.h> -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 9d2d9b6285..fe3a194cd5 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 bd87932e6f..780e55aaa3 100644 --- a/Servers/WindowServer/WSButton.h +++ b/Servers/WindowServer/WSButton.h @@ -1,9 +1,9 @@ #pragma once -#include <SharedGraphics/Rect.h> #include <AK/Function.h> #include <AK/Retained.h> #include <AK/Weakable.h> +#include <SharedGraphics/Rect.h> 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 da5eeb94b0..e2d1025e8c 100644 --- a/Servers/WindowServer/WSClientConnection.h +++ b/Servers/WindowServer/WSClientConnection.h @@ -1,11 +1,11 @@ #pragma once +#include <AK/Function.h> #include <AK/HashMap.h> #include <AK/OwnPtr.h> #include <AK/WeakPtr.h> -#include <AK/Function.h> -#include <SharedGraphics/GraphicsBitmap.h> #include <LibCore/CObject.h> +#include <SharedGraphics/GraphicsBitmap.h> #include <WindowServer/WSEvent.h> class WSWindow; @@ -21,7 +21,7 @@ public: static WSClientConnection* from_client_id(int client_id); static void for_each_client(Function<void(WSClientConnection&)>); - 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<typename Matching, typename Callback> void for_each_window_matching(Matching, Callback); - template<typename Callback> void for_each_window(Callback); + template<typename Matching, typename Callback> + void for_each_window_matching(Matching, Callback); + template<typename Callback> + 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 02440ab553..eb217d88a8 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 889fdcdef1..e16eada5c7 100644 --- a/Servers/WindowServer/WSCursor.h +++ b/Servers/WindowServer/WSCursor.h @@ -2,7 +2,8 @@ #include <SharedGraphics/GraphicsBitmap.h> -enum class WSStandardCursor { +enum class WSStandardCursor +{ None = 0, Arrow, IBeam, diff --git a/Servers/WindowServer/WSEvent.h b/Servers/WindowServer/WSEvent.h index 635f7bb6e6..95276d642a 100644 --- a/Servers/WindowServer/WSEvent.h +++ b/Servers/WindowServer/WSEvent.h @@ -1,17 +1,18 @@ #pragma once -#include <SharedGraphics/Point.h> -#include <SharedGraphics/Rect.h> #include <AK/AKString.h> #include <AK/Types.h> #include <Kernel/KeyCode.h> +#include <LibCore/CEvent.h> +#include <SharedGraphics/Point.h> +#include <SharedGraphics/Rect.h> #include <WindowServer/WSCursor.h> #include <WindowServer/WSWindowType.h> -#include <LibCore/CEvent.h> 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<Rect, 32> 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 a45a9eb9d4..8c76a17efb 100644 --- a/Servers/WindowServer/WSEventLoop.h +++ b/Servers/WindowServer/WSEventLoop.h @@ -1,7 +1,7 @@ #pragma once -#include <LibCore/CEventLoop.h> #include <AK/ByteBuffer.h> +#include <LibCore/CEventLoop.h> class WSClientConnection; struct WSAPI_ClientMessage; diff --git a/Servers/WindowServer/WSMenu.h b/Servers/WindowServer/WSMenu.h index b9a9713256..25d27179e3 100644 --- a/Servers/WindowServer/WSMenu.h +++ b/Servers/WindowServer/WSMenu.h @@ -3,9 +3,9 @@ #include <AK/AKString.h> #include <AK/Vector.h> #include <AK/WeakPtr.h> +#include <LibCore/CObject.h> #include <SharedGraphics/Rect.h> #include <WindowServer/WSMenuItem.h> -#include <LibCore/CObject.h> class WSClientConnection; class WSMenuBar; @@ -91,4 +91,3 @@ private: Vector<OwnPtr<WSMenuItem>> m_items; OwnPtr<WSWindow> m_menu_window; }; - diff --git a/Servers/WindowServer/WSMenuBar.h b/Servers/WindowServer/WSMenuBar.h index 08fc527e59..c26a3447b0 100644 --- a/Servers/WindowServer/WSMenuBar.h +++ b/Servers/WindowServer/WSMenuBar.h @@ -2,8 +2,8 @@ #include "WSMenu.h" #include <AK/Vector.h> -#include <AK/Weakable.h> #include <AK/WeakPtr.h> +#include <AK/Weakable.h> class WSMenuBar : public Weakable<WSMenuBar> { public: diff --git a/Servers/WindowServer/WSMenuItem.h b/Servers/WindowServer/WSMenuItem.h index c725a43c14..7b381386e7 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 891ac527b0..77fb5880a2 100644 --- a/Servers/WindowServer/WSScreen.h +++ b/Servers/WindowServer/WSScreen.h @@ -1,9 +1,9 @@ #pragma once +#include <Kernel/KeyCode.h> +#include <SharedGraphics/Color.h> #include <SharedGraphics/Rect.h> #include <SharedGraphics/Size.h> -#include <SharedGraphics/Color.h> -#include <Kernel/KeyCode.h> class WSScreen { public: diff --git a/Servers/WindowServer/WSWindow.h b/Servers/WindowServer/WSWindow.h index 1f76a25c8a..4e938b44a0 100644 --- a/Servers/WindowServer/WSWindow.h +++ b/Servers/WindowServer/WSWindow.h @@ -1,20 +1,21 @@ #pragma once -#include <SharedGraphics/Rect.h> -#include <SharedGraphics/GraphicsBitmap.h> #include <AK/AKString.h> #include <AK/InlineLinkedList.h> #include <LibCore/CObject.h> -#include <WindowServer/WSWindowType.h> -#include <WindowServer/WSWindowFrame.h> #include <SharedGraphics/DisjointRectSet.h> +#include <SharedGraphics/GraphicsBitmap.h> +#include <SharedGraphics/Rect.h> +#include <WindowServer/WSWindowFrame.h> +#include <WindowServer/WSWindowType.h> class WSClientConnection; class WSCursor; class WSMenu; class WSMouseEvent; -class WSWindow final : public CObject, public InlineLinkedListNode<WSWindow> { +class WSWindow final : public CObject + , public InlineLinkedListNode<WSWindow> { 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 9192a35860..6c2fde241f 100644 --- a/Servers/WindowServer/WSWindowManager.h +++ b/Servers/WindowServer/WSWindowManager.h @@ -1,22 +1,22 @@ #pragma once -#include <SharedGraphics/Rect.h> -#include <SharedGraphics/Color.h> -#include <SharedGraphics/Painter.h> -#include <SharedGraphics/DisjointRectSet.h> +#include "WSMenuBar.h" +#include <AK/HashMap.h> #include <AK/HashTable.h> #include <AK/InlineLinkedList.h> #include <AK/WeakPtr.h> -#include <AK/HashMap.h> -#include "WSMenuBar.h" -#include <WindowServer/WSWindowSwitcher.h> -#include <WindowServer/WSWindowType.h> -#include <WindowServer/WSWindow.h> +#include <LibCore/CConfigFile.h> +#include <LibCore/CElapsedTimer.h> +#include <SharedGraphics/Color.h> +#include <SharedGraphics/DisjointRectSet.h> +#include <SharedGraphics/Painter.h> +#include <SharedGraphics/Rect.h> +#include <WindowServer/WSCPUMonitor.h> #include <WindowServer/WSCursor.h> #include <WindowServer/WSEvent.h> -#include <WindowServer/WSCPUMonitor.h> -#include <LibCore/CElapsedTimer.h> -#include <LibCore/CConfigFile.h> +#include <WindowServer/WSWindow.h> +#include <WindowServer/WSWindowSwitcher.h> +#include <WindowServer/WSWindowType.h> 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<typename Callback> IterationDecision for_each_visible_window_of_type_from_back_to_front(WSWindowType, Callback, bool ignore_highlight = false); - template<typename Callback> IterationDecision for_each_visible_window_of_type_from_front_to_back(WSWindowType, Callback, bool ignore_highlight = false); - template<typename Callback> IterationDecision for_each_visible_window_from_front_to_back(Callback); - template<typename Callback> IterationDecision for_each_visible_window_from_back_to_front(Callback); - template<typename Callback> void for_each_window_listening_to_wm_events(Callback); - template<typename Callback> void for_each_window(Callback); + template<typename Callback> + IterationDecision for_each_visible_window_of_type_from_back_to_front(WSWindowType, Callback, bool ignore_highlight = false); + template<typename Callback> + IterationDecision for_each_visible_window_of_type_from_front_to_back(WSWindowType, Callback, bool ignore_highlight = false); + template<typename Callback> + IterationDecision for_each_visible_window_from_front_to_back(Callback); + template<typename Callback> + IterationDecision for_each_visible_window_from_back_to_front(Callback); + template<typename Callback> + void for_each_window_listening_to_wm_events(Callback); + template<typename Callback> + void for_each_window(Callback); template<typename Callback> void for_each_active_menubar_menu(Callback callback) @@ -185,10 +203,10 @@ private: HashTable<WSWindow*> m_windows; InlineLinkedList<WSWindow> 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 e3d5016080..1feed2625c 100644 --- a/Servers/WindowServer/WSWindowSwitcher.h +++ b/Servers/WindowServer/WSWindowSwitcher.h @@ -1,9 +1,9 @@ #pragma once -#include <SharedGraphics/Rect.h> #include <AK/Vector.h> #include <AK/WeakPtr.h> #include <LibCore/CObject.h> +#include <SharedGraphics/Rect.h> class Painter; class WSKeyEvent; diff --git a/Servers/WindowServer/WSWindowType.h b/Servers/WindowServer/WSWindowType.h index 897e81f74e..5197046f2c 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 da01c435af..2de7d52e14 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 ed94a888dc..4f3bde4a7f 100644 --- a/Shell/Parser.h +++ b/Shell/Parser.h @@ -4,11 +4,18 @@ #include <AK/Vector.h> 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<Subcommand> 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<Redirection> m_redirections; Vector<char> m_token; }; - |