summaryrefslogtreecommitdiff
path: root/numlib
diff options
context:
space:
mode:
Diffstat (limited to 'numlib')
-rwxr-xr-x[-rw-r--r--]numlib/Jamfile4
-rwxr-xr-x[-rw-r--r--]numlib/LUtest.c0
-rwxr-xr-x[-rw-r--r--]numlib/License.txt0
-rwxr-xr-x[-rw-r--r--]numlib/Readme.txt0
-rwxr-xr-x[-rw-r--r--]numlib/aatree.c0
-rwxr-xr-x[-rw-r--r--]numlib/aatree.h0
-rwxr-xr-x[-rw-r--r--]numlib/afiles0
-rwxr-xr-x[-rw-r--r--]numlib/dhsx.c0
-rwxr-xr-x[-rw-r--r--]numlib/dhsx.h0
-rwxr-xr-x[-rw-r--r--]numlib/dnsq.c0
-rwxr-xr-x[-rw-r--r--]numlib/dnsq.h0
-rwxr-xr-x[-rw-r--r--]numlib/dnsqtest.c0
-rwxr-xr-x[-rw-r--r--]numlib/ludecomp.c0
-rwxr-xr-x[-rw-r--r--]numlib/ludecomp.h0
-rwxr-xr-x[-rw-r--r--]numlib/numlib.h0
-rwxr-xr-x[-rw-r--r--]numlib/numsup.c310
-rwxr-xr-x[-rw-r--r--]numlib/numsup.h19
-rwxr-xr-x[-rw-r--r--]numlib/powell.c0
-rwxr-xr-x[-rw-r--r--]numlib/powell.h0
-rwxr-xr-x[-rw-r--r--]numlib/rand.c0
-rwxr-xr-x[-rw-r--r--]numlib/rand.h0
-rwxr-xr-x[-rw-r--r--]numlib/sobol.c0
-rwxr-xr-x[-rw-r--r--]numlib/sobol.h0
-rwxr-xr-x[-rw-r--r--]numlib/soboltest.c0
-rwxr-xr-x[-rw-r--r--]numlib/svd.c0
-rwxr-xr-x[-rw-r--r--]numlib/svd.h0
-rwxr-xr-x[-rw-r--r--]numlib/svdtest.c0
-rwxr-xr-x[-rw-r--r--]numlib/tdhsx.c0
-rwxr-xr-x[-rw-r--r--]numlib/tpowell.c0
-rwxr-xr-x[-rw-r--r--]numlib/ui.c21
-rwxr-xr-x[-rw-r--r--]numlib/ui.h0
-rwxr-xr-x[-rw-r--r--]numlib/zbrent.c0
-rwxr-xr-x[-rw-r--r--]numlib/zbrent.h0
-rwxr-xr-x[-rw-r--r--]numlib/zbrenttest.c0
34 files changed, 349 insertions, 5 deletions
diff --git a/numlib/Jamfile b/numlib/Jamfile
index 87c3c78..1053612 100644..100755
--- a/numlib/Jamfile
+++ b/numlib/Jamfile
@@ -17,6 +17,8 @@ Headers = numlib.h libui.h ;
#InstallFile $(DESTDIR)$(PREFIX)/h : $(Headers) ;
#InstallLib $(DESTDIR)$(PREFIX)/lib : $(Libraries) ;
+HDRS = ../h ;
+
# Numeric library
Library libnum.lib : numsup.c dnsq.c powell.c dhsx.c ludecomp.c svd.c zbrent.c rand.c sobol.c aatree.c ;
@@ -33,3 +35,5 @@ if $(OS) = MACOSX {
# UI setup library
Library libui.lib : ui.c ;
+
+
diff --git a/numlib/LUtest.c b/numlib/LUtest.c
index feb2277..feb2277 100644..100755
--- a/numlib/LUtest.c
+++ b/numlib/LUtest.c
diff --git a/numlib/License.txt b/numlib/License.txt
index a871fcf..a871fcf 100644..100755
--- a/numlib/License.txt
+++ b/numlib/License.txt
diff --git a/numlib/Readme.txt b/numlib/Readme.txt
index 8cc0173..8cc0173 100644..100755
--- a/numlib/Readme.txt
+++ b/numlib/Readme.txt
diff --git a/numlib/aatree.c b/numlib/aatree.c
index 2f38b1d..2f38b1d 100644..100755
--- a/numlib/aatree.c
+++ b/numlib/aatree.c
diff --git a/numlib/aatree.h b/numlib/aatree.h
index 4212b09..4212b09 100644..100755
--- a/numlib/aatree.h
+++ b/numlib/aatree.h
diff --git a/numlib/afiles b/numlib/afiles
index 29d6699..29d6699 100644..100755
--- a/numlib/afiles
+++ b/numlib/afiles
diff --git a/numlib/dhsx.c b/numlib/dhsx.c
index 180d15c..180d15c 100644..100755
--- a/numlib/dhsx.c
+++ b/numlib/dhsx.c
diff --git a/numlib/dhsx.h b/numlib/dhsx.h
index 828b8b2..828b8b2 100644..100755
--- a/numlib/dhsx.h
+++ b/numlib/dhsx.h
diff --git a/numlib/dnsq.c b/numlib/dnsq.c
index 75f00a8..75f00a8 100644..100755
--- a/numlib/dnsq.c
+++ b/numlib/dnsq.c
diff --git a/numlib/dnsq.h b/numlib/dnsq.h
index e06e562..e06e562 100644..100755
--- a/numlib/dnsq.h
+++ b/numlib/dnsq.h
diff --git a/numlib/dnsqtest.c b/numlib/dnsqtest.c
index 3f02819..3f02819 100644..100755
--- a/numlib/dnsqtest.c
+++ b/numlib/dnsqtest.c
diff --git a/numlib/ludecomp.c b/numlib/ludecomp.c
index 72e014a..72e014a 100644..100755
--- a/numlib/ludecomp.c
+++ b/numlib/ludecomp.c
diff --git a/numlib/ludecomp.h b/numlib/ludecomp.h
index cdb4382..cdb4382 100644..100755
--- a/numlib/ludecomp.h
+++ b/numlib/ludecomp.h
diff --git a/numlib/numlib.h b/numlib/numlib.h
index aa34b2d..aa34b2d 100644..100755
--- a/numlib/numlib.h
+++ b/numlib/numlib.h
diff --git a/numlib/numsup.c b/numlib/numsup.c
index 43f6e73..c08ed99 100644..100755
--- a/numlib/numsup.c
+++ b/numlib/numsup.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <limits.h>
#include <time.h>
+#include <ctype.h>
#if defined (NT)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -24,8 +25,14 @@
#ifdef UNIX
#include <unistd.h>
#include <sys/param.h>
+#include <sys/utsname.h>
#include <pthread.h>
#endif
+#ifndef SALONEINSTLIB
+#include "aconfig.h"
+#else
+#include "sa_config.h"
+#endif
#define NUMSUP_C
#include "numsup.h"
@@ -220,22 +227,138 @@ void check_if_not_interactive() {
/* It's values can be overridden to redirect these messages. */
/******************************************************************/
+static void va_loge(a1log *p, char *fmt, ...);
+
#ifdef NT
+
+/* Get a string describing the MWin operating system */
+
+typedef struct {
+ DWORD dwOSVersionInfoSize;
+ DWORD dwMajorVersion;
+ DWORD dwMinorVersion;
+ DWORD dwBuildNumber;
+ DWORD dwPlatformId;
+ WCHAR szCSDVersion[128];
+ WORD wServicePackMajor;
+ WORD wServicePackMinor;
+ WORD wSuiteMask;
+ BYTE wProductType;
+ BYTE wReserved;
+} osversioninfoexw;
+
+#define VER_NT_DOMAIN_CONTROLLER 0x0000002
+#define VER_NT_SERVER 0x0000003
+#define VER_NT_WORKSTATION 0x0000001
+
+static char *get_sys_info() {
+ static char sysinfo[100] = { "Unknown" };
+ LONG (WINAPI *pfnRtlGetVersion)(osversioninfoexw*);
+
+ *(FARPROC *)&pfnRtlGetVersion
+ = GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetVersion");
+ if (pfnRtlGetVersion != NULL) {
+ osversioninfoexw ver = { 0 };
+ ver.dwOSVersionInfoSize = sizeof(ver);
+
+ if (pfnRtlGetVersion(&ver) == 0) {
+ if (ver.dwMajorVersion > 6 || (ver.dwMajorVersion == 6 && ver.dwMinorVersion > 3)) {
+ if (ver.wProductType == VER_NT_WORKSTATION)
+ sprintf(sysinfo,"Windows V%d.%d SP %d",
+ ver.dwMajorVersion,ver.dwMinorVersion,
+ ver.wServicePackMajor);
+ else
+ sprintf(sysinfo,"Windows Server 2016 V%d.%d SP %d",
+ ver.dwMajorVersion,ver.dwMinorVersion,
+ ver.wServicePackMajor);
+
+ } else if (ver.dwMajorVersion == 6 && ver.dwMinorVersion == 3) {
+ if (ver.wProductType == VER_NT_WORKSTATION)
+ sprintf(sysinfo,"Windows V8.1 SP %d",
+ ver.wServicePackMajor);
+ else
+ sprintf(sysinfo,"Windows Server 2012 R2 SP %d",
+ ver.wServicePackMajor);
+
+ } else if (ver.dwMajorVersion == 6 && ver.dwMinorVersion == 2) {
+ if (ver.wProductType == VER_NT_WORKSTATION)
+ sprintf(sysinfo,"Windows V8 SP %d",
+ ver.wServicePackMajor);
+ else
+ sprintf(sysinfo,"Windows Server SP %d",
+ ver.wServicePackMajor);
+
+ } else if (ver.dwMajorVersion == 6 && ver.dwMinorVersion == 1) {
+ if (ver.wProductType == VER_NT_WORKSTATION)
+ sprintf(sysinfo,"Windows V7 SP %d",
+ ver.wServicePackMajor);
+ else
+ sprintf(sysinfo,"Windows Server 2008 R2 SP %d",
+ ver.wServicePackMajor);
+
+ } else if (ver.dwMajorVersion == 6 && ver.dwMinorVersion == 0) {
+ if (ver.wProductType == VER_NT_WORKSTATION)
+ sprintf(sysinfo,"Windows Vista SP %d",
+ ver.wServicePackMajor);
+ else
+ sprintf(sysinfo,"Windows Server 2008 SP %d",
+ ver.wServicePackMajor);
+
+ } else if (ver.dwMajorVersion == 5 && ver.dwMinorVersion == 2) {
+ // Actually could be Server 2003, Home Server, Server 2003 R2
+ sprintf(sysinfo,"Windows XP Pro64 SP %d",
+ ver.wServicePackMajor);
+
+ } else if (ver.dwMajorVersion == 5 && ver.dwMinorVersion == 1) {
+ sprintf(sysinfo,"Windows XP SP %d",
+ ver.wServicePackMajor);
+
+ } else if (ver.dwMajorVersion == 5 && ver.dwMinorVersion == 0) {
+ sprintf(sysinfo,"Windows XP SP %d",
+ ver.wServicePackMajor);
+
+ } else {
+ sprintf(sysinfo,"Windows Maj %d Min %d SP %d",
+ ver.dwMajorVersion,ver.dwMinorVersion,
+ ver.wServicePackMajor);
+ }
+ }
+ }
+ return sysinfo;
+}
+
+
# define A1LOG_LOCK(log) \
if (g_log_init == 0) { \
InitializeCriticalSection(&log->lock); \
+ EnterCriticalSection(&log->lock); \
g_log_init = 1; \
- } \
- EnterCriticalSection(&log->lock)
+ va_loge(log, "Argyll 'V%s' Build '%s' System '%s'\n",ARGYLL_VERSION_STR,ARGYLL_BUILD_STR, get_sys_info()); \
+ } else { \
+ EnterCriticalSection(&log->lock); \
+ }
# define A1LOG_UNLOCK(log) LeaveCriticalSection(&log->lock)
#endif
#ifdef UNIX
+
+static char *get_sys_info() {
+ static char sysinfo[200] = { "Unknown" };
+ struct utsname ver;
+
+ if (uname(&ver) == 0)
+ sprintf(sysinfo,"%s %s %s %s",ver.sysname, ver.version, ver.release, ver.machine);
+ return sysinfo;
+}
+
# define A1LOG_LOCK(log) \
if (g_log_init == 0) { \
pthread_mutex_init(&log->lock, NULL); \
+ pthread_mutex_lock(&log->lock); \
g_log_init = 1; \
- } \
- pthread_mutex_lock(&log->lock)
+ va_loge(log, "Argyll 'V%s' Build '%s' System '%s'\n",ARGYLL_VERSION_STR,ARGYLL_BUILD_STR, get_sys_info()); \
+ } else { \
+ pthread_mutex_lock(&log->lock); \
+ }
# define A1LOG_UNLOCK(log) pthread_mutex_unlock(&log->lock)
#endif
@@ -257,6 +380,14 @@ static void a1_default_de_log(void *cntx, a1log *p, char *fmt, va_list args) {
#define a1_default_e_log a1_default_de_log
+/* Call log->loge() with variags */
+static void va_loge(a1log *p, char *fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ p->loge(p->cntx, p, fmt, args);
+ va_end(args);
+}
+
/* Global log */
a1log default_log = {
1, /* Refcount of 1 because this is not allocated or free'd */
@@ -598,6 +729,177 @@ size_t nsize
}
/******************************************************************/
+/* OS X App Nap fixes */
+/******************************************************************/
+
+#if defined(__APPLE__)
+
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
+# include <objc/runtime.h>
+# include <objc/message.h>
+#else
+# include <objc/objc-runtime.h>
+#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
+# include <objc/objc-auto.h>
+#endif
+
+/*
+ OS X 10.9+ App Nap problems bug:
+
+ <http://stackoverflow.com/questions/22784886/what-can-make-nanosleep-drift-with-exactly-10-sec-on-mac-os-x-10-9>
+
+ NSProcessInfo variables:
+
+ <https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSProcessInfo_Class/#//apple_ref/c/tdef/NSActivityOptions>
+
+ typedef enum : uint64_t { NSActivityIdleDisplaySleepDisabled = (1ULL << 40),
+ NSActivityIdleSystemSleepDisabled = (1ULL << 20),
+ NSActivitySuddenTerminationDisabled = (1ULL << 14),
+ NSActivityAutomaticTerminationDisabled = (1ULL << 15),
+ NSActivityUserInitiated = (0x00FFFFFFULL | NSActivityIdleSystemSleepDisabled ),
+ NSActivityUserInitiatedAllowingIdleSystemSleep =
+ (NSActivityUserInitiated & ~NSActivityIdleSystemSleepDisabled ),
+ NSActivityBackground = 0x000000FFULL,
+ NSActivityLatencyCritical = 0xFF00000000ULL,
+ } NSActivityOptions;
+
+ See <http://stackoverflow.com/questions/19847293/disable-app-nap-in-macos-10-9-mavericks-application>:
+
+ @property (strong) id activity;
+
+ if ([[NSProcessInfo processInfo] respondsToSelector:@selector(beginActivityWithOptions:reason:)]) {
+ self.activity = [[NSProcessInfo processInfo] beginActivityWithOptions:0x00FFFFFF reason:@"receiving OSC messages"];
+}
+
+ <http://stackoverflow.com/questions/19671197/disabling-app-nap-with-beginactivitywithoptions>
+
+ NSProcessInfo = interface(NSObject)['{B96935F6-3809-4A49-AD4F-CBBAB0F2C961}']
+ function beginActivityWithOptions(options: NSActivityOptions; reason: NSString): NSObject; cdecl;
+
+ <http://stackoverflow.com/questions/22164571/weird-behaviour-of-dispatch-after>
+
+*/
+
+static int osx_userinitiated_cnt = 0;
+static id osx_userinitiated_activity = nil;
+
+/* Tell App Nap that this is user initiated */
+void osx_userinitiated_start() {
+ Class pic; /* Process info class */
+ SEL pis; /* Process info selector */
+ SEL bawo; /* Begin Activity With Options selector */
+ id pi; /* Process info */
+ id str;
+
+ if (osx_userinitiated_cnt++ != 0)
+ return;
+
+ a1logd(g_log, 7, "OS X - User Initiated Activity start\n");
+
+ /* We have to be conservative to avoid triggering an exception when run on older OS X */
+ if ((pic = (Class)objc_getClass("NSProcessInfo")) == nil) {
+ return;
+ }
+
+ if (class_getClassMethod(pic, (pis = sel_getUid("processInfo"))) == NULL) {
+ return;
+ }
+
+ if (class_getInstanceMethod(pic, (bawo = sel_getUid("beginActivityWithOptions:reason:"))) == NULL) {
+ a1logd(g_log, 7, "OS X - beginActivityWithOptions not supported\n");
+ return;
+ }
+
+ /* Get the process instance */
+ if ((pi = objc_msgSend((id)pic, pis)) == nil) {
+ return;
+ }
+
+ /* Create a reason string */
+ str = objc_msgSend(objc_getClass("NSString"), sel_getUid("alloc"));
+ str = objc_msgSend(str, sel_getUid("initWithUTF8String:"), "ArgyllCMS");
+
+ /* Start activity that tells App Nap to mind its own business. */
+ /* NSActivityUserInitiatedAllowingIdleSystemSleep */
+ osx_userinitiated_activity = objc_msgSend(pi, bawo, 0x00FFFFFFULL, str);
+}
+
+/* Done with user initiated */
+void osx_userinitiated_end() {
+ if (osx_userinitiated_cnt > 0) {
+ osx_userinitiated_cnt--;
+ if (osx_userinitiated_cnt == 0 && osx_userinitiated_activity != nil) {
+ a1logd(g_log, 7, "OS X - User Initiated Activity end");
+ objc_msgSend(
+ objc_msgSend(objc_getClass("NSProcessInfo"), sel_getUid("processInfo")),
+ sel_getUid("endActivity:"), osx_userinitiated_activity);
+ osx_userinitiated_activity = nil;
+ }
+ }
+}
+
+static int osx_latencycritical_cnt = 0;
+static id osx_latencycritical_activity = nil;
+
+/* Tell App Nap that this is latency critical */
+void osx_latencycritical_start() {
+ Class pic; /* Process info class */
+ SEL pis; /* Process info selector */
+ SEL bawo; /* Begin Activity With Options selector */
+ id pi; /* Process info */
+ id str;
+
+ if (osx_latencycritical_cnt++ != 0)
+ return;
+
+ a1logd(g_log, 7, "OS X - Latency Critical Activity start\n");
+
+ /* We have to be conservative to avoid triggering an exception when run on older OS X */
+ if ((pic = (Class)objc_getClass("NSProcessInfo")) == nil) {
+ return;
+ }
+
+ if (class_getClassMethod(pic, (pis = sel_getUid("processInfo"))) == NULL) {
+ return;
+ }
+
+ if (class_getInstanceMethod(pic, (bawo = sel_getUid("beginActivityWithOptions:reason:"))) == NULL) {
+ a1logd(g_log, 7, "OS X - beginActivityWithOptions not supported\n");
+ return;
+ }
+
+ /* Get the process instance */
+ if ((pi = objc_msgSend((id)pic, pis)) == nil) {
+ return;
+ }
+
+ /* Create a reason string */
+ str = objc_msgSend(objc_getClass("NSString"), sel_getUid("alloc"));
+ str = objc_msgSend(str, sel_getUid("initWithUTF8String:"), "Measuring Color");
+
+ /* Start activity that tells App Nap to mind its own business. */
+ /* NSActivityUserInitiatedAllowingIdleSystemSleep | NSActivityLatencyCritical */
+ osx_latencycritical_activity = objc_msgSend(pi, bawo, 0x00FFFFFFULL | 0xFF00000000ULL, str);
+}
+
+/* Done with latency critical */
+void osx_latencycritical_end() {
+ if (osx_latencycritical_cnt > 0) {
+ osx_latencycritical_cnt--;
+ if (osx_latencycritical_cnt == 0 && osx_latencycritical_activity != nil) {
+ a1logd(g_log, 7, "OS X - Latency Critical Activity end");
+ objc_msgSend(
+ objc_msgSend(objc_getClass("NSProcessInfo"), sel_getUid("processInfo")),
+ sel_getUid("endActivity:"), osx_latencycritical_activity);
+ osx_latencycritical_activity = nil;
+ }
+ }
+}
+
+#endif /* __APPLE__ */
+
+/******************************************************************/
/* Numerical Recipes Vector/Matrix Support functions */
/******************************************************************/
/* Note the z suffix versions return zero'd vectors/matricies */
diff --git a/numlib/numsup.h b/numlib/numsup.h
index a284809..366763d 100644..100755
--- a/numlib/numsup.h
+++ b/numlib/numsup.h
@@ -350,6 +350,24 @@ size_t nsize
/* =========================================================== */
+#if defined(__APPLE__)
+
+/* Tell App Nap that this is user initiated */
+void osx_userinitiated_start();
+
+/* Done with user initiated */
+void osx_userinitiated_end();
+
+/* Tell App Nap that this is latency critical */
+void osx_latencycritical_start();
+
+/* Done with latency critical */
+void osx_latencycritical_end();
+
+#endif /* __APPLE__ */
+
+/* =========================================================== */
+
/* Numerical recipes vector/matrix support functions */
/* Note that the index arguments are the inclusive low and high values */
@@ -504,6 +522,7 @@ void write_INR64_le(ORD8 *p, INR64 d);
#ifndef isNan
#define isNan(x) ((x) != (x))
#define isFinite(x) ((x) == 0.0 || (x) * 1.0000001 != (x))
+#define isNFinite(x) ((x) != 0.0 && (x) * 1.0000001 == (x))
#endif
diff --git a/numlib/powell.c b/numlib/powell.c
index 5d2adac..5d2adac 100644..100755
--- a/numlib/powell.c
+++ b/numlib/powell.c
diff --git a/numlib/powell.h b/numlib/powell.h
index a1db8b6..a1db8b6 100644..100755
--- a/numlib/powell.h
+++ b/numlib/powell.h
diff --git a/numlib/rand.c b/numlib/rand.c
index 436de52..436de52 100644..100755
--- a/numlib/rand.c
+++ b/numlib/rand.c
diff --git a/numlib/rand.h b/numlib/rand.h
index 46f79f2..46f79f2 100644..100755
--- a/numlib/rand.h
+++ b/numlib/rand.h
diff --git a/numlib/sobol.c b/numlib/sobol.c
index 40a2c38..40a2c38 100644..100755
--- a/numlib/sobol.c
+++ b/numlib/sobol.c
diff --git a/numlib/sobol.h b/numlib/sobol.h
index 08ac5c0..08ac5c0 100644..100755
--- a/numlib/sobol.h
+++ b/numlib/sobol.h
diff --git a/numlib/soboltest.c b/numlib/soboltest.c
index 32c26ee..32c26ee 100644..100755
--- a/numlib/soboltest.c
+++ b/numlib/soboltest.c
diff --git a/numlib/svd.c b/numlib/svd.c
index fdb8edd..fdb8edd 100644..100755
--- a/numlib/svd.c
+++ b/numlib/svd.c
diff --git a/numlib/svd.h b/numlib/svd.h
index 59b080d..59b080d 100644..100755
--- a/numlib/svd.h
+++ b/numlib/svd.h
diff --git a/numlib/svdtest.c b/numlib/svdtest.c
index 100120d..100120d 100644..100755
--- a/numlib/svdtest.c
+++ b/numlib/svdtest.c
diff --git a/numlib/tdhsx.c b/numlib/tdhsx.c
index d1738c4..d1738c4 100644..100755
--- a/numlib/tdhsx.c
+++ b/numlib/tdhsx.c
diff --git a/numlib/tpowell.c b/numlib/tpowell.c
index f7b0aad..f7b0aad 100644..100755
--- a/numlib/tpowell.c
+++ b/numlib/tpowell.c
diff --git a/numlib/ui.c b/numlib/ui.c
index 31fd3b6..a3cdbe8 100644..100755
--- a/numlib/ui.c
+++ b/numlib/ui.c
@@ -12,7 +12,8 @@
* see the License.txt file for licencing details.
*
* Typically we need to set things up and then call the
- * "normal" main, called "uimain" in ArgyllCMS utils.
+ * "normal" main, called "uimain" in ArgyllCMS utils,
+ * created by ui.h #defining main to uimain.
*/
#ifdef UNIX
@@ -48,6 +49,14 @@
# include <Foundation/Foundation.h>
# include <AppKit/AppKit.h>
+/* (Duplicate declaration from numsup.h) */
+
+/* Tell App Nap that this is user initiated */
+void osx_userinitiated_start();
+
+/* Done with user initiated */
+void osx_userinitiated_end();
+
/* This is a mechanism to force libui to link */
int ui_initialized = 0;
@@ -57,6 +66,9 @@ static char **g_argv;
pthread_t ui_thid = 0; /* Thread ID of main thread running io run loop */
pthread_t ui_main_thid = 0; /* Thread ID of thread running application main() */
+extern int uimain(int argc, char *argv[]);
+
+/* Thread that calls the real application main() */
static void *callMain(void *p) {
int rv;
@@ -64,8 +76,13 @@ static void *callMain(void *p) {
NSAutoreleasePool *tpool = [NSAutoreleasePool new];
+ /* Turn App Nap off */
+ osx_userinitiated_start();
+
rv = uimain(g_argc, g_argv);
+ osx_userinitiated_end();
+
[tpool release];
exit(rv);
@@ -204,6 +221,8 @@ int ui_initialized = 0;
//# pragma comment( linker, "/subsystem:windows /ENTRY:mainCRTStartup" )
//# pragma comment( linker, "/subsystem:windows /ENTRY:WinMainCRTStartup" )
+extern int uimain(int argc, char *argv[]);
+
APIENTRY WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
diff --git a/numlib/ui.h b/numlib/ui.h
index e1d7a58..e1d7a58 100644..100755
--- a/numlib/ui.h
+++ b/numlib/ui.h
diff --git a/numlib/zbrent.c b/numlib/zbrent.c
index a811818..a811818 100644..100755
--- a/numlib/zbrent.c
+++ b/numlib/zbrent.c
diff --git a/numlib/zbrent.h b/numlib/zbrent.h
index 2f8aac4..2f8aac4 100644..100755
--- a/numlib/zbrent.h
+++ b/numlib/zbrent.h
diff --git a/numlib/zbrenttest.c b/numlib/zbrenttest.c
index d7b44d3..d7b44d3 100644..100755
--- a/numlib/zbrenttest.c
+++ b/numlib/zbrenttest.c