PIPS
tab.c
Go to the documentation of this file.
1
/*
2
3
$Id: tab.c 23065 2016-03-02 09:05:50Z coelho $
4
5
Copyright 1989-2016 MINES ParisTech
6
7
This file is part of PIPS.
8
9
PIPS is free software: you can redistribute it and/or modify it
10
under the terms of the GNU General Public License as published by
11
the Free Software Foundation, either version 3 of the License, or
12
any later version.
13
14
PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15
WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
FITNESS FOR A PARTICULAR PURPOSE.
17
18
See the GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22
23
*/
24
#ifdef HAVE_CONFIG_H
25
#include "pips_config.h"
26
#endif
27
28
#ifndef lint
29
char
vcid_pip_tab
[] =
"$Id: tab.c 23065 2016-03-02 09:05:50Z coelho $"
;
30
#endif
/* lint */
31
32
#include <stdio.h>
33
#include <stdlib.h>
34
35
/* Newgen includes */
36
#include "
genC.h
"
37
38
/* C3 includes */
39
#include "
boolean.h
"
40
#include "
arithmetique.h
"
41
#include "
vecteur.h
"
42
#include "
contrainte.h
"
43
#include "
ray_dte.h
"
44
#include "
sommet.h
"
45
#include "
sg.h
"
46
#include "
sc.h
"
47
#include "
polyedre.h
"
48
#include "
matrix.h
"
49
50
/* Pips includes */
51
#include "
ri.h
"
52
#include "constants.h"
53
#include "
ri-util.h
"
54
#include "
misc.h
"
55
#include "
bootstrap.h
"
56
#include "
complexity_ri.h
"
57
#include "
database.h
"
58
#include "
graph.h
"
59
#include "
dg.h
"
60
#include "
paf_ri.h
"
61
#include "
parser_private.h
"
62
#include "
property.h
"
63
#include "
reduction.h
"
64
#include "
text.h
"
65
#include "
paf-util.h
"
66
#include "pip.h"
67
68
69
#define max(x,y) (x>y? x : y)
70
#define TAB_CHUNK 4096*sizeof(Entier)
71
72
static
char
*
tab_free
, *
tab_top
;
73
static
struct
A
*
tab_base
;
74
extern
int
allocation
;
75
extern
long
int
cross_product
,
limit
;
76
77
void
tab_init
()
78
{
79
tab_free
= (
char
*)
malloc
(
sizeof
(
struct
A
));
80
if
(!
tab_free
)
81
{
printf
(
"tab_init : la machine est trop petite\n"
);
82
exit
(21);
83
}
84
allocation
= 1;
85
tab_top
=
tab_free
+
sizeof
(
struct
A
);
86
tab_base
= (
struct
A
*)
tab_free
;
87
tab_free
+=
sizeof
(
struct
A
);
88
tab_base
->
precedent
= NULL;
89
tab_base
->
bout
=
tab_top
;
90
}
91
92
char
*
tab_hwm
()
93
{
94
return
(
tab_free
);
95
}
96
97
void
tab_reset
(p)
98
char
*p;
99
{
struct
A
*g;
100
while
(
tab_base
)
101
{
102
if
((
char
*)
tab_base
+
sizeof
(
struct
A
) <= p && p <=
tab_top
)
break
;
103
g =
tab_base
->
precedent
;
104
free
(
tab_base
);
105
allocation
--;
106
tab_base
= g;
107
tab_top
=
tab_base
->
bout
;
108
}
109
if
(
tab_base
)
tab_free
= p;
110
else
printf
(
"tab_reset : panique\n"
);
111
}
112
113
Tableau
*
tab_alloc
(h, w, n)
114
int
h, w, n;
115
/* h : le nombre de ligne reelles;
116
n : le nombre de lignes virtuelles
117
*/
118
{
119
char
*p;
Tableau
*tp;
120
Entier
*q;
121
long
taille;
122
int
i;
123
taille = 2 *
sizeof
(
int
) + (h+n) *
sizeof
(
struct
L
)
124
+ h * w *
sizeof
(
Entier
);
125
if
(
tab_free
+ taille >=
tab_top
)
126
{
struct
A
* g;
127
long
int
d;
128
d =
max
(
TAB_CHUNK
, taille +
sizeof
(
struct
A
));
129
tab_free
= (
char
*)
malloc
(d);
130
if
(!
tab_free
)
131
{
printf
(
"tab_alloc : plus de place\n"
);
132
exit
(23);
133
}
134
allocation
++;
135
g = (
struct
A
*)
tab_free
;
136
g->
precedent
=
tab_base
;
137
tab_top
=
tab_free
+ d;
138
tab_free
+=
sizeof
(
struct
A
);
139
tab_base
= g;
140
g->
bout
=
tab_top
;
141
}
142
p =
tab_free
;
143
tab_free
+= taille;
144
tp = (
Tableau
*)p;
145
q = (
Entier
*)(p + 2 *
sizeof
(
int
) + (h+n) *
sizeof
(
struct
L
));
146
for
(i = 0; i<n ; i++)
147
{tp->
row
[i].
flags
=
Unit
|
Zero
;
148
tp->
row
[i].
objet
.
unit
= i;
149
}
150
for
(i = n; i < (h+n); i++)
151
{tp->
row
[i].
flags
= 0;
152
tp->
row
[i].
objet
.
val
= q;
153
q += w;
154
}
155
tp->
height
= h + n; tp->
width
= w;
156
return
(tp);
157
}
158
159
Tableau
*
tab_get
(foo, h, w, n)
160
FILE * foo;
161
int
h, w, n;
162
{
163
Tableau
*p;
164
int
i, j, c;
165
p =
tab_alloc
(h, w, n);
166
while
((c =
dgetc
(foo)) != EOF)
if
(c ==
'('
)
break
;
167
for
(i = n; i<h+n; i++)
168
{p->
row
[i].
flags
=
Unknown
;
169
while
((c =
dgetc
(foo)) != EOF)
if
(c ==
'['
)
break
;
170
for
(j = 0; j<w; j++)
171
if
(
dscanf
(foo,
FORMAT
, p->
row
[i].
objet
.
val
+j) < 0)
172
return
NULL;
173
while
((c =
dgetc
(foo)) != EOF)
if
(c ==
']'
)
break
;
174
}
175
while
((c =
dgetc
(foo)) != EOF)
if
(c ==
')'
)
break
;
176
return
((
Tableau
*) p);
177
}
178
179
char
*
Attr
[] = {
"Unit"
,
"+"
,
"-"
,
"0"
,
"*"
,
"?"
};
180
181
void
tab_display
(p, foo)
182
FILE *foo;
183
Tableau
*p;
184
{
185
186
int
i, j, ff, fff, n;
187
Entier
x
;
188
fprintf
(foo,
"%ld/[%d * %d]\n"
,
cross_product
, p->
height
, p->
width
);
189
for
(i = 0; i<p->
height
; i++)
190
{fff = ff = p->
row
[i].
flags
;
191
if
(ff == 0)
break
;
192
n = 0;
193
while
(fff)
194
{
if
(fff & 1)
fprintf
(foo,
"%s "
,
Attr
[n]);
195
n++; fff >>= 1;
196
}
197
fprintf
(foo,
"#["
);
198
if
(ff &
Unit
)
199
for
(j = 0; j<p->
width
; j++)
200
fprintf
(foo,
" /%d/"
,(j == p->
row
[i].
objet
.
unit
)? 1: 0);
201
else
202
for
(j = 0; j<p->
width
; j++)
203
{
x
=
Index
(p,i,j);
204
fprintf
(foo,
FORMAT
,
x
);
205
fprintf
(foo,
" "
);
206
}
207
fprintf
(foo,
" ]\n"
);
208
}
209
}
210
int
void const char const char const int
Definition:
arithmetique-local.h:585
arithmetique.h
boolean.h
bootstrap.h
complexity_ri.h
contrainte.h
database.h
dg.h
genC.h
malloc
void * malloc(YYSIZE_T)
free
void free(void *)
graph.h
dgetc
int dgetc(FILE *foo)
Definition:
maind.c:52
dscanf
int dscanf(FILE *foo, char *format, Entier *val)
Definition:
maind.c:70
matrix.h
exit
#define exit(code)
Definition:
misc-local.h:54
misc.h
paf-util.h
paf_ri.h
parser_private.h
Index
#define Index(p, i, j)
Definition:
pip__tab.h:45
Unknown
#define Unknown
Definition:
pip__tab.h:41
Unit
#define Unit
Definition:
pip__tab.h:36
Zero
#define Zero
Definition:
pip__tab.h:39
Entier
#define Entier
Definition:
pip__type.h:24
FORMAT
#define FORMAT
Definition:
pip__type.h:25
polyedre.h
property.h
ray_dte.h
reduction.h
ri-util.h
ri.h
sc.h
fprintf
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
printf
int printf()
sg.h
sommet.h
x
static char * x
Definition:
split_file.c:159
A
Definition:
pip__tab.h:25
A::bout
char * bout
Definition:
pip__tab.h:26
A::precedent
struct A * precedent
Definition:
pip__tab.h:25
L
Definition:
pip__tab.h:30
L::flags
int flags
Definition:
pip__tab.h:30
L::unit
int unit
Definition:
pip__tab.h:31
L::val
Entier * val
Definition:
pip__tab.h:32
L::objet
union L::@15 objet
T
Definition:
pip__tab.h:48
T::width
int width
Definition:
pip__tab.h:48
T::height
int height
Definition:
pip__tab.h:48
T::row
struct L row[1]
Definition:
pip__tab.h:49
Attr
char * Attr[]
Definition:
tab.c:179
tab_top
static char * tab_top
Definition:
tab.c:72
tab_alloc
Tableau * tab_alloc(int h, int w, int n)
h : le nombre de ligne reelles; n : le nombre de lignes virtuelles
Definition:
tab.c:113
tab_reset
void tab_reset(char *p)
Definition:
tab.c:97
limit
long int limit
Definition:
tab.c:75
tab_init
void tab_init()
Definition:
tab.c:77
tab_hwm
char * tab_hwm()
Definition:
tab.c:92
tab_base
static struct A * tab_base
Definition:
tab.c:73
vcid_pip_tab
char vcid_pip_tab[]
Definition:
tab.c:29
TAB_CHUNK
#define TAB_CHUNK
Definition:
tab.c:70
allocation
int allocation
External variables for direct call to PIP.
Definition:
pip.c:92
tab_free
static char * tab_free
Definition:
tab.c:72
max
#define max(x, y)
lint
Definition:
tab.c:69
tab_display
void tab_display(Tableau *p, FILE *foo)
Definition:
tab.c:181
cross_product
long int cross_product
Definition:
pip.c:91
tab_get
Tableau * tab_get(FILE *foo, int h, int w, int n)
Definition:
tab.c:159
text.h
vecteur.h
pips
src
Libs
pip
tab.c
Generated on Thu Sep 26 2024 22:11:43 for PIPS by
1.9.1