Index: src/OpenGLExtensions.C =================================================================== RCS file: /vmd/cvsroot/vmd/src/OpenGLExtensions.C,v retrieving revision 1.80 diff -p -u -r1.80 OpenGLExtensions.C --- src/OpenGLExtensions.C 28 Nov 2016 03:05:02 -0000 1.80 +++ src/OpenGLExtensions.C 2 Dec 2016 13:30:31 -0000 @@ -128,12 +128,11 @@ VMDGLXextFuncPtr OpenGLExtensions::vmdGe // According to the MacOS X documentation, they provide(d) statically // linkable OpenGL extensions tied to to each specific rev of MacOS X. -#if defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) // MacOS X >= 10.4 apps are directed to use the Unix standard - // dlopen() family of routines or to use explicit tests against + // dlopen() family of routines or to use explicit tests against // weak-linked OpenGL API entry points instead. if (gllibraryhandle == NULL) { - // Path to GL on OSX. True for at least versions 10.8 through 10.10.x. + // Path to GL on OSX. True for at least versions 10.8 through 10.12. static const char * glLibPath = "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"; gllibraryhandle = vmddlopen(glLibPath); @@ -142,23 +141,6 @@ VMDGLXextFuncPtr OpenGLExtensions::vmdGe if (gllibraryhandle != NULL) { return (VMDGLXextFuncPtr) vmddlsym(gllibraryhandle, procname); } -#else - // This implementation is based off of the MacOS X developer information - // provided by Apple, circa MacOS X 10.[23]. - // http://developer.apple.com/technotes/tn2002/tn2080.html#TAN55 - // http://developer.apple.com/technotes/tn2002/tn2080.html#TAN28 - NSSymbol symbol; - char *symbolName; - // Prepend a '_' for the Unix C symbol mangling convention - symbolName = (char *) calloc(1, strlen(procname) + 2); - strcpy(symbolName+1, procname); - symbolName[0] = '_'; - symbol = NULL; - if (NSIsSymbolNameDefined(symbolName)) - symbol = NSLookupAndBindSymbol (symbolName); - free(symbolName); - return (VMDGLXextFuncPtr) (symbol ? NSAddressOfSymbol(symbol) : NULL); -#endif #endif #if !defined(_MSC_VER) && !defined(__APPLE__) Index: src/VMDThreads.C =================================================================== RCS file: /vmd/cvsroot/vmd/src/VMDThreads.C,v retrieving revision 1.90 diff -p -u -r1.90 VMDThreads.C --- src/VMDThreads.C 28 Nov 2016 03:05:05 -0000 1.90 +++ src/VMDThreads.C 2 Dec 2016 13:30:31 -0000 @@ -53,12 +53,8 @@ #endif #if defined(__APPLE__) && defined(VMDTHREADS) -#if 1 #include #include /**< OSX >= 10.7 queries sysctl() for CPU count */ -#else -#include /**< Deprecated Carbon APIs for Multiprocessing */ -#endif #endif #if defined(__hpux) @@ -76,7 +72,6 @@ int vmd_thread_numphysprocessors(void) { #ifdef VMDTHREADS #if defined(__APPLE__) -#if 1 int rc; int mib[2]; u_int miblen; @@ -89,9 +84,6 @@ int vmd_thread_numphysprocessors(void) { perror("Error during sysctl() query for CPU count"); a = 1; } -#else - a = MPProcessorsScheduled(); /**< Number of active/running CPUs */ -#endif #endif #ifdef _MSC_VER Index: src/WKFThreads.C =================================================================== RCS file: /vmd/cvsroot/vmd/src/WKFThreads.C,v retrieving revision 1.18 diff -p -u -r1.18 WKFThreads.C --- src/WKFThreads.C 27 Oct 2016 05:03:59 -0000 1.18 +++ src/WKFThreads.C 2 Dec 2016 13:30:32 -0000 @@ -84,12 +84,8 @@ #endif #if defined(__APPLE__) && defined(WKFTHREADS) -#if 1 #include #include /**< OSX >= 10.7 queries sysctl() for CPU count */ -#else -#include /**< Deprecated Carbon APIs for Multiprocessing */ -#endif #endif #if defined(__hpux) @@ -106,7 +102,6 @@ int wkf_thread_numphysprocessors(void) { #ifdef WKFTHREADS #if defined(__APPLE__) -#if 1 int rc; int mib[2]; u_int miblen; @@ -119,9 +114,6 @@ int wkf_thread_numphysprocessors(void) { perror("Error during sysctl() query for CPU count"); a = 1; } -#else - a = MPProcessorsScheduled(); /**< Number of active/running CPUs */ -#endif #endif #ifdef _MSC_VER Index: src/glwin.c =================================================================== RCS file: /vmd/cvsroot/vmd/src/glwin.c,v retrieving revision 1.29 diff -p -u -r1.29 glwin.c --- src/glwin.c 19 Dec 2015 06:28:15 -0000 1.29 +++ src/glwin.c 2 Dec 2016 13:30:32 -0000 @@ -86,11 +86,6 @@ #include #endif -/* not needed with recent OSX 10.9 revs */ -#if 0 && defined(__APPLE__) -#include -#endif - /* required for Win32 calling conventions to work correctly */ #ifndef APIENTRY #define APIENTRY Index: src/macosxvmdstart.C =================================================================== RCS file: /vmd/cvsroot/vmd/src/macosxvmdstart.C,v retrieving revision 1.25 diff -p -u -r1.25 macosxvmdstart.C --- src/macosxvmdstart.C 28 Nov 2016 03:05:07 -0000 1.25 +++ src/macosxvmdstart.C 2 Dec 2016 13:30:32 -0000 @@ -25,66 +25,36 @@ #include /* Carbon APIs for process management */ #include #include +#include #include "utilities.h" /* string/filename manipulation routines */ -OSErr GetApplicationBundleFSSpec(FSSpecPtr theFSSpecPtr) { - OSErr err; - ProcessSerialNumber psn; - err = GetCurrentProcess(&psn); - if (err != noErr) return err; - - FSRef location; - err = GetProcessBundleLocation(&psn, &location); - if (err != noErr) return err; - return FSGetCatalogInfo(&location, kFSCatInfoNone, - NULL, NULL, theFSSpecPtr, NULL); -} - -OSErr GetApplicationPackageFSSpecFromBundle(FSSpecPtr theFSSpecPtr) { - OSErr err = fnfErr; - CFBundleRef myAppsBundle = CFBundleGetMainBundle(); - if (myAppsBundle == NULL) return err; - CFURLRef myBundleURL = CFBundleCopyBundleURL(myAppsBundle); - if (myBundleURL == NULL) return err; - - FSRef myBundleRef; - Boolean ok = CFURLGetFSRef(myBundleURL, &myBundleRef); - CFRelease(myBundleURL); - if (!ok) return err; - - return FSGetCatalogInfo(&myBundleRef, kFSCatInfoNone, - NULL, NULL, theFSSpecPtr, NULL); -} +// Target-specific binary suffix +#if defined(ARCH_MACOSXX86_64) +# define EXE_SUFFIX "_MACOSXX86_64" +#elif defined(ARCH_MACOSXX86) +# define EXE_SUFFIX "_MACOSXX86" +#else +# define EXE_SUFFIX "_MACOSX" +#endif static char * vmd_get_vmddir(void) { - OSErr rc = 0; - FSSpec spec; - FSRef ref; - UInt8 *path = NULL; + char *path = NULL; char *bundledir = NULL; char *vmddir = NULL; char *tmp = NULL; - bundledir = (char *) malloc(2048 * sizeof(UInt8)); - memset(bundledir, 0, 2048 * sizeof(UInt8)); - -#if defined(ARCH_MACOSXX86_64) - // - // CoreFoundation/Cocoa-based application bundle path query code + // + // Use CoreFoundation to get the bundle path // CFBundleRef mainbundle = CFBundleGetMainBundle(); if (mainbundle != NULL) { -#if 1 CFURLRef appurl = CFBundleCopyBundleURL(mainbundle); -#else - CFURLRef appurl = CFBundleCopyExecutableURL(mainbundle); -#endif CFStringRef cfpath = CFURLCopyFileSystemPath(appurl, kCFURLPOSIXPathStyle); - if (CFStringGetFileSystemRepresentation(cfpath, bundledir, 2048 * sizeof(UInt8) - 1) == true) { -// printf("MacOS X Bundle path: %s\n", bundledir); - + CFIndex size = CFStringGetMaximumSizeOfFileSystemRepresentation(cfpath); + bundledir = (char *) malloc(size); + if (CFStringGetFileSystemRepresentation(cfpath, bundledir, size) == true) { // Truncate bundle path to parent bundle directory, // if needed, when the executable is launched by double clicking // the application bundle in the GUI. When the application @@ -106,9 +76,7 @@ static char * vmd_get_vmddir(void) { strcat(bundledir, "/Contents/vmd"); } - - vmddir = (char *) malloc(strlen(bundledir) + 1 + strlen("/vmd")); - strcpy(vmddir, bundledir); + vmddir = strdup(bundledir); } free(bundledir); @@ -121,55 +89,11 @@ static char * vmd_get_vmddir(void) { vmddir = getenv("VMDDIR"); } -#else - - // - // Carbon-based application bundle path query code - // -#if 0 - if (!(rc = GetApplicationPackageFSSpecFromBundle(&spec))) { -#else - if (!(rc = GetApplicationBundleFSSpec(&spec))) { -#endif - rc = FSpMakeFSRef(&spec, &ref); - if (rc) printf("makefsref OSErr: %d\n", rc); - - rc = FSRefMakePath(&ref,(UInt8 *) bundledir, 2048); - if (rc) printf("makepath OSErr: %d\n", rc); - } else { - printf("getappbundlepath OSErr: %d\n", rc); - } - - if (rc) { - free(bundledir); - return NULL; - } - - // truncate bundle path to parent bundle directory - if ((tmp = strrchr(bundledir, '/')) != NULL) { - tmp[0] = '\0'; - } - if ((tmp = strrchr(bundledir, '/')) != NULL) { - tmp[0] = '\0'; - } - - // add "/vmd" to parent bundle directory - vmddir = (char *) malloc(strlen(bundledir) + 1 + strlen("/vmd")); - strcpy(vmddir, bundledir); - strcat(vmddir, "/vmd"); - - free(bundledir); -#endif - - return (char *) vmddir; + return vmddir; } -#if 1 int macosxvmdstart(int argc, char **argv) { -#else -int main(int argc, char **argv) { -#endif char tmp[8192]; char * vmddir; int i; @@ -242,43 +166,24 @@ printf("Executing VMD startup command: % if (!getenv("STRIDE_BIN")) { strcpy(tmp, vmddir); -#if defined(ARCH_MACOSXX86_64) - strcat(tmp, "/stride_MACOSXX86_64"); -#elif defined(ARCH_MACOSXX86) - strcat(tmp, "/stride_MACOSXX86"); -#else - strcat(tmp, "/stride_MACOSX"); -#endif + strcat(tmp, "/stride" EXE_SUFFIX); setenv("STRIDE_BIN", tmp, 1); } if (!getenv("SURF_BIN")) { strcpy(tmp, vmddir); -#if defined(ARCH_MACOSXX86_64) - strcat(tmp, "/surf_MACOSXX86_64"); -#elif defined(ARCH_MACOSXX86) - strcat(tmp, "/surf_MACOSXX86"); -#else - strcat(tmp, "/surf_MACOSX"); -#endif + strcat(tmp, "/surf" EXE_SUFFIX); setenv("SURF_BIN", tmp, 1); } if (!getenv("TACHYON_BIN")) { strcpy(tmp, vmddir); -#if defined(ARCH_MACOSXX86_64) - strcat(tmp, "/tachyon_MACOSXX86_64"); -#elif defined(ARCH_MACOSXX86) - strcat(tmp, "/tachyon_MACOSXX86"); -#else - strcat(tmp, "/tachyon_MACOSX"); -#endif + strcat(tmp, "/tachyon" EXE_SUFFIX); setenv("TACHYON_BIN", tmp, 1); } return 0; } - #endif Index: src/vmddlopen.c =================================================================== RCS file: /vmd/cvsroot/vmd/src/vmddlopen.c,v retrieving revision 1.20 diff -p -u -r1.20 vmddlopen.c --- src/vmddlopen.c 28 Nov 2016 03:05:08 -0000 1.20 +++ src/vmddlopen.c 2 Dec 2016 13:30:32 -0000 @@ -57,58 +57,6 @@ const char *vmddlerror( void ) { return strerror( errno ); } -#elif 0 && defined(__APPLE__) -/* - * This is only needed for MacOS X version 10.3 or older - */ -#include - -void *vmddlopen( const char *path) { - NSObjectFileImage image; - NSObjectFileImageReturnCode retval; - NSModule module; - - retval = NSCreateObjectFileImageFromFile(path, &image); - if (retval != NSObjectFileImageSuccess) - return NULL; - - module = NSLinkModule(image, path, - NSLINKMODULE_OPTION_BINDNOW | NSLINKMODULE_OPTION_PRIVATE - | NSLINKMODULE_OPTION_RETURN_ON_ERROR); - return module; /* module will be NULL on error */ -} - -int vmddlclose( void *handle ) { - NSModule module = (NSModule *)handle; - NSUnLinkModule(module, NSUNLINKMODULE_OPTION_NONE); - return 0; -} - -void *vmddlsym( void *handle, const char *symname ) { - char *realsymname; - NSModule module; - NSSymbol sym; - /* Hack around the leading underscore in the symbol name */ - realsymname = (char *)malloc(strlen(symname)+2); - strcpy(realsymname, "_"); - strcat(realsymname, symname); - module = (NSModule)handle; - sym = NSLookupSymbolInModule(module, realsymname); - free(realsymname); - if (sym) - return (void *)(NSAddressOfSymbol(sym)); - return NULL; -} - -const char *vmddlerror( void ) { - NSLinkEditErrors c; - int errorNumber; - const char *fileName; - const char *errorString = NULL; - NSLinkEditError(&c, &errorNumber, &fileName, &errorString); - return errorString; -} - #elif defined(_MSC_VER) #include @@ -136,7 +84,7 @@ int vmddlclose(void *h) { #else -/* All remaining platforms (not Windows, HP-UX, or MacOS X <= 10.3) */ +/* All remaining platforms (not Windows or HP-UX) */ #include void *vmddlopen(const char *fname) {