summaryrefslogtreecommitdiff
path: root/src/bin/evas/evas_cserve2_shm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/evas/evas_cserve2_shm.c')
-rw-r--r--src/bin/evas/evas_cserve2_shm.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/bin/evas/evas_cserve2_shm.c b/src/bin/evas/evas_cserve2_shm.c
index 2045cdd8ca..d95afc7782 100644
--- a/src/bin/evas/evas_cserve2_shm.c
+++ b/src/bin/evas/evas_cserve2_shm.c
@@ -35,7 +35,7 @@ struct _Shm_Handle
35static int id = 0; 35static int id = 0;
36 36
37size_t 37size_t
38cserve2_shm_size_normalize(size_t size) 38cserve2_shm_size_normalize(size_t size, size_t align)
39{ 39{
40 long pagesize; 40 long pagesize;
41 size_t normalized; 41 size_t normalized;
@@ -47,7 +47,11 @@ cserve2_shm_size_normalize(size_t size)
47 pagesize = 4096; 47 pagesize = 4096;
48 } 48 }
49 49
50 normalized = ((size + pagesize - 1) / pagesize) * pagesize; 50 if (align)
51 align = ((align + pagesize - 1) / pagesize) * pagesize;
52 else
53 align = pagesize;
54 normalized = ((size + align - 1) / align) * align;
51 55
52 return normalized; 56 return normalized;
53} 57}
@@ -89,7 +93,7 @@ cserve2_shm_request(const char *infix, size_t size)
89 } 93 }
90 } while (fd == -1); 94 } while (fd == -1);
91 95
92 map_size = cserve2_shm_size_normalize(size); 96 map_size = cserve2_shm_size_normalize(size, 0);
93 97
94 if (ftruncate(fd, map_size) == -1) 98 if (ftruncate(fd, map_size) == -1)
95 { 99 {
@@ -135,7 +139,7 @@ cserve2_shm_segment_request(Shm_Handle *shm, size_t size)
135 return NULL; 139 return NULL;
136 } 140 }
137 141
138 map_size = cserve2_shm_size_normalize(size); 142 map_size = cserve2_shm_size_normalize(size, 0);
139 map_size += map->length; 143 map_size += map->length;
140 144
141 if (ftruncate(fd, map_size) == -1) 145 if (ftruncate(fd, map_size) == -1)
@@ -186,7 +190,7 @@ cserve2_shm_resize(Shm_Handle *shm, size_t newsize)
186 return NULL; 190 return NULL;
187 } 191 }
188 192
189 map_size = cserve2_shm_size_normalize(newsize); 193 map_size = cserve2_shm_size_normalize(newsize, 0);
190 if (ftruncate(fd, map_size)) 194 if (ftruncate(fd, map_size))
191 { 195 {
192 ERR("Could not set the size of the shm: %m"); 196 ERR("Could not set the size of the shm: %m");