summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-02-13 13:08:54 +0100
committerLars-Dominik Braun <lars@6xq.net>2015-05-02 21:36:44 +0200
commitf286661035f4f6b01cef7d80c510140c2518f25b (patch)
tree5894cdb2b48087eee9023562faba48c00a503e00
parent1ca79e948aa4bf923b92757ea68a98b7bcd0767d (diff)
downloadpucket-f286661035f4f6b01cef7d80c510140c2518f25b.tar.gz
pucket-f286661035f4f6b01cef7d80c510140c2518f25b.tar.bz2
pucket-f286661035f4f6b01cef7d80c510140c2518f25b.zip
Drop Windows/Mac support, require pthreads
-rw-r--r--flam3-animate.c19
-rw-r--r--flam3-convert.c16
-rw-r--r--flam3-genome.c20
-rw-r--r--flam3-render.c54
-rw-r--r--flam3.c63
-rw-r--r--flam3.h5
-rw-r--r--img.h4
-rw-r--r--png.c4
-rw-r--r--private.h23
-rw-r--r--rect.c64
-rw-r--r--variations.c11
-rw-r--r--wscript2
12 files changed, 6 insertions, 279 deletions
diff --git a/flam3-animate.c b/flam3-animate.c
index ccf0b5a..267064c 100644
--- a/flam3-animate.c
+++ b/flam3-animate.c
@@ -55,25 +55,6 @@ int main(int argc, char **argv) {
char numiter_string[64];
char rtime_string[64];
-#ifdef WIN32
-
- char *slashloc;
- char exepath[256];
- char palpath[256];
- memset(exepath,0,256);
- memset(palpath,0,256);
- slashloc = strrchr(argv[0],'\\');
- if (NULL==slashloc) {
- sprintf(palpath,"flam3_palettes=flam3-palettes.xml");
- } else {
- strncpy(exepath,argv[0],slashloc-argv[0]+1);
- sprintf(palpath,"flam3_palettes=%sflam3-palettes.xml",exepath);
- }
- putenv(palpath);
-
-#endif
-
-
memset(&center_cp,0, sizeof(flam3_genome));
if (1 != argc) {
diff --git a/flam3-convert.c b/flam3-convert.c
index 3062a4b..3758fba 100644
--- a/flam3-convert.c
+++ b/flam3-convert.c
@@ -188,22 +188,6 @@ main(int argc, char **argv)
{
char *s, *ss;
-#ifdef WIN32
-
- char *slashloc;
- char palpath[256],exepath[256];
-
- slashloc = strrchr(argv[0],'\\');
- if (NULL==slashloc) {
- sprintf(palpath,"flam3_palettes=flam3-palettes.xml");
- } else {
- strncpy(exepath,argv[0],slashloc-argv[0]+1);
- sprintf(palpath,"flam3_palettes=%sflam3-palettes.xml",exepath);
- }
- putenv(palpath);
-
-#endif
-
if (1 != argc) {
docstring();
exit(0);
diff --git a/flam3-genome.c b/flam3-genome.c
index 9ab08ad..af2f8f6 100644
--- a/flam3-genome.c
+++ b/flam3-genome.c
@@ -430,26 +430,6 @@ main(argc, argv)
stat_struct stats;
-
-
-#ifdef WIN32
-
- char *slashloc;
- char exepath[256];
- char palpath[256];
- memset(exepath,0,256);
- memset(palpath,0,256);
- slashloc = strrchr(argv[0],'\\');
- if (NULL==slashloc) {
- sprintf(palpath,"flam3_palettes=flam3-palettes.xml");
- } else {
- strncpy(exepath,argv[0],slashloc-argv[0]+1);
- sprintf(palpath,"flam3_palettes=%sflam3-palettes.xml",exepath);
- }
- putenv(palpath);
-
-#endif
-
if (argc>1) {
if (strcmp("--version",argv[1])==0) {
printf("FLAM3-%s\n",flam3_version());
diff --git a/flam3-render.c b/flam3-render.c
index e3acd64..47727da 100644
--- a/flam3-render.c
+++ b/flam3-render.c
@@ -16,15 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef WIN32
-#define WINVER 0x0500
-#include <windows.h>
-#endif
-
-#ifdef __APPLE__
-#include <sys/sysctl.h>
-#endif
-
#include <limits.h>
@@ -37,32 +28,9 @@ int calc_nstrips(flam3_frame *spec) {
double mem_available;
int nstrips,ninc;
char *testmalloc;
-#ifdef WIN32
- MEMORYSTATUS stat;
- stat.dwLength = sizeof(stat);
- GlobalMemoryStatus(&stat); // may want to go to GlobalMemoryStatusEx eventually
- mem_available = (double)stat.dwTotalPhys;
-// fprintf(stderr,"%lu bytes free memory...\n",(size_t)stat.dwAvailPhys);
-// if (mem_available > 1e9) mem_available = 1e9;
-#elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
+#if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
mem_available =
(double)sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE);
-#elif defined __APPLE__
-#ifdef __LP64__
-long physmem;
-size_t len = sizeof(physmem);
-static int mib[2] = { CTL_HW, HW_MEMSIZE };
-#else
-unsigned int physmem;
-size_t len = sizeof(physmem);
-static int mib[2] = { CTL_HW, HW_PHYSMEM };
-#endif
-if (sysctl(mib, 2, &physmem, &len, NULL, 0) == 0 && len == sizeof(physmem)) {
- mem_available = (double )physmem;
-} else {
- fprintf(stderr, "warning: unable to determine physical memory.n");
- mem_available = 2e9;
-}
#else
fprintf(stderr, "warning: unable to determine physical memory.\n");
mem_available = 2e9;
@@ -145,26 +113,6 @@ int main(int argc, char **argv) {
char badval_string[64];
char rtime_string[64];
-#ifdef WIN32
-
- char *slashloc;
- char exepath[256];
- char palpath[256];
- memset(exepath,0,256);
- memset(palpath,0,256);
-
- slashloc = strrchr(argv[0],'\\');
- if (NULL==slashloc) {
- sprintf(palpath,"flam3_palettes=flam3-palettes.xml");
- } else {
- strncpy(exepath,argv[0],slashloc-argv[0]+1);
- sprintf(palpath,"flam3_palettes=%sflam3-palettes.xml",exepath);
- }
- putenv(palpath);
-
-#endif
-
-
if (1 != argc) {
docstring();
exit(0);
diff --git a/flam3.c b/flam3.c
index f1b72be..eb2d2ab 100644
--- a/flam3.c
+++ b/flam3.c
@@ -16,10 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _MSC_VER /* VC++ */
-#define _GNU_SOURCE
-#endif
-
#include "private.h"
#include "img.h"
#include "config.h"
@@ -40,25 +36,7 @@
#endif
#include <errno.h>
-#ifdef HAVE_LIBPTHREAD
#include <pthread.h>
-#endif
-
-#ifdef __APPLE__
-#include <mach/mach.h>
-#include <mach/mach_error.h>
-#define flam3_os "OSX"
-#else
-#ifdef _WIN32
-#define WINVER 0x0500
-#include <windows.h>
-#define flam3_os "WIN"
-#else
-#define flam3_os "LNX"
-#endif
-#endif
-
-
char *flam3_version() {
return VERSION;
@@ -1357,31 +1335,7 @@ void clear_cp(flam3_genome *cp, int default_flag) {
int flam3_count_nthreads(void) {
int nthreads;
-#ifndef HAVE_LIBPTHREAD
- return(1);
-#endif
-#ifdef _WIN32
- SYSTEM_INFO sysInfo;
- GetSystemInfo(&sysInfo);
- nthreads = sysInfo.dwNumberOfProcessors;
-#else
-#ifdef __APPLE__
- kern_return_t kr;
- host_name_port_t host;
- unsigned int size;
- struct host_basic_info hi;
-
- host = mach_host_self();
- size = sizeof(hi)/sizeof(int);
- kr = host_info(host, HOST_BASIC_INFO, (host_info_t)&hi, &size);
- if (kr != KERN_SUCCESS) {
- mach_error("host_info():", kr);
- /* set threads to 1 on error */
- nthreads = 1;
- } else
- nthreads = hi.avail_cpus;
-#else
#ifndef _SC_NPROCESSORS_ONLN
char line[MAXBUF];
FILE *f = fopen("/proc/cpuinfo", "r");
@@ -1401,8 +1355,6 @@ def:
nthreads = sysconf(_SC_NPROCESSORS_ONLN);
if (nthreads < 1) nthreads = 1;
#endif
-#endif
-#endif
return (nthreads);
}
@@ -1618,20 +1570,6 @@ char *flam3_print_to_string(flam3_genome *cp) {
tmpflame = tmpfile();
if (NULL==tmpflame) {
-#ifdef _WIN32
- // This might be a permissions problem, so let's try to open a
- // tempfile in the env var TEMP's area instead
- tmp_path = getenv("TEMP");
-
- if (tmp_path != NULL) {
- strcpy(tmpnam, tmp_path);
- strcat(tmpnam, "\\fr0st.tmp");
- tmpflame = fopen(tmpnam, "w+");
- if (tmpflame != NULL) {
- using_tmpdir = 1;
- }
- }
-#endif
if (using_tmpdir == 0) {
perror("FLAM3: opening temporary file");
return (NULL);
@@ -3603,7 +3541,6 @@ typedef float abucket_float[4];
} \
} while (0)
/* single-threaded */
-#define USE_LOCKS
#define bump_no_overflow(dest, delta) do { \
if (UINT_MAX - dest > delta) dest += delta; else dest = UINT_MAX; \
} while (0)
diff --git a/flam3.h b/flam3.h
index 611cb22..12b8baf 100644
--- a/flam3.h
+++ b/flam3.h
@@ -24,12 +24,7 @@
#include <libxml/parser.h>
#include "xorshift.h"
-#if defined(_MSC_VER) /* VC++ */
-#include <windows.h>
-#define EXPORT __declspec (dllexport)
-#else
#define EXPORT
-#endif
EXPORT char *flam3_version();
diff --git a/img.h b/img.h
index 6bab912..a2693fc 100644
--- a/img.h
+++ b/img.h
@@ -22,10 +22,6 @@
#define FLAM3_PNG_COM 8
-#ifdef WIN32
- #define snprintf _snprintf
-#endif
-
typedef struct {
char *genome;
diff --git a/png.c b/png.c
index e86cfcb..ced86ad 100644
--- a/png.c
+++ b/png.c
@@ -27,11 +27,7 @@
#include "flam3.h"
#include "private.h"
-#ifdef _WIN32
-#include <winsock.h> /* for htons */
-#else
#include <arpa/inet.h>
-#endif
void write_png(FILE *file, void *image, int width, int height, flam3_img_comments *fpc, int bpc) {
png_structp png_ptr;
diff --git a/private.h b/private.h
index c33a099..466104b 100644
--- a/private.h
+++ b/private.h
@@ -28,20 +28,12 @@
#include <string.h>
#include <libxml/parser.h>
-#ifdef _WIN32
-#define basename(x) strdup(x)
-#define snprintf _snprintf
-#define _USE_MATH_DEFINES
-#else
#include <unistd.h>
#include <libgen.h>
-#endif
#include <math.h>
-#ifdef HAVE_LIBPTHREAD
#include <pthread.h>
-#endif
#define PREFILTER_WHITE 255
#define EPS (1e-10)
@@ -53,19 +45,6 @@
#define vlen(x) (sizeof(x)/sizeof(*x))
-#ifdef _WIN32
-
-#ifndef M_PI
- #define M_PI 3.1415926536
- #define M_1_PI 0.3183098862
- #define M_PI_4 0.7853981634
-#endif
-#define random() (rand() ^ (rand()<<15))
-#define srandom(x) (srand(x))
-extern int getpid();
-#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
-#endif
-
#define argi(s,d) ((ai = getenv(s)) ? atoi(ai) : (d))
#define argf(s,d) ((ai = getenv(s)) ? atof(ai) : (d))
#define args(s,d) ((ai = getenv(s)) ? ai : (d))
@@ -92,10 +71,8 @@ typedef struct {
time_t *progress_timer_history;
double *progress_history;
int *progress_history_mark;
-#ifdef HAVE_LIBPTHREAD
/* mutex for bucket accumulator */
pthread_mutex_t bucket_mutex;
-#endif
} flam3_iter_constants;
diff --git a/rect.c b/rect.c
index 0c99e39..7044998 100644
--- a/rect.c
+++ b/rect.c
@@ -199,11 +199,7 @@ static void de_thread(void *dth) {
*(dthp->aborted) = -1;
do {
-#if defined(_WIN32) /* mingw or msvc */
- Sleep(100);
-#else
nanosleep(&pauset,NULL);
-#endif
rv = (*dthp->spec->progress)(dthp->spec->progress_parameter,
100*(j-str)/(double)(enr-str), 1, 0);
} while (rv==2);
@@ -214,38 +210,24 @@ static void de_thread(void *dth) {
if (rv==1) {
*(dthp->aborted) = 1;
-#ifdef HAVE_LIBPTHREAD
pthread_exit((void *)0);
-#else
- return;
-#endif
}
} else {
-#ifdef HAVE_LIBPTHREAD
if (*(dthp->aborted)<0) {
do {
-#if defined(_WIN32) /* mingw or msvc */
- Sleep(100);
-#else
nanosleep(&pauset,NULL);
-#endif
} while (*(dthp->aborted)<0);
}
if (*(dthp->aborted)>0) pthread_exit((void *)0);
-#else
- if (*(dthp->aborted)>0) return;
-#endif
}
}
}
- #ifdef HAVE_LIBPTHREAD
pthread_exit((void *)0);
- #endif
}
@@ -341,11 +323,7 @@ static void iter_thread(void *fth) {
ficp->aborted = -1;
do {
-#if defined(_WIN32) /* mingw or msvc */
- Sleep(100);
-#else
nanosleep(&pauset,NULL);
-#endif
rv = (*ficp->spec->progress)(ficp->spec->progress_parameter, percent, 0, eta);
} while (rv==2);
@@ -364,28 +342,16 @@ static void iter_thread(void *fth) {
if (rv==1) { /* ABORT */
ficp->aborted = 1;
-#ifdef HAVE_LIBPTHREAD
pthread_exit((void *)0);
-#else
- return;
-#endif
}
} else {
if (ficp->aborted<0) {
do {
-#if defined(_WIN32) /* mingw or msvc */
- Sleep(100);
-#else
nanosleep(&pauset,NULL);
-#endif
} while (ficp->aborted==-1);
}
-#ifdef HAVE_LIBPTHREAD
if (ficp->aborted>0) pthread_exit((void *)0);
-#else
- if (ficp->aborted>0) return;
-#endif
}
}
@@ -400,10 +366,8 @@ static void iter_thread(void *fth) {
/* Execute iterations */
badcount = flam3_iterate(&(fthp->cp), sub_batch_size, fuse, start, fthp->iter_storage, ficp->xform_distrib, &(fthp->rc));
- #if defined(HAVE_LIBPTHREAD) && defined(USE_LOCKS)
- /* Lock mutex for access to accumulator */
- pthread_mutex_lock(&ficp->bucket_mutex);
- #endif
+ /* Lock mutex for access to accumulator */
+ pthread_mutex_lock(&ficp->bucket_mutex);
/* Add the badcount to the counter */
ficp->badvals += badcount;
@@ -490,15 +454,11 @@ static void iter_thread(void *fth) {
}
}
- #if defined(HAVE_LIBPTHREAD) && defined(USE_LOCKS)
- /* Release mutex */
- pthread_mutex_unlock(&ficp->bucket_mutex);
- #endif
+ /* Release mutex */
+ pthread_mutex_unlock(&ficp->bucket_mutex);
}
- #ifdef HAVE_LIBPTHREAD
pthread_exit((void *)0);
- #endif
}
static int render_rectangle(flam3_frame *spec, void *out,
@@ -532,10 +492,8 @@ static int render_rectangle(flam3_frame *spec, void *out,
unsigned short *xform_distrib;
flam3_iter_constants fic;
flam3_thread_helper *fth;
-#ifdef HAVE_LIBPTHREAD
pthread_attr_t pt_attr;
pthread_t *myThreads=NULL;
-#endif
int thread_status;
int thi;
time_t tstart,tend;
@@ -856,13 +814,10 @@ static int render_rectangle(flam3_frame *spec, void *out,
}
-#ifdef HAVE_LIBPTHREAD
/* Let's make some threads */
myThreads = (pthread_t *)malloc(spec->nthreads * sizeof(pthread_t));
- #if defined(USE_LOCKS)
pthread_mutex_init(&fic.bucket_mutex, NULL);
- #endif
pthread_attr_init(&pt_attr);
pthread_attr_setdetachstate(&pt_attr,PTHREAD_CREATE_JOINABLE);
@@ -876,15 +831,9 @@ static int render_rectangle(flam3_frame *spec, void *out,
for (thi=0; thi < spec->nthreads; thi++)
pthread_join(myThreads[thi], NULL);
- #if defined(USE_LOCKS)
pthread_mutex_destroy(&fic.bucket_mutex);
- #endif
free(myThreads);
-#else
- for (thi=0; thi < spec->nthreads; thi++)
- iter_thread( (void *)(&(fth[thi])) );
-#endif
/* Free the xform_distrib array */
free(xform_distrib);
@@ -991,7 +940,6 @@ static int render_rectangle(flam3_frame *spec, void *out,
}
}
-#ifdef HAVE_LIBPTHREAD
/* Let's make some threads */
myThreads = (pthread_t *)malloc(spec->nthreads * sizeof(pthread_t));
@@ -1008,10 +956,6 @@ static int render_rectangle(flam3_frame *spec, void *out,
pthread_join(myThreads[thi], NULL);
free(myThreads);
-#else
- for (thi=0; thi <spec->nthreads; thi ++)
- de_thread((void *)(&(deth[thi])));
-#endif
free(deth);
diff --git a/variations.c b/variations.c
index e07983e..6d443ce 100644
--- a/variations.c
+++ b/variations.c
@@ -26,17 +26,6 @@
#define badvalue(x) (((x)!=(x))||((x)>1e10)||((x)<-1e10))
-/* Wrap the sincos function for Macs */
-#if defined(__APPLE__) || defined(_MSC_VER)
-#define sincos(x,s,c) *(s)=sin(x); *(c)=cos(x);
-#else
-extern void sincos(double x, double *s, double *c);
-#endif
-
-#ifdef _MSC_VER
-#define trunc (int)
-#endif
-
typedef struct {
double precalc_atan, precalc_sina; /* Precalculated, if needed */
double precalc_cosa, precalc_sqrt;
diff --git a/wscript b/wscript
index 1f97094..8a1f64a 100644
--- a/wscript
+++ b/wscript
@@ -10,7 +10,7 @@ def configure(conf):
conf.check_cfg (path='xml2-config', args='--cflags --libs', package='', uselib_store='xml2')
conf.check_cc (lib='xml2', header_name='libxml/parser.h', function_name='xmlParseFile', use='xml2')
- conf.check_cc (lib='pthread', uselib_store='pthread', define_name='HAVE_LIBPTHREAD')
+ conf.check_cc (lib='pthread', uselib_store='pthread')
conf.check_cc (lib='jpeg', uselib_store='jpeg')
conf.check_cfg (package='libpng', uselib_store='png', args=['--cflags', '--libs'], msg='Checking for library png')
conf.check_cc (lib='amdlibm', header_name='amdlibm.h', mandatory=False, define_name='HAVE_AMDLIBM', uselib_store='amdlibm')