Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove/cleanup/fix some #include
[simgrid.git] / src / mc / mc_mmu.h
index 7f601c1..e0236e5 100644 (file)
@@ -1,16 +1,20 @@
-/* Copyright (c) 2014. The SimGrid Team.
+/* Copyright (c) 2014-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef MC_MMU_H
-#define MC_MMU_H
+#ifndef SIMGRID_MC_MMU_H
+#define SIMGRID_MC_MMU_H
 
-#include <stdint.h>
-#include <stdbool.h>
+#include <cstdint>
 
-#include "mc_private.h"
+#include <xbt/asserts.h>
+#include <xbt/misc.h>
+
+#include <simgrid_config.h>
+
+SG_BEGIN_DECL()
 
 /** @brief How many memory pages are necessary to store size bytes?
  *
@@ -33,10 +37,10 @@ size_t mc_page_count(size_t size)
  *  @return Virtual memory page number of the given address
  */
 static inline __attribute__ ((always_inline))
-size_t mc_page_number(void* base, void* address)
+size_t mc_page_number(const void* base, const void* address)
 {
   xbt_assert(address>=base, "The address is not in the range");
-  return ((uintptr_t) address - (uintptr_t) base) >> xbt_pagebits;
+  return ((std::uintptr_t) address - (std::uintptr_t) base) >> xbt_pagebits;
 }
 
 /** @brief Get the offset of an address within a memory page
@@ -45,9 +49,9 @@ size_t mc_page_number(void* base, void* address)
  *  @return Offset within the memory page
  */
 static inline __attribute__ ((always_inline))
-size_t mc_page_offset(void* address)
+size_t mc_page_offset(const void* address)
 {
-  return ((uintptr_t) address) & (xbt_pagesize-1);
+  return ((std::uintptr_t) address) & (xbt_pagesize-1);
 }
 
 /** @brief Get the virtual address of a virtual memory page
@@ -56,15 +60,18 @@ size_t mc_page_offset(void* address)
  *  @param page Index of the page
  */
 static inline __attribute__ ((always_inline))
-void* mc_page_from_number(void* base, size_t page)
+void* mc_page_from_number(const void* base, size_t page)
 {
   return (void*) ((char*)base + (page << xbt_pagebits));
 }
 
 static inline __attribute__ ((always_inline))
-bool mc_same_page(void* a, void* b)
+bool mc_same_page(const void* a, const void* b)
 {
-  return ((uintptr_t) a >> xbt_pagebits) == ((uintptr_t) b >> xbt_pagebits);
+  return ((std::uintptr_t) a >> xbt_pagebits)
+    == ((std::uintptr_t) b >> xbt_pagebits);
 }
 
+SG_END_DECL()
+
 #endif