diff --git a/include/tvm/runtime/c_runtime_api.h b/include/tvm/runtime/c_runtime_api.h index f9f002945f854..085935101cd2c 100644 --- a/include/tvm/runtime/c_runtime_api.h +++ b/include/tvm/runtime/c_runtime_api.h @@ -76,18 +76,6 @@ extern "C" { #endif #include #include -#include -#include - -#if defined(_MSC_VER) -#if defined(_WIN64) -typedef int64_t tvm_ssize_t; -#else -typedef int32_t tvm_ssize_t; -#endif -#else -typedef ssize_t tvm_ssize_t; -#endif /*! \brief type of array index. */ typedef int64_t tvm_index_t; diff --git a/src/runtime/minrpc/minrpc_server.h b/src/runtime/minrpc/minrpc_server.h index ae50f16f33fe3..4684aa0e16165 100644 --- a/src/runtime/minrpc/minrpc_server.h +++ b/src/runtime/minrpc/minrpc_server.h @@ -150,7 +150,7 @@ class MinRPCReturns : public MinRPCReturnInterface { const uint8_t* buf = static_cast(data); size_t ndone = 0; while (ndone < size) { - tvm_ssize_t ret = io_->PosixWrite(buf, size - ndone); + ssize_t ret = io_->PosixWrite(buf, size - ndone); if (ret <= 0) { this->ThrowError(RPCServerStatus::kWriteError); } @@ -526,7 +526,7 @@ class MinRPCExecute : public MinRPCExecInterface { uint8_t* buf = static_cast(data); size_t ndone = 0; while (ndone < size) { - tvm_ssize_t ret = io_->PosixRead(buf, size - ndone); + ssize_t ret = io_->PosixRead(buf, size - ndone); if (ret <= 0) return ret; ndone += ret; buf += ret; @@ -757,7 +757,7 @@ class MinRPCServer { uint8_t* buf = static_cast(data); size_t ndone = 0; while (ndone < size) { - tvm_ssize_t ret = io_->PosixRead(buf, size - ndone); + ssize_t ret = io_->PosixRead(buf, size - ndone); if (ret == 0) { if (allow_clean_shutdown_) { Shutdown(); diff --git a/src/runtime/minrpc/minrpc_server_logging.h b/src/runtime/minrpc/minrpc_server_logging.h index ccfe1af44a7a8..deca2156ce62f 100644 --- a/src/runtime/minrpc/minrpc_server_logging.h +++ b/src/runtime/minrpc/minrpc_server_logging.h @@ -140,7 +140,7 @@ class MinRPCSniffer { uint8_t* buf = reinterpret_cast(data); size_t ndone = 0; while (ndone < size) { - tvm_ssize_t ret = io_->PosixRead(buf, size - ndone); + ssize_t ret = io_->PosixRead(buf, size - ndone); if (ret <= 0) { this->ThrowError(RPCServerStatus::kReadError); return false; diff --git a/src/runtime/rpc/rpc_channel_logger.h b/src/runtime/rpc/rpc_channel_logger.h index 7f26841d9ad0a..8fe68f6690076 100644 --- a/src/runtime/rpc/rpc_channel_logger.h +++ b/src/runtime/rpc/rpc_channel_logger.h @@ -29,6 +29,7 @@ #include #include +#include "../../support/ssize.h" #include "../minrpc/minrpc_server_logging.h" #include "rpc_channel.h" @@ -98,11 +99,11 @@ class SnifferIOHandler { void MessageStart(size_t message_size_bytes) {} - tvm_ssize_t PosixWrite(const uint8_t* buf, size_t buf_size_bytes) { return 0; } + ssize_t PosixWrite(const uint8_t* buf, size_t buf_size_bytes) { return 0; } void MessageDone() {} - tvm_ssize_t PosixRead(uint8_t* buf, size_t buf_size_bytes) { + ssize_t PosixRead(uint8_t* buf, size_t buf_size_bytes) { return receive_buffer_->Read(buf, buf_size_bytes); } diff --git a/src/support/socket.h b/src/support/socket.h index 42d5d9004c156..52de2f72f548f 100644 --- a/src/support/socket.h +++ b/src/support/socket.h @@ -34,7 +34,6 @@ #include #include -using ssize_t = int; #ifdef _MSC_VER #pragma comment(lib, "Ws2_32.lib") #endif @@ -57,6 +56,7 @@ using ssize_t = int; #include #include +#include "../support/ssize.h" #include "../support/utils.h" #if defined(_WIN32) diff --git a/src/support/ssize.h b/src/support/ssize.h new file mode 100644 index 0000000000000..2a62a9b36989e --- /dev/null +++ b/src/support/ssize.h @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file ssize.h + * \brief this file aims to define ssize_t for Windows platform + */ + +#ifndef TVM_SUPPORT_SSIZE_H_ +#define TVM_SUPPORT_SSIZE_H_ + +#if defined(_MSC_VER) +#if defined(_WIN32) +using ssize_t = int32_t; +#else +using ssize_t = int64_t; +#endif +#endif + +#endif // TVM_SUPPORT_SSIZE_H_