Backed out 3 changesets (bug 1854025) for causing build bustages.
[gecko.git] / memory / build / fallback.cpp
blob6f1791bed9cf421a3ef931a29bbb476c514f0481
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozmemory.h"
8 #include "mozjemalloc.h"
9 #include <stdlib.h>
11 #ifndef HAVE_MEMALIGN
12 MOZ_MEMORY_API void* memalign(size_t aAlignment, size_t aSize) {
13 # ifdef XP_WIN
14 return _aligned_malloc(aSize, aAlignment);
15 # else
16 void* ret;
17 if (posix_memalign(&ret, aAlignment, aSize) != 0) {
18 return nullptr;
20 return ret;
21 # endif
23 #endif
25 struct SystemMalloc {
26 #define MALLOC_DECL(name, return_type, ...) \
27 static inline return_type name(ARGS_HELPER(TYPED_ARGS, ##__VA_ARGS__)) { \
28 return ::name(ARGS_HELPER(ARGS, ##__VA_ARGS__)); \
30 #define MALLOC_FUNCS MALLOC_FUNCS_MALLOC_BASE
31 #include "malloc_decls.h"
34 #define MALLOC_DECL(name, return_type, ...) \
35 MOZ_JEMALLOC_API return_type name(ARGS_HELPER(TYPED_ARGS, ##__VA_ARGS__)) { \
36 return DummyArenaAllocator<SystemMalloc>::name( \
37 ARGS_HELPER(ARGS, ##__VA_ARGS__)); \
39 #define MALLOC_FUNCS MALLOC_FUNCS_ARENA
40 #include "malloc_decls.h"