A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove/cleanup/fix some #include
[simgrid.git]
/
src
/
mc
/
mc_mmu.h
diff --git
a/src/mc/mc_mmu.h
b/src/mc/mc_mmu.h
index
8df82fa
..
e0236e5
100644
(file)
--- a/
src/mc/mc_mmu.h
+++ b/
src/mc/mc_mmu.h
@@
-1,22
+1,28
@@
-/* 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. */
* 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 <
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?
*
* @param size Byte size
* @return Number of memory pages
*/
/** @brief How many memory pages are necessary to store size bytes?
*
* @param size Byte size
* @return Number of memory pages
*/
-static inline size_t mc_page_count(size_t size)
+static inline __attribute__ ((always_inline))
+size_t mc_page_count(size_t size)
{
size_t page_count = size >> xbt_pagebits;
if (size & (xbt_pagesize-1)) {
{
size_t page_count = size >> xbt_pagebits;
if (size & (xbt_pagesize-1)) {
@@
-30,9
+36,11
@@
static inline size_t mc_page_count(size_t size)
* @param address Address
* @return Virtual memory page number of the given address
*/
* @param address Address
* @return Virtual memory page number of the given address
*/
-static inline size_t mc_page_number(void* address)
+static inline __attribute__ ((always_inline))
+size_t mc_page_number(const void* base, const void* address)
{
{
- return ((uintptr_t) address) >> xbt_pagebits;
+ xbt_assert(address>=base, "The address is not in the range");
+ return ((std::uintptr_t) address - (std::uintptr_t) base) >> xbt_pagebits;
}
/** @brief Get the offset of an address within a memory page
}
/** @brief Get the offset of an address within a memory page
@@
-40,9
+48,10
@@
static inline size_t mc_page_number(void* address)
* @param address Address
* @return Offset within the memory page
*/
* @param address Address
* @return Offset within the memory page
*/
-static inline size_t mc_page_offset(void* address)
+static inline __attribute__ ((always_inline))
+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
}
/** @brief Get the virtual address of a virtual memory page
@@
-50,9
+59,19
@@
static inline size_t mc_page_offset(void* address)
* @param base Address of the first page
* @param page Index of the page
*/
* @param base Address of the first page
* @param page Index of the page
*/
-static inline void* mc_page_from_number(void* base, size_t page)
+static inline __attribute__ ((always_inline))
+void* mc_page_from_number(const void* base, size_t page)
{
return (void*) ((char*)base + (page << xbt_pagebits));
}
{
return (void*) ((char*)base + (page << xbt_pagebits));
}
+static inline __attribute__ ((always_inline))
+bool mc_same_page(const void* a, const void* b)
+{
+ return ((std::uintptr_t) a >> xbt_pagebits)
+ == ((std::uintptr_t) b >> xbt_pagebits);
+}
+
+SG_END_DECL()
+
#endif
#endif