Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / inference_engine / w_unistd.h
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #if defined(_WIN32)
8
9 #include <winsock2.h>
10 #include <windows.h>
11 #include <stdlib.h>
12 #include <process.h>
13 #include <direct.h>
14 #include <io.h>
15 #include <chrono>
16
17 #define strncasecmp _strnicmp
18 #define getcwd _getcwd
19 #define fileno _fileno
20
21 #define SecuredGetEnv GetEnvironmentVariableA
22
23 #if defined usleep
24 #undef usleep
25 #endif
26
27 #define usleep(m) std::this_thread::sleep_for(std::chrono::microseconds(m))
28
29 #else
30
31 #include <unistd.h>
32 #include <cstdlib>
33 #include <string.h>
34
35 static inline int SecuredGetEnv(const char *envName, char *buf, int bufLen) {
36     char *pe = getenv(envName);
37     if (!pe) return 0;
38     strncpy(buf, pe, bufLen - 1);
39     buf[bufLen - 1] = 0;
40     return strlen(buf);
41 }
42
43 #endif
44
45