1// 2// Copyright 2015 The ANGLE Project Authors. All rights reserved. 3// Use of this source code is governed by a BSD-style license that can be 4// found in the LICENSE file. 5// 6 7// system_utils_ios.mm: Implementation of iOS-specific functions for OSX 8 9#include "system_utils.h" 10 11#include <unistd.h> 12 13#include <CoreServices/CoreServices.h> 14#include <mach-o/dyld.h> 15#include <mach/mach.h> 16#include <mach/mach_time.h> 17#include <array> 18#include <cstdlib> 19#include <vector> 20 21#import <Foundation/Foundation.h> 22 23namespace angle 24{ 25std::string GetExecutablePath() 26{ 27 28 NSString *executableString = [[NSBundle mainBundle] executablePath]; 29 std::string result([executableString UTF8String]); 30 return result; 31} 32 33std::string GetExecutableDirectory() 34{ 35 std::string executablePath = GetExecutablePath(); 36 size_t lastPathSepLoc = executablePath.find_last_of("/"); 37 return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : ""; 38} 39 40const char *GetSharedLibraryExtension() 41{ 42 return "dylib"; 43} 44 45double GetCurrentTime() 46{ 47 mach_timebase_info_data_t timebaseInfo; 48 mach_timebase_info(&timebaseInfo); 49 50 double secondCoeff = timebaseInfo.numer * 1e-9 / timebaseInfo.denom; 51 return secondCoeff * mach_absolute_time(); 52} 53} // namespace angle 54