Browse Source

Fixed sbrk in new Linux systems.

Ioannis Koutras 14 years ago
parent
commit
a5d79931bd
2 changed files with 5 additions and 3 deletions
  1. 1 0
      dmm_init.c
  2. 4 3
      sys_alloc.c

+ 1 - 0
dmm_init.c

@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
 #include <unistd.h>
 #include <pthread.h>
 #include "dmm_init.h"

+ 4 - 3
sys_alloc.c

@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
 #include <unistd.h>
 #include <stdio.h>
 #include "posix_lock.h"
@@ -17,7 +18,7 @@ void setHeaders(void *ptr, size_t sz) {
 }
 
 void *sys_alloc(size_t size) {
-	unsigned int allocation_size;
+	size_t allocation_size;
 	void *ptr;
 
 	sbrk_lock();
@@ -25,7 +26,7 @@ void *sys_alloc(size_t size) {
 
 	if (borderPtr == NULL) {
 
-		ptr = sbrk(allocation_size + 2*HDR_SIZE); //extra space for coalescing support
+		ptr = sbrk((intptr_t) (allocation_size + 2*HDR_SIZE)); //extra space for coalescing support
 
 		if (ptr == (void *) -1){
 			printf("sbrk Fail\n");
@@ -40,7 +41,7 @@ void *sys_alloc(size_t size) {
 
 	} else {
 
-		ptr = sbrk(allocation_size);
+		ptr = sbrk((intptr_t) allocation_size);
 
 		if ((ptr == (char *) -1)){
 			printf("sbrk Fail: out of Memory\n");