proxygen
MallocImpl.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <stdlib.h>
20 
21 #include <folly/Portability.h>
22 
23 extern "C" {
24 
25 #if FOLLY_HAVE_WEAK_SYMBOLS
26 void* mallocx(size_t, int) __attribute__((__weak__));
27 void* rallocx(void*, size_t, int) __attribute__((__weak__));
28 size_t xallocx(void*, size_t, size_t, int) __attribute__((__weak__));
29 size_t sallocx(const void*, int) __attribute__((__weak__));
30 void dallocx(void*, int) __attribute__((__weak__));
31 void sdallocx(void*, size_t, int) __attribute__((__weak__));
32 size_t nallocx(size_t, int) __attribute__((__weak__));
33 int mallctl(const char*, void*, size_t*, void*, size_t)
34  __attribute__((__weak__));
35 int mallctlnametomib(const char*, size_t*, size_t*) __attribute__((__weak__));
36 int mallctlbymib(const size_t*, size_t, void*, size_t*, void*, size_t)
37  __attribute__((__weak__));
38 #else
39 extern void* (*mallocx)(size_t, int);
40 extern void* (*rallocx)(void*, size_t, int);
41 extern size_t (*xallocx)(void*, size_t, size_t, int);
42 extern size_t (*sallocx)(const void*, int);
43 extern void (*dallocx)(void*, int);
44 extern void (*sdallocx)(void*, size_t, int);
45 extern size_t (*nallocx)(size_t, int);
46 extern int (*mallctl)(const char*, void*, size_t*, void*, size_t);
47 extern int (*mallctlnametomib)(const char*, size_t*, size_t*);
48 extern int (
49  *mallctlbymib)(const size_t*, size_t, void*, size_t*, void*, size_t);
50 #ifdef _MSC_VER
51 // We emulate weak linkage for MSVC. The symbols we're
52 // aliasing to are hiding in MallocImpl.cpp
53 #pragma comment(linker, "/alternatename:mallocx=mallocxWeak")
54 #pragma comment(linker, "/alternatename:rallocx=rallocxWeak")
55 #pragma comment(linker, "/alternatename:xallocx=xallocxWeak")
56 #pragma comment(linker, "/alternatename:sallocx=sallocxWeak")
57 #pragma comment(linker, "/alternatename:dallocx=dallocxWeak")
58 #pragma comment(linker, "/alternatename:sdallocx=sdallocxWeak")
59 #pragma comment(linker, "/alternatename:nallocx=nallocxWeak")
60 #pragma comment(linker, "/alternatename:mallctl=mallctlWeak")
61 #pragma comment(linker, "/alternatename:mallctlnametomib=mallctlnametomibWeak")
62 #pragma comment(linker, "/alternatename:mallctlbymib=mallctlbymibWeak")
63 #endif
64 #endif
65 }
int(* mallctlnametomib)(const char *, size_t *, size_t *)
Definition: MallocImpl.cpp:43
void *(* rallocx)(void *, size_t, int)
Definition: MallocImpl.cpp:36
size_t(* nallocx)(size_t, int)
Definition: MallocImpl.cpp:41
int(* mallctl)(const char *, void *, size_t *, void *, size_t)
Definition: MallocImpl.cpp:42
void(* dallocx)(void *, int)
Definition: MallocImpl.cpp:39
size_t(* sallocx)(const void *, int)
Definition: MallocImpl.cpp:38
size_t(* xallocx)(void *, size_t, size_t, int)
Definition: MallocImpl.cpp:37
void *(* mallocx)(size_t, int)
Definition: MallocImpl.cpp:35
void(* sdallocx)(void *, size_t, int)
Definition: MallocImpl.cpp:40
__attribute__((noinline, noclone)) VirtualBase *makeVirtual()
const
Definition: upload.py:398
int(* mallctlbymib)(const size_t *, size_t, void *, size_t *, void *, size_t)
Definition: MallocImpl.cpp:44