This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Dead code (was: Re: Good numbers from Ritter's new string allocator)


On Nov 29, 2001, Paolo Carlini <pcarlini@unitus.it> wrote:

> So: do you think it would be feasible for you to contribute to the
> project?

I've just given it a look, and I'm afraid I foresee some
difficulties.

First of all, since this is code in libstdc++, we can't just link
libiberty in, because there are licensing issues that might have to be
resolved.  We'd probably be better off just compiling in this
particular module of libiberty along with libstdc++.  And we should
probably use the C compiler to compile that, in order to avoid issues
such as getpagesize() not being declared.

What I'd recomment is to add a new C source file to libstdc++ with
contents such as:

#ifdef HAVE_CONFIG_H
#include <config.h>
#undef HAVE_CONFIG_H
#endif

#if ! HAVE_GETPAGESIZE
/* Don't introduce this function in libstdc++.  */
static int getpagesize(void);

#include "..../libiberty/getpagesize.c"
#endif

int
__libstdcxx_getpagesize()
{
  return getpagesize();
}


Then, add to libstdc++'s configure.in the following chunk of code, if
there's nothing similar already there:

AC_LANG_SAVE
AC_LANG_C
AC_CHECK_HEADERS([unistd.h sys/param.h])
AC_CHECK_FUNCS([getpagesize sysconf])
AC_LANG_RESTORE


Then, instead of calling getpagesize(), you'd declare

extern "C" int __libstdcxx_getpagesize(void);

and call this function wherever you'd call getpagesize().

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]