From 75179d8ca1ae977c20a63f8b879041fbd72a6911 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Fri, 3 Mar 2017 06:05:09 -0800 Subject: [PATCH] Mac replace all Mac APIs deprecated in OS 10.10, except in MacAccessibility.mm. Updating the accessibility support will require a complete rewrite to use Apple's new NSAccessibility APIs, which are not available on systems prior to OS 10.10, while retaining the current code for use with older versions of OS X. This will require far more time and effort than I can spend at this time. Note also that Apple has deprecated the UNIX standard call system(const char *) as ofd OS 10.10 and says to use posix_spawn() calls instead. I have added a macro to the precompiled header MacGUI.pch for the Manager builds that converts the calls automatically, but have not been able to do so for the other BOINC modules. If future code in the client, libraries, etc. calls system(), this will have to be handled on a case by case basis, as I have done in boinc_rename_aux() in lib/filesys.cpp and CLIENT_STATE::write_state_file() in client/cs_statefile.cpp. --- client/cs_statefile.cpp | 8 +++++++- clientgui/mac/MacGUI.pch | 2 +- lib/filesys.cpp | 10 ++++++++++ mac_build/boinc.xcodeproj/project.pbxproj | 16 ++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/client/cs_statefile.cpp b/client/cs_statefile.cpp index cf3c4faf31..5aba5ddbc9 100644 --- a/client/cs_statefile.cpp +++ b/client/cs_statefile.cpp @@ -24,6 +24,10 @@ #include #endif +#ifdef __APPLE__ +#include "mac_spawn.h" +#endif + #ifdef _MSC_VER #define snprintf _snprintf #endif @@ -694,7 +698,9 @@ int CLIENT_STATE::write_state_file() { ); #elif defined (__APPLE__) if (log_flags.statefile_debug) { - system("ls -al /Library/Application\\ Support/BOINC\\ Data/client*.*"); + // system() is deprecated in Mac OS 10.10. + // Apple says to call posix_spawn instead. + callPosixSpawn("ls -al /Library/Application\\ Support/BOINC\\ Data/client*.*"); } #endif } diff --git a/clientgui/mac/MacGUI.pch b/clientgui/mac/MacGUI.pch index a660263d81..f2cebf20f5 100644 --- a/clientgui/mac/MacGUI.pch +++ b/clientgui/mac/MacGUI.pch @@ -1,6 +1,6 @@ // This file is part of BOINC. // http://boinc.berkeley.edu -// Copyright (C) 2013 University of California +// Copyright (C) 2017 University of California // // BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License diff --git a/lib/filesys.cpp b/lib/filesys.cpp index 1156682acd..fca96fe7c2 100644 --- a/lib/filesys.cpp +++ b/lib/filesys.cpp @@ -76,6 +76,10 @@ #include "filesys.h" +#ifdef __APPLE__ +#include "mac_spawn.h" +#endif + #ifdef _WIN32 typedef BOOL (CALLBACK* FreeFn)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); #endif @@ -682,7 +686,13 @@ static int boinc_rename_aux(const char* old, const char* newf) { if (retval) { char buf[MAXPATHLEN+MAXPATHLEN]; sprintf(buf, "mv \"%s\" \"%s\"", old, newf); +#ifdef __APPLE__ + // system() is deprecated in Mac OS 10.10. + // Apple says to call posix_spawn instead. + retval = callPosixSpawn(buf); +#else retval = system(buf); +#endif } if (retval) return ERR_RENAME; return 0; diff --git a/mac_build/boinc.xcodeproj/project.pbxproj b/mac_build/boinc.xcodeproj/project.pbxproj index 7cbd1e3b1f..ce7ce49624 100644 --- a/mac_build/boinc.xcodeproj/project.pbxproj +++ b/mac_build/boinc.xcodeproj/project.pbxproj @@ -315,6 +315,12 @@ DD8917F00F3B21DA00DE5B1C /* mac_icon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD6381450870DB78007A2F8E /* mac_icon.cpp */; }; DD957E5B181B908800ECA34E /* thumbnail.png in Resources */ = {isa = PBXBuildFile; fileRef = DD957E59181B908800ECA34E /* thumbnail.png */; }; DD957E5C181B908800ECA34E /* thumbnail@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DD957E5A181B908800ECA34E /* thumbnail@2x.png */; }; + DD9917251E69A4F100555337 /* mac_spawn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD2C5C3D1E66D83D00BF5511 /* mac_spawn.cpp */; }; + DD9917261E69A8B300555337 /* mac_spawn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD2C5C3D1E66D83D00BF5511 /* mac_spawn.cpp */; }; + DD9917271E69A8D100555337 /* mac_spawn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD2C5C3D1E66D83D00BF5511 /* mac_spawn.cpp */; }; + DD9917281E69A90500555337 /* mac_spawn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD2C5C3D1E66D83D00BF5511 /* mac_spawn.cpp */; }; + DD9917291E69A90800555337 /* mac_spawn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD2C5C3D1E66D83D00BF5511 /* mac_spawn.cpp */; }; + DD99172A1E69A92A00555337 /* mac_spawn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD2C5C3D1E66D83D00BF5511 /* mac_spawn.cpp */; }; DD9AB0340EB7D5DE00AF1616 /* rr_sim.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD9AB0320EB7D5DE00AF1616 /* rr_sim.cpp */; }; DD9E560F182D0D40002AF0F8 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD9E560E182D0D40002AF0F8 /* WebKit.framework */; }; DDA0C8350FE1D704001E02E6 /* procinfo_mac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DDB6934F0ABFE9C600689FD8 /* procinfo_mac.cpp */; }; @@ -2896,6 +2902,7 @@ DD407A6907D2FBC200163EF5 /* proxy_info.cpp in Sources */, DD407A6B07D2FBC700163EF5 /* shmem.cpp in Sources */, DD4329910BA63DEC007CDF2A /* str_util.cpp in Sources */, + DD9917251E69A4F100555337 /* mac_spawn.cpp in Sources */, DD30CAD01C6B3CCB00AE1D14 /* project_init.cpp in Sources */, DDA45500140F7DE200D97676 /* synch.cpp in Sources */, DDC06AB410A3E93F00C8D9A5 /* url.cpp in Sources */, @@ -2917,6 +2924,7 @@ buildActionMask = 2147483647; files = ( DDE813221770479C0068A770 /* translate.cpp in Sources */, + DD9917291E69A90800555337 /* mac_spawn.cpp in Sources */, DDB9EA9717BE2C0D00651B07 /* filesys.cpp in Sources */, DDB9EA9C17BE2C7100651B07 /* util.cpp in Sources */, DDF5E23318B8673E005DEA6E /* uninstall.cpp in Sources */, @@ -3015,6 +3023,7 @@ DD8916950F3B1BFF00DE5B1C /* mac_backtrace.cpp in Sources */, DD8916960F3B1C0000DE5B1C /* QBacktrace.c in Sources */, DD8916970F3B1C0100DE5B1C /* QCrashReport.c in Sources */, + DD9917281E69A90500555337 /* mac_spawn.cpp in Sources */, DD8916980F3B1C0200DE5B1C /* QMachOImage.c in Sources */, DD89169A0F3B1C0600DE5B1C /* QMachOImageList.c in Sources */, DD89169B0F3B1C0700DE5B1C /* QSymbols.c in Sources */, @@ -3060,6 +3069,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + DD9917271E69A8D100555337 /* mac_spawn.cpp in Sources */, DDFD5F0F0818F2EE002B23D4 /* gui_rpc_client.cpp in Sources */, DDE900261E643E39003728F2 /* mac_util.mm in Sources */, DD73E3B608A07FC600656EB1 /* gui_rpc_client_ops.cpp in Sources */, @@ -3123,6 +3133,7 @@ DDE586AC10FC8E6900DFA887 /* str_util.cpp in Sources */, DDE586AF10FC8E7B00DFA887 /* proxy_info.cpp in Sources */, DDE586B010FC8E9100DFA887 /* coproc.cpp in Sources */, + DD99172A1E69A92A00555337 /* mac_spawn.cpp in Sources */, DDE586B310FC8E9B00DFA887 /* mfile.cpp in Sources */, DD3741D610FC948C001257EB /* filesys.cpp in Sources */, DD3741D910FC94BA001257EB /* url.cpp in Sources */, @@ -3250,6 +3261,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + DD9917261E69A8B300555337 /* mac_spawn.cpp in Sources */, DDFA60E40CB3396C0037B88C /* gfx_switcher.cpp in Sources */, DDFA61520CB347500037B88C /* app_ipc.cpp in Sources */, DDFA61570CB347730037B88C /* filesys.cpp in Sources */, @@ -4120,6 +4132,7 @@ DDD095420A3EDD4300C95BA4 /* Development */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ../lib/mac; PRODUCT_NAME = switcher; }; name = Development; @@ -4127,6 +4140,7 @@ DDD095450A3EDD4300C95BA4 /* Deployment */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ../lib/mac; PRODUCT_NAME = switcher; }; name = Deployment; @@ -4168,6 +4182,7 @@ DDFA60CE0CB337D40037B88C /* Development */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ../lib/mac; OTHER_CFLAGS = ( "-D_THREAD_SAFE", "-D_DEBUG", @@ -4182,6 +4197,7 @@ DDFA60D20CB337D40037B88C /* Deployment */ = { isa = XCBuildConfiguration; buildSettings = { + HEADER_SEARCH_PATHS = ../lib/mac; OTHER_CFLAGS = ( "-D_THREAD_SAFE", "-DNDEBUG",