mirror of https://github.com/CGAL/cgal
eliminated code related to the handling of RS allocators (now done automatically inside the library)
This commit is contained in:
parent
2e17c21b01
commit
d96f41a2fb
|
|
@ -1 +1,2 @@
|
||||||
|
include/CGAL/RS/memory.h
|
||||||
include/CGAL/RS/refine_1.h
|
include/CGAL/RS/refine_1.h
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,6 @@
|
||||||
#include <mpfi.h>
|
#include <mpfi.h>
|
||||||
#include <boost/operators.hpp>
|
#include <boost/operators.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
# include <CGAL/RS/memory.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace CGAL{
|
namespace CGAL{
|
||||||
|
|
||||||
|
|
@ -63,13 +60,6 @@ class RS_polynomial_1:
|
||||||
void *(*_allocf)(size_t);
|
void *(*_allocf)(size_t);
|
||||||
void *(*_reallocf)(void*,size_t,size_t);
|
void *(*_reallocf)(void*,size_t,size_t);
|
||||||
void (*_freef)(void*,size_t);
|
void (*_freef)(void*,size_t);
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
// in case of using rs3, _gc_address stores the
|
|
||||||
// address of the memory zone used to allocate this
|
|
||||||
// polynomial (which is generally one of the two
|
|
||||||
// garbage collectors, rs2 or rs3)
|
|
||||||
gc_session *_gc_address;
|
|
||||||
#endif
|
|
||||||
void fetch_gmp_functions();
|
void fetch_gmp_functions();
|
||||||
public:
|
public:
|
||||||
// copy constructor and copy assignement operator
|
// copy constructor and copy assignement operator
|
||||||
|
|
@ -140,9 +130,6 @@ class RS_polynomial_1:
|
||||||
template<class T>RS_polynomial_1& operator*=(const T&);
|
template<class T>RS_polynomial_1& operator*=(const T&);
|
||||||
template<class T>RS_polynomial_1& operator/=(const T&);
|
template<class T>RS_polynomial_1& operator/=(const T&);
|
||||||
template<class T>RS_polynomial_1 operator/(const T&)const;
|
template<class T>RS_polynomial_1 operator/(const T&)const;
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
gc_session *get_gc_address() const;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
|
||||||
|
|
@ -32,28 +32,14 @@ void RS_polynomial_1::create_storage(int size){
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void RS_polynomial_1::free_storage(){
|
void RS_polynomial_1::free_storage(){
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
gc_session *old_address;
|
|
||||||
#endif
|
|
||||||
void *(*af)(size_t);
|
void *(*af)(size_t);
|
||||||
void *(*rf)(void*,size_t,size_t);
|
void *(*rf)(void*,size_t,size_t);
|
||||||
void (*ff)(void*,size_t);
|
void (*ff)(void*,size_t);
|
||||||
mp_get_memory_functions(&af,&rf,&ff);
|
mp_get_memory_functions(&af,&rf,&ff);
|
||||||
mp_set_memory_functions(_allocf,_reallocf,_freef);
|
mp_set_memory_functions(_allocf,_reallocf,_freef);
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
old_address=_gc_address;
|
|
||||||
//std::cout<<"set _gc_address to "<<_gc_address<<std::flush;
|
|
||||||
set_gc_session(_gc_address);
|
|
||||||
//std::cout<<" ok"<<std::endl;
|
|
||||||
#endif
|
|
||||||
for(int i=0;i<_degree+1;++i)
|
for(int i=0;i<_degree+1;++i)
|
||||||
mpz_clear(coef(i));
|
mpz_clear(coef(i));
|
||||||
mp_set_memory_functions(af,rf,ff);
|
mp_set_memory_functions(af,rf,ff);
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
//std::cout<<"set _gc_address to "<<old_address<<std::flush;
|
|
||||||
set_gc_session(old_address);
|
|
||||||
//std::cout<<" ok"<<std::endl;
|
|
||||||
#endif
|
|
||||||
(*_freef)(_coef,sizeof(mpz_t)*_capacity);
|
(*_freef)(_coef,sizeof(mpz_t)*_capacity);
|
||||||
_capacity=0;
|
_capacity=0;
|
||||||
}
|
}
|
||||||
|
|
@ -61,16 +47,6 @@ void RS_polynomial_1::free_storage(){
|
||||||
inline
|
inline
|
||||||
void RS_polynomial_1::fetch_gmp_functions(){
|
void RS_polynomial_1::fetch_gmp_functions(){
|
||||||
mp_get_memory_functions(&_allocf,&_reallocf,&_freef);
|
mp_get_memory_functions(&_allocf,&_reallocf,&_freef);
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
if(_allocf==rs3_rs_alloc){
|
|
||||||
//std::cout<<"alloc by rs3: "<<std::flush;
|
|
||||||
_gc_address=&rs3_gc_session;
|
|
||||||
}else{
|
|
||||||
//std::cout<<"alloc by something else: "<<std::flush;
|
|
||||||
_gc_address=&rs_default_gc_session;
|
|
||||||
}
|
|
||||||
//std::cout<<_gc_address<<std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
@ -296,13 +272,6 @@ RS_polynomial_1::times_monomial(mpz_srcptr c,int p)const{
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
inline
|
|
||||||
gc_session* RS_polynomial_1::get_gc_address() const{
|
|
||||||
return _gc_address;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
||||||
#endif // CGAL_RS_POLYNOMIAL_1_MEMBER_H
|
#endif // CGAL_RS_POLYNOMIAL_1_MEMBER_H
|
||||||
|
|
|
||||||
|
|
@ -26,16 +26,6 @@
|
||||||
#include <CGAL/RS/solve_1.h>
|
#include <CGAL/RS/solve_1.h>
|
||||||
#include <CGAL/RS/ugcd.h>
|
#include <CGAL/RS/ugcd.h>
|
||||||
#include <rs_exports.h>
|
#include <rs_exports.h>
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
extern "C"{
|
|
||||||
# define RS_I32 int
|
|
||||||
# include <rs_export.h>
|
|
||||||
# ifdef CGAL_USE_RS3
|
|
||||||
# include <rs_gc.h>
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
# include <CGAL/RS/memory.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace CGAL{
|
namespace CGAL{
|
||||||
|
|
||||||
|
|
@ -48,9 +38,6 @@ public std::binary_function<RS_polynomial_1,RS_polynomial_1,RS_polynomial_1>{
|
||||||
const RS_polynomial_1 &p2)const{
|
const RS_polynomial_1 &p2)const{
|
||||||
int dr,d1,d2;
|
int dr,d1,d2;
|
||||||
mpz_t * r_z;
|
mpz_t * r_z;
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
init_rs3();
|
|
||||||
#endif
|
|
||||||
d1=p1.get_degree();
|
d1=p1.get_degree();
|
||||||
d2=p2.get_degree();
|
d2=p2.get_degree();
|
||||||
dr=rs3_up_mz_gcd(
|
dr=rs3_up_mz_gcd(
|
||||||
|
|
@ -60,13 +47,6 @@ public std::binary_function<RS_polynomial_1,RS_polynomial_1,RS_polynomial_1>{
|
||||||
(const mpz_t*)p2.get_coefs(),
|
(const mpz_t*)p2.get_coefs(),
|
||||||
d2);
|
d2);
|
||||||
RS_polynomial_1 *result=new RS_polynomial_1(&r_z,dr);
|
RS_polynomial_1 *result=new RS_polynomial_1(&r_z,dr);
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
done_with_rs3();
|
|
||||||
mp_set_memory_functions(
|
|
||||||
__cgalrs_allocate_func,
|
|
||||||
__cgalrs_reallocate_func,
|
|
||||||
__cgalrs_free_func);
|
|
||||||
#endif
|
|
||||||
return *result;
|
return *result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -392,21 +372,11 @@ public std::unary_function<RS_polynomial_1,RS_polynomial_1*>{
|
||||||
if(P.get_degree()){
|
if(P.get_degree()){
|
||||||
int d_sfp;
|
int d_sfp;
|
||||||
mpz_t* sfp_z;
|
mpz_t* sfp_z;
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
init_rs3();
|
|
||||||
#endif
|
|
||||||
d_sfp=rs3_up_mz_sfp(
|
d_sfp=rs3_up_mz_sfp(
|
||||||
&sfp_z,
|
&sfp_z,
|
||||||
(const mpz_t*)P.get_coefs(),
|
(const mpz_t*)P.get_coefs(),
|
||||||
P.get_degree());
|
P.get_degree());
|
||||||
RS_polynomial_1 *result=new RS_polynomial_1(&sfp_z,d_sfp);
|
RS_polynomial_1 *result=new RS_polynomial_1(&sfp_z,d_sfp);
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
done_with_rs3();
|
|
||||||
mp_set_memory_functions(
|
|
||||||
__cgalrs_allocate_func,
|
|
||||||
__cgalrs_reallocate_func,
|
|
||||||
__cgalrs_free_func);
|
|
||||||
#endif
|
|
||||||
return result;
|
return result;
|
||||||
}else
|
}else
|
||||||
return (new RS_polynomial_1(
|
return (new RS_polynomial_1(
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,6 @@
|
||||||
|
|
||||||
#include <CGAL/Polynomial.h>
|
#include <CGAL/Polynomial.h>
|
||||||
#include <CGAL/RS/polynomial_1.h>
|
#include <CGAL/RS/polynomial_1.h>
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
# include <CGAL/RS/memory.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace CGAL{
|
namespace CGAL{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,6 @@
|
||||||
#include <CGAL/RS/polynomial_1.h>
|
#include <CGAL/RS/polynomial_1.h>
|
||||||
#include <CGAL/RS/algebraic_1.h>
|
#include <CGAL/RS/algebraic_1.h>
|
||||||
#include <rs_exports.h>
|
#include <rs_exports.h>
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
# include <CGAL/RS/memory.h>
|
|
||||||
# define RS_I32 int
|
|
||||||
# include <rs_export.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace CGAL{
|
namespace CGAL{
|
||||||
|
|
||||||
|
|
@ -53,34 +48,6 @@ inline void init_solver(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
inline void init_rs3(){
|
|
||||||
static bool first=true;
|
|
||||||
if(first){
|
|
||||||
first=false;
|
|
||||||
init_solver();
|
|
||||||
rs_set_usr_memory_fncts
|
|
||||||
(rs3_rs_alloc,rs3_rs_realloc,rs3_rs_free);
|
|
||||||
mp_set_memory_functions
|
|
||||||
(rs3_rs_alloc,rs3_rs_gmp_realloc,rs3_rs_gmp_free);
|
|
||||||
set_gc_session(&rs3_gc_session);
|
|
||||||
rs_internal_init();
|
|
||||||
}else{
|
|
||||||
rs_set_usr_memory_fncts
|
|
||||||
(rs3_rs_alloc,rs3_rs_realloc,rs3_rs_free);
|
|
||||||
mp_set_memory_functions
|
|
||||||
(rs3_rs_alloc,rs3_rs_gmp_realloc,rs3_rs_gmp_free);
|
|
||||||
set_gc_session(&rs3_gc_session);
|
|
||||||
rs_internal_reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void done_with_rs3(){
|
|
||||||
mp_set_memory_functions(RS_gmpalloc,RS_gmprealloc,RS_gmpfree);
|
|
||||||
set_gc_session(&rs_default_gc_session);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// reset RS memory
|
// reset RS memory
|
||||||
inline void reset_solver(){
|
inline void reset_solver(){
|
||||||
rs_reset_all();
|
rs_reset_all();
|
||||||
|
|
@ -192,10 +159,6 @@ inline int solve_1(
|
||||||
mpfi_ptr *x,
|
mpfi_ptr *x,
|
||||||
const RS_polynomial_1 &p1,
|
const RS_polynomial_1 &p1,
|
||||||
unsigned int prec=CGAL_RS_DEF_PREC){
|
unsigned int prec=CGAL_RS_DEF_PREC){
|
||||||
#ifdef CGAL_USE_OLD_RS3
|
|
||||||
set_gc_session(p1.get_gc_address());
|
|
||||||
//set_gc_session(&rs3_gc_session);
|
|
||||||
#endif
|
|
||||||
rs_reset_all();
|
rs_reset_all();
|
||||||
create_rs_upoly(p1.get_coefs(),p1.get_degree(),rs_get_default_up());
|
create_rs_upoly(p1.get_coefs(),p1.get_degree(),rs_get_default_up());
|
||||||
set_rs_precisol(prec);
|
set_rs_precisol(prec);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue