Avoid a C++ runtime dependency.
Short-term, we will need to use these macros and build without RTTI when defining any virtual base class. Long-term, it would be good to remove these constraints, but it will require some downstream work. Bug: 132 Change-Id: I3bc65bb12d7653978612b7d1bf06f772a2f3b1cd Reviewed-on: https://boringssl-review.googlesource.com/18344 Commit-Queue: David Benjamin <davidben@google.com> Commit-Queue: Adam Langley <agl@google.com> Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
c642aca28f
commit
c937699735
@ -42,7 +42,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|||||||
set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-free-nonheap-object")
|
set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-free-nonheap-object")
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_CXX_FLAGS} -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_CXX_FLAGS} -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${C_CXX_FLAGS} -Wmissing-declarations -fno-exceptions")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${C_CXX_FLAGS} -Wmissing-declarations -fno-exceptions -fno-rtti")
|
||||||
# In GCC, -Wmissing-declarations is the C++ spelling of -Wmissing-prototypes
|
# In GCC, -Wmissing-declarations is the C++ spelling of -Wmissing-prototypes
|
||||||
# and using the wrong one is an error. In Clang, -Wmissing-prototypes is the
|
# and using the wrong one is an error. In Clang, -Wmissing-prototypes is the
|
||||||
# spelling for both and -Wmissing-declarations is some other warning.
|
# spelling for both and -Wmissing-declarations is some other warning.
|
||||||
|
@ -144,6 +144,8 @@
|
|||||||
|
|
||||||
#include <openssl/base.h>
|
#include <openssl/base.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -217,6 +219,17 @@ UniquePtr<T> MakeUnique(Args &&... args) {
|
|||||||
return UniquePtr<T>(New<T>(std::forward<Args>(args)...));
|
return UniquePtr<T>(New<T>(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* HAS_VIRTUAL_DESTRUCTOR should be declared in any base class which defines a
|
||||||
|
* virtual destructor. This avoids a dependency on |_ZdlPv| and prevents the
|
||||||
|
* class from being used with |delete|. */
|
||||||
|
#define HAS_VIRTUAL_DESTRUCTOR \
|
||||||
|
void operator delete(void *) { abort(); }
|
||||||
|
|
||||||
|
/* PURE_VIRTUAL should be used instead of = 0 when defining pure-virtual
|
||||||
|
* functions. This avoids a dependency on |__cxa_pure_virtual| but loses
|
||||||
|
* compile-time checking. */
|
||||||
|
#define PURE_VIRTUAL { abort(); }
|
||||||
|
|
||||||
|
|
||||||
/* Protocol versions.
|
/* Protocol versions.
|
||||||
*
|
*
|
||||||
@ -753,17 +766,18 @@ int custom_ext_add_serverhello(SSL_HANDSHAKE *hs, CBB *extensions);
|
|||||||
class SSLKeyShare {
|
class SSLKeyShare {
|
||||||
public:
|
public:
|
||||||
virtual ~SSLKeyShare() {}
|
virtual ~SSLKeyShare() {}
|
||||||
|
HAS_VIRTUAL_DESTRUCTOR
|
||||||
|
|
||||||
/* Create returns a SSLKeyShare instance for use with group |group_id| or
|
/* Create returns a SSLKeyShare instance for use with group |group_id| or
|
||||||
* nullptr on error. */
|
* nullptr on error. */
|
||||||
static UniquePtr<SSLKeyShare> Create(uint16_t group_id);
|
static UniquePtr<SSLKeyShare> Create(uint16_t group_id);
|
||||||
|
|
||||||
/* GroupID returns the group ID. */
|
/* GroupID returns the group ID. */
|
||||||
virtual uint16_t GroupID() const = 0;
|
virtual uint16_t GroupID() const PURE_VIRTUAL;
|
||||||
|
|
||||||
/* Offer generates a keypair and writes the public value to
|
/* Offer generates a keypair and writes the public value to
|
||||||
* |out_public_key|. It returns true on success and false on error. */
|
* |out_public_key|. It returns true on success and false on error. */
|
||||||
virtual bool Offer(CBB *out_public_key) = 0;
|
virtual bool Offer(CBB *out_public_key) PURE_VIRTUAL;
|
||||||
|
|
||||||
/* Accept performs a key exchange against the |peer_key| generated by |offer|.
|
/* Accept performs a key exchange against the |peer_key| generated by |offer|.
|
||||||
* On success, it returns true, writes the public value to |out_public_key|,
|
* On success, it returns true, writes the public value to |out_public_key|,
|
||||||
@ -790,7 +804,7 @@ class SSLKeyShare {
|
|||||||
* TODO(davidben): out_secret should be a smart pointer. */
|
* TODO(davidben): out_secret should be a smart pointer. */
|
||||||
virtual bool Finish(uint8_t **out_secret, size_t *out_secret_len,
|
virtual bool Finish(uint8_t **out_secret, size_t *out_secret_len,
|
||||||
uint8_t *out_alert, const uint8_t *peer_key,
|
uint8_t *out_alert, const uint8_t *peer_key,
|
||||||
size_t peer_key_len) = 0;
|
size_t peer_key_len) PURE_VIRTUAL;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ssl_nid_to_group_id looks up the group corresponding to |nid|. On success, it
|
/* ssl_nid_to_group_id looks up the group corresponding to |nid|. On success, it
|
||||||
|
Loading…
Reference in New Issue
Block a user