Skip to content
Snippets Groups Projects
Commit 95c8f764 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Fix warning on macos from usage of deprecated Gestalt API

parent ba841b78
No related branches found
No related tags found
No related merge requests found
Showing
with 138 additions and 40 deletions
......@@ -254,6 +254,11 @@ set(llcommon_HEADER_FILES
StackWalker.h
)
if (DARWIN)
list(APPEND llcommon_HEADER_FILES llsys_objc.h)
list(APPEND llcommon_SOURCE_FILES llsys_objc.mm)
endif (DARWIN)
set_source_files_properties(${llcommon_HEADER_FILES}
PROPERTIES HEADER_FILE_ONLY TRUE)
......
......@@ -62,6 +62,7 @@ using namespace llsd;
# include <psapi.h> // GetPerformanceInfo() et al.
# include <VersionHelpers.h>
#elif LL_DARWIN
# include "llsys_objc.h"
# include <errno.h>
# include <sys/sysctl.h>
# include <sys/utsname.h>
......@@ -72,12 +73,6 @@ using namespace llsd;
# include <mach/mach_host.h>
# include <mach/task.h>
# include <mach/task_info.h>
// disable warnings about Gestalt calls being deprecated
// until Apple get's on the ball and provides an alternative
//
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif LL_LINUX
# include <errno.h>
# include <sys/utsname.h>
......@@ -301,21 +296,18 @@ LLOSInfo::LLOSInfo() :
#elif LL_DARWIN
// Initialize mOSStringSimple to something like:
// "Mac OS X 10.6.7"
// "macOS 10.6.7"
{
const char * DARWIN_PRODUCT_NAME = "Mac OS X";
SInt32 major_version, minor_version, bugfix_version;
OSErr r1 = Gestalt(gestaltSystemVersionMajor, &major_version);
OSErr r2 = Gestalt(gestaltSystemVersionMinor, &minor_version);
OSErr r3 = Gestalt(gestaltSystemVersionBugFix, &bugfix_version);
S32 major_version, minor_version, bugfix_version = 0;
if((r1 == noErr) && (r2 == noErr) && (r3 == noErr))
if (LLSysDarwin::getOperatingSystemInfo(major_version, minor_version, bugfix_version))
{
mMajorVer = major_version;
mMinorVer = minor_version;
mBuild = bugfix_version;
const char * DARWIN_PRODUCT_NAME = "macOS";
std::stringstream os_version_string;
os_version_string << DARWIN_PRODUCT_NAME << " " << mMajorVer << "." << mMinorVer << "." << mBuild;
......@@ -329,7 +321,7 @@ LLOSInfo::LLOSInfo() :
}
// Initialize mOSString to something like:
// "Mac OS X 10.6.7 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386"
// "macOS 10.6.7 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386"
struct utsname un;
if(uname(&un) != -1)
{
......@@ -988,9 +980,15 @@ LLSD LLMemoryInfo::loadStatsMap()
stats.add("PrivateUsage KB", pmem.PrivateUsage/div);
#elif LL_DARWIN
const vm_size_t pagekb(vm_page_size / 1024);
vm_size_t page_size_kb;
if (host_page_size(mach_host_self(), &page_size_kb) != KERN_SUCCESS)
{
LL_WARNS() << "Unable to get host page size. Using default value." << LL_ENDL;
page_size_kb = 4096;
}
page_size_kb = page_size_kb / 1024;
//
// Collect the vm_stat's
//
......@@ -1005,10 +1003,10 @@ LLSD LLMemoryInfo::loadStatsMap()
}
else
{
stats.add("Pages free KB", pagekb * vmstat.free_count);
stats.add("Pages active KB", pagekb * vmstat.active_count);
stats.add("Pages inactive KB", pagekb * vmstat.inactive_count);
stats.add("Pages wired KB", pagekb * vmstat.wire_count);
stats.add("Pages free KB", page_size_kb * vmstat.free_count);
stats.add("Pages active KB", page_size_kb * vmstat.active_count);
stats.add("Pages inactive KB", page_size_kb * vmstat.inactive_count);
stats.add("Pages wired KB", page_size_kb * vmstat.wire_count);
stats.add("Pages zero fill", vmstat.zero_fill_count);
stats.add("Page reactivations", vmstat.reactivations);
......@@ -1073,13 +1071,6 @@ LLSD LLMemoryInfo::loadStatsMap()
}
}
#elif LL_SOLARIS
U64 phys = 0;
phys = (U64)(sysconf(_SC_PHYS_PAGES)) * (U64)(sysconf(_SC_PAGESIZE)/1024);
stats.add("Total Physical KB", phys);
#elif LL_LINUX
llifstream meminfo(MEMINFO_FILE);
if (meminfo.is_open())
......@@ -1392,10 +1383,3 @@ BOOL gzip_file(const std::string& srcfile, const std::string& dstfile)
if (dst != NULL) gzclose(dst);
return retval;
}
#if LL_DARWIN
// disable warnings about Gestalt calls being deprecated
// until Apple get's on the ball and provides an alternative
//
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
/*
* @file llsys_objc.h
* @brief Some objective-c crap for llcommon
*
* (C) 2014 Cinder Roxley @ Second Life <cinder@alchemyviewer.org>
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef LL_SYS_OBJC_H
#define LL_SYS_OBJC_H
#ifndef LL_DARWIN
# error "This file should only be included when building on mac!"
#else
namespace LLSysDarwin
{
bool getOperatingSystemInfo(int &major, int &minor, int &patch);
const char* getPreferredLanguage();
}
#endif // !LL_DARWIN
#endif // LL_SYS_OBJC_H
/*
* @file llsys_objc.mm
* @brief Some objective-c crap for llcommon
*
* (C) 2014 Cinder Roxley @ Second Life <cinder@alchemyviewer.org>
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef LL_DARWIN
# error "This file should only be included when building on mac!"
#else
#import "llsys_objc.h"
#import <Foundation/Foundation.h>
#import <AppKit/NSApplication.h>
bool LLSysDarwin::getOperatingSystemInfo(int &major, int &minor, int &patch)
{
NSOperatingSystemVersion osVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
major = osVersion.majorVersion;
minor = osVersion.minorVersion;
patch = osVersion.patchVersion;
return true;
}
const char* LLSysDarwin::getPreferredLanguage()
{
NSString* lang = [[NSLocale preferredLanguages] objectAtIndex:0];
const char* ret = [lang cStringUsingEncoding:NSASCIIStringEncoding];
return ret;
}
#endif // !LL_DARWIN
......@@ -5,7 +5,8 @@
<!-- Locale Information -->
<string name="MicrosoftLocale">danish</string>
<string name="MacLocale">da_DK.UTF-8</string>
<string name="DarwinLocale">da_DK.UTF-8</string>
<string name="macOSLocale">da_DK.UTF-8</string>
<string name="DarwinLocale">da_DK.UTF-8</string>
<string name="LinuxLocale">da_DK.UTF-8</string>
<!--
......
......@@ -5,6 +5,7 @@
<!-- Locale Information -->
<string name="MicrosoftLocale">german</string>
<string name="MacLocale">de_DE.UTF-8</string>
<string name="macOSLocale">de_DE.UTF-8</string>
<string name="DarwinLocale">de_DE.UTF-8</string>
<string name="LinuxLocale">de_DE.UTF-8</string>
......
......@@ -5,6 +5,7 @@
<!-- Locale Information -->
<string name="MicrosoftLocale">english</string>
<string name="MacLocale">C</string>
<string name="macOSLocale">C</string>
<string name="DarwinLocale">C</string>
<string name="LinuxLocale">C</string>
......
......@@ -5,6 +5,7 @@
<!-- Locale Information -->
<string name="MicrosoftLocale">spanish</string>
<string name="MacLocale">es_ES.UTF-8</string>
<string name="macOSLocale">es_ES.UTF-8</string>
<string name="DarwinLocale">es_ES.UTF-8</string>
<string name="LinuxLocale">es_ES.UTF-8</string>
......
......@@ -5,7 +5,8 @@
<!-- Locale Information -->
<string name="MicrosoftLocale">french</string>
<string name="MacLocale">fr_FR.UTF-8</string>
<string name="DarwinLocale">fr_FR.UTF-8</string>
<string name="macOSLocale">fr_FR.UTF-8</string>
<string name="DarwinLocale">fr_FR.UTF-8</string>
<string name="LinuxLocale">fr_FR.UTF-8</string>
<!--
......
......@@ -5,7 +5,8 @@
<!-- Locale Information -->
<string name="MicrosoftLocale">italian</string>
<string name="MacLocale">it_IT.UTF-8</string>
<string name="DarwinLocale">it_IT.UTF-8</string>
<string name="macOSLocale">it_IT.UTF-8</string>
<string name="DarwinLocale">it_IT.UTF-8</string>
<string name="LinuxLocale">it_IT.UTF-8</string>
<!--
......
......@@ -5,7 +5,8 @@
<!-- Locale Information -->
<string name="MicrosoftLocale">japanese</string>
<string name="MacLocale">ja_JP.UTF-8</string>
<string name="DarwinLocale">ja_JP.UTF-8</string>
<string name="macOSLocale">ja_JP.UTF-8</string>
<string name="DarwinLocale">ja_JP.UTF-8</string>
<string name="LinuxLocale">ja_JP.UTF-8</string>
<!--
......
......@@ -2,7 +2,8 @@
<strings>
<string name="MicrosoftLocale">polish</string>
<string name="MacLocale">pl_PL.UTF-8</string>
<string name="DarwinLocale">pl_PL.UTF-8</string>
<string name="macOSLocale">pl_PL.UTF-8</string>
<string name="DarwinLocale">pl_PL.UTF-8</string>
<string name="LinuxLocale">pl_PL.UTF-8</string>
<string name="TimeHour">hour,datetime,slt</string>
<string name="TimeMin">min,datetime,slt</string>
......
......@@ -5,6 +5,7 @@
<!-- Locale Information -->
<string name="MicrosoftLocale">portuguese</string>
<string name="MacLocale">pt_PT.UTF-8</string>
<string name="macOSLocale">pt_PT.UTF-8</string>
<string name="DarwinLocale">pt_PT.UTF-8</string>
<string name="LinuxLocale">pt_PT.UTF-8</string>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment