Home | History | Annotate | Download | only in jemalloc
      1 #!/bin/sh
      2 
      3 public_symbols_txt=$1
      4 symbol_prefix=$2
      5 
      6 cat <<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
     18 EOF
     19 
     20 for nm in `cat ${public_symbols_txt}` ; do
     21   n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'`
     22   echo "#  define ${n} ${symbol_prefix}${n}"
     23 done
     24 
     25 cat <<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
     36 EOF
     37 
     38 for nm in `cat ${public_symbols_txt}` ; do
     39   n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'`
     40   echo "#  undef ${symbol_prefix}${n}"
     41 done
     42 
     43 cat <<EOF
     44 #endif
     45 EOF
     46