Windows cleanup (#9508)

* Remove unneeded code for Windows

* Get rid of usleep()

* Make platform_shims includes non-transitive

Co-authored-by: Mehrdad <noreply@github.com>
This commit is contained in:
mehrdadn 2020-07-17 02:08:15 -07:00 committed by GitHub
parent 22a5c3d3ee
commit 37942ea1e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 84 additions and 292 deletions

View file

@ -341,7 +341,6 @@ cc_library(
deps = [
":object_manager_fbs",
":plasma_fbs",
":platform_shims",
":ray_common",
":ray_util",
"@arrow",
@ -415,7 +414,6 @@ cc_library(
deps = [
":ae",
":plasma_client",
":platform_shims",
"@com_github_google_glog//:glog",
],
)
@ -429,7 +427,6 @@ cc_binary(
visibility = ["//visibility:public"],
deps = [
":plasma_store_server_lib",
":platform_shims",
],
)
@ -1359,11 +1356,9 @@ cc_library(
"//conditions:default": [],
}),
copts = COPTS,
includes = [] + select({
"@bazel_tools//src/conditions:windows": [
"src/shims/windows",
],
"//conditions:default": [],
strip_include_prefix = select({
"@bazel_tools//src/conditions:windows": "src/shims/windows",
"//conditions:default": "",
}),
visibility = ["//visibility:public"],
)
@ -1387,7 +1382,6 @@ cc_library(
],
visibility = ["//visibility:public"],
deps = [
":platform_shims",
":sha256",
"@boost//:asio",
"@com_github_google_glog//:glog",

View file

@ -44,7 +44,6 @@ cc_library(
include_prefix = "hiredis",
deps = [
":_hiredis",
"@//:platform_shims",
],
visibility = ["//visibility:public"],
)

View file

@ -53,7 +53,7 @@ int TestSetupUtil::StartUpRedisServer(const int &port) {
cmdargs.insert(cmdargs.end(), {"--port", std::to_string(actual_port)});
RAY_LOG(INFO) << "Start redis command is: " << CreateCommandLine(cmdargs);
RAY_CHECK(!Process::Spawn(cmdargs, true).second);
usleep(200 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
return actual_port;
}
@ -71,7 +71,7 @@ void TestSetupUtil::ShutDownRedisServer(const int &port) {
if (Process::Call(cmdargs) != std::error_code()) {
RAY_LOG(WARNING) << "Failed to stop redis. The redis process may no longer exist.";
}
usleep(100 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
void TestSetupUtil::FlushAllRedisServers() {
@ -87,7 +87,7 @@ void TestSetupUtil::FlushRedisServer(const int &port) {
if (Process::Call(cmdargs)) {
RAY_LOG(WARNING) << "Failed to flush redis. The redis process may no longer exist.";
}
usleep(100 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
std::string TestSetupUtil::StartObjectStore(
@ -104,7 +104,7 @@ std::string TestSetupUtil::StartObjectStore(
{TEST_STORE_EXEC_PATH, "-m", "10000000", "-s", store_socket_name});
RAY_LOG(DEBUG) << CreateCommandLine(cmdargs);
RAY_CHECK(!Process::Spawn(cmdargs, true, store_socket_name + ".pid").second);
usleep(200 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
return store_socket_name;
}
@ -120,7 +120,7 @@ std::string TestSetupUtil::StartGcsServer(const std::string &redis_address) {
"--config_list=initial_reconstruction_timeout_milliseconds,2000"});
RAY_LOG(INFO) << "Start gcs server command: " << CreateCommandLine(cmdargs);
RAY_CHECK(!Process::Spawn(cmdargs, true, gcs_server_socket_name + ".pid").second);
usleep(200 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
RAY_LOG(INFO) << "GCS server started.";
return gcs_server_socket_name;
}
@ -149,7 +149,7 @@ std::string TestSetupUtil::StartRaylet(const std::string &store_socket_name,
"--config_list=initial_reconstruction_timeout_milliseconds,2000"});
RAY_LOG(DEBUG) << "Raylet Start command: " << CreateCommandLine(cmdargs);
RAY_CHECK(!Process::Spawn(cmdargs, true, raylet_socket_name + ".pid").second);
usleep(200 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
return raylet_socket_name;
}
@ -166,7 +166,7 @@ bool WaitForCondition(std::function<bool()> condition, int timeout_ms) {
// sleep 10ms.
const int wait_interval_ms = 10;
usleep(wait_interval_ms * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(wait_interval_ms));
wait_time += wait_interval_ms;
if (wait_time > timeout_ms) {
break;

View file

@ -710,7 +710,7 @@ TEST_F(SingleNodeTest, TestMemoryStoreProvider) {
provider.Delete(ids_set, &plasma_object_ids);
ASSERT_TRUE(plasma_object_ids.empty());
usleep(200 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
ASSERT_TRUE(provider.Get(ids_set, 0, ctx, &results, &got_exception).IsTimedOut());
ASSERT_TRUE(!got_exception);
ASSERT_EQ(results.size(), 0);
@ -725,7 +725,7 @@ TEST_F(SingleNodeTest, TestMemoryStoreProvider) {
}
auto thread_func = [&unready_ids, &provider, &buffers]() {
sleep(1);
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
for (size_t i = 0; i < unready_ids.size(); i++) {
RAY_CHECK(provider.Put(buffers[i], unready_ids[i]));
@ -821,7 +821,7 @@ TEST_F(SingleNodeTest, TestObjectInterface) {
// Note that Delete() calls RayletClient::FreeObjects and would not
// wait for objects being deleted, so wait a while for plasma store
// to process the command.
usleep(200 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
ASSERT_TRUE(core_worker.Get(ids, 0, &results).ok());
// Since array2 has been deleted from the plasma store, the Get should
// return UnreconstructableError for all results.

View file

@ -921,7 +921,8 @@ TEST(DirectTaskTransportTest, TestWorkerLeaseTimeout) {
// Task 2 runs successfully on the second worker; the worker is returned due to the
// timeout.
ASSERT_TRUE(raylet_client->GrantWorkerLease("localhost", 1001, ClientID::Nil()));
usleep(10 * 1000); // Sleep for 10ms, causing the lease to time out.
std::this_thread::sleep_for(
std::chrono::milliseconds(10)); // Sleep for 10ms, causing the lease to time out.
ASSERT_TRUE(worker_client->ReplyPushTask());
ASSERT_EQ(raylet_client->num_workers_returned, 1);
ASSERT_EQ(raylet_client->num_workers_disconnected, 1);

View file

@ -112,8 +112,8 @@ bool ServiceBasedGcsClient::GetGcsServerAddressFromRedis(
num_attempts++;
if (num_attempts < max_attempts) {
usleep(RayConfig::instance().internal_gcs_service_connect_wait_milliseconds() *
1000);
std::this_thread::sleep_for(std::chrono::milliseconds(
RayConfig::instance().internal_gcs_service_connect_wait_milliseconds()));
}
}
@ -194,7 +194,8 @@ void ServiceBasedGcsClient::ReconnectGcsServer() {
break;
}
}
usleep(RayConfig::instance().ping_gcs_rpc_server_interval_milliseconds() * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(
RayConfig::instance().ping_gcs_rpc_server_interval_milliseconds()));
}
if (index < RayConfig::instance().ping_gcs_rpc_server_max_retries()) {

View file

@ -623,7 +623,7 @@ TEST_F(ServiceBasedGcsClientTest, TestNodeInfo) {
// Register local node to GCS.
ASSERT_TRUE(RegisterSelf(*gcs_node1_info));
sleep(1);
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
EXPECT_EQ(gcs_client_->Nodes().GetSelfId(), node1_id);
EXPECT_EQ(gcs_client_->Nodes().GetSelfInfo().node_id(), gcs_node1_info->node_id());
EXPECT_EQ(gcs_client_->Nodes().GetSelfInfo().state(), gcs_node1_info->state());
@ -735,7 +735,7 @@ TEST_F(ServiceBasedGcsClientTest, TestTaskInfo) {
ASSERT_TRUE(AddTask(task_table_data));
// Assert unsubscribe succeeded.
usleep(100 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
EXPECT_EQ(task_count, 1);
// Delete tasks from GCS.
@ -764,7 +764,7 @@ TEST_F(ServiceBasedGcsClientTest, TestTaskInfo) {
ASSERT_TRUE(AddTaskLease(task_lease));
// Assert unsubscribe succeeded.
usleep(100 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
EXPECT_EQ(task_lease_count, 2);
// Attempt task reconstruction to GCS.
@ -815,7 +815,7 @@ TEST_F(ServiceBasedGcsClientTest, TestObjectInfo) {
ASSERT_TRUE(AddLocation(object_id, node_id));
// Assert unsubscribe succeeded.
usleep(100 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
ASSERT_EQ(object_add_count, 1);
}
@ -972,7 +972,7 @@ TEST_F(ServiceBasedGcsClientTest, TestObjectTableResubscribe) {
// Cancel subscription to any update of an object's location.
UnsubscribeToLocations(object1_id);
usleep(100 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// Restart GCS.
RestartGcsServer();

View file

@ -126,7 +126,7 @@ TEST_F(GcsPubSubTest, TestPubSubApi) {
WaitPendingDone(all_result, 1);
Unsubscribe(channel, id);
Publish(channel, id, data);
usleep(100 * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
EXPECT_EQ(result.size(), 1);
Subscribe(channel, id, result);

View file

@ -41,7 +41,8 @@ static void GetRedisShards(redisContext *context, std::vector<std::string> *addr
// Sleep for a little, and try again if the entry isn't there yet.
freeReplyObject(reply);
usleep(RayConfig::instance().redis_db_connect_wait_milliseconds() * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(
RayConfig::instance().redis_db_connect_wait_milliseconds()));
num_attempts++;
}
RAY_CHECK(num_attempts < RayConfig::instance().redis_db_connect_retries())
@ -67,7 +68,8 @@ static void GetRedisShards(redisContext *context, std::vector<std::string> *addr
// Sleep for a little, and try again if not all Redis shard addresses have
// been added yet.
freeReplyObject(reply);
usleep(RayConfig::instance().redis_db_connect_wait_milliseconds() * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(
RayConfig::instance().redis_db_connect_wait_milliseconds()));
num_attempts++;
}
RAY_CHECK(num_attempts < RayConfig::instance().redis_db_connect_retries())

View file

@ -306,7 +306,8 @@ Status ConnectWithRetries(const std::string &address, int port,
}
RAY_LOG(WARNING) << "Failed to connect to Redis, retrying.";
// Sleep for a little.
usleep(RayConfig::instance().redis_db_connect_wait_milliseconds() * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(
RayConfig::instance().redis_db_connect_wait_milliseconds()));
*context = connect_function(address.c_str(), port);
connection_attempts += 1;
}

View file

@ -20,19 +20,25 @@
#include "ray/object_manager/plasma/client.h"
#include <fcntl.h>
#ifndef _WIN32
#include <netinet/in.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#ifndef _WIN32
#include <strings.h>
#include <sys/ioctl.h>
#endif
#ifdef _WIN32
#include <Windows.h>
#else
#include <sys/ioctl.h>
#include <sys/mman.h>
#endif
#include <sys/socket.h>
#include <sys/types.h>
#ifndef _WIN32
#include <sys/un.h>
#endif
#include <time.h>
#ifndef _WIN32
#include <unistd.h>

View file

@ -28,7 +28,9 @@
#include <errno.h>
#include <sys/socket.h>
#include <sys/types.h>
#ifndef _WIN32
#include <sys/un.h>
#endif
#include <unistd.h>
// This is necessary for Mac OS X, see http://www.apuebook.com/faqs2e.html

View file

@ -116,7 +116,9 @@ Status ReadMessage(int fd, MessageType* type, std::vector<uint8_t>* buffer) {
int ConnectOrListenIpcSock(const std::string& pathname, bool shall_listen) {
union {
struct sockaddr addr;
#ifndef _WIN32
struct sockaddr_un un;
#endif
struct sockaddr_in in;
} socket_address;
int addrlen;
@ -142,6 +144,10 @@ int ConnectOrListenIpcSock(const std::string& pathname, bool shall_listen) {
return -1;
}
} else {
#ifdef _WIN32
RAY_LOG(ERROR) << "UNIX domain sockets not supported on Windows: " << pathname;
return -1;
#else
addrlen = sizeof(socket_address.un);
socket_address.un.sun_family = AF_UNIX;
if (pathname.size() + 1 > sizeof(socket_address.un.sun_path)) {
@ -149,6 +155,7 @@ int ConnectOrListenIpcSock(const std::string& pathname, bool shall_listen) {
return -1;
}
strncpy(socket_address.un.sun_path, pathname.c_str(), pathname.size() + 1);
#endif
}
int socket_fd = socket(socket_address.addr.sa_family, SOCK_STREAM, 0);
@ -207,7 +214,7 @@ Status ConnectIpcSocketRetry(const std::string& pathname, int num_retries,
RAY_LOG(ERROR) << "Connection to IPC socket failed for pathname " << pathname
<< ", retrying " << num_retries << " more times";
// Sleep for timeout milliseconds.
usleep(static_cast<int>(timeout * 1000));
std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
*fd = ConnectOrListenIpcSock(pathname, false);
--num_retries;
}

View file

@ -18,8 +18,10 @@
#pragma once
#include <inttypes.h>
#ifndef _WIN32
#include <sys/socket.h>
#include <sys/un.h>
#endif
#include <unistd.h>
#include <memory>

View file

@ -17,7 +17,9 @@
#include "ray/object_manager/plasma/plasma.h"
#ifndef _WIN32
#include <sys/socket.h>
#endif
#include <sys/types.h>
#include <unistd.h>

View file

@ -2,7 +2,9 @@
#include <fcntl.h>
#include <stdio.h>
#ifndef _WIN32
#include <sys/statvfs.h>
#endif
#include <sys/types.h>
#include <unistd.h>

View file

@ -62,7 +62,8 @@ void GrpcServer::Run() {
if (port_ > 0) {
break;
}
usleep(RayConfig::instance().grpc_server_retry_timeout_milliseconds() * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(
RayConfig::instance().grpc_server_retry_timeout_milliseconds()));
num_retries--;
}

View file

@ -29,7 +29,11 @@
*/
#ifdef _WIN32
#include <WinSock2.h>
#else
#include <sys/select.h>
#endif
#include <string.h>
typedef struct aeApiState {

View file

@ -14,13 +14,17 @@
#include "ray/util/logging.h"
#ifndef _WIN32
#ifdef _WIN32
#include <process.h>
#else
#include <execinfo.h>
#endif
#include <signal.h>
#include <stdlib.h>
#ifndef _WIN32
#include <unistd.h>
#endif
#include <algorithm>
#include <cstdlib>
@ -188,9 +192,14 @@ void RayLog::StartRayLog(const std::string &app_name, RayLogLevel severity_thres
char buffer[80];
time_t rawtime;
time(&rawtime);
#ifdef _WIN32
int pid = _getpid();
#else
pid_t pid = getpid();
#endif
strftime(buffer, sizeof(buffer), "%Y%m%d-%H%M%S", localtime(&rawtime));
std::string path = dir_ends_with_slash + app_name_without_path + "." + buffer + "." +
std::to_string(getpid()) + ".log";
std::to_string(pid) + ".log";
stream_logger_singleton.out_.open(path.c_str(),
std::ios_base::app | std::ios_base::binary);
}

View file

@ -22,8 +22,8 @@
#include <stddef.h>
#include <sys/types.h>
#include <sys/wait.h>
#endif
#include <unistd.h>
#endif
#include <algorithm>
#include <fstream>
@ -445,6 +445,7 @@ namespace std {
bool equal_to<ray::Process>::operator()(const ray::Process &x,
const ray::Process &y) const {
using namespace ray;
return !x.IsNull()
? !y.IsNull()
? x.IsValid()
@ -456,6 +457,7 @@ bool equal_to<ray::Process>::operator()(const ray::Process &x,
}
size_t hash<ray::Process>::operator()(const ray::Process &value) const {
using namespace ray;
return !value.IsNull() ? value.IsValid() ? hash<pid_t>()(value.GetId())
: hash<void const *>()(value.Get())
: size_t();

View file

@ -13,7 +13,10 @@
// limitations under the License.
#include "ray/util/sequencer.h"
#include <unistd.h>
#include <chrono>
#include <thread>
#include "gtest/gtest.h"
#include "ray/util/logging.h"
@ -26,7 +29,7 @@ TEST(SequencerTest, ExecuteOrderedTest) {
int size = 100;
for (int index = 0; index < size; ++index) {
auto operation = [index, &queue](SequencerDoneCallback done_callback) {
usleep(1000);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
queue.push_back(index);
done_callback();
};
@ -34,7 +37,7 @@ TEST(SequencerTest, ExecuteOrderedTest) {
}
while (queue.size() < (size_t)size) {
usleep(1000);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
for (int index = 0; index < size; ++index) {

View file

@ -24,7 +24,7 @@
namespace ray {
#ifndef _WIN32
void Sleep() { usleep(100000); }
void Sleep() { std::this_thread::sleep_for(std::chrono::milliseconds(100)); }
void TestSendSignal(const std::string &test_name, int signal) {
pid_t pid;

View file

@ -1,4 +0,0 @@
#ifndef INET_H
#define INET_H
#endif /* INET_H */

View file

@ -1,103 +0,0 @@
/*
From:
http://stackoverflow.com/a/17195644/541686
Also posted on:
https://gist.github.com/superwills/5815344
Previously from:
http://www.raspberryginger.com/jbailey/minix/html/lib_2posix_2getopt_8c-source.html
*/
/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
optopt, /* character checked for validity */
optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#define BADCH (int)'?'
#define BADARG (int)':'
static char EMSG[] = "";
/*
* getopt --
* Parse argc/argv argument vector.
*/
int getopt(int nargc, char *const nargv[], const char *ostr) {
static char *place = EMSG; /* option letter processing */
const char *oli; /* option letter list index */
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;
return (-1);
}
if (place[1] && *++place == '-') { /* found "--" */
++optind;
place = EMSG;
return (-1);
}
} /* option letter okay? */
if ((optopt = (int)*place++) == (int)':' || !(oli = strchr(ostr, optopt))) {
/*
* if the user didn't specify '-' as an option,
* assume it means -1.
*/
if (optopt == (int)'-') return (-1);
if (!*place) ++optind;
if (opterr && *ostr != ':') (void)printf("illegal option -- %c\n", optopt);
return (BADCH);
}
if (*++oli != ':') { /* don't need argument */
optarg = NULL;
if (!*place) ++optind;
} else { /* need an argument */
if (*place) /* no white space */
optarg = place;
else if (nargc <= ++optind) { /* no arg */
place = EMSG;
if (*ostr == ':') return (BADARG);
if (opterr) (void)printf("option requires an argument -- %c\n", optopt);
return (BADCH);
} else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;
}
return (optopt); /* dump back option letter */
}

View file

@ -1,8 +0,0 @@
#ifndef GETOPT_H
#define GETOPT_H
extern char *optarg;
extern int optind, opterr, optopt;
int getopt(int nargc, char *const nargv[], const char *ostr);
#endif /* GETOPT_H */

View file

@ -1,6 +0,0 @@
#ifndef NETDB_H
#define NETDB_H
#include <ws2tcpip.h>
#endif /* NETDB_H */

View file

@ -1,4 +0,0 @@
#ifndef IN_H
#define IN_H
#endif /* IN_H */

View file

@ -1,4 +0,0 @@
#ifndef TCP_H
#define TCP_H
#endif /* TCP_H */

View file

@ -1,13 +0,0 @@
#ifndef _PTHREAD_H
#define _PTHREAD_H 1
#ifndef _INC_WINDOWS
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <Windows.h>
#endif
typedef CRITICAL_SECTION pthread_mutex_t;
#endif /* pthread.h */

View file

@ -1,12 +0,0 @@
#ifndef STRINGS_H
#define STRINGS_H
#include <string.h>
static int strcasecmp(const char *s1, const char *s2) { return _stricmp(s1, s2); }
static int strncasecmp(const char *s1, const char *s2, size_t n) {
return _strnicmp(s1, s2, n);
}
#endif /* STRINGS_H */

View file

@ -1,4 +0,0 @@
#ifndef IOCTL_H
#define IOCTL_H
#endif /* IOCTL_H */

View file

@ -1,4 +0,0 @@
#ifndef SELECT_H
#define SELECT_H
#endif /* SELECT_H */

View file

@ -1,4 +0,0 @@
#ifndef STATVFS_H
#define STATVFS_H 1
#endif

View file

@ -1,4 +0,0 @@
#ifndef _SYS_SYSLOG_H
#define _SYS_SYSLOG_H 1
#endif /* sys/syslog.h */

View file

@ -1,17 +0,0 @@
#ifndef UN_H
#define UN_H
#include <sys/socket.h>
#define UNIX_PATH_MAX 108
typedef struct sockaddr_un {
ADDRESS_FAMILY sun_family;
char sun_path[UNIX_PATH_MAX];
} SOCKADDR_UN, *PSOCKADDR_UN;
#ifndef AF_LOCAL
#define AF_LOCAL AF_UNIX
#endif
#endif /* UN_H */

View file

@ -1 +0,0 @@
#include <sys/syslog.h>

View file

@ -22,7 +22,8 @@ typedef NTSTATUS WINAPI NtQueryInformationProcess_t(HANDLE ProcessHandle,
static std::atomic<NtQueryInformationProcess_t *> NtQueryInformationProcess_ =
ATOMIC_VAR_INIT(NULL);
pid_t getppid() {
typedef int pid_t;
int getppid() {
NtQueryInformationProcess_t *NtQueryInformationProcess = ::NtQueryInformationProcess_;
if (!NtQueryInformationProcess) {
NtQueryInformationProcess = reinterpret_cast<NtQueryInformationProcess_t *>(
@ -61,13 +62,3 @@ pid_t getppid() {
}
return result;
}
int usleep(useconds_t usec) {
Sleep((usec + (1000 - 1)) / 1000);
return 0;
}
unsigned sleep(unsigned seconds) {
Sleep(seconds * 1000);
return 0;
}

View file

@ -1,57 +1,12 @@
#ifndef UNISTD_H
#define UNISTD_H
#include <getopt.h>
#include <io.h> // open/read/write/close
#include <process.h> // getpid
#ifndef EXTERN_C
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C
#endif
#endif
#ifndef DECLSPEC_IMPORT
#define DECLSPEC_IMPORT __declspec(dllimport)
#endif
#ifndef WINBASEAPI
#define WINBASEAPI DECLSPEC_IMPORT
#endif
#ifndef WINAPI
#define WINAPI __stdcall
#endif
typedef int BOOL;
typedef void *HANDLE;
typedef unsigned long DWORD;
#ifdef _WIN64
typedef unsigned long long UINT_PTR;
typedef unsigned long long ULONG_PTR;
typedef long long ssize_t;
#else
typedef unsigned int UINT_PTR;
typedef unsigned long ULONG_PTR;
typedef int ssize_t;
#endif
typedef int pid_t /* technically unsigned on Windows, but no practical concern */;
enum { SIGKILL = 9 };
typedef ULONG_PTR SIZE_T;
EXTERN_C WINBASEAPI void WINAPI Sleep(DWORD dwMilliseconds);
typedef unsigned int useconds_t;
int usleep(useconds_t usec);
unsigned sleep(unsigned seconds);
pid_t getppid();
__declspec(
deprecated("Killing a process by ID has an inherent race condition on Windows"
" and is HIGHLY discouraged. "
"Furthermore, signals other than SIGKILL are NOT portable. "
"Please use a wrapper that keeps the process handle alive"
" and terminates it directly as needed. "
"For SIGTERM or other signals, a different IPC mechanism may be"
" more appropriate (such as window messages on Windows)."
"")) int kill(pid_t pid, int sig);
int getppid();
#endif /* UNISTD_H */

View file

@ -1,7 +1,3 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "streaming_logging.h"
namespace ray {