Skip to content

Commit

Permalink
fixing windows build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mkatanbaf committed May 10, 2022
1 parent 111e6ff commit 540b001
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
12 changes: 12 additions & 0 deletions include/tvm/runtime/c_runtime_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ extern "C" {
#endif
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>

#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;
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/minrpc/minrpc_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class MinRPCReturns : public MinRPCReturnInterface {
const uint8_t* buf = static_cast<const uint8_t*>(data);
size_t ndone = 0;
while (ndone < size) {
ssize_t ret = io_->PosixWrite(buf, size - ndone);
tvm_ssize_t ret = io_->PosixWrite(buf, size - ndone);
if (ret <= 0) {
this->ThrowError(RPCServerStatus::kWriteError);
}
Expand Down Expand Up @@ -526,7 +526,7 @@ class MinRPCExecute : public MinRPCExecInterface {
uint8_t* buf = static_cast<uint8_t*>(data);
size_t ndone = 0;
while (ndone < size) {
ssize_t ret = io_->PosixRead(buf, size - ndone);
tvm_ssize_t ret = io_->PosixRead(buf, size - ndone);
if (ret <= 0) return ret;
ndone += ret;
buf += ret;
Expand Down Expand Up @@ -757,7 +757,7 @@ class MinRPCServer {
uint8_t* buf = static_cast<uint8_t*>(data);
size_t ndone = 0;
while (ndone < size) {
ssize_t ret = io_->PosixRead(buf, size - ndone);
tvm_ssize_t ret = io_->PosixRead(buf, size - ndone);
if (ret == 0) {
if (allow_clean_shutdown_) {
Shutdown();
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/minrpc/minrpc_server_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class MinRPCSniffer {
uint8_t* buf = reinterpret_cast<uint8_t*>(data);
size_t ndone = 0;
while (ndone < size) {
ssize_t ret = io_->PosixRead(buf, size - ndone);
tvm_ssize_t ret = io_->PosixRead(buf, size - ndone);
if (ret <= 0) {
this->ThrowError(RPCServerStatus::kReadError);
return false;
Expand Down
6 changes: 4 additions & 2 deletions src/runtime/rpc/rpc_channel_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#ifndef TVM_RUNTIME_RPC_RPC_CHANNEL_LOGGER_H_
#define TVM_RUNTIME_RPC_RPC_CHANNEL_LOGGER_H_

#include <tvm/runtime/c_runtime_api.h>

#include <memory>
#include <utility>

Expand Down Expand Up @@ -96,11 +98,11 @@ class SnifferIOHandler {

void MessageStart(size_t message_size_bytes) {}

ssize_t PosixWrite(const uint8_t* buf, size_t buf_size_bytes) { return 0; }
tvm_ssize_t PosixWrite(const uint8_t* buf, size_t buf_size_bytes) { return 0; }

void MessageDone() {}

ssize_t PosixRead(uint8_t* buf, size_t buf_size_bytes) {
tvm_ssize_t PosixRead(uint8_t* buf, size_t buf_size_bytes) {
return receive_buffer_->Read(buf, buf_size_bytes);
}

Expand Down

0 comments on commit 540b001

Please sign in to comment.