File: Taucs_fix.h

package info (click to toggle)
cgal 3.2.1-2
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 47,752 kB
  • ctags: 72,510
  • sloc: cpp: 397,707; ansic: 10,393; sh: 4,232; makefile: 3,713; perl: 394; sed: 9
file content (92 lines) | stat: -rw-r--r-- 2,818 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright (c) 2005  INRIA (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.2-branch/Surface_mesh_parameterization/include/CGAL/Taucs_fix.h $
// $Id: Taucs_fix.h 30771 2006-04-26 13:54:53Z lsaboret $
//
//
// Author(s)     : Laurent Saboret, Pierre Alliez, Bruno Levy


#ifndef CGAL_TAUCS_FIX
#define CGAL_TAUCS_FIX

// Include TAUCS main header taucs.h
#ifndef CGAL_INCLUDED_TAUCS_H
    #define CGAL_INCLUDED_TAUCS_H

    // GCC 3.x does not compile if we include <complex.h> within "extern C {}"
    // and complains that this header is deprecated
    #if defined(__GNUC__)
        #undef __DEPRECATED
        #include <complex.h>
    #endif

    // TAUCS is a C library
    extern "C" {
        #include <taucs.h>
    }

    // Avoid error with std::min() and std::max()
    #undef min
    #undef max

#endif

#ifdef OSTYPE_linux
    #include <unistd.h>
    #include <math.h>
#endif


extern "C"
{

/********************************************************************/
/*                                                                  */
/* FIX OF TAUCS BUGGY FUNCTION taucs_available_memory_size()        */
/*                                                                  */
/********************************************************************/

/* taucs_available_memory_size/cgal_taucs_available_memory_size     */
/*   returns size of memory available for allocation                */
inline double cgal_taucs_available_memory_size()
{
    double m;       /* size of memory available for allocation */

#ifdef OSTYPE_linux
    /* taucs_available_memory_size() is buggy on Linux 2.6 */
    /* It returns only 1% of the actual memory             */
    double m_sys;   /* size of physical memory */
    m_sys  = (double) sysconf(_SC_PAGESIZE);
    m_sys *= (double) sysconf(_SC_PHYS_PAGES);

    /* we limit m by 0.75*m_sys */
    m = floor(0.75 * m_sys);
#else
    m = taucs_available_memory_size();
#endif

    taucs_printf("cgal_taucs_available_memory_size returns %lfMB\n", m/1048576.0);

    return m;
}

/* Redirect calls to cgal_taucs_available_memory_size()             */
/* to taucs_available_memory_size()                                 */
#define taucs_available_memory_size cgal_taucs_available_memory_size

} // extern "C"


#endif // CGAL_TAUCS_FIX