Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c940ee9f69fdbb4cb21bd8c3821715299d47f1bc
[simgrid.git] / src / xbt / mmalloc / mvalloc.c
1 /* Allocate memory on a page boundary.
2    Copyright (C) 1991 Free Software Foundation, Inc. */
3
4 /* Copyright (c) 2010. The SimGrid Team.
5  * All rights reserved.                                                     */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10
11 #include "mmprivate.h"
12 #include <unistd.h>
13
14 /* Cache the pagesize for the current host machine.  Note that if the host
15    does not readily provide a getpagesize() function, we need to emulate it
16    elsewhere, not clutter up this file with lots of kluges to try to figure
17    it out. */
18
19 static size_t cache_pagesize;
20 #if NEED_DECLARATION_GETPAGESIZE
21 extern int getpagesize PARAMS((void));
22 #endif
23
24 void *mvalloc(xbt_mheap_t mdp, size_t size)
25 {
26   if (cache_pagesize == 0) {
27     cache_pagesize = getpagesize();
28   }
29
30   return (mmemalign(mdp, cache_pagesize, size));
31 }
32