Warnings on vc14 were eliminated
[occt.git] / src / AdvApp2Var / AdvApp2Var_SysBase.hxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 // AdvApp2Var_SysBase.hxx
15 #ifndef AdvApp2Var_SysBase_HeaderFile
16 #define AdvApp2Var_SysBase_HeaderFile
17
18 #include <Standard_Macro.hxx>
19 #include <AdvApp2Var_Data_f2c.hxx>
20 #if _MSC_VER
21 #include <stddef.h>
22 #else
23 #include <stdint.h>
24 #endif
25
26 class AdvApp2Var_SysBase {
27  public:
28   Standard_EXPORT AdvApp2Var_SysBase();
29   Standard_EXPORT ~AdvApp2Var_SysBase();
30   
31   //
32   Standard_EXPORT int mainial_();
33
34   Standard_EXPORT static int macinit_(int *, 
35                                       int *);
36   //
37   Standard_EXPORT int mcrdelt_(integer *iunit, 
38                                       integer *isize, 
39                                       void *t, 
40                                       intptr_t *iofset, 
41                                       integer *iercod);
42
43   Standard_EXPORT static int mcrfill_(integer *size, 
44                                       void *tin, 
45                                       void *tout);
46
47   Standard_EXPORT int mcrrqst_(integer *iunit, 
48                                       integer *isize, 
49                                       void *t, 
50                                       intptr_t *iofset, 
51                                       integer *iercod);
52   Standard_EXPORT static integer mnfndeb_();
53
54   Standard_EXPORT static int do__fio(); 
55   Standard_EXPORT static int do__lio ();
56   Standard_EXPORT int macrai4_(integer *nbelem, 
57                                       integer *maxelm, 
58                                       integer *itablo,
59                                       intptr_t *iofset,
60                                       integer *iercod);
61   Standard_EXPORT int macrar8_(integer *nbelem, 
62                                       integer *maxelm,
63                                       doublereal *xtablo, 
64                                       intptr_t *iofset, 
65                                       integer *iercod);
66   Standard_EXPORT int macrdi4_(integer *nbelem, 
67                                       integer *maxelm, 
68                                       integer *itablo, 
69                                       intptr_t *iofset, 
70                                       integer *iercod);
71
72   Standard_EXPORT int macrdr8_(integer *nbelem,
73                                       integer *maxelm, 
74                                       doublereal *xtablo, 
75                                       intptr_t *iofset, 
76                                       integer *iercod);
77   Standard_EXPORT static int maermsg_(const char *cnompg, 
78                                       integer *icoder, 
79                                       ftnlen cnompg_len);
80   Standard_EXPORT static int maitbr8_(integer *itaill, 
81                                       doublereal *xtab, 
82                                       doublereal *xval);
83   Standard_EXPORT static int maovsr8_(integer *ivalcs);
84   Standard_EXPORT static int mgenmsg_(const char *nomprg, 
85                                       ftnlen nomprg_len);
86
87   Standard_EXPORT static int mgsomsg_(const char *nomprg, 
88                                       ftnlen nomprg_len);
89   Standard_EXPORT static void miraz_(integer *taille,
90                                      void *adt);
91   Standard_EXPORT static int msifill_(integer *nbintg, 
92                                       integer *ivecin,
93                                       integer *ivecou);
94   Standard_EXPORT static int msrfill_(integer *nbreel, 
95                                       doublereal *vecent,
96                                       doublereal * vecsor);
97   Standard_EXPORT static int mswrdbg_(const char *ctexte, 
98                                       ftnlen ctexte_len);
99   Standard_EXPORT static void mvriraz_(integer *taille,
100                                        void*adt);
101   
102 private:
103   int macrchk_();
104   int mcrlist_(integer *ier) const;
105
106   /* Maximum number of allowed allocation requests.
107      Currently the maximum known number of requests is 7 - see
108      AdvApp2Var_MathBase::mmresol_(). So the current value is a safe margin and
109      a reasonable balance to not provoke stack overflow (especially in
110      multi-threaded execution). Previous number of 1000 was excessive but
111      tolerable when used for static memory.
112   */
113   static const int MAX_ALLOC_NB = 32;
114   
115   enum {
116     static_allocation = 0, /* indicates static allocation, currently not used */
117     heap_allocation   = 1  /* indicates heap allocation */
118   };
119   
120   /* Describes an individual memory allocation request.
121      See format description in the AdvApp2Var_SysBase.cxx.
122      The field order is preserved and the sizes are chosen to minimize
123      memory footprint. Fields containing address have the intptr_t type
124      for easier arithmetic and to avoid casts in the source code.
125
126      No initialization constructor should be provided to avoid wasting
127      time when allocating a field mcrgene_.
128   */
129   struct mitem {
130     unsigned char   prot;
131     unsigned char   unit; //unit of allocation: 1, 2, 4 or 8
132     integer         reqsize;
133     intptr_t        loc;
134     intptr_t        offset;
135     unsigned char   alloctype; // static_allocation or heap_allocation
136     integer         size;
137     intptr_t        addr;
138     integer         userzone; //not used
139     intptr_t        startaddr;
140     intptr_t        endaddr;
141     integer         rank;
142   };
143   
144   struct {
145     mitem           icore[MAX_ALLOC_NB];
146     integer         ncore;
147     unsigned char   lprot;
148   } mcrgene_;
149
150   /* Contains statistics on allocation requests.
151      Index 0 corresponds to static_allocation, 1 - to heap allocation.
152      nrqst - number of allocation requests;
153      ndelt - number of deallocation requests;
154      nbyte - current number of allocated bytes;
155      mbyte - maximum number of ever allocated bytes.
156   */
157   struct {
158     integer nrqst[2], ndelt[2], nbyte[2], mbyte[2];
159   } mcrstac_; 
160 };
161
162 #endif