source: trunk/ADOL-C/include/adolc/common.h @ 392

Last change on this file since 392 was 392, checked in by kulshres, 7 years ago

Visual studio doesn't have trunc()

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     common.h
4 Revision: $Id: common.h 392 2013-01-28 15:19:28Z kulshres $
5 Contents: Common (global) ADOL-C header 
6 
7 Copyright (c) Andrea Walther, Andreas Griewank, Andreas Kowarz,
8               Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel
9 
10 This file is part of ADOL-C. This software is provided as open source.
11 Any use, reproduction, or distribution of the software constitutes
12 recipient's acceptance of the terms of the accompanying license file.
13 
14----------------------------------------------------------------------------*/
15
16#if !defined(ADOLC_COMMON_H)
17#define ADOLC_COMMON_H 1
18
19#include <stdint.h>
20/*--------------------------------------------------------------------------*/
21/* standard includes */
22#if !defined(__cplusplus)
23#   include <stdlib.h>
24#   include <stdio.h>
25#else
26#   include <cstdlib>
27#   include <cstdio>
28    using namespace std;
29#endif
30
31/*--------------------------------------------------------------------------*/
32/* type definitions */
33    typedef unsigned int uint;
34
35/*--------------------------------------------------------------------------*/
36/* OpenMP includes */
37#if defined(_OPENMP)
38#include <omp.h>
39#endif
40
41/*--------------------------------------------------------------------------*/
42/* system dependend configuration */
43#if defined(ADOLC_INTERNAL)
44#   if HAVE_CONFIG_H
45#       include "config.h"
46
47/*      malloc/calloc/realloc replacments */
48#       undef ADOLC_NO_MALLOC
49#       undef ADOLC_NO_REALLOC
50#       if !defined(HAVE_MALLOC)
51#           define ADOLC_NO_MALLOC 1
52#       else
53#           if (HAVE_MALLOC == 0)
54#               define ADOLC_NO_MALLOC 1
55#           endif /* HAVE_MALLOC == 0 */
56#       endif /* HAVE_MALLOC */
57#       if !defined(HAVE_REALLOC)
58#           define ADOLC_NO_REALLOC 1
59#       else
60#           if (HAVE_REALLOC == 0)
61#               define ADOLC_NO_REALLOC 1
62#           endif /* HAVE_REALLOC == 0 */
63#       endif /* HAVE_REALLOC */
64
65#       if defined(ADOLC_NO_MALLOC)
66#           include "malloc.h"
67#           define malloc rpl_malloc
68#           define calloc rpl_calloc
69#       endif /* ADOLC_NO_MALLOC */
70#       if defined(ADOLC_NO_REALLOC)
71#           include "malloc.h"
72#           define realloc rpl_realloc
73#       endif /* ADOLC_NO_REALLOC */
74
75#       ifndef HAVE_TRUNC
76#           define trunc(x) ( (x<0) ? ceil(x) : floor(x) )
77#       endif
78
79#   endif /* HAVE_CONFIG_H */
80#endif /* ADOLC_INTERNAL */
81
82/*--------------------------------------------------------------------------*/
83/* developer and user parameters */
84#include <adolc/dvlparms.h>
85#include <adolc/usrparms.h>
86#include <adolc/adolc_settings.h>
87
88/*--------------------------------------------------------------------------*/
89/* windows dll exports/imports */
90#if defined(ADOLC_DLL)
91#       define ADOLC_DLL_EXPORT __declspec(dllexport)
92#else
93#       define ADOLC_DLL_EXPORT
94#endif
95
96/*--------------------------------------------------------------------------*/
97/* further helpful macros */
98#if defined(__cplusplus)
99#  define BEGIN_C_DECLS extern "C" {
100#  define END_C_DECLS   }
101#else
102#  define BEGIN_C_DECLS
103#  define END_C_DECLS
104#endif
105
106#define MAXDEC(a,b) do { register revreal __r = (b); if ( __r > (a) ) (a) = __r; } while (0)
107#define MAXDECI(a,b) do { register int __r = (b); if ( __r > (a) ) (a) = __r; } while (0)
108#define MINDECR(a,b) do { register revreal __r = (b); if ( __r < (a) ) (a) = __r; } while (0)
109#define MINDEC(a,b) do { register int __r = (b); if ( __r < (a) ) (a) = __r; } while (0)
110
111#define MAX_ADOLC(a,b) ( (a)<(b)? (b):(a) )
112#define MIN_ADOLC(a,b) ( (a)>(b)? (b):(a) )
113
114/*--------------------------------------------------------------------------*/
115#endif
116
Note: See TracBrowser for help on using the repository browser.