File: Use-mmap-only-if-it-exists.patch

package info (click to toggle)
source-extractor 2.25.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,004 kB
  • sloc: ansic: 39,413; sh: 1,063; makefile: 312; python: 26
file content (63 lines) | stat: -rw-r--r-- 1,879 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
From: Justin Pryzby <justinpryzby@users.sf.net>
Date: Fri, 9 Dec 2011 10:09:33 +0100
Subject: Use mmap only if it exists.

---
 src/fits/fitsbody.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/fits/fitsbody.c b/src/fits/fitsbody.c
index e13be1a..24ac78f 100644
--- a/src/fits/fitsbody.c
+++ b/src/fits/fitsbody.c
@@ -64,9 +64,12 @@ VERSION	05/05/2001
  ***/
 PIXTYPE	*alloc_body(tabstruct *tab, void (*func)(PIXTYPE *ptr, int npix))
   {
+#ifdef	HAVE_MMAP
    FILE		*file;
    PIXTYPE	*buffer;
-   size_t	npix, size, sizeleft, spoonful;
+   size_t	sizeleft, spoonful;
+#endif
+   size_t	npix, size;
 
   if (!body_ramflag)
     {
@@ -87,7 +90,9 @@ PIXTYPE	*alloc_body(tabstruct *tab, void (*func)(PIXTYPE *ptr, int npix))
 /* Decide if the data will go in physical memory or on swap-space */
   npix = tab->tabsize/tab->bytepix;
   size = npix*sizeof(PIXTYPE);
+#if !HAVE_MMAP
   if (size < body_ramleft)
+#endif
     {
 /*-- There should be enough RAM left: try to do a malloc() */
     if ((tab->bodybuf = malloc(size)))
@@ -105,6 +110,7 @@ PIXTYPE	*alloc_body(tabstruct *tab, void (*func)(PIXTYPE *ptr, int npix))
       tab->bodybuf = NULL;
     }
 
+#if HAVE_MMAP
   if (size < body_vramleft)
     {
 /*-- Convert and copy the data to a swap file, and mmap() it */
@@ -144,6 +150,7 @@ PIXTYPE	*alloc_body(tabstruct *tab, void (*func)(PIXTYPE *ptr, int npix))
       return NULL;
     return (PIXTYPE *)tab->bodybuf;
     }
+#endif
 
 /* If no memory left at all: forget it! */
   return NULL;
@@ -270,8 +277,10 @@ void	free_body(tabstruct *tab)
     size = (tab->tabsize/tab->bytepix)*sizeof(PIXTYPE);
     if (tab->swapflag)
       {
+#if HAVE_MMAP
       if (munmap(tab->bodybuf, size))
         warning("Can't unmap ", tab->cat->filename);
+#endif
       tab->swapflag = 0;
       tab->bodybuf = NULL;
       body_vramleft += size;