!10698 [MD][MAC] Fix MAC compile problem

From: @xiefangqi
Reviewed-by: @heleiwang,@pandoublefeng
Signed-off-by: @pandoublefeng
This commit is contained in:
mindspore-ci-bot 2020-12-28 19:29:32 +08:00 committed by Gitee
commit 27ce376ec8
9 changed files with 18 additions and 18 deletions

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
#include "minddata/dataset/engine/cache/cache_request.h"
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
#include <sched.h>
#include <sys/types.h>
#include <unistd.h>

View File

@ -16,7 +16,7 @@
#include "minddata/dataset/util/services.h"
#include <limits.h>
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
#include <sys/syscall.h>
#else
#include <stdlib.h>
@ -39,7 +39,7 @@ std::map<std::string, uint64_t> Services::unique_id_list_ = {};
uint64_t Services::unique_id_count_ = 0;
std::mutex Services::unique_id_mutex_;
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
std::string Services::GetUserName() {
char user[LOGIN_NAME_MAX];
(void)getlogin_r(user, sizeof(user));

View File

@ -66,7 +66,7 @@ class Services {
std::shared_ptr<MemoryPool> GetServiceMemPool() { return pool_; }
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
static std::string GetUserName();
static std::string GetHostName();

View File

@ -25,7 +25,7 @@
namespace mindspore {
namespace dataset {
// Register the custom signal handlers
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
void RegisterHandlers() {
struct sigaction new_int_action;

View File

@ -22,7 +22,7 @@
namespace mindspore {
namespace dataset {
// Register the custom signal handlers
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
extern void RegisterHandlers();
// A signal handler for SIGINT. Drives interrupt to watchdog

View File

@ -42,7 +42,7 @@ void Task::operator()() {
#endif
MS_LOG(DEBUG) << my_name_ << " Thread ID " << ss.str() << " Started.";
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
native_handle_ = pthread_self();
#endif
@ -200,7 +200,7 @@ Status Task::OverrideInterruptRc(const Status &rc) {
return rc;
}
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
pthread_t Task::GetNativeHandle() const { return native_handle_; }
#endif

View File

@ -16,7 +16,7 @@
#ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_H_
#define MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_H_
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
#include <pthread.h>
#endif
#include <chrono>
@ -100,7 +100,7 @@ class Task : public IntrpResource {
static Status OverrideInterruptRc(const Status &rc);
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
pthread_t GetNativeHandle() const;
#endif
@ -120,7 +120,7 @@ class Task : public IntrpResource {
volatile bool running_;
volatile bool caught_severe_exception_;
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
pthread_t native_handle_;
#else
uint64_t native_handle_;

View File

@ -124,7 +124,7 @@ TaskManager::TaskManager() try : global_interrupt_(0),
master_->is_master_ = true;
#if !defined(_WIN32) && !defined(_WIN64)
gMyTask = master_.get();
#if !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
// Initialize the semaphore for the watchdog
errno_t rc = sem_init(&sem_, 0, 0);
if (rc == -1) {
@ -147,14 +147,14 @@ TaskManager::~TaskManager() {
watchdog_grp_ = nullptr;
watchdog_ = nullptr;
}
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
(void)sem_destroy(&sem_);
#endif
}
Status TaskManager::DoServiceStart() {
MS_LOG(INFO) << "Starting Task Manager.";
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
// Create a watchdog for control-c
std::shared_ptr<MemoryPool> mp = Services::GetInstance().GetServiceMemPool();
// A dummy group just for the watchdog. We aren't really using it. But most code assumes a thread must
@ -183,7 +183,7 @@ Status TaskManager::DoServiceStop() {
Status TaskManager::WatchDog() {
TaskManager::FindMe()->Post();
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
errno_t err = sem_wait(&sem_);
if (err == -1) {
RETURN_STATUS_UNEXPECTED("Errno = " + std::to_string(errno));

View File

@ -16,7 +16,7 @@
#ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_MANAGER_H_
#define MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_MANAGER_H_
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
#include <semaphore.h>
#include <signal.h> // for sig_atomic_t
#endif
@ -92,7 +92,7 @@ class TaskManager : public Service {
static void InterruptMaster(const Status &rc = Status::OK());
static void WakeUpWatchDog() {
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
TaskManager &tm = TaskManager::GetInstance();
(void)sem_post(&tm.sem_);
#endif
@ -113,7 +113,7 @@ class TaskManager : public Service {
std::shared_ptr<Task> master_;
List<Task> lru_;
List<Task> free_lst_;
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
sem_t sem_;
#endif
TaskGroup *watchdog_grp_;