Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Unify the copyright headers of mmalloc with the rest of the library
[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*
25 mvalloc (void *md, size_t size)
26 {
27   if (cache_pagesize == 0)
28     {
29       cache_pagesize = getpagesize ();
30     }
31
32   return (mmemalign (md, cache_pagesize, size));
33 }
34
35 /* Useless prototype to make gcc happy */
36 void* valloc (size_t size);
37
38 void* valloc (size_t size) {
39   return mvalloc (NULL, size);
40 }