/*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// includes and uses fbstring.
#if defined(_GLIBCXX_USE_FB) && !defined(_LIBSTDCXX_FBSTRING)
+#include "folly/detail/Malloc.h"
+
#include <string>
namespace folly {
using std::goodMallocSize;
#ifdef _LIBSTDCXX_FBSTRING
#pragma GCC system_header
+
+/**
+ * Declare rallocm() and allocm() as weak symbols. These will be provided by
+ * jemalloc if we are using jemalloc, or will be NULL if we are using another
+ * malloc implementation.
+ */
+extern "C" int rallocm(void**, size_t*, size_t, size_t, int)
+__attribute__((weak));
+extern "C" int allocm(void**, size_t*, size_t, int)
+__attribute__((weak));
+
+#include <bits/functexcept.h>
#define FOLLY_HAVE_MALLOC_H 1
#else
+#include "folly/detail/Malloc.h"
#include "folly/Portability.h"
#endif
// for malloc_usable_size
// NOTE: FreeBSD 9 doesn't have malloc.h. It's defitions
// are found in stdlib.h.
-#ifdef FOLLY_HAVE_MALLOC_H
+#if FOLLY_HAVE_MALLOC_H
#include <malloc.h>
#else
#include <stdlib.h>
#include <new>
-#include <bits/functexcept.h>
-
/**
* Define various ALLOCM_* macros normally provided by jemalloc. We define
* them so that we don't have to include jemalloc.h, in case the program is
#endif /* ALLOCM_SUCCESS */
-/**
- * Declare rallocm() and malloc_usable_size() as weak symbols. It
- * will be provided by jemalloc if we are using jemalloc, or it will
- * be NULL if we are using another malloc implementation.
- */
-extern "C" int rallocm(void**, size_t*, size_t, size_t, int)
-__attribute__((weak));
-extern "C" int allocm(void**, size_t*, size_t, int)
-__attribute__((weak));
-
#ifdef _LIBSTDCXX_FBSTRING
namespace std _GLIBCXX_VISIBILITY(default) {
_GLIBCXX_BEGIN_NAMESPACE_VERSION