diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h index a27c1f80570..8a5c74df6ef 100644 --- a/include/grpc++/impl/codegen/core_codegen_interface.h +++ b/include/grpc++/impl/codegen/core_codegen_interface.h @@ -74,6 +74,8 @@ class CoreCodegenInterface { virtual void grpc_metadata_array_init(grpc_metadata_array* array) = 0; virtual void grpc_metadata_array_destroy(grpc_metadata_array* array) = 0; + virtual gpr_timespec gpr_inf_future(gpr_clock_type type) = 0; + virtual void assert_fail(const char* failed_assertion) = 0; }; diff --git a/include/grpc/impl/codegen/time.h b/include/grpc/impl/codegen/time.h index 9776dabc11d..c22bedfe77c 100644 --- a/include/grpc/impl/codegen/time.h +++ b/include/grpc/impl/codegen/time.h @@ -69,33 +69,10 @@ typedef struct gpr_timespec { } gpr_timespec; /* Time constants. */ -/* The zero time interval. */ -GPRAPI static inline gpr_timespec gpr_time_0(gpr_clock_type type) { - gpr_timespec out; - out.tv_sec = 0; - out.tv_nsec = 0; - out.clock_type = type; - return out; -} - -/* The far future */ -GPRAPI static inline gpr_timespec gpr_inf_future(gpr_clock_type type) { - gpr_timespec out; - out.tv_sec = INT64_MAX; - out.tv_nsec = 0; - out.clock_type = type; - return out; -} - -/* The far past. */ -GPRAPI static inline gpr_timespec gpr_inf_past(gpr_clock_type type) { - gpr_timespec out; - out.tv_sec = INT64_MIN; - out.tv_nsec = 0; - out.clock_type = type; - return out; -} - +GPRAPI gpr_timespec +gpr_time_0(gpr_clock_type type); /* The zero time interval. */ +GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type); /* The far future */ +GPRAPI gpr_timespec gpr_inf_past(gpr_clock_type type); /* The far past. */ #define GPR_MS_PER_SEC 1000 #define GPR_US_PER_SEC 1000000 diff --git a/src/core/support/time.c b/src/core/support/time.c index fec3c7a2c5d..423d12ffc0f 100644 --- a/src/core/support/time.c +++ b/src/core/support/time.c @@ -56,6 +56,30 @@ gpr_timespec gpr_time_max(gpr_timespec a, gpr_timespec b) { return gpr_time_cmp(a, b) > 0 ? a : b; } +gpr_timespec gpr_time_0(gpr_clock_type type) { + gpr_timespec out; + out.tv_sec = 0; + out.tv_nsec = 0; + out.clock_type = type; + return out; +} + +gpr_timespec gpr_inf_future(gpr_clock_type type) { + gpr_timespec out; + out.tv_sec = INT64_MAX; + out.tv_nsec = 0; + out.clock_type = type; + return out; +} + +gpr_timespec gpr_inf_past(gpr_clock_type type) { + gpr_timespec out; + out.tv_sec = INT64_MIN; + out.tv_nsec = 0; + out.clock_type = type; + return out; +} + /* TODO(ctiller): consider merging _nanos, _micros, _millis into a single function for maintainability. Similarly for _seconds, _minutes, and _hours */ diff --git a/src/cpp/common/core_codegen.cc b/src/cpp/common/core_codegen.cc index 2c1c11c7a42..9b8ff5d30cf 100644 --- a/src/cpp/common/core_codegen.cc +++ b/src/cpp/common/core_codegen.cc @@ -200,6 +200,11 @@ void CoreCodegen::grpc_metadata_array_destroy(grpc_metadata_array* array) { ::grpc_metadata_array_destroy(array); } + +gpr_timespec CoreCodegen::gpr_inf_future(gpr_clock_type type) { + return ::gpr_inf_future(type); +} + void CoreCodegen::assert_fail(const char* failed_assertion) { gpr_log(GPR_ERROR, "assertion failed: %s", failed_assertion); abort(); diff --git a/src/cpp/common/core_codegen.h b/src/cpp/common/core_codegen.h index b591209427e..e0e26a85732 100644 --- a/src/cpp/common/core_codegen.h +++ b/src/cpp/common/core_codegen.h @@ -57,6 +57,8 @@ class CoreCodegen : public CoreCodegenInterface { void grpc_metadata_array_destroy(grpc_metadata_array* array) override; + void gpr_inf_future(gpr_clock_type type) override; + void assert_fail(const char* failed_assertion) override; Status SerializeProto(const grpc::protobuf::Message& msg,