mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 11:27:29 +00:00
base: make RPC framework compatible to C++20
Avoid the use of arithmetics on enum values. Issue #4869
This commit is contained in:
parent
81e85bf1b5
commit
1dac048413
@ -167,29 +167,27 @@ namespace Genode {
|
||||
{
|
||||
long value;
|
||||
|
||||
enum {
|
||||
SUCCESS = 0,
|
||||
static constexpr long SUCCESS = 0;
|
||||
|
||||
/**
|
||||
* Server-side object does not exist
|
||||
*
|
||||
* This exception code is not meant to be reflected from the server
|
||||
* to the client. On kernels with capability support, the condition
|
||||
* can never occur. On kernels without capability protection, the
|
||||
* code is merely used for diagnostic purposes at the server side.
|
||||
*/
|
||||
INVALID_OBJECT = -1,
|
||||
/**
|
||||
* Server-side object does not exist
|
||||
*
|
||||
* This exception code is not meant to be reflected from the server
|
||||
* to the client. On kernels with capability support, the condition
|
||||
* can never occur. On kernels without capability protection, the
|
||||
* code is merely used for diagnostic purposes at the server side.
|
||||
*/
|
||||
static constexpr long INVALID_OBJECT = -1;
|
||||
|
||||
/**
|
||||
* Special exception code used to respond to illegal opcodes
|
||||
*/
|
||||
INVALID_OPCODE = -2,
|
||||
/**
|
||||
* Special exception code used to respond to illegal opcodes
|
||||
*/
|
||||
static constexpr long INVALID_OPCODE = -2;
|
||||
|
||||
/**
|
||||
* Opcode base used for passing exception information
|
||||
*/
|
||||
EXCEPTION_BASE = -1000
|
||||
};
|
||||
/**
|
||||
* Opcode base used for passing exception information
|
||||
*/
|
||||
static constexpr long EXCEPTION_BASE = -1000;
|
||||
|
||||
explicit Rpc_exception_code(int value) : value(value) { }
|
||||
};
|
||||
@ -268,14 +266,16 @@ namespace Genode {
|
||||
|
||||
template <typename RPC_FUNCTION>
|
||||
struct Rpc_function_msg_size<RPC_FUNCTION, RPC_CALL> {
|
||||
enum { Value = Rpc_msg_payload_size<RPC_FUNCTION, true, false>::Value
|
||||
+ sizeof(Rpc_opcode) }; };
|
||||
static constexpr unsigned
|
||||
Value = Rpc_msg_payload_size<RPC_FUNCTION, true, false>::Value
|
||||
+ sizeof(Rpc_opcode); };
|
||||
|
||||
template <typename RPC_FUNCTION>
|
||||
struct Rpc_function_msg_size<RPC_FUNCTION, RPC_REPLY> {
|
||||
enum { Value = Rpc_msg_payload_size<RPC_FUNCTION, false, true>::Value
|
||||
+ Rpc_retval_size<typename RPC_FUNCTION::Ret_type>::Value
|
||||
+ sizeof(Rpc_exception_code) }; };
|
||||
static constexpr unsigned
|
||||
Value = Rpc_msg_payload_size<RPC_FUNCTION, false, true>::Value
|
||||
+ Rpc_retval_size<typename RPC_FUNCTION::Ret_type>::Value
|
||||
+ sizeof(Rpc_exception_code); };
|
||||
|
||||
|
||||
/**
|
||||
|
@ -49,16 +49,18 @@ namespace Genode {
|
||||
|
||||
template <typename ARGS>
|
||||
struct Rpc_caps_out {
|
||||
enum { Value = Cap_para_out<typename ARGS::Head>::Value
|
||||
+ Rpc_caps_out<typename ARGS::Tail>::Value }; };
|
||||
static constexpr unsigned
|
||||
Value = Cap_para_out<typename ARGS::Head>::Value
|
||||
+ Rpc_caps_out<typename ARGS::Tail>::Value; };
|
||||
|
||||
template <>
|
||||
struct Rpc_caps_out<Meta::Empty> { enum { Value = 0 }; };
|
||||
struct Rpc_caps_out<Meta::Empty> { static constexpr unsigned Value = 0; };
|
||||
|
||||
template <typename RPC_FUNCTION>
|
||||
struct Rpc_function_caps_out {
|
||||
enum { Value = Rpc_caps_out<typename RPC_FUNCTION::Server_args>::Value +
|
||||
Cap_return <typename RPC_FUNCTION::Ret_type>::Value}; };
|
||||
static constexpr unsigned
|
||||
Value = Rpc_caps_out<typename RPC_FUNCTION::Server_args>::Value +
|
||||
Cap_return <typename RPC_FUNCTION::Ret_type>::Value; };
|
||||
|
||||
|
||||
/***************************************************
|
||||
|
@ -120,8 +120,9 @@ class Genode::Rpc_dispatcher : public RPC_INTERFACE
|
||||
_do_serve(typename RPC_FUNCTION::Server_args &args,
|
||||
Meta::Overload_selector<RPC_FUNCTION, EXC_TL>)
|
||||
{
|
||||
enum { EXCEPTION_CODE = Rpc_exception_code::EXCEPTION_BASE
|
||||
- Meta::Length<EXC_TL>::Value };
|
||||
static constexpr unsigned
|
||||
EXCEPTION_CODE = Rpc_exception_code::EXCEPTION_BASE
|
||||
- Meta::Length<EXC_TL>::Value;
|
||||
try {
|
||||
typedef typename EXC_TL::Tail Exc_tail;
|
||||
return _do_serve(args,
|
||||
|
@ -43,7 +43,8 @@ struct Genode::Cpu_session : Session
|
||||
* allocation, its session capability, the capability of the 'Native_cpu'
|
||||
* RPC interface, and a capability for the trace-control dataspace.
|
||||
*/
|
||||
enum { CAP_QUOTA = 6, RAM_QUOTA = 36*1024 };
|
||||
static constexpr unsigned CAP_QUOTA = 6;
|
||||
static constexpr size_t RAM_QUOTA = 36*1024;
|
||||
|
||||
typedef Cpu_session_client Client;
|
||||
|
||||
|
@ -41,7 +41,8 @@ struct Genode::Io_mem_session : Session
|
||||
* session-object allocation, its session capability, and a dataspace
|
||||
* capability for the handed-out memory-mapped I/O dataspace.
|
||||
*/
|
||||
enum { CAP_QUOTA = 3, RAM_QUOTA = 6*1024 };
|
||||
static constexpr unsigned CAP_QUOTA = 3;
|
||||
static constexpr size_t RAM_QUOTA = 6*1024;
|
||||
|
||||
virtual ~Io_mem_session() { }
|
||||
|
||||
|
@ -38,7 +38,8 @@ struct Genode::Io_port_session : Session
|
||||
*/
|
||||
static const char *service_name() { return "IO_PORT"; }
|
||||
|
||||
enum { CAP_QUOTA = 2, RAM_QUOTA = 6*1024 };
|
||||
static constexpr unsigned CAP_QUOTA = 2;
|
||||
static constexpr size_t RAM_QUOTA = 6*1024;
|
||||
|
||||
virtual ~Io_port_session() { }
|
||||
|
||||
|
@ -78,7 +78,8 @@ struct Genode::Irq_session : Session
|
||||
*/
|
||||
static const char * service_name() { return "IRQ"; }
|
||||
|
||||
enum { CAP_QUOTA = 3, RAM_QUOTA = 6*1024 };
|
||||
static constexpr unsigned CAP_QUOTA = 3;
|
||||
static constexpr size_t RAM_QUOTA = 6*1024;
|
||||
|
||||
|
||||
/*********************
|
||||
|
@ -37,7 +37,8 @@ struct Genode::Log_session : Session
|
||||
* A LOG connection consumes a dataspace capability for the session-object
|
||||
* allocation and its session capability.
|
||||
*/
|
||||
enum { CAP_QUOTA = 2, RAM_QUOTA = 8*1024 };
|
||||
static constexpr unsigned CAP_QUOTA = 2;
|
||||
static constexpr size_t RAM_QUOTA = 8*1024;
|
||||
|
||||
typedef Log_session_client Client;
|
||||
|
||||
|
@ -46,7 +46,8 @@ struct Genode::Pd_session : Session, Ram_allocator
|
||||
* Furthermore, we account for the dataspace capabilities allocated during
|
||||
* the component bootstrapping.
|
||||
*/
|
||||
enum { CAP_QUOTA = 6 + 7, RAM_QUOTA = 24*1024*sizeof(long) };
|
||||
static constexpr unsigned CAP_QUOTA = 6 + 7;
|
||||
static constexpr size_t RAM_QUOTA = 24*1024*sizeof(long);
|
||||
|
||||
typedef Pd_session_client Client;
|
||||
|
||||
|
@ -46,7 +46,8 @@ struct Genode::Rom_session : Session
|
||||
* allocation, a dataspace capability for the ROM dataspace, and its
|
||||
* session capability.
|
||||
*/
|
||||
enum { CAP_QUOTA = 3, RAM_QUOTA = 6*1024 };
|
||||
static constexpr unsigned CAP_QUOTA = 3;
|
||||
static constexpr size_t RAM_QUOTA = 6*1024;
|
||||
|
||||
typedef Rom_session_client Client;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user