1*1208bc7eSAndroid Build Coastguard Worker#!/bin/sh -eu 2*1208bc7eSAndroid Build Coastguard Worker 3*1208bc7eSAndroid Build Coastguard Workerpublic_symbols_txt=$1 4*1208bc7eSAndroid Build Coastguard Workersymbol_prefix=$2 5*1208bc7eSAndroid Build Coastguard Worker 6*1208bc7eSAndroid Build Coastguard Workercat <<EOF 7*1208bc7eSAndroid Build Coastguard Worker/* 8*1208bc7eSAndroid Build Coastguard Worker * By default application code must explicitly refer to mangled symbol names, 9*1208bc7eSAndroid Build Coastguard Worker * so that it is possible to use jemalloc in conjunction with another allocator 10*1208bc7eSAndroid Build Coastguard Worker * in the same application. Define JEMALLOC_MANGLE in order to cause automatic 11*1208bc7eSAndroid Build Coastguard Worker * name mangling that matches the API prefixing that happened as a result of 12*1208bc7eSAndroid Build Coastguard Worker * --with-mangling and/or --with-jemalloc-prefix configuration settings. 13*1208bc7eSAndroid Build Coastguard Worker */ 14*1208bc7eSAndroid Build Coastguard Worker#ifdef JEMALLOC_MANGLE 15*1208bc7eSAndroid Build Coastguard Worker# ifndef JEMALLOC_NO_DEMANGLE 16*1208bc7eSAndroid Build Coastguard Worker# define JEMALLOC_NO_DEMANGLE 17*1208bc7eSAndroid Build Coastguard Worker# endif 18*1208bc7eSAndroid Build Coastguard WorkerEOF 19*1208bc7eSAndroid Build Coastguard Worker 20*1208bc7eSAndroid Build Coastguard Workerfor nm in `cat ${public_symbols_txt}` ; do 21*1208bc7eSAndroid Build Coastguard Worker n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 22*1208bc7eSAndroid Build Coastguard Worker echo "# define ${n} ${symbol_prefix}${n}" 23*1208bc7eSAndroid Build Coastguard Workerdone 24*1208bc7eSAndroid Build Coastguard Worker 25*1208bc7eSAndroid Build Coastguard Workercat <<EOF 26*1208bc7eSAndroid Build Coastguard Worker#endif 27*1208bc7eSAndroid Build Coastguard Worker 28*1208bc7eSAndroid Build Coastguard Worker/* 29*1208bc7eSAndroid Build Coastguard Worker * The ${symbol_prefix}* macros can be used as stable alternative names for the 30*1208bc7eSAndroid Build Coastguard Worker * public jemalloc API if JEMALLOC_NO_DEMANGLE is defined. This is primarily 31*1208bc7eSAndroid Build Coastguard Worker * meant for use in jemalloc itself, but it can be used by application code to 32*1208bc7eSAndroid Build Coastguard Worker * provide isolation from the name mangling specified via --with-mangling 33*1208bc7eSAndroid Build Coastguard Worker * and/or --with-jemalloc-prefix. 34*1208bc7eSAndroid Build Coastguard Worker */ 35*1208bc7eSAndroid Build Coastguard Worker#ifndef JEMALLOC_NO_DEMANGLE 36*1208bc7eSAndroid Build Coastguard WorkerEOF 37*1208bc7eSAndroid Build Coastguard Worker 38*1208bc7eSAndroid Build Coastguard Workerfor nm in `cat ${public_symbols_txt}` ; do 39*1208bc7eSAndroid Build Coastguard Worker n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 40*1208bc7eSAndroid Build Coastguard Worker echo "# undef ${symbol_prefix}${n}" 41*1208bc7eSAndroid Build Coastguard Workerdone 42*1208bc7eSAndroid Build Coastguard Worker 43*1208bc7eSAndroid Build Coastguard Workercat <<EOF 44*1208bc7eSAndroid Build Coastguard Worker#endif 45*1208bc7eSAndroid Build Coastguard WorkerEOF 46