mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
--with-gc enables now support for Boehm's GC, if it's found and glib2 is
used. This also enables an extra check for perl library to verify scripts aren't using objects that have already been free'd - while not a fully safe solution it's much better than before :) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3063 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
495501c284
commit
cdc52b773e
92
configure.in
92
configure.in
@ -111,7 +111,7 @@ if test "x$prefix" != "xNONE"; then
|
||||
perl_prefix_note=yes
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(tests,
|
||||
AC_ARG_WITH(glib2,
|
||||
[ --with-glib2 Use GLIB 2.0 instead of 1.2],
|
||||
if test x$withval = xyes; then
|
||||
want_glib2=yes
|
||||
@ -124,6 +124,19 @@ AC_ARG_WITH(tests,
|
||||
fi,
|
||||
want_glib2=yes)
|
||||
|
||||
AC_ARG_WITH(gc,
|
||||
[ --with-gc Use garbage collector, requires GLIB2],
|
||||
if test x$withval = xyes; then
|
||||
want_gc=yes
|
||||
else
|
||||
if test "x$withval" = xno; then
|
||||
want_gc=no
|
||||
else
|
||||
want_gc=yes
|
||||
fi
|
||||
fi,
|
||||
want_gc=no)
|
||||
|
||||
AC_ARG_WITH(perl-staticlib,
|
||||
[ --with-perl-staticlib Specify that we want to link perl libraries
|
||||
statically in irssi, default is no],
|
||||
@ -219,6 +232,63 @@ AC_ARG_WITH(openssl-libs,
|
||||
[openssl_prefix=$withval],
|
||||
[openssl_prefix=/usr/lib])
|
||||
|
||||
dnl **
|
||||
dnl ** SSL Library checks (OpenSSL)
|
||||
dnl **
|
||||
|
||||
AC_ARG_ENABLE(ssl,
|
||||
[ --enable-ssl Turn on Secure Sockets Layer support [default=yes]],,
|
||||
enable_ssl=yes)
|
||||
|
||||
AC_ARG_WITH(openssl-includes,
|
||||
[ --with-openssl-includes Specify location of OpenSSL header files],
|
||||
[openssl_inc_prefix=-I$withval])
|
||||
|
||||
AC_ARG_WITH(openssl-libs,
|
||||
[ --with-openssl-libs Specify location of OpenSSL libs],
|
||||
[openssl_prefix=$withval],
|
||||
[openssl_prefix=/usr/lib])
|
||||
|
||||
if test "x$enable_ssl" = xyes; then
|
||||
###
|
||||
### Check for OpenSSL
|
||||
###
|
||||
save_CFLAGS=$CFLAGS;
|
||||
CFLAGS="-lcrypto";
|
||||
|
||||
enable_openssl="no";
|
||||
OPENSSL_LDFLAGS="";
|
||||
AC_CHECK_LIB(ssl, SSL_read,
|
||||
AC_CHECK_LIB(crypto, X509_new,
|
||||
AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h,
|
||||
[
|
||||
enable_openssl="yes";
|
||||
OPENSSL_LDFLAGS="-lssl -lcrypto"
|
||||
],
|
||||
AC_ERROR([Cannot find OpenSSL includes !])),
|
||||
AC_ERROR([Cannot find libCrypto !])),
|
||||
AC_ERROR([Cannot find libSSL !]))
|
||||
CFLAGS=$save_CFLAGS
|
||||
|
||||
if test "x$enable_openssl" = xyes; then
|
||||
AC_DEFINE(HAVE_OPENSSL)
|
||||
OPENSSL_LIBS="-L$openssl_prefix $OPENSSL_LDFLAGS"
|
||||
OPENSSL_CFLAGS="$openssl_inc_prefix"
|
||||
enable_openssl="yes, in $openssl_prefix"
|
||||
else
|
||||
OPENSSL_LIBS=
|
||||
OPENSSL_CFLAGS=
|
||||
fi
|
||||
|
||||
AC_SUBST(OPENSSL_CFLAGS)
|
||||
AC_SUBST(OPENSSL_LIBS)
|
||||
LIBS="$LIBS $OPENSSL_LIBS"
|
||||
CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
|
||||
else
|
||||
enable_openssl="no"
|
||||
fi
|
||||
|
||||
|
||||
dnl **
|
||||
dnl ** just some generic stuff...
|
||||
dnl **
|
||||
@ -462,7 +532,6 @@ fi
|
||||
|
||||
LIBS="$LIBS $GLIB_LIBS"
|
||||
|
||||
dnl * make sure glib2 + ssl isn't tried to be used, it won't work
|
||||
if test "x$enable_ssl" = xyes; then
|
||||
###
|
||||
### Check for OpenSSL
|
||||
@ -492,6 +561,22 @@ else
|
||||
enable_openssl="no"
|
||||
fi
|
||||
|
||||
dnl **
|
||||
dnl ** Garbage Collector
|
||||
dnl **
|
||||
if test "x$want_gc" = xyes; then
|
||||
if test "$glib_config_major_version" = "2"; then
|
||||
AC_CHECK_LIB(gc, GC_malloc, [
|
||||
AC_DEFINE(HAVE_GC)
|
||||
LIBS="$LIBS -lgc"
|
||||
], [
|
||||
want_gc=no
|
||||
])
|
||||
else
|
||||
want_gc=no
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl **
|
||||
dnl ** check if we can link dynamic libraries to modules
|
||||
dnl ** also checks if libraries are built to .libs dir
|
||||
@ -875,6 +960,8 @@ if test "x$want_ipv6" = "xyes"; then
|
||||
AC_MSG_RESULT($irssi_cv_type_in6_addr)
|
||||
fi
|
||||
|
||||
echo "OpenSSL support .............: ${enable_openssl}"
|
||||
|
||||
dnl **
|
||||
dnl ** IRSSI_VERSION_DATE and IRSSI_VERSION_TIME
|
||||
dnl **
|
||||
@ -1002,6 +1089,7 @@ echo
|
||||
echo "Building with IPv6 support ....... : $want_ipv6"
|
||||
echo "Building with SSL support ........ : ${enable_openssl}"
|
||||
echo "Building with 64bit DCC support .. : $offt_64bit"
|
||||
echo "Building with garbage collector .. : $want_gc"
|
||||
if test "x$enable_openssl" = "xno" -a "x$ssl_error" != "x"; then
|
||||
echo " - $ssl_error"
|
||||
fi
|
||||
|
@ -309,6 +309,17 @@ static void winsock_init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GC
|
||||
#include <gc/gc.h>
|
||||
GMemVTable gc_mem_table = {
|
||||
GC_malloc,
|
||||
GC_realloc,
|
||||
GC_free,
|
||||
|
||||
NULL, NULL, NULL
|
||||
};
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static struct poptOption options[] = {
|
||||
@ -316,6 +327,10 @@ int main(int argc, char **argv)
|
||||
{ NULL, '\0', 0, NULL }
|
||||
};
|
||||
|
||||
#ifdef HAVE_GC
|
||||
g_mem_set_vtable(&gc_mem_table);
|
||||
#endif
|
||||
|
||||
dummy = FALSE;
|
||||
quitting = FALSE;
|
||||
core_init_paths(argc, argv);
|
||||
|
@ -43,6 +43,10 @@
|
||||
#include "perl-core.h"
|
||||
#include "perl-common.h"
|
||||
|
||||
#ifdef HAVE_GC
|
||||
# include <gc/gc.h>
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char *stash;
|
||||
PERL_OBJECT_FUNC fill_func;
|
||||
@ -151,6 +155,7 @@ void *irssi_ref_object(SV *o)
|
||||
{
|
||||
SV **sv;
|
||||
HV *hv;
|
||||
void *p;
|
||||
|
||||
hv = hvref(o);
|
||||
if (hv == NULL)
|
||||
@ -158,8 +163,13 @@ void *irssi_ref_object(SV *o)
|
||||
|
||||
sv = hv_fetch(hv, "_irssi", 6, 0);
|
||||
if (sv == NULL)
|
||||
croak("variable is damaged");
|
||||
return GINT_TO_POINTER(SvIV(*sv));
|
||||
croak("variable is damaged");
|
||||
p = GINT_TO_POINTER(SvIV(*sv));
|
||||
#ifdef HAVE_GC
|
||||
if (GC_base(p) == NULL)
|
||||
croak("variable is already free'd");
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
void irssi_add_object(int type, int chat_type, const char *stash,
|
||||
|
Loading…
Reference in New Issue
Block a user