Skip to content

Commit

Permalink
Making autoloading of 'reference' and 'shared' customizable
Browse files Browse the repository at this point in the history
new Added configure option
chg Explained more generic CountedRef::is_ref(leftv)
  • Loading branch information
Alexander Dreyer committed Sep 10, 2012
1 parent 8353e43 commit dadb843
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 129 deletions.
25 changes: 25 additions & 0 deletions Singular/configure
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ NEED_LIBS
FLINT_HOME
FLINT_LIBS
FLINT_CFLAGS
SI_COUNTEDREF_AUTOLOAD
MP_LIBS
HAVE_MPSR
HAVE_SVD
Expand Down Expand Up @@ -732,6 +733,7 @@ with_Plural
with_NTL
with_RatGB
with_flint
enable_countedref
'
ac_precious_vars='build_alias
host_alias
Expand Down Expand Up @@ -1351,6 +1353,12 @@ if test -n "$ac_init_help"; then

cat <<\_ACEOF
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-countedref Enable autoloading of reference counted types
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
Expand Down Expand Up @@ -8821,6 +8829,23 @@ fi

min_flint_version=2.3

# Check whether --enable-countedref was given.
if test "${enable_countedref+set}" = set; then :
enableval=$enable_countedref; if test "x$enableval" = "xyes"; then
ENABLE_COUNTEDREF_AUTOLOAD=yes
fi
else
ENABLE_COUNTEDREF_AUTOLOAD=no
fi


if test x"${ENABLE_COUNTEDREF_AUTOLOAD}" == xyes; then

$as_echo "#define SI_COUNTEDREF_AUTOLOAD 1" >>confdefs.h


fi


BACKUP_CFLAGS=${CFLAGS}
BACKUP_LIBS=${LIBS}
Expand Down
11 changes: 11 additions & 0 deletions Singular/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ AC_ARG_WITH(flint,

min_flint_version=ifelse([$1], ,2.3,$1)

AC_ARG_ENABLE(countedref,
[ --enable-countedref Enable autoloading of reference counted types],
[if test "x$enableval" = "xyes"; then
ENABLE_COUNTEDREF_AUTOLOAD=yes
fi], ENABLE_COUNTEDREF_AUTOLOAD=no)

if test x"${ENABLE_COUNTEDREF_AUTOLOAD}" == xyes; then
AC_DEFINE([SI_COUNTEDREF_AUTOLOAD],1,[Enable autoloading of reference counted types])
AC_SUBST(SI_COUNTEDREF_AUTOLOAD)
fi


dnl Check for existence
BACKUP_CFLAGS=${CFLAGS}
Expand Down
10 changes: 5 additions & 5 deletions Singular/countedref.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ void* countedref_Init(blackbox*)
return NULL;
}

/// We use the as a marker of refernce types.
/// We use the function pointer as a marker of reference types
/// for CountedRef::is_ref(leftv), see the latter for details
BOOLEAN countedref_CheckAssign(blackbox *b, leftv L, leftv R)
{
return FALSE;
Expand All @@ -203,6 +204,9 @@ class CountedRef {
typedef CountedRefPtr<CountedRefData*> data_ptr;

/// Check whether argument is already a reference type
/// @note We check for the function pointer @c countedref_CheckAssign here,
/// that we (ab-)use as a unique marker. This avoids to check a bunch of
/// of runtime-varying @c typ IDs for identifying reference-like types.
static BOOLEAN is_ref(leftv arg) {
int typ = arg->Typ();
return ((typ > MAX_TOK) &&
Expand Down Expand Up @@ -712,7 +716,3 @@ void countedref_shared_load()
}


#ifdef HAVE_DYNAMIC_COUNTEDREF
extern "C" { void mod_init() { countedref_init(); } }
#endif

4 changes: 0 additions & 4 deletions Singular/countedref.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,11 @@ class LeftvDeep:
void countedref_reference_load();
void countedref_shared_load();

//#define SINGULAR_COUNTEDREF_AUTOLOAD

inline void
countedref_init()
{
#ifdef SINGULAR_COUNTEDREF_AUTOLOAD
countedref_reference_load();
countedref_shared_load();
#endif
}


Expand Down
4 changes: 2 additions & 2 deletions Singular/extra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2896,7 +2896,7 @@ static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h)
/*==== countedref: reference and shared ====*/
if (strcmp(sys_cmd, "shared") == 0)
{
#ifndef SINGULAR_COUNTEDREF_AUTOLOAD
#ifndef SI_COUNTEDREF_AUTOLOAD
void countedref_shared_load();
countedref_shared_load();
#endif
Expand All @@ -2905,7 +2905,7 @@ static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h)
}
else if (strcmp(sys_cmd, "reference") == 0)
{
#ifndef SINGULAR_COUNTEDREF_AUTOLOAD
#ifndef SI_COUNTEDREF_AUTOLOAD
void countedref_reference_load();
countedref_reference_load();
#endif
Expand Down
2 changes: 2 additions & 0 deletions Singular/mod2.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
#undef SI_CPU_IA64
/* CPU type: x86_64: */
#undef SI_CPU_X86_64
/* Autoload reference counted types like reference and shared */
#undef SI_COUNTEDREF_AUTOLOAD
/* whether development version of python is available */
#undef HAVE_PYTHON
/* whether static development version of python is available */
Expand Down
2 changes: 2 additions & 0 deletions Singular/tesths.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ int main( /* main entry to Singular */
*/
}
pyobject_setup();
#ifdef SI_COUNTEDREF_AUTOLOAD
countedref_init();
#endif
#ifdef HAVE_FANS
bbcone_setup();
bbpolytope_setup();
Expand Down
Loading

0 comments on commit dadb843

Please sign in to comment.