mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Build in C++17 mode.
Practically all current compilers fully support C++17 by now, with the exception of `filesystem` (which we won't use). PiperOrigin-RevId: 281494879 Change-Id: Ia0ef650ede4e5907e4a6421b8ad11743c8bae88f
This commit is contained in:
parent
8a7d0d1cb3
commit
ae2954f598
|
@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.10)
|
||||||
project(SandboxedAPI C CXX ASM)
|
project(SandboxedAPI C CXX ASM)
|
||||||
|
|
||||||
# SAPI-wide setting for the language level
|
# SAPI-wide setting for the language level
|
||||||
set(SAPI_CXX_STANDARD 11)
|
set(SAPI_CXX_STANDARD 17)
|
||||||
|
|
||||||
set(SAPI_BINARY_DIR "${PROJECT_BINARY_DIR}" CACHE INTERNAL "" FORCE)
|
set(SAPI_BINARY_DIR "${PROJECT_BINARY_DIR}" CACHE INTERNAL "" FORCE)
|
||||||
set(SAPI_SOURCE_DIR "${PROJECT_SOURCE_DIR}" CACHE INTERNAL "" FORCE)
|
set(SAPI_SOURCE_DIR "${PROJECT_SOURCE_DIR}" CACHE INTERNAL "" FORCE)
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
#include "sandboxed_api/util/canonical_errors.h"
|
#include "sandboxed_api/util/canonical_errors.h"
|
||||||
#include "sandboxed_api/util/status_macros.h"
|
#include "sandboxed_api/util/status_macros.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
Var::~Var() {
|
Var::~Var() {
|
||||||
if (free_rpc_channel_ && GetRemote()) {
|
if (free_rpc_channel_ && GetRemote()) {
|
||||||
|
@ -130,5 +129,4 @@ sapi::Status Var::TransferFromSandboxee(RPCChannel* rpc_channel, pid_t pid) {
|
||||||
return sapi::OkStatus();
|
return sapi::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
|
@ -25,13 +25,14 @@
|
||||||
|
|
||||||
namespace sandbox2 {
|
namespace sandbox2 {
|
||||||
class Comms;
|
class Comms;
|
||||||
}
|
} // namespace sandbox2
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi {
|
||||||
class Sandbox;
|
class Sandbox;
|
||||||
class RPCChannel;
|
class RPCChannel;
|
||||||
|
} // namespace sapi
|
||||||
|
|
||||||
namespace v {
|
namespace sapi::v {
|
||||||
|
|
||||||
class Ptr;
|
class Ptr;
|
||||||
|
|
||||||
|
@ -71,8 +72,8 @@ class Var {
|
||||||
void SetLocal(void* local) { local_ = local; }
|
void SetLocal(void* local) { local_ = local; }
|
||||||
|
|
||||||
// Setter/Getter for the address of a Comms object which can be used to
|
// Setter/Getter for the address of a Comms object which can be used to
|
||||||
// remotely free allocated memory backing up this variable, upon this object's
|
// remotely free allocated memory backing up this variable, upon this
|
||||||
// end of life-time
|
// object's end of life-time
|
||||||
void SetFreeRPCChannel(RPCChannel* rpc_channel) {
|
void SetFreeRPCChannel(RPCChannel* rpc_channel) {
|
||||||
free_rpc_channel_ = rpc_channel;
|
free_rpc_channel_ = rpc_channel;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +109,6 @@ class Var {
|
||||||
friend class ::sapi::Sandbox;
|
friend class ::sapi::Sandbox;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
||||||
#endif // SANDBOXED_API_VAR_ABSTRACT_H_
|
#endif // SANDBOXED_API_VAR_ABSTRACT_H_
|
||||||
|
|
|
@ -27,8 +27,7 @@
|
||||||
#include "sandboxed_api/util/canonical_errors.h"
|
#include "sandboxed_api/util/canonical_errors.h"
|
||||||
#include "sandboxed_api/util/status_macros.h"
|
#include "sandboxed_api/util/status_macros.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
// Class representing an array.
|
// Class representing an array.
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -168,7 +167,6 @@ class ConstCStr : public Array<const char> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
||||||
#endif // SANDBOXED_API_VAR_ARRAY_H_
|
#endif // SANDBOXED_API_VAR_ARRAY_H_
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
#include "sandboxed_api/util/canonical_errors.h"
|
#include "sandboxed_api/util/canonical_errors.h"
|
||||||
#include "sandboxed_api/util/status_macros.h"
|
#include "sandboxed_api/util/status_macros.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
Fd::~Fd() {
|
Fd::~Fd() {
|
||||||
if (GetFreeRPCChannel() && GetRemoteFd() >= 0 && own_remote_) {
|
if (GetFreeRPCChannel() && GetRemoteFd() >= 0 && own_remote_) {
|
||||||
|
@ -92,5 +91,4 @@ sapi::Status Fd::TransferFromSandboxee(RPCChannel* rpc_channel,
|
||||||
return sapi::OkStatus();
|
return sapi::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
|
@ -22,8 +22,7 @@
|
||||||
#include "sandboxed_api/var_ptr.h"
|
#include "sandboxed_api/var_ptr.h"
|
||||||
#include "sandboxed_api/var_reg.h"
|
#include "sandboxed_api/var_reg.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
// Intermediate class for register sized variables
|
// Intermediate class for register sized variables
|
||||||
// so we don't have to implement ptr() everywhere.
|
// so we don't have to implement ptr() everywhere.
|
||||||
|
@ -101,7 +100,6 @@ class Fd : public Int {
|
||||||
bool own_remote_;
|
bool own_remote_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
||||||
#endif // SANDBOXED_API_VAR_INT_H_
|
#endif // SANDBOXED_API_VAR_INT_H_
|
||||||
|
|
|
@ -22,8 +22,7 @@
|
||||||
#include "sandboxed_api/sandbox2/comms.h"
|
#include "sandboxed_api/sandbox2/comms.h"
|
||||||
#include "sandboxed_api/rpcchannel.h"
|
#include "sandboxed_api/rpcchannel.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
sapi::Status LenVal::Allocate(RPCChannel* rpc_channel, bool automatic_free) {
|
sapi::Status LenVal::Allocate(RPCChannel* rpc_channel, bool automatic_free) {
|
||||||
SAPI_RETURN_IF_ERROR(struct_.Allocate(rpc_channel, automatic_free));
|
SAPI_RETURN_IF_ERROR(struct_.Allocate(rpc_channel, automatic_free));
|
||||||
|
@ -69,5 +68,4 @@ sapi::Status LenVal::ResizeData(RPCChannel* rpc_channel, size_t size) {
|
||||||
return sapi::OkStatus();
|
return sapi::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
|
@ -27,8 +27,7 @@
|
||||||
#include "sandboxed_api/var_ptr.h"
|
#include "sandboxed_api/var_ptr.h"
|
||||||
#include "sandboxed_api/var_struct.h"
|
#include "sandboxed_api/var_struct.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class Proto;
|
class Proto;
|
||||||
|
@ -79,7 +78,6 @@ class LenVal : public Var, public Pointable {
|
||||||
friend class Proto;
|
friend class Proto;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
||||||
#endif // SANDBOXED_API_VAR_LENVAL_H_
|
#endif // SANDBOXED_API_VAR_LENVAL_H_
|
||||||
|
|
|
@ -15,10 +15,8 @@
|
||||||
#include "sandboxed_api/var_pointable.h"
|
#include "sandboxed_api/var_pointable.h"
|
||||||
#include "sandboxed_api/var_ptr.h"
|
#include "sandboxed_api/var_ptr.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
void PtrDeleter::operator()(Ptr *p) { delete p; }
|
void PtrDeleter::operator()(Ptr *p) { delete p; }
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
|
|
||||||
#include "sandboxed_api/var_reg.h"
|
#include "sandboxed_api/var_reg.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
class Ptr;
|
class Ptr;
|
||||||
|
|
||||||
|
@ -93,7 +92,6 @@ class Pointable {
|
||||||
std::unique_ptr<Ptr, PtrDeleter> ptr_after_;
|
std::unique_ptr<Ptr, PtrDeleter> ptr_after_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
||||||
#endif // SANDBOXED_API_VAR_POINTABLE_H_
|
#endif // SANDBOXED_API_VAR_POINTABLE_H_
|
||||||
|
|
|
@ -29,8 +29,7 @@
|
||||||
#include "sandboxed_api/var_ptr.h"
|
#include "sandboxed_api/var_ptr.h"
|
||||||
#include "sandboxed_api/util/status_macros.h"
|
#include "sandboxed_api/util/status_macros.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class Proto : public Pointable, public Var {
|
class Proto : public Pointable, public Var {
|
||||||
|
@ -110,7 +109,6 @@ class Proto : public Pointable, public Var {
|
||||||
LenVal wrapped_var_;
|
LenVal wrapped_var_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
||||||
#endif // SANDBOXED_API_VAR_PROTO_H_
|
#endif // SANDBOXED_API_VAR_PROTO_H_
|
||||||
|
|
|
@ -22,8 +22,7 @@
|
||||||
#include "sandboxed_api/var_pointable.h"
|
#include "sandboxed_api/var_pointable.h"
|
||||||
#include "sandboxed_api/var_reg.h"
|
#include "sandboxed_api/var_reg.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
// Class representing a pointer. Takes both Var* and regular pointers in the
|
// Class representing a pointer. Takes both Var* and regular pointers in the
|
||||||
// initializers.
|
// initializers.
|
||||||
|
@ -100,7 +99,6 @@ class RemotePtr : public Ptr {
|
||||||
Reg<void*> pointed_obj_;
|
Reg<void*> pointed_obj_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
||||||
#endif // SANDBOXED_API_VAR_PTR_H_
|
#endif // SANDBOXED_API_VAR_PTR_H_
|
||||||
|
|
|
@ -21,8 +21,7 @@
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include "sandboxed_api/var_abstract.h"
|
#include "sandboxed_api/var_abstract.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
// The super-class for Reg. Specified as a class, so it can be used as a
|
// The super-class for Reg. Specified as a class, so it can be used as a
|
||||||
// type specifier in methods.
|
// type specifier in methods.
|
||||||
|
@ -177,7 +176,6 @@ class Reg : public Callable {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
||||||
#endif // SANDBOXED_API_VAR_REG_H_
|
#endif // SANDBOXED_API_VAR_REG_H_
|
||||||
|
|
|
@ -22,8 +22,7 @@
|
||||||
#include "sandboxed_api/var_pointable.h"
|
#include "sandboxed_api/var_pointable.h"
|
||||||
#include "sandboxed_api/var_ptr.h"
|
#include "sandboxed_api/var_ptr.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
// Class representing a structure.
|
// Class representing a structure.
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -55,7 +54,6 @@ class Struct : public Var, public Pointable {
|
||||||
friend class LenVal;
|
friend class LenVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
||||||
#endif // SANDBOXED_API_VAR_STRUCT_H_
|
#endif // SANDBOXED_API_VAR_STRUCT_H_
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
enum class Type {
|
enum class Type {
|
||||||
kVoid, // Void
|
kVoid, // Void
|
||||||
|
@ -36,7 +35,6 @@ inline std::ostream& operator<<(std::ostream& os, const Type& type) {
|
||||||
return os << static_cast<int>(type);
|
return os << static_cast<int>(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
||||||
#endif // SANDBOXED_API_TYPE_H_
|
#endif // SANDBOXED_API_TYPE_H_
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
#include "sandboxed_api/var_ptr.h"
|
#include "sandboxed_api/var_ptr.h"
|
||||||
#include "sandboxed_api/var_reg.h"
|
#include "sandboxed_api/var_reg.h"
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi::v {
|
||||||
namespace v {
|
|
||||||
|
|
||||||
// Good, old void.
|
// Good, old void.
|
||||||
class Void : public Callable, public Pointable {
|
class Void : public Callable, public Pointable {
|
||||||
|
@ -44,7 +43,6 @@ class Void : public Callable, public Pointable {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace v
|
} // namespace sapi::v
|
||||||
} // namespace sapi
|
|
||||||
|
|
||||||
#endif // SANDBOXED_API_VAR_VOID_H_
|
#endif // SANDBOXED_API_VAR_VOID_H_
|
||||||
|
|
Loading…
Reference in New Issue
Block a user