10 #ifndef LLVM_EXECUTIONENGINE_ORC_RAWBYTECHANNEL_H 11 #define LLVM_EXECUTIONENGINE_ORC_RAWBYTECHANNEL_H 20 #include <type_traits> 42 template <
typename FunctionIdT,
typename SequenceIdT>
61 template <
typename FunctionIdT,
typename SequenceNumberT>
85 std::mutex readLock, writeLock;
88 template <
typename ChannelT,
typename T>
91 typename
std::enable_if<
92 std::is_base_of<RawByteChannel, ChannelT>::value &&
93 (std::is_same<T, uint8_t>::value || std::is_same<T, int8_t>::value ||
94 std::is_same<T, uint16_t>::value || std::is_same<T, int16_t>::value ||
95 std::is_same<T, uint32_t>::value || std::is_same<T, int32_t>::value ||
96 std::is_same<T, uint64_t>::value || std::is_same<T, int64_t>::value ||
97 std::is_same<T, char>::value)>
::type> {
100 support::endian::byte_swap<T, support::big>(V);
101 return C.appendBytes(reinterpret_cast<const char *>(&V),
sizeof(
T));
105 if (
auto Err = C.readBytes(reinterpret_cast<char *>(&V),
sizeof(
T)))
107 support::endian::byte_swap<T, support::big>(V);
112 template <
typename ChannelT>
114 typename
std::enable_if<std::is_base_of<
115 RawByteChannel, ChannelT>::value>
::type> {
118 uint8_t Tmp = V ? 1 : 0;
120 C.appendBytes(reinterpret_cast<const char *>(&Tmp), 1))
127 if (
auto Err = C.readBytes(reinterpret_cast<char *>(&Tmp), 1))
134 template <
typename ChannelT>
136 typename std::enable_if<std::is_base_of<
137 RawByteChannel, ChannelT>::value>
::type> {
147 template <
typename ChannelT,
typename T>
149 typename std::enable_if<
150 std::is_base_of<RawByteChannel, ChannelT>::value &&
151 (std::is_same<T, const char*>::value ||
152 std::is_same<T, char*>::value)>
::type> {
160 template <
typename ChannelT>
162 typename std::enable_if<std::is_base_of<
163 RawByteChannel, ChannelT>::value>
::type> {
185 #endif // LLVM_EXECUTIONENGINE_ORC_RAWBYTECHANNEL_H
This class represents lattice values for constants.
std::mutex & getReadLock()
Get the lock for stream reading.
Error startReceiveMessage(FunctionIdT &FnId, SequenceNumberT &SeqNo)
Notify the channel that we're starting a message receive.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Interface for byte-streams to be used with RPC.
Error startSendMessage(const FunctionIdT &FnId, const SequenceIdT &SeqNo)
Notify the channel that we're starting a message send.
virtual Error send()=0
Flush the stream if possible.
llvm::orc::rpc::SerializationTraits< ChannelT, T, T, typename std::enable_if< std::is_base_of< RawByteChannel, ChannelT >::value &&(std::is_same< T, uint8_t >::value||std::is_same< T, int8_t >::value||std::is_same< T, uint16_t >::value||std::is_same< T, int16_t >::value||std::is_same< T, uint32_t >::value||std::is_same< T, int32_t >::value||std::is_same< T, uint64_t >::value||std::is_same< T, int64_t >::value||std::is_same< T, char >::value)>::type >::deserialize static Error deserialize(ChannelT &C, T &V)
static Error serialize(RawByteChannel &C, const std::string &S)
RPC channel serialization for std::strings.
static Error deserialize(RawByteChannel &C, std::string &S)
RPC channel deserialization for std::strings.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Error serializeSeq(ChannelT &C, ArgTs &&... Args)
Error endSendMessage()
Notify the channel that we're ending a message send.
static Error serialize(ChannelT &C, bool V)
virtual Error readBytes(char *Dst, unsigned Size)=0
Read Size bytes from the stream into *Dst.
The SerializationTraits<ChannelT, T> class describes how to serialize and deserialize an instance of ...
virtual ~RawByteChannel()=default
static Error serialize(RawByteChannel &C, const char *S)
static ErrorSuccess success()
Create a success value.
Error endReceiveMessage()
Notify the channel that we're ending a message receive.
llvm::orc::rpc::SerializationTraits< ChannelT, T, T, typename std::enable_if< std::is_base_of< RawByteChannel, ChannelT >::value &&(std::is_same< T, uint8_t >::value||std::is_same< T, int8_t >::value||std::is_same< T, uint16_t >::value||std::is_same< T, int16_t >::value||std::is_same< T, uint32_t >::value||std::is_same< T, int32_t >::value||std::is_same< T, uint64_t >::value||std::is_same< T, int64_t >::value||std::is_same< T, char >::value)>::type >::serialize static Error serialize(ChannelT &C, T V)
static Error serialize(RawByteChannel &C, StringRef S)
RPC channel serialization for std::strings.
virtual Error appendBytes(const char *Src, unsigned Size)=0
Read size bytes from *Src and append them to the stream.
Error deserializeSeq(ChannelT &C, ArgTs &... Args)
static Error deserialize(ChannelT &C, bool &V)
std::mutex & getWriteLock()
Get the lock for stream writing.
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.