summaryrefslogtreecommitdiff
path: root/cpputil
diff options
context:
space:
mode:
authorMartin Thomson <martin.thomson@gmail.com>2017-07-06 10:06:34 +1000
committerMartin Thomson <martin.thomson@gmail.com>2017-07-06 10:06:34 +1000
commitb4622eec33b619908e7fc0b3c3fd2321bfb3080a (patch)
treed87d97ab1fda17784bc71aa07a9ff452e0022f05 /cpputil
parent823d50bdf35175819613c7f810dab7d54293d0f1 (diff)
parent4c4f3b4dfc834144de66fc42f002268314b7598c (diff)
downloadnss-hg-b4622eec33b619908e7fc0b3c3fd2321bfb3080a.tar.gz
Merge NSS trunk to NSS_TLS13_DRAFT19_BRANCH, a=merge
Hg: changed gtests/nss_bogo_shim/nss_bogo_shim.gyp
Diffstat (limited to 'cpputil')
-rw-r--r--cpputil/Makefile49
-rw-r--r--cpputil/config.mk15
-rw-r--r--cpputil/dummy_io.cc4
-rw-r--r--cpputil/manifest.mn18
-rw-r--r--cpputil/scoped_ptrs_util.h39
5 files changed, 125 insertions, 0 deletions
diff --git a/cpputil/Makefile b/cpputil/Makefile
new file mode 100644
index 000000000..7adfc6117
--- /dev/null
+++ b/cpputil/Makefile
@@ -0,0 +1,49 @@
+#! gmake
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#######################################################################
+# (1) Include initial platform-independent assignments (MANDATORY). #
+#######################################################################
+
+include manifest.mn
+
+#######################################################################
+# (2) Include "global" configuration information. (OPTIONAL) #
+#######################################################################
+
+include $(CORE_DEPTH)/coreconf/config.mk
+
+#######################################################################
+# (3) Include "component" configuration information. (OPTIONAL) #
+#######################################################################
+
+ifeq (WINNT,$(OS_ARCH))
+OS_CFLAGS += -EHsc
+else
+CXXFLAGS += -std=c++0x
+endif
+
+#######################################################################
+# (4) Include "local" platform-dependent assignments (OPTIONAL). #
+#######################################################################
+
+include config.mk
+
+#######################################################################
+# (5) Execute "global" rules. (OPTIONAL) #
+#######################################################################
+
+include $(CORE_DEPTH)/coreconf/rules.mk
+
+#######################################################################
+# (6) Execute "component" rules. (OPTIONAL) #
+#######################################################################
+
+
+
+#######################################################################
+# (7) Execute "local" rules. (OPTIONAL). #
+#######################################################################
diff --git a/cpputil/config.mk b/cpputil/config.mk
new file mode 100644
index 000000000..b8c03de79
--- /dev/null
+++ b/cpputil/config.mk
@@ -0,0 +1,15 @@
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#
+# Override TARGETS variable so that only static libraries
+# are specifed as dependencies within rules.mk.
+#
+
+TARGETS = $(LIBRARY)
+SHARED_LIBRARY =
+IMPORT_LIBRARY =
+PROGRAM =
+
diff --git a/cpputil/dummy_io.cc b/cpputil/dummy_io.cc
index a8dacedbe..ef45db833 100644
--- a/cpputil/dummy_io.cc
+++ b/cpputil/dummy_io.cc
@@ -19,6 +19,10 @@ extern const struct PRIOMethods DummyMethodsForward;
ScopedPRFileDesc DummyIOLayerMethods::CreateFD(PRDescIdentity id,
DummyIOLayerMethods *methods) {
ScopedPRFileDesc fd(PR_CreateIOLayerStub(id, &DummyMethodsForward));
+ assert(fd);
+ if (!fd) {
+ return nullptr;
+ }
fd->secret = reinterpret_cast<PRFilePrivate *>(methods);
return fd;
}
diff --git a/cpputil/manifest.mn b/cpputil/manifest.mn
new file mode 100644
index 000000000..ad2d31b45
--- /dev/null
+++ b/cpputil/manifest.mn
@@ -0,0 +1,18 @@
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+CORE_DEPTH = ..
+DEPTH = ..
+
+MODULE = nss
+LIBRARY_NAME = cpputil
+
+CPPSRCS = \
+ dummy_io.cc \
+ dummy_io_fwd.cc \
+ tls_parser.cc \
+ $(NULL)
+
+EXPORTS = \
+ $(NULL)
diff --git a/cpputil/scoped_ptrs_util.h b/cpputil/scoped_ptrs_util.h
new file mode 100644
index 000000000..2dbf34e1d
--- /dev/null
+++ b/cpputil/scoped_ptrs_util.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef scoped_ptrs_util_h__
+#define scoped_ptrs_util_h__
+
+#include <memory>
+#include "pkcs11uri.h"
+#include "secoid.h"
+
+struct ScopedDelete {
+ void operator()(SECAlgorithmID* id) { SECOID_DestroyAlgorithmID(id, true); }
+ void operator()(SECItem* item) { SECITEM_FreeItem(item, true); }
+ void operator()(PK11URI* uri) { PK11URI_DestroyURI(uri); }
+ void operator()(PLArenaPool* arena) { PORT_FreeArena(arena, PR_FALSE); }
+};
+
+template <class T>
+struct ScopedMaybeDelete {
+ void operator()(T* ptr) {
+ if (ptr) {
+ ScopedDelete del;
+ del(ptr);
+ }
+ }
+};
+
+#define SCOPED(x) typedef std::unique_ptr<x, ScopedMaybeDelete<x> > Scoped##x
+
+SCOPED(SECAlgorithmID);
+SCOPED(SECItem);
+SCOPED(PK11URI);
+
+#undef SCOPED
+
+#endif // scoped_ptrs_util_h__