aboutsummaryrefslogtreecommitdiffstats
path: root/vespamalloc
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-12-18 03:23:53 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2016-12-19 14:15:44 +0000
commitef031ed8d62e86a7355200b6982682d39dee5032 (patch)
treeb13ef2676937b1977313bdf7f158432bf3e67a57 /vespamalloc
parent876b07cf8ce2f17d08c772381877a468feefc7b4 (diff)
Do not include fastos.h in header files.
Diffstat (limited to 'vespamalloc')
-rw-r--r--vespamalloc/src/vespamalloc/malloc/common.cpp1
-rw-r--r--vespamalloc/src/vespamalloc/malloc/common.h3
-rw-r--r--vespamalloc/src/vespamalloc/malloc/memorywatcher.h1
-rw-r--r--vespamalloc/src/vespamalloc/malloc/overload.h22
-rw-r--r--vespamalloc/src/vespamalloc/malloc/threadproxy.cpp3
-rw-r--r--vespamalloc/src/vespamalloc/util/stream.cpp9
-rw-r--r--vespamalloc/src/vespamalloc/util/stream.h8
7 files changed, 27 insertions, 20 deletions
diff --git a/vespamalloc/src/vespamalloc/malloc/common.cpp b/vespamalloc/src/vespamalloc/malloc/common.cpp
index 68181c664a4..d14a0317630 100644
--- a/vespamalloc/src/vespamalloc/malloc/common.cpp
+++ b/vespamalloc/src/vespamalloc/malloc/common.cpp
@@ -1,5 +1,6 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespamalloc/malloc/common.h>
+#include <pthread.h>
namespace vespamalloc {
diff --git a/vespamalloc/src/vespamalloc/malloc/common.h b/vespamalloc/src/vespamalloc/malloc/common.h
index a065bc43a0a..ee08cfbafaa 100644
--- a/vespamalloc/src/vespamalloc/malloc/common.h
+++ b/vespamalloc/src/vespamalloc/malloc/common.h
@@ -1,7 +1,6 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/fastos/fastos.h>
#include <vespa/vespalib/util/atomic.h>
#include <vespa/vespalib/util/optimized.h>
#include <new>
@@ -13,6 +12,8 @@ extern "C" void MallocRecurseOnSuspend(bool recurse) __attribute__ ((noinline));
namespace vespamalloc {
+#define VESPA_DLL_EXPORT __attribute__ ((visibility("default")))
+
#define NELEMS(a) sizeof(a)/sizeof(a[0])
#define NUM_SIZE_CLASSES 32 // Max 64G
diff --git a/vespamalloc/src/vespamalloc/malloc/memorywatcher.h b/vespamalloc/src/vespamalloc/malloc/memorywatcher.h
index 8b41e1cc5e3..9bbfa38c416 100644
--- a/vespamalloc/src/vespamalloc/malloc/memorywatcher.h
+++ b/vespamalloc/src/vespamalloc/malloc/memorywatcher.h
@@ -6,6 +6,7 @@
#include <limits.h>
#include <sys/stat.h>
#include <ctype.h>
+#include <fcntl.h>
#include <vespa/defaults.h>
#include <vespamalloc/malloc/malloc.h>
#include <vespamalloc/util/callstack.h>
diff --git a/vespamalloc/src/vespamalloc/malloc/overload.h b/vespamalloc/src/vespamalloc/malloc/overload.h
index caf8184acd0..4f3f62b8655 100644
--- a/vespamalloc/src/vespamalloc/malloc/overload.h
+++ b/vespamalloc/src/vespamalloc/malloc/overload.h
@@ -28,7 +28,7 @@ void operator delete[](void* ptr, std::size_t sz, const std::nothrow_t&) noexcep
void* operator new(std::size_t sz) throw (std::bad_alloc)
{
void * ptr(vespamalloc::createAllocator()->malloc(sz));
- if (ptr == NULL) {
+ if (ptr == nullptr) {
throw std::bad_alloc();
}
return ptr;
@@ -90,7 +90,7 @@ void * realloc(void * ptr, size_t sz)
void* memalign(size_t align, size_t sz) __attribute__((visibility ("default")));
void* memalign(size_t align, size_t sz)
{
- void *ptr(NULL);
+ void *ptr(nullptr);
size_t align_1(align - 1);
if ((align & (align_1)) == 0) {
ptr = vespamalloc::_GmemP->malloc(vespamalloc::_GmemP->getMinSizeForAlignment(align, sz));
@@ -151,13 +151,13 @@ extern "C" VESPA_DLL_EXPORT void * local_dlopen(const char *filename, int flag)
VESPA_DLL_EXPORT void * local_dlopen(const char *filename, int flag)
{
// A pointer to the library version of dlopen.
- static dlopen_function real_dlopen = NULL;
+ static dlopen_function real_dlopen = nullptr;
const char * dlopenName = "dlopen";
- if (real_dlopen == NULL) {
+ if (real_dlopen == nullptr) {
real_dlopen = (dlopen_function) dlsym (RTLD_NEXT, dlopenName);
- if (real_dlopen == NULL) {
+ if (real_dlopen == nullptr) {
fprintf (stderr, "Could not find the dlopen function!\n");
abort();
}
@@ -174,13 +174,13 @@ extern "C" VESPA_DLL_EXPORT int local_dlclose(void * handle) __asm__("dlclose");
VESPA_DLL_EXPORT int local_dlclose(void * handle)
{
// A pointer to the library version of dlclose.
- static dlclose_function real_dlclose = NULL;
+ static dlclose_function real_dlclose = nullptr;
const char * dlcloseName = "dlclose";
- if (real_dlclose == NULL) {
+ if (real_dlclose == nullptr) {
real_dlclose = (dlclose_function) dlsym (RTLD_NEXT, dlcloseName);
- if (real_dlclose == NULL) {
+ if (real_dlclose == nullptr) {
fprintf (stderr, "Could not find the dlclose function!\n");
abort();
}
@@ -195,13 +195,13 @@ extern "C" VESPA_DLL_EXPORT void * local_dlsym(void * handle, const char * symbo
VESPA_DLL_EXPORT void * local_dlsym(void * handle, const char * symbol)
{
// A pointer to the library version of dlsym.
- static dlsym_function real_dlsym = NULL;
+ static dlsym_function real_dlsym = nullptr;
const char * dlsymName = "dlsym";
- if (real_dlsym == NULL) {
+ if (real_dlsym == nullptr) {
real_dlsym = (dlsym_function) dlvsym (RTLD_NEXT, dlsymName, "GLIBC_2.2.5");
- if (real_dlsym == NULL) {
+ if (real_dlsym == nullptr) {
fprintf (stderr, "Could not find the dlsym function!\n");
abort();
}
diff --git a/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp b/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp
index 7bbe2da345d..17da09f9b35 100644
--- a/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp
+++ b/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp
@@ -1,6 +1,9 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespamalloc/malloc/threadproxy.h>
#include <dlfcn.h>
+#include <pthread.h>
+#include <cstdio>
+#include <cerrno>
namespace vespamalloc {
diff --git a/vespamalloc/src/vespamalloc/util/stream.cpp b/vespamalloc/src/vespamalloc/util/stream.cpp
index 592d3a07709..dc0692350d1 100644
--- a/vespamalloc/src/vespamalloc/util/stream.cpp
+++ b/vespamalloc/src/vespamalloc/util/stream.cpp
@@ -1,6 +1,7 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <algorithm>
#include "stream.h"
+#include <algorithm>
+#include <stdio.h>
namespace vespamalloc {
@@ -15,7 +16,7 @@ asciistream::asciistream() :
asciistream::~asciistream()
{
free(_buffer);
- _buffer = NULL;
+ _buffer = nullptr;
}
asciistream::asciistream(const asciistream & rhs) :
@@ -64,7 +65,7 @@ asciistream & asciistream::operator << (uint32_t v)
asciistream & asciistream::operator << (int64_t v)
{
char tmp[32];
- int len = snprintf(tmp, sizeof(tmp), "%" PRId64, v);
+ int len = snprintf(tmp, sizeof(tmp), "%ld", v);
write(tmp, len);
return *this;
}
@@ -72,7 +73,7 @@ asciistream & asciistream::operator << (int64_t v)
asciistream & asciistream::operator << (uint64_t v)
{
char tmp[32];
- int len = snprintf(tmp, sizeof(tmp), "%" PRIu64, v);
+ int len = snprintf(tmp, sizeof(tmp), "%lu", v);
write(tmp, len);
return *this;
}
diff --git a/vespamalloc/src/vespamalloc/util/stream.h b/vespamalloc/src/vespamalloc/util/stream.h
index 175ae5de00f..67a33a542db 100644
--- a/vespamalloc/src/vespamalloc/util/stream.h
+++ b/vespamalloc/src/vespamalloc/util/stream.h
@@ -1,8 +1,8 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/fastos/fastos.h>
-#include <string>
+#include <cstring>
+#include <cstdint>
namespace vespamalloc {
@@ -16,7 +16,7 @@ public:
void swap(asciistream & rhs);
asciistream & operator << (char v) { write(&v, 1); return *this; }
asciistream & operator << (unsigned char v) { write(&v, 1); return *this; }
- asciistream & operator << (const char * v) { if (v != NULL) { write(v, strlen(v)); } return *this; }
+ asciistream & operator << (const char * v) { if (v != nullptr) { write(v, strlen(v)); } return *this; }
asciistream & operator << (int32_t v);
asciistream & operator << (uint32_t v);
asciistream & operator << (int64_t v);
@@ -38,7 +38,7 @@ private:
class string : public asciistream
{
public:
- string(const char * v = NULL) : asciistream() { *this << v; }
+ string(const char * v = nullptr) : asciistream() { *this << v; }
string & operator += (const char * v) { *this << v; return *this; }
string & operator += (const asciistream & v) { *this << v.c_str(); return *this; }
};