1 /*
   2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_JFR_WRITERS_JFRPOSITION_INLINE_HPP
  26 #define SHARE_VM_JFR_WRITERS_JFRPOSITION_INLINE_HPP
  27 
  28 #include "jfr/writers/jfrPosition.hpp"
  29 
  30 template <typename AP>
  31 inline const u1* Position<AP>::start_pos() const {
  32   return _start_pos;
  33 }
  34 
  35 template <typename AP>
  36 inline void Position<AP>::set_start_pos(const u1* position) {
  37   _start_pos = position;
  38 }
  39 
  40 template <typename AP>
  41 inline u1* Position<AP>::current_pos() {
  42   return _current_pos;
  43 }
  44 
  45 template <typename AP>
  46 inline void Position<AP>::set_current_pos(const u1* new_position) {
  47   _current_pos = const_cast<u1*>(new_position);
  48 }
  49 
  50 template <typename AP>
  51 inline void Position<AP>::set_current_pos(size_t size) {
  52   _current_pos += size;
  53 }
  54 
  55 template <typename AP>
  56 inline const u1* Position<AP>::end_pos() const {
  57   return _end_pos;
  58 }
  59 
  60 template <typename AP>
  61 inline void Position<AP>::set_end_pos(const u1* position) {
  62   _end_pos = position;
  63 }
  64 
  65 template <typename AP>
  66 inline Position<AP>::Position(const u1* start_pos, size_t size) :
  67   AP(),
  68   _start_pos(start_pos),
  69   _current_pos(const_cast<u1*>(start_pos)),
  70   _end_pos(start_pos + size) {
  71 }
  72 
  73 template <typename AP>
  74 inline Position<AP>::Position() : _start_pos(NULL), _current_pos(NULL), _end_pos(NULL) {
  75 }
  76 
  77 template <typename AP>
  78 inline size_t Position<AP>::available_size() const {
  79   return _end_pos - _current_pos;
  80 }
  81 
  82 template <typename AP>
  83 inline intptr_t Position<AP>::used_offset() const {
  84   return _current_pos - _start_pos;
  85 }
  86 
  87 template <typename AP>
  88 inline intptr_t Position<AP>::current_offset() const {
  89   return this->used_offset();
  90 }
  91 
  92 template <typename AP>
  93 inline size_t Position<AP>::used_size() const {
  94   return (size_t)used_offset();
  95 }
  96 
  97 template <typename AP>
  98 inline void Position<AP>::reset() {
  99   set_current_pos(_start_pos);
 100 }
 101 
 102 #endif // SHARE_VM_JFR_WRITERS_JFRPOSITION_INLINE_HPP