LCOV - code coverage report
Current view: top level - asmjit - codebuffer.h (source / functions) Hit Total Coverage
Test: plumed test coverage (other modules) Lines: 4 4 100.0 %
Date: 2026-11-05 10:19:06 Functions: 0 0 -

          Line data    Source code
       1             : #ifdef __PLUMED_HAS_ASMJIT
       2             : // This file is part of AsmJit project <https://asmjit.com>
       3             : //
       4             : // See asmjit.h or LICENSE.md for license and copyright information
       5             : // SPDX-License-Identifier: Zlib
       6             : 
       7             : #ifndef ASMJIT_CORE_CODEBUFFER_H_INCLUDED
       8             : #define ASMJIT_CORE_CODEBUFFER_H_INCLUDED
       9             : 
      10             : #include "globals.h"
      11             : #include "support.h"
      12             : 
      13             : ASMJIT_BEGIN_NAMESPACE
      14             : 
      15             : //! \addtogroup asmjit_core
      16             : //! \{
      17             : 
      18             : //! Flags used by \ref CodeBuffer.
      19             : enum class CodeBufferFlags : uint32_t {
      20             :   //! No flags.
      21             :   kNone = 0,
      22             :   //! Buffer is external (not allocated by asmjit).
      23             :   kIsExternal = 0x00000001u,
      24             :   //! Buffer is fixed (cannot be reallocated).
      25             :   kIsFixed = 0x00000002u
      26             : };
      27             : ASMJIT_DEFINE_ENUM_FLAGS(CodeBufferFlags)
      28             : 
      29             : //! Code or data buffer.
      30             : struct CodeBuffer {
      31             :   //! \name Members
      32             :   //! \{
      33             : 
      34             :   //! The content of the buffer (data).
      35             :   uint8_t* _data;
      36             :   //! Number of bytes of `data` used.
      37             :   size_t _size;
      38             :   //! Buffer capacity (in bytes).
      39             :   size_t _capacity;
      40             :   //! Buffer flags.
      41             :   CodeBufferFlags _flags;
      42             : 
      43             :   //! \}
      44             : 
      45             :   //! \name Overloaded Operators
      46             :   //! \{
      47             : 
      48             :   //! Returns a referebce to the byte at the given `index`.
      49             :   inline uint8_t& operator[](size_t index) noexcept {
      50             :     ASMJIT_ASSERT(index < _size);
      51             :     return _data[index];
      52             :   }
      53             :   //! \overload
      54             :   inline const uint8_t& operator[](size_t index) const noexcept {
      55             :     ASMJIT_ASSERT(index < _size);
      56             :     return _data[index];
      57             :   }
      58             : 
      59             :   //! \}
      60             : 
      61             :   //! \name Accessors
      62             :   //! \{
      63             : 
      64             :   //! Returns code buffer flags.
      65             :   inline CodeBufferFlags flags() const noexcept { return _flags; }
      66             :   //! Tests whether the code buffer has the given `flag` set.
      67       54984 :   inline bool hasFlag(CodeBufferFlags flag) const noexcept { return Support::test(_flags, flag); }
      68             : 
      69             :   //! Tests whether this code buffer has a fixed size.
      70             :   //!
      71             :   //! Fixed size means that the code buffer is fixed and cannot grow.
      72             :   inline bool isFixed() const noexcept { return hasFlag(CodeBufferFlags::kIsFixed); }
      73             : 
      74             :   //! Tests whether the data in this code buffer is external.
      75             :   //!
      76             :   //! External data can only be provided by users, it's never used by AsmJit.
      77             :   inline bool isExternal() const noexcept { return hasFlag(CodeBufferFlags::kIsExternal); }
      78             : 
      79             :   //! Tests whether the data in this code buffer is allocated (non-null).
      80             :   inline bool isAllocated() const noexcept { return _data != nullptr; }
      81             : 
      82             :   //! Tests whether the code buffer is empty.
      83             :   inline bool empty() const noexcept { return !_size; }
      84             : 
      85             :   //! Returns the size of the data.
      86      164952 :   inline size_t size() const noexcept { return _size; }
      87             :   //! Returns the capacity of the data.
      88       27492 :   inline size_t capacity() const noexcept { return _capacity; }
      89             : 
      90             :   //! Returns the pointer to the data the buffer references.
      91       54984 :   inline uint8_t* data() noexcept { return _data; }
      92             :   //! \overload
      93             :   inline const uint8_t* data() const noexcept { return _data; }
      94             : 
      95             :   //! \}
      96             : 
      97             :   //! \name Iterators
      98             :   //! \{
      99             : 
     100             :   inline uint8_t* begin() noexcept { return _data; }
     101             :   inline const uint8_t* begin() const noexcept { return _data; }
     102             : 
     103             :   inline uint8_t* end() noexcept { return _data + _size; }
     104             :   inline const uint8_t* end() const noexcept { return _data + _size; }
     105             : 
     106             :   //! \}
     107             : };
     108             : 
     109             : //! \}
     110             : 
     111             : ASMJIT_END_NAMESPACE
     112             : 
     113             : #endif // ASMJIT_CORE_CODEBUFFER_H_INCLUDED
     114             : 
     115             : 
     116             : #endif // __PLUMED_HAS_ASMJIT

Generated by: LCOV version 1.16