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