Commits

Ben Bass committed 7c01543

get working on Linux

Comments (0)

Files changed (2)

-all: out.tiff
+all: out_image
 
-out.tiff: out.ppm
-	ppm2tiff out.ppm out.tiff
+out_image: out.ppm
+	which pnmtopng > /dev/null && pnmtopng out.ppm > out_image || ppm2tiff out.ppm out_image
 
 out.ppm: make_ppm mandel.dat
 	./make_ppm
 	g++ mandelmap.cc -Werror -O3 -o mandelmap -lc -lpthread
 	
 clean:
-	rm -f mandelmap make_ppm out.ppm out.tiff
+	rm -f mandelmap make_ppm out.ppm out_image
 
 superclean: clean
 	rm -f mandel_*.dat
 
 #include <pthread.h>
 
+#ifndef MAP_NOCACHE
+#define MAP_NOCACHE 0
+#endif
+
 long mpoint(pinfo* p);
 
 long inside_points = 0;
     char fname[21];
     snprintf(fname, 20, "mandel_%d.dat", BINARY_DIGITS);
     int fd = open(fname, O_RDWR|O_CREAT, 0644);
-    ftruncate(fd, mapsize);
+    if (ftruncate(fd, mapsize) != 0) {
+        printf("ftruncate failed\n");
+        return 1;
+    }
 
     // we will use mmap to write to the data file. It makes things wonderful.
     void* mapping;