diff options
| -rw-r--r-- | arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp | 3 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp | 27 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/paging/page_entry.hpp | 2 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/stl/container.hpp | 24 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/stl/contiguous_pointer_iterator.hpp | 34 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/stl/forward_value_iterator.hpp | 15 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/stl/mutex.hpp | 3 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/stl/shared_pointer.hpp | 40 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/stl/stack.hpp | 42 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/stl/unique_pointer.hpp | 37 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/stl/vector.hpp | 126 | ||||
| -rw-r--r-- | arch/x86_64/scripts/kernel.ld | 5 | ||||
| -rw-r--r-- | arch/x86_64/src/memory/paging/page_entry.cpp | 2 |
13 files changed, 305 insertions, 55 deletions
diff --git a/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp b/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp index b20a452..6fcab6f 100644 --- a/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp +++ b/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp @@ -77,8 +77,7 @@ namespace teachos::arch::memory::heap private: static heap_allocator * kernel_allocator_instance; ///< Instance used to allocate and deallocate kernel heap memory - [[gnu::section(".user_data")]] - static user_heap_allocator * + [[gnu::section(".user_data")]] static user_heap_allocator * user_allocator_instance; ///< Instance used to allocate and deallocate user heap memory /** diff --git a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp index 95d04f4..05fde8b 100644 --- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp +++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp @@ -40,6 +40,10 @@ namespace teachos::arch::memory::paging */ auto remap_kernel() -> active_page_table & { + // Set Page Global Enable bit + auto cr4 = kernel::cpu::read_control_register(kernel::cpu::control_register::CR4); + kernel::cpu::write_control_register(kernel::cpu::control_register::CR4, cr4 | 0x80); + temporary_page temporary_page{virtual_page{0xCAFEBABE}, allocator}; auto & active_table = active_page_table::create_or_get(); auto const frame = allocator.allocate_frame(); @@ -138,14 +142,21 @@ namespace teachos::arch::memory::paging allocator::frame_container const frames{begin, end}; entry entry{section.flags}; - // TODO: Why exactly are this section required or not required? - // Required to be accesible in User Mode: .user_text (Contains the actual code executed), .boot_bss (Contains - // statically allocated variables), .boot_rodata (Contains constant data stored in ROM), .user_data (Contains - // static user variables - // Not required: .text, .rodata, .ctors, .dtors, .bss, .data, .boot_data, .boot_text, .init - if (section.physical_address == 0x100000 || section.physical_address == 0x102000 || - section.physical_address == 0x217000 || section.physical_address == 0x21D000 || - section.physical_address == 0x209000) + // Required to be accesible in User Mode: + // - .user_text (Contains the actual code executed) + // - .boot_bss (Contains statically allocated variables) + // - .boot_rodata (Contains constant data stored in ROM) + // - .user_data (Contains static user variables) + if (section.physical_address == 0x100000 /* .boot_rodata */ || + section.physical_address == 0x102000 /* .boot_bss */ || + section.physical_address == 0x218000 /* .stl_text */) + { + entry.set_user_accesible(); + entry.set_global(); + } + + if (section.physical_address == 0x217000 /* .user_text */ || + section.physical_address == 0x21D000 /* .user_data */) { entry.set_user_accesible(); } diff --git a/arch/x86_64/include/arch/memory/paging/page_entry.hpp b/arch/x86_64/include/arch/memory/paging/page_entry.hpp index 5cba1bc..6ee1a13 100644 --- a/arch/x86_64/include/arch/memory/paging/page_entry.hpp +++ b/arch/x86_64/include/arch/memory/paging/page_entry.hpp @@ -77,6 +77,8 @@ namespace teachos::arch::memory::paging */ auto set_user_accesible() -> void; + auto set_global() -> void; + /** * @brief Calculates the physical frame this entry is pointing too, can be null if the page is not present in * memory. diff --git a/arch/x86_64/include/arch/stl/container.hpp b/arch/x86_64/include/arch/stl/container.hpp index b0f513b..4ea08c7 100644 --- a/arch/x86_64/include/arch/stl/container.hpp +++ b/arch/x86_64/include/arch/stl/container.hpp @@ -48,7 +48,11 @@ namespace teachos::arch::stl * * @return Iterator pointing to first element of the memory area. */ - auto begin() const -> iterator { return begin_itr; } + [[gnu::section(".stl_text")]] + auto begin() const -> iterator + { + return begin_itr; + } /** * @brief Returns the iterator pointing to one past the last element of the memory area. @@ -56,7 +60,11 @@ namespace teachos::arch::stl * * @return Iterator pointing to one past the last element of the memory area. */ - auto end() const -> iterator { return end_itr; } + [[gnu::section(".stl_text")]] + auto end() const -> iterator + { + return end_itr; + } /** * @brief Calculates the size of this container, simply subtracts the iterator pointing to the first element by the @@ -64,14 +72,22 @@ namespace teachos::arch::stl * * @return Actual size of this container. */ - auto size() const -> size_type { return std::distance(begin(), end()); } + [[gnu::section(".stl_text")]] + auto size() const -> size_type + { + return std::distance(begin(), end()); + } /** * @brief Calcualtes the size and returns true if the size is 0 and the container therefore emtpy. * * @return Whether the container is empty, size being 0 or not */ - auto empty() const -> bool { return size() == 0; } + [[gnu::section(".stl_text")]] + auto empty() const -> bool + { + return size() == 0; + } private: iterator begin_itr = {}; ///< Pointer to the first element of the given template type. diff --git a/arch/x86_64/include/arch/stl/contiguous_pointer_iterator.hpp b/arch/x86_64/include/arch/stl/contiguous_pointer_iterator.hpp index d15d2e2..f2dfb2b 100644 --- a/arch/x86_64/include/arch/stl/contiguous_pointer_iterator.hpp +++ b/arch/x86_64/include/arch/stl/contiguous_pointer_iterator.hpp @@ -45,20 +45,29 @@ namespace teachos::arch::stl * * @return Reference to the value. */ - auto operator*() const -> reference_type { return *ptr; } + [[gnu::section(".stl_text")]] + auto operator*() const -> reference_type + { + return *ptr; + } /** * @brief Get underlying value, which is the intially passed pointer. * * @return Pointer to the underlying value passed intially. */ - auto operator->() const -> pointer_type { return ptr; } + [[gnu::section(".stl_text")]] + auto operator->() const -> pointer_type + { + return ptr; + } /** * @brief Pre decrement operator. Returns a reference to the changed address. * * @return Reference to the decremented underlying address. */ + [[gnu::section(".stl_text")]] auto operator--() -> contiguous_pointer_iterator & { contiguous_pointer_iterator const old_value = *this; @@ -71,6 +80,7 @@ namespace teachos::arch::stl * * @return Reference to the incremented underlying address. */ + [[gnu::section(".stl_text")]] auto operator++() -> contiguous_pointer_iterator & { ++ptr; @@ -82,6 +92,7 @@ namespace teachos::arch::stl * * @return Copy of the decremented underlying address. */ + [[gnu::section(".stl_text")]] auto operator--(int) -> contiguous_pointer_iterator { auto const old_value = *this; @@ -94,6 +105,7 @@ namespace teachos::arch::stl * * @return Copy of the incremented underlying address. */ + [[gnu::section(".stl_text")]] auto operator++(int) -> contiguous_pointer_iterator { auto const old_value = *this; @@ -107,6 +119,7 @@ namespace teachos::arch::stl * @param value Value we want to add to the underlying address. * @return Reference to the changed underlying address. */ + [[gnu::section(".stl_text")]] auto operator+=(difference_type value) -> contiguous_pointer_iterator & { ptr += value; @@ -119,6 +132,7 @@ namespace teachos::arch::stl * @param value Value we want to subtract from the underlying address. * @return Reference to the changed underlying address. */ + [[gnu::section(".stl_text")]] auto operator-=(difference_type value) -> contiguous_pointer_iterator & { ptr -= value; @@ -131,6 +145,7 @@ namespace teachos::arch::stl * @param value Value we want to add to a copy of the underlying address. * @return Copy of underlying address incremented by the given value. */ + [[gnu::section(".stl_text")]] auto operator+(difference_type value) const -> contiguous_pointer_iterator { return contiguous_pointer_iterator{ptr + value}; @@ -142,6 +157,7 @@ namespace teachos::arch::stl * @param value Value we want to subtrcat from a copy of the underlying address. * @return Copy of underlying address decremented by the given value. */ + [[gnu::section(".stl_text")]] auto operator-(difference_type value) const -> contiguous_pointer_iterator { return contiguous_pointer_iterator{ptr - value}; @@ -153,7 +169,11 @@ namespace teachos::arch::stl * @param other Other iterator we want to substract the underlying address with ours. * @return Size difference between the underlying address of this instance and the given iterator. */ - auto operator-(const contiguous_pointer_iterator & other) const -> difference_type { return ptr - other.ptr; } + [[gnu::section(".stl_text")]] + auto operator-(const contiguous_pointer_iterator & other) const -> difference_type + { + return ptr - other.ptr; + } /** * @brief Index operator overload. Returns a reference to the value at the given index. Simply returns the @@ -162,7 +182,11 @@ namespace teachos::arch::stl * @param index Index we want to access and get the value from. * @return Reference to the value at the given index. */ - auto operator[](difference_type index) const -> value_type & { return *(ptr + index); } + [[gnu::section(".stl_text")]] + auto operator[](difference_type index) const -> value_type & + { + return *(ptr + index); + } /** * @brief Defaulted comparsion operator. Simply compares the memory address of both iterators. @@ -170,6 +194,7 @@ namespace teachos::arch::stl * @param other Other iterator to compare to. * @return Whether both iterators point to the same underlying address in memory. */ + [[gnu::section(".stl_text")]] auto operator==(contiguous_pointer_iterator const & other) const -> bool = default; /** @@ -178,6 +203,7 @@ namespace teachos::arch::stl * @param other Other iterator to compare to. * @return Whether the given iterator is smaller or larger than this iterator. */ + [[gnu::section(".stl_text")]] auto operator<=>(contiguous_pointer_iterator const & other) const -> std::strong_ordering = default; private: diff --git a/arch/x86_64/include/arch/stl/forward_value_iterator.hpp b/arch/x86_64/include/arch/stl/forward_value_iterator.hpp index 7c30964..be3d8e6 100644 --- a/arch/x86_64/include/arch/stl/forward_value_iterator.hpp +++ b/arch/x86_64/include/arch/stl/forward_value_iterator.hpp @@ -60,20 +60,29 @@ namespace teachos::arch::stl * * @return Reference to the value. */ - auto operator*() const -> const_reference_type { return value; } + [[gnu::section(".stl_text")]] + auto operator*() const -> const_reference_type + { + return value; + } /** * @brief Gets pointer to the underlying value passed intially. * * @return Pointer to the underlying value passed intially. */ - auto operator->() const -> const_pointer_type { return &value; } + [[gnu::section(".stl_text")]] + auto operator->() const -> const_pointer_type + { + return &value; + } /** * @brief Pre increment operator. Returns a reference to the changed value. * * @return Reference to the incremented underlying value. */ + [[gnu::section(".stl_text")]] auto operator++() -> forward_value_iterator & { ++value; @@ -85,6 +94,7 @@ namespace teachos::arch::stl * * @return Copy of the incremented underlying value. */ + [[gnu::section(".stl_text")]] auto operator++(int) -> forward_value_iterator { auto const old_value = *this; @@ -98,6 +108,7 @@ namespace teachos::arch::stl * @param other Other iterator to compare to. * @return Whether both iterators point to the same underlying address in memory. */ + [[gnu::section(".stl_text")]] auto operator==(forward_value_iterator const & other) const -> bool = default; private: diff --git a/arch/x86_64/include/arch/stl/mutex.hpp b/arch/x86_64/include/arch/stl/mutex.hpp index d8fd9dc..a7d297d 100644 --- a/arch/x86_64/include/arch/stl/mutex.hpp +++ b/arch/x86_64/include/arch/stl/mutex.hpp @@ -34,6 +34,7 @@ namespace teachos::arch::stl /** * @brief Lock the mutex (blocks for as long as it is not available). */ + [[gnu::section(".stl_text")]] auto lock() -> void; /** @@ -41,11 +42,13 @@ namespace teachos::arch::stl * * @return True if lock has been acquired and false otherwise. */ + [[gnu::section(".stl_text")]] auto try_lock() -> bool; /** * @brief Unlock the mutex. */ + [[gnu::section(".stl_text")]] auto unlock() -> void; private: diff --git a/arch/x86_64/include/arch/stl/shared_pointer.hpp b/arch/x86_64/include/arch/stl/shared_pointer.hpp index 1ddc182..c9796a8 100644 --- a/arch/x86_64/include/arch/stl/shared_pointer.hpp +++ b/arch/x86_64/include/arch/stl/shared_pointer.hpp @@ -25,6 +25,7 @@ namespace teachos::arch::stl * * @param pointer A pointer to an object to manage (default is nullptr). */ + [[gnu::section(".stl_text")]] explicit shared_pointer(T * pointer = nullptr) : pointer(pointer) , ref_count(new std::atomic<std::size_t>(pointer != nullptr ? 1 : 0)) @@ -37,6 +38,7 @@ namespace teachos::arch::stl * * @param other The shared_pointer to copy from. */ + [[gnu::section(".stl_text")]] shared_pointer(const shared_pointer & other) : pointer(other.pointer) , ref_count(other.ref_count) @@ -52,6 +54,7 @@ namespace teachos::arch::stl * * @param other The shared_pointer to move from. */ + [[gnu::section(".stl_text")]] shared_pointer(shared_pointer && other) noexcept : pointer(other.pointer) , ref_count(other.ref_count) @@ -68,6 +71,7 @@ namespace teachos::arch::stl * @param other Another smart pointer to share the ownership with. * @return Reference to this shared pointer. */ + [[gnu::section(".stl_text")]] shared_pointer & operator=(const shared_pointer & other) { if (this != &other) @@ -92,6 +96,7 @@ namespace teachos::arch::stl * @param other Another smart pointer to acquire the ownership from. * @return Reference to this shared pointer. */ + [[gnu::section(".stl_text")]] shared_pointer & operator=(shared_pointer && other) noexcept { if (this != &other) @@ -109,13 +114,18 @@ namespace teachos::arch::stl /** * @brief Destructor. Cleans up resources if necessary. */ - ~shared_pointer() { cleanup(); } + [[gnu::section(".stl_text")]] + ~shared_pointer() + { + cleanup(); + } /** * @brief Replaces the managed object. * * @param ptr Pointer to a new object to manage (default = nullptr). */ + [[gnu::section(".stl_text")]] void reset(T * ptr = nullptr) { cleanup(); @@ -129,6 +139,7 @@ namespace teachos::arch::stl * * @param other The shared_pointer to swap with. */ + [[gnu::section(".stl_text")]] void swap(shared_pointer & other) { std::swap(pointer, other.pointer); @@ -140,21 +151,33 @@ namespace teachos::arch::stl * * @return Returns the object owned by *this, equivalent to *get(). */ - auto operator*() const -> T & { return *pointer; } + [[gnu::section(".stl_text")]] + auto operator*() const -> T & + { + return *pointer; + } /** * @brief Member access operator. * * @return Returns a pointer to the object owned by *this, i.e. get(). */ - auto operator->() const -> T * { return pointer; } + [[gnu::section(".stl_text")]] + auto operator->() const -> T * + { + return pointer; + } /** * @brief Returns a pointer to the managed object or nullptr if no object is owned. * * @return Pointer to the managed object or nullptr if no object is owned. */ - auto get() const -> T * { return pointer; } + [[gnu::section(".stl_text")]] + auto get() const -> T * + { + return pointer; + } /** * @brief Returns the number of different shared_pointer instances (*this included) managing the current object. If @@ -167,6 +190,7 @@ namespace teachos::arch::stl * @return The number of Shared_pointer instances managing the current object or 0 if there is no managed * object. */ + [[gnu::section(".stl_text")]] auto use_count() const -> std::size_t { if (pointer != nullptr) @@ -182,17 +206,23 @@ namespace teachos::arch::stl * * @return true if *this owns an object, false otherwise. */ - explicit operator bool() const { return pointer != nullptr; } + [[gnu::section(".stl_text")]] + explicit operator bool() const + { + return pointer != nullptr; + } /** * @brief Defaulted three-way comparator operator. */ + [[gnu::section(".stl_text")]] auto operator<=>(const shared_pointer & other) const = default; private: /** * @brief Releases ownership and deletes the object if this was the last ereference to the owned managed object. */ + [[gnu::section(".stl_text")]] auto cleanup() -> void { if (pointer != nullptr && ref_count != nullptr && --(*ref_count) == 0) diff --git a/arch/x86_64/include/arch/stl/stack.hpp b/arch/x86_64/include/arch/stl/stack.hpp index 9ecf0ca..48bcf10 100644 --- a/arch/x86_64/include/arch/stl/stack.hpp +++ b/arch/x86_64/include/arch/stl/stack.hpp @@ -35,6 +35,7 @@ namespace teachos::arch::stl * @param n Amount of elements we want to create and set the given value for. * @param initial Inital value of all elements in the underlying data array. */ + [[gnu::section(".stl_text")]] explicit stack(size_type n, value_type initial = value_type{}) : _container(n, initial) { @@ -49,6 +50,7 @@ namespace teachos::arch::stl * @param last Input iterator to one past the last element in the range we want to copy from. */ template<typename InputIterator> + [[gnu::section(".stl_text")]] explicit stack(InputIterator first, InputIterator last) : _container(first, last) { @@ -60,6 +62,7 @@ namespace teachos::arch::stl * * @param initalizer_list List we want to copy all elements from. */ + [[gnu::section(".stl_text")]] explicit stack(std::initializer_list<T> initalizer_list) : _container(initalizer_list) { @@ -74,6 +77,7 @@ namespace teachos::arch::stl * * @param other Other instance of stack we want to copy the data from. */ + [[gnu::section(".stl_text")]] stack(stack<T> const & other) : _container(other) { @@ -89,7 +93,11 @@ namespace teachos::arch::stl * @param other Other instance of vector we want to copy the data from. * @return Newly created copy. */ - stack<T> & operator=(stack<T> const & other) { _container = other; } + [[gnu::section(".stl_text")]] + stack<T> & operator=(stack<T> const & other) + { + _container = other; + } /** * @brief Destructor. @@ -102,7 +110,11 @@ namespace teachos::arch::stl * * @return Current amount of elements. */ - auto size() const -> size_type { return _container.size(); } + [[gnu::section(".stl_text")]] + auto size() const -> size_type + { + return _container.size(); + } /** * @brief Returns a reference to the last element in the container. Calling back on an empty container causes @@ -110,7 +122,11 @@ namespace teachos::arch::stl * * @return Reference to the last element. */ - auto top() -> reference { return _container.back(); } + [[gnu::section(".stl_text")]] + auto top() -> reference + { + return _container.back(); + } /** * @brief Returns a reference to the last element in the container. Calling back on an empty container causes @@ -118,7 +134,11 @@ namespace teachos::arch::stl * * @return Reference to the last element. */ - auto top() const -> const_reference { return _container.back(); } + [[gnu::section(".stl_text")]] + auto top() const -> const_reference + { + return _container.back(); + } /** * @brief Appends the given element value to the end of the container. The element is assigned through the @@ -133,6 +153,7 @@ namespace teachos::arch::stl * @param value The value of the element to append. */ template<class U> + [[gnu::section(".stl_text")]] auto push(U && value) -> void { _container.push_back(std::forward<U>(value)); @@ -152,6 +173,7 @@ namespace teachos::arch::stl * @return value_type& */ template<class... Args> + [[gnu::section(".stl_text")]] auto emplace(Args &&... args) -> reference { _container.emplace_back(std::forward<Args>(args)...); @@ -164,14 +186,22 @@ namespace teachos::arch::stl * further execution. Iterators and references to the last element are invalidated. The end() * iterator is also invalidated. */ - auto pop() -> void { _container.pop_back(); } + [[gnu::section(".stl_text")]] + auto pop() -> void + { + _container.pop_back(); + } /** * @brief Wheter there are currently any items this container or not. * * @return True if there are no elements, false if there are. */ - auto empty() const -> bool { return _container.empty(); } + [[gnu::section(".stl_text")]] + auto empty() const -> bool + { + return _container.empty(); + } private: container_type _container = {}; ///< Underlying container used by the stack to actually save the data. diff --git a/arch/x86_64/include/arch/stl/unique_pointer.hpp b/arch/x86_64/include/arch/stl/unique_pointer.hpp index 899a35b..03b4ef3 100644 --- a/arch/x86_64/include/arch/stl/unique_pointer.hpp +++ b/arch/x86_64/include/arch/stl/unique_pointer.hpp @@ -17,6 +17,7 @@ namespace teachos::arch::stl * * @param ptr A pointer to an object to manage (default is nullptr). */ + [[gnu::section(".stl_text")]] explicit unique_pointer(T * ptr = nullptr) : pointer(ptr) { @@ -26,7 +27,11 @@ namespace teachos::arch::stl /** * @brief Destructor that deletes the managed object. */ - ~unique_pointer() { delete pointer; } + [[gnu::section(".stl_text")]] + ~unique_pointer() + { + delete pointer; + } /** * @brief Deleted copy constructor to enforce unique ownership. @@ -43,6 +48,7 @@ namespace teachos::arch::stl * * @param other Unique pointer to move from. */ + [[gnu::section(".stl_text")]] unique_pointer(unique_pointer && other) noexcept : pointer(other.pointer) { @@ -55,6 +61,7 @@ namespace teachos::arch::stl * @param other Smart pointer from which ownership will be transferred. * @return Reference to this unique pointer. */ + [[gnu::section(".stl_text")]] auto operator=(unique_pointer && other) noexcept -> unique_pointer & { if (this != &other) @@ -71,28 +78,44 @@ namespace teachos::arch::stl * * @return Returns the object owned by *this, equivalent to *get(). */ - auto operator*() const -> T & { return *pointer; } + [[gnu::section(".stl_text")]] + auto operator*() const -> T & + { + return *pointer; + } /** * @brief Member access operator. * * @return Returns a pointer to the object owned by *this, i.e. get(). */ - auto operator->() const -> T * { return pointer; } + [[gnu::section(".stl_text")]] + auto operator->() const -> T * + { + return pointer; + } /** * @brief Returns a pointer to the managed object or nullptr if no object is owned. * * @return Pointer to the managed object or nullptr if no object is owned. */ - auto get() const -> T * { return pointer; } + [[gnu::section(".stl_text")]] + auto get() const -> T * + { + return pointer; + } /** * @brief Checks whether *this owns an object, i.e. whether get() != nullptr. * * @return true if *this owns an object, false otherwise. */ - explicit operator bool() const noexcept { return pointer != nullptr; } + [[gnu::section(".stl_text")]] + explicit operator bool() const noexcept + { + return pointer != nullptr; + } /** * @brief Releases the ownership of the managed object, if any. @@ -102,6 +125,7 @@ namespace teachos::arch::stl * @return Pointer to the managed object or nullptr if there was no managed object, i.e. the value which would be * returned by get() before the call. */ + [[gnu::section(".stl_text")]] auto release() -> T * { T * temp = pointer; @@ -118,6 +142,7 @@ namespace teachos::arch::stl * * @param ptr Pointer to a new object to manage (default = nullptr). */ + [[gnu::section(".stl_text")]] auto reset(T * ptr = nullptr) -> void { delete pointer; @@ -129,6 +154,7 @@ namespace teachos::arch::stl * * @param other Another unique_ptr object to swap the managed object and the deleter with. */ + [[gnu::section(".stl_text")]] auto swap(unique_pointer & other) -> void { using std::swap; @@ -138,6 +164,7 @@ namespace teachos::arch::stl /** * @brief Defaulted three-way comparator operator. */ + [[gnu::section(".stl_text")]] auto operator<=>(const unique_pointer & other) const = default; private: diff --git a/arch/x86_64/include/arch/stl/vector.hpp b/arch/x86_64/include/arch/stl/vector.hpp index c7d7853..5314029 100644 --- a/arch/x86_64/include/arch/stl/vector.hpp +++ b/arch/x86_64/include/arch/stl/vector.hpp @@ -101,6 +101,7 @@ namespace teachos::arch::stl * @param other Other instance of vector we want to copy the data from. * @return Newly created copy. */ + [[gnu::section(".stl_text")]] vector<value_type> & operator=(vector<value_type> const & other) { delete[] _data; @@ -122,7 +123,11 @@ namespace teachos::arch::stl * * @return Current amount of elements. */ - auto size() const -> size_type { return _size; } + [[gnu::section(".stl_text")]] + auto size() const -> size_type + { + return _size; + } /** * @brief Amount of space the vector currently has, can be different than the size, because we allocate more than we @@ -130,7 +135,11 @@ namespace teachos::arch::stl * * @return Current amount of space the vector has for elements. */ - auto capacity() const -> size_type { return _capacity; } + [[gnu::section(".stl_text")]] + auto capacity() const -> size_type + { + return _capacity; + } /** * @brief Array indexing operator. Allowing to access element at the given index. @@ -140,7 +149,11 @@ namespace teachos::arch::stl * @param index Index we want to access elements at. * @return Reference to the underlying element. */ - auto operator[](size_type index) -> reference { return _data[index]; } + [[gnu::section(".stl_text")]] + auto operator[](size_type index) -> reference + { + return _data[index]; + } /** * @brief Array indexing operator. Allowing to access element at the given index. @@ -150,7 +163,11 @@ namespace teachos::arch::stl * @param index Index we want to access elements at. * @return Reference to the underlying element. */ - auto operator[](size_type index) const -> const_reference { return _data[index]; } + [[gnu::section(".stl_text")]] + auto operator[](size_type index) const -> const_reference + { + return _data[index]; + } /** * @brief Array indexing operator. Allowing to access element at the given index. @@ -160,6 +177,7 @@ namespace teachos::arch::stl * @param index Index we want to access elements at. * @return Reference to the underlying element. */ + [[gnu::section(".stl_text")]] auto at(size_type index) -> reference { throw_if_out_of_range(index); @@ -174,6 +192,7 @@ namespace teachos::arch::stl * @param index Index we want to access elements at. * @return Reference to the underlying element. */ + [[gnu::section(".stl_text")]] auto at(size_type index) const -> const_reference { throw_if_out_of_range(index); @@ -193,6 +212,7 @@ namespace teachos::arch::stl * @param value The value of the element to append. */ template<class U> + [[gnu::section(".stl_text")]] auto push_back(U && value) -> void { increase_capacity_if_full(); @@ -214,6 +234,7 @@ namespace teachos::arch::stl * @return value_type& */ template<class... Args> + [[gnu::section(".stl_text")]] auto emplace_back(Args &&... args) -> value_type & { increase_capacity_if_full(); @@ -227,6 +248,7 @@ namespace teachos::arch::stl * further execution. Iterators and references to the last element are invalidated. The end() * iterator is also invalidated. */ + [[gnu::section(".stl_text")]] auto pop_back() -> void { throw_if_empty(); @@ -239,7 +261,11 @@ namespace teachos::arch::stl * * @return Iterator to the first element. */ - auto begin() noexcept -> pointer { return _data; } + [[gnu::section(".stl_text")]] + auto begin() noexcept -> pointer + { + return _data; + } /** * @brief Returns an iterator to the first element of the vector. @@ -247,7 +273,11 @@ namespace teachos::arch::stl * * @return Iterator to the first element. */ - auto begin() const noexcept -> const_pointer { return _data; } + [[gnu::section(".stl_text")]] + auto begin() const noexcept -> const_pointer + { + return _data; + } /** * @brief Returns an iterator to the first element of the vector. @@ -255,7 +285,11 @@ namespace teachos::arch::stl * * @return Iterator to the first element. */ - auto cbegin() const noexcept -> const_pointer { return begin(); } + [[gnu::section(".stl_text")]] + auto cbegin() const noexcept -> const_pointer + { + return begin(); + } /** * @brief Returns a reverse iterator to the first element of the reversed vector. It corresponds to the last element @@ -263,7 +297,11 @@ namespace teachos::arch::stl * * @return Reverse iterator to the first element. */ - auto rbegin() noexcept -> pointer { return _data + _size - 1; } + [[gnu::section(".stl_text")]] + auto rbegin() noexcept -> pointer + { + return _data + _size - 1; + } /** * @brief Returns a reverse iterator to the first element of the reversed vector. It corresponds to the last element @@ -271,7 +309,11 @@ namespace teachos::arch::stl * * @return Reverse iterator to the first element. */ - auto rbegin() const noexcept -> const_pointer { return _data + _size - 1; } |
