#ifndef SQUID_DEBUG_H
#define SQUID_DEBUG_H
+// XXX should be mem/forward.h once it removes dependencies on typedefs.h
+#include "mem/AllocatorProxy.h"
+
#include <iostream>
#undef assert
#include <sstream>
/// with the libc++6 std::ostringstream definitions
class OutStream : public std::ostringstream
{
- // XXX: use MEMPROXY_CLASS() once that no longer pulls in typedefs.h and enums.h and globals.h
+ MEMPROXY_CLASS(OutStream);
public:
- void *operator new(size_t size) throw(std::bad_alloc) {return xmalloc(size);}
- void operator delete(void *address) throw() {xfree(address);}
- void *operator new[] (size_t size) throw(std::bad_alloc) ; //{return xmalloc(size);}
- void operator delete[] (void *address) throw() ; // {xfree(address);}
+ void *operator new[] (size_t size) throw(std::bad_alloc) = delete; //{return xmalloc(size);}
+ void operator delete[] (void *address) throw() = delete; // {xfree(address);}
};
static OutStream *CurrentDebug;
tests/stub_libcomm.cc \
tests/stub_libdiskio.cc \
tests/stub_libformat.cc \
+ tests/stub_libmem.cc \
tests/stub_libsslsquid.cc \
tests/stub_MemObject.cc \
tests/stub_MemStore.cc \
tests/stub_time.cc \
url.cc \
URL.h \
- tests/stub_libmem.cc \
MemBuf.cc \
wordlist.h \
wordlist.cc
tests/testBoilerplate.cc \
tests/testBoilerplate.h \
tests/stub_debug.cc \
+ tests/stub_libmem.cc \
tests/stub_time.cc
nodist_tests_testBoilerplate_SOURCES = \
tests/stub_cbdata.cc \
$(TESTSOURCES) \
tests/stub_cbdata.cc \
tests/stub_debug.cc \
+ tests/stub_libmem.cc \
tests/stub_MemBuf.cc
tests_testCharacterSet_LDFLAGS = $(LIBADD_DL)
tests_testCharacterSet_LDADD= \
tests/testRFC1035.h
nodist_tests_testDns_SOURCES= \
tests/stub_debug.cc \
+ tests/stub_libmem.cc \
tests/stub_SBuf.cc \
tests/stub_tools.cc
tests_testDns_LDADD= \
MemBuf.cc \
MemBuf.h \
tests/stub_MemObject.cc \
- tests/stub_libmem.cc \
mime_header.cc \
mime_header.h \
String.cc \
tests/stub_debug.cc \
tests/stub_event.cc \
tests/stub_HelperChildConfig.cc \
+ tests/stub_libmem.cc \
tests/stub_libsecurity.cc \
tests/stub_stmem.cc \
tests/stub_store.cc \
icmp/Icmp.h \
SquidTime.h \
tests/stub_debug.cc \
+ tests/stub_libmem.cc \
time.cc \
globals.cc
tests_testIcmp_LDFLAGS = $(LIBADD_DL)
nodist_tests_testIpAddress_SOURCES= \
ip/Address.h \
tests/stub_debug.cc \
+ tests/stub_libmem.cc \
tests/stub_tools.cc
tests_testIpAddress_LDADD= \
ip/libip.la \
## libsquid pulls in SquidConfig and children. stub them.
tests_testString_SOURCES = \
ClientInfo.h \
- tests/stub_libmem.cc \
MemBuf.cc \
String.cc \
$(SBUF_SOURCE) \
tests/stub_cbdata.cc \
tests/stub_debug.cc \
tests/stub_HelperChildConfig.cc \
+ tests/stub_libmem.cc \
tools.h \
tests/stub_tools.cc \
tests/stub_time.cc \
base/RefCount.h \
tests/stub_cbdata.cc \
tests/stub_debug.cc \
+ tests/stub_libmem.cc \
tests/stub_MemBuf.cc \
tests/testRefCount.cc
testRefCount_LDADD = \
MasterXaction.h \
multicast.h \
multicast.cc \
- tests/stub_libmem.cc \
mem_node.cc \
MemBuf.cc \
MemObject.cc \
tests/stub_libauth_acls.cc \
tests/stub_libauth.cc \
tests/stub_libdiskio.cc \
+ tests/stub_libmem.cc \
tests/stub_libsecurity.cc \
tests/stub_main_cc.cc \
tests/stub_ipc_Forwarder.cc \
tests_testConfigParser_SOURCES = \
ClientInfo.h \
- tests/stub_libmem.cc \
tests/stub_MemBuf.cc \
tests/stub_time.cc \
$(SBUF_SOURCE) \
tests/stub_cache_manager.cc \
tests/stub_cbdata.cc \
tests/stub_debug.cc \
+ tests/stub_libmem.cc \
tests/stub_HelperChildConfig.cc \
tools.h \
tests/stub_tools.cc \
#include "squid.h"
#include "SBufAlgos.h"
-std::size_t std::hash<SBuf>::operator() (const SBuf & sbuf) const noexcept
+static std::size_t
+lowSBufHash (const SBuf & sbuf, bool caseInsensitive = false) noexcept
{
//ripped and adapted from hash_string
const char *s = sbuf.rawContent();
size_t rv = 0;
SBuf::size_type len=sbuf.length();
while (len != 0) {
- rv ^= 271 * *s;
+ rv ^= 271 * (caseInsensitive? xtolower(*s) : *s);
++s;
--len;
}
return rv ^ (sbuf.length() * 271);
}
+std::size_t
+std::hash<SBuf>::operator() (const SBuf & sbuf) const noexcept
+{
+ return lowSBufHash(sbuf);
+}
+
+std::size_t
+CaseInsensitiveSBufHash::operator() (const SBuf & sbuf) const noexcept
+{
+ return lowSBufHash(sbuf, true);
+}
+
};
}
+/** hash functor for SBufs, meant so support case-insensitive std::unordered_map
+ *
+ * Typical use:
+ * \code
+ * auto m = std::unordered_map<SBuf, ValueType, CaseInsensitiveSBufHash>();
+ * \endcode
+ */
+class CaseInsensitiveSBufHash
+{
+public:
+ std::size_t operator()(const SBuf &) const noexcept;
+};
+
#endif /* SQUID_SBUFALGOS_H_ */
SquidConfig.cc \
SquidNew.cc \
stub_HelperChildConfig.cc \
+ stub_libmem.cc \
+ STUB.h \
time.cc
# ICMP lookup helper
## files we need to pull in from other locations
## copied like this to avoid subdir-objects collisions on 'make clean'
debug.cc: $(top_srcdir)/src/debug.cc
- cp $(top_srcdir)/src/debug.cc .
+ cp $< $@
globals.cc: $(top_srcdir)/src/globals.h
cp $(top_builddir)/src/globals.cc .
time.cc: $(top_srcdir)/src/time.cc
- cp $(top_srcdir)/src/time.cc .
+ cp $< $@
SquidConfig.cc: $(top_srcdir)/src/SquidConfig.cc
- cp $(top_srcdir)/src/SquidConfig.cc .
+ cp $< $@
SquidNew.cc: $(top_srcdir)/src/SquidNew.cc
- cp $(top_srcdir)/src/SquidNew.cc .
+ cp $< $@
stub_HelperChildConfig.cc: $(top_srcdir)/src/tests/stub_HelperChildConfig.cc
- cp $(top_srcdir)/src/tests/stub_HelperChildConfig.cc .
+ cp $< $@
+
+stub_libmem.cc: $(top_srcdir)/src/tests/stub_libmem.cc STUB.h
+ cp $< $@
+
+STUB.h: $(top_srcdir)/src/tests/STUB.h
+ cp $< $@
+
\ No newline at end of file
tcp_banger2_LDADD = $(top_builddir)/lib/libmiscutil.la
-STUBS = stub_cbdata.cc stub_debug.cc stub_MemBuf.cc stub_SBuf.cc stub_tools.cc stub_fatal.cc
+#do not include stub_libmem.cc here, as it would override libmem.la in
+# several tests whose purpose is testing libmem itself.
+STUBS = \
+ stub_cbdata.cc \
+ stub_debug.cc \
+ stub_MemBuf.cc \
+ stub_SBuf.cc \
+ stub_tools.cc \
+ stub_fatal.cc \
+ STUB.h
DEBUG_SOURCE = test_tools.cc $(STUBS)
CLEANFILES += $(STUBS)
stub_cbdata.cc: $(top_srcdir)/src/tests/stub_cbdata.cc
- cp $(top_srcdir)/src/tests/stub_cbdata.cc .
+ cp $< $@
stub_debug.cc: $(top_srcdir)/src/tests/stub_debug.cc
- cp $(top_srcdir)/src/tests/stub_debug.cc .
+ cp $< $@
stub_MemBuf.cc: $(top_srcdir)/src/tests/stub_MemBuf.cc
- cp $(top_srcdir)/src/tests/stub_MemBuf.cc .
+ cp $< $@
stub_SBuf.cc: $(top_srcdir)/src/tests/stub_SBuf.cc
- cp $(top_srcdir)/src/tests/stub_SBuf.cc .
+ cp $< $@
stub_tools.cc: $(top_srcdir)/src/tests/stub_tools.cc
- cp $(top_srcdir)/src/tests/stub_tools.cc .
+ cp $< $@
stub_fatal.cc: $(top_srcdir)/src/tests/stub_fatal.cc
- cp $(top_srcdir)/src/tests/stub_fatal.cc .
+ cp $< $@
+
+stub_libmem.cc : $(top_srcdir)/src/tests/stub_libmem.cc STUB.h
+ cp $< $@
+
+STUB.h : $(top_srcdir)/src/tests/STUB.h
+ cp $< $@
## XXX: somewhat broken. Its meant to test our debugs() implementation.
## but it has never been linked to the actual src/debug.cc implementation !!
## all it tests are the stream operators and macro in src/Debug.h
-debug_SOURCES = debug.cc $(DEBUG_SOURCE)
+debug_SOURCES = debug.cc stub_libmem.cc $(DEBUG_SOURCE)
-ESIExpressions_SOURCES = ESIExpressions.cc $(DEBUG_SOURCE)
+ESIExpressions_SOURCES = ESIExpressions.cc stub_libmem.cc $(DEBUG_SOURCE)
ESIExpressions_LDADD = $(top_builddir)/src/esi/Expression.o \
$(LDADD)
$(LDADD)
MemPoolTest_SOURCES = MemPoolTest.cc $(DEBUG_SOURCE)
+MemPoolTest_LDADD = \
+ $(top_builddir)/src/mem/libmem.la \
+ $(LDADD)
-splay_SOURCES = splay.cc $(DEBUG_SOURCE)
+splay_SOURCES = splay.cc stub_libmem.cc $(DEBUG_SOURCE)
-syntheticoperators_SOURCES = syntheticoperators.cc $(DEBUG_SOURCE)
+syntheticoperators_SOURCES = syntheticoperators.cc stub_libmem.cc $(DEBUG_SOURCE)
-VirtualDeleteOperator_SOURCES = VirtualDeleteOperator.cc $(DEBUG_SOURCE)
+VirtualDeleteOperator_SOURCES = VirtualDeleteOperator.cc stub_libmem.cc $(DEBUG_SOURCE)
## membanger won't link today. Bitrot..
##CC = gcc
## Several files need to be shared but we cannot depend on the other
## directories to be built.
test_tools.cc: $(top_srcdir)/test-suite/test_tools.cc
- cp $(top_srcdir)/test-suite/test_tools.cc .
+ cp $< $@
stub_debug.cc: $(top_srcdir)/src/tests/stub_debug.cc
- cp $(top_srcdir)/src/tests/stub_debug.cc .
+ cp $< $@
time.cc: $(top_srcdir)/src/time.cc
- cp $(top_srcdir)/src/time.cc .
+ cp $< $@
+
+stub_libmem.cc : $(top_srcdir)/src/tests/stub_libmem.cc STUB.h
+ cp $< $@
+
+STUB.h : $(top_srcdir)/src/tests/STUB.h
+ cp $< $@
# stock tools for unit tests - library independent versions of dlink_list
# etc.
# globals.cc is needed by test_tools.cc.
# Neither of these should be disted from here.
TESTSOURCES= test_tools.cc
-CLEANFILES += test_tools.cc stub_debug.cc time.cc
+CLEANFILES += test_tools.cc stub_debug.cc time.cc stub_libmem.cc STUB.h
## Test Scripts
EXTRA_DIST += helper-ok-dying.pl helper-ok.pl
-
## ##### cachemgr.cgi #####
DEFAULT_CACHEMGR_CONFIG = $(sysconfdir)/cachemgr.conf
cachemgr__CGIEXT__SOURCES = cachemgr.cc \
stub_debug.cc \
+ stub_libmem.cc \
test_tools.cc \
+ STUB.h \
time.cc
cachemgr__CGIEXT__CXXFLAGS = -DDEFAULT_CACHEMGR_CONFIG=\"$(DEFAULT_CACHEMGR_CONFIG)\" $(AM_CXXFLAGS)
cachemgr.cgi.8: $(srcdir)/cachemgr.cgi.8.in Makefile
$(SUBSTITUTE) < $(srcdir)/cachemgr.cgi.8.in > $@
-
-
## Shared
install-data-local:
## Several files need to be shared but we cannot depend on the other
## directories to be built.
test_tools.cc: $(top_srcdir)/test-suite/test_tools.cc
- cp $(top_srcdir)/test-suite/test_tools.cc .
+ cp $< $@
stub_debug.cc: $(top_srcdir)/src/tests/stub_debug.cc
- cp $(top_srcdir)/src/tests/stub_debug.cc .
+ cp $< $@
time.cc: $(top_srcdir)/src/time.cc
- cp $(top_srcdir)/src/time.cc .
+ cp $< $@
+
+stub_libmem.cc : $(top_srcdir)/src/tests/stub_libmem.cc STUB.h
+ cp $< $@
+
+STUB.h : $(top_srcdir)/src/tests/STUB.h
+ cp $< $@
+
# stock tools for unit tests - library independent versions of dlink_list
# etc.
# globals.cc is needed by test_tools.cc.
# Neither of these should be disted from here.
TESTSOURCES= test_tools.cc
-CLEANFILES += test_tools.cc stub_debug.cc time.cc
+CLEANFILES += test_tools.cc stub_debug.cc time.cc stub_libmem.cc STUB.h
## ##### squidclient #####
squidclient.cc \
stub_debug.cc \
test_tools.cc \
+ stub_libmem.cc \
+ STUB.h \
time.cc \
Transport.cc \
Transport.h