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
Throw an exception if return value shows an error.
[simgrid.git]
/
src
/
xbt
/
mmalloc
/
mmap-sup.c
diff --git
a/src/xbt/mmalloc/mmap-sup.c
b/src/xbt/mmalloc/mmap-sup.c
index
3b48e72
..
28f89bc
100644
(file)
--- a/
src/xbt/mmalloc/mmap-sup.c
+++ b/
src/xbt/mmalloc/mmap-sup.c
@@
-25,6
+25,7
@@
#endif
#include "mmprivate.h"
#endif
#include "mmprivate.h"
+#include "xbt/ex.h"
/* Cache the pagesize for the current host machine. Note that if the host
does not readily provide a getpagesize() function, we need to emulate it
/* Cache the pagesize for the current host machine. Note that if the host
does not readily provide a getpagesize() function, we need to emulate it
@@
-77,6
+78,7
@@
void *__mmalloc_mmap_morecore(struct mdesc *mdp, int size)
if (size == 0) {
/* Just return the current "break" value. */
result = mdp->breakval;
if (size == 0) {
/* Just return the current "break" value. */
result = mdp->breakval;
+
} else if (size < 0) {
/* We are deallocating memory. If the amount requested would cause
us to try to deallocate back past the base of the mmap'd region
} else if (size < 0) {
/* We are deallocating memory. If the amount requested would cause
us to try to deallocate back past the base of the mmap'd region
@@
-94,6
+96,7
@@
void *__mmalloc_mmap_morecore(struct mdesc *mdp, int size)
/* We are allocating memory. Make sure we have an open file
descriptor if not working with anonymous memory. */
if (!(mdp->flags & MMALLOC_ANONYMOUS) && mdp->fd < 0) {
/* We are allocating memory. Make sure we have an open file
descriptor if not working with anonymous memory. */
if (!(mdp->flags & MMALLOC_ANONYMOUS) && mdp->fd < 0) {
+ THROWF(system_error,0,"mmap file descriptor <0 (%d), without MMALLOC_ANONYMOUS being in the flags",mdp->fd);
result = NULL;
} else if ((char *) mdp->breakval + size > (char *) mdp->top) {
/* The request would move us past the end of the currently
result = NULL;
} else if ((char *) mdp->breakval + size > (char *) mdp->top) {
/* The request would move us past the end of the currently
@@
-106,9
+109,11
@@
void *__mmalloc_mmap_morecore(struct mdesc *mdp, int size)
foffset = (char *) mdp->top - (char *) mdp->base;
if (mdp->fd > 0) {
foffset = (char *) mdp->top - (char *) mdp->base;
if (mdp->fd > 0) {
- /* FIXME: Test results of lseek()
and write()
*/
+ /* FIXME: Test results of lseek() */
lseek(mdp->fd, foffset + mapbytes - 1, SEEK_SET);
test = write(mdp->fd, &buf, 1);
lseek(mdp->fd, foffset + mapbytes - 1, SEEK_SET);
test = write(mdp->fd, &buf, 1);
+ if (test == -1)
+ THROWF(system_error, 0, "write to mmap'ed fd failed! error: %s", strerror(errno));
}
/* Let's call mmap. Note that it is possible that mdp->top
}
/* Let's call mmap. Note that it is possible that mdp->top
@@
-117,7
+122,7
@@
void *__mmalloc_mmap_morecore(struct mdesc *mdp, int size)
MAP_PRIVATE_OR_SHARED(mdp) | MAP_IS_ANONYMOUS(mdp) |
MAP_FIXED, MAP_ANON_OR_FD(mdp), foffset);
MAP_PRIVATE_OR_SHARED(mdp) | MAP_IS_ANONYMOUS(mdp) |
MAP_FIXED, MAP_ANON_OR_FD(mdp), foffset);
- if (mapto != (void *) -1) {
+ if (mapto != (void *) -1
/* That's MAP_FAILED */
) {
if (mdp->top == 0)
mdp->base = mdp->breakval = mapto;
if (mdp->top == 0)
mdp->base = mdp->breakval = mapto;
@@
-125,6
+130,8
@@
void *__mmalloc_mmap_morecore(struct mdesc *mdp, int size)
mdp->top = PAGE_ALIGN((char *) mdp->breakval + size);
result = (void *) mdp->breakval;
mdp->breakval = (char *) mdp->breakval + size;
mdp->top = PAGE_ALIGN((char *) mdp->breakval + size);
result = (void *) mdp->breakval;
mdp->breakval = (char *) mdp->breakval + size;
+ } else {
+ THROWF(system_error,0,"mmap returned MAP_FAILED! error: %s",strerror(errno));
}
} else {
result = (void *) mdp->breakval;
}
} else {
result = (void *) mdp->breakval;