Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
34e56753
Commit
34e56753
authored
Jan 17, 1992
by
Richard Stallman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
From-SVN: r204
parent
6c65299b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
475 additions
and
366 deletions
+475
-366
gcc/global.c
+21
-5
gcc/integrate.c
+1
-1
gcc/optabs.c
+136
-151
gcc/print-tree.c
+1
-1
gcc/protoize.c
+316
-208
No files found.
gcc/global.c
View file @
34e56753
/* Allocate registers for pseudo-registers that span basic blocks.
/* Allocate registers for pseudo-registers that span basic blocks.
Copyright (C) 1987
-
1991 Free Software Foundation, Inc.
Copyright (C) 1987
, 1988,
1991 Free Software Foundation, Inc.
This file is part of GNU CC.
This file is part of GNU CC.
...
@@ -394,9 +394,17 @@ global_alloc (file)
...
@@ -394,9 +394,17 @@ global_alloc (file)
for
(
i
=
FIRST_PSEUDO_REGISTER
;
i
<
max_regno
;
i
++
)
for
(
i
=
FIRST_PSEUDO_REGISTER
;
i
<
max_regno
;
i
++
)
if
(
reg_allocno
[
i
]
<
0
&&
reg_renumber
[
i
]
>=
0
)
if
(
reg_allocno
[
i
]
<
0
&&
reg_renumber
[
i
]
>=
0
)
{
{
local_reg_n_refs
[
reg_renumber
[
i
]]
+=
reg_n_refs
[
i
];
int
regno
=
reg_renumber
[
i
];
local_reg_live_length
[
reg_renumber
[
i
]]
+=
reg_live_length
[
i
];
int
endregno
=
regno
+
HARD_REGNO_NREGS
(
regno
,
PSEUDO_REGNO_MODE
(
i
));
int
j
;
for
(
j
=
regno
;
j
<
endregno
;
j
++
)
{
local_reg_n_refs
[
j
]
+=
reg_n_refs
[
i
];
local_reg_live_length
[
j
]
+=
reg_live_length
[
i
];
}
}
}
/* We can't override local-alloc for a reg used not just by local-alloc. */
/* We can't override local-alloc for a reg used not just by local-alloc. */
for
(
i
=
0
;
i
<
FIRST_PSEUDO_REGISTER
;
i
++
)
for
(
i
=
0
;
i
<
FIRST_PSEUDO_REGISTER
;
i
++
)
if
(
regs_ever_live
[
i
])
if
(
regs_ever_live
[
i
])
...
@@ -1016,8 +1024,16 @@ find_reg (allocno, losers, all_regs_p, accept_call_clobbered, retrying)
...
@@ -1016,8 +1024,16 @@ find_reg (allocno, losers, all_regs_p, accept_call_clobbered, retrying)
than it would be used by this one allocno! */
than it would be used by this one allocno! */
int
k
;
int
k
;
for
(
k
=
0
;
k
<
max_regno
;
k
++
)
for
(
k
=
0
;
k
<
max_regno
;
k
++
)
if
(
reg_renumber
[
k
]
==
i
)
if
(
reg_renumber
[
k
]
>=
0
)
reg_renumber
[
k
]
=
-
1
;
{
int
regno
=
reg_renumber
[
k
];
int
endregno
=
regno
+
HARD_REGNO_NREGS
(
regno
,
PSEUDO_REGNO_MODE
(
k
));
if
(
i
>=
regno
&&
i
<
endregno
)
reg_renumber
[
k
]
=
-
1
;
}
best_reg
=
i
;
best_reg
=
i
;
break
;
break
;
}
}
...
...
gcc/integrate.c
View file @
34e56753
/* Procedure integration for GNU CC.
/* Procedure integration for GNU CC.
Copyright (C) 1988, 199
2
Free Software Foundation, Inc.
Copyright (C) 1988, 199
1
Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
Contributed by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
This file is part of GNU CC.
...
...
gcc/optabs.c
View file @
34e56753
/* Expand the basic unary and binary arithmetic operations, for GNU compiler.
/* Expand the basic unary and binary arithmetic operations, for GNU compiler.
Copyright (C) 1987
-1991
Free Software Foundation, Inc.
Copyright (C) 1987
, 1988, 1992
Free Software Foundation, Inc.
This file is part of GNU CC.
This file is part of GNU CC.
...
@@ -189,7 +189,6 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -189,7 +189,6 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
{
{
enum
mode_class
class
;
enum
mode_class
class
;
enum
machine_mode
wider_mode
;
enum
machine_mode
wider_mode
;
enum
machine_mode
submode
=
mode_for_size
(
BITS_PER_WORD
,
MODE_INT
,
0
);
register
rtx
temp
;
register
rtx
temp
;
int
commutative_op
=
0
;
int
commutative_op
=
0
;
int
shift_op
=
(
binoptab
->
code
==
ASHIFT
int
shift_op
=
(
binoptab
->
code
==
ASHIFT
...
@@ -219,10 +218,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -219,10 +218,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
op0
=
force_reg
(
mode
,
op0
);
op0
=
force_reg
(
mode
,
op0
);
if
(
CONSTANT_P
(
op1
)
&&
preserve_subexpressions_p
()
&&
rtx_cost
(
op1
)
>
2
)
if
(
CONSTANT_P
(
op1
)
&&
preserve_subexpressions_p
()
&&
rtx_cost
(
op1
)
>
2
)
op1
=
force_reg
((
shift_op
op1
=
force_reg
(
shift_op
?
word_mode
:
mode
,
op1
);
?
mode_for_size
(
BITS_PER_WORD
,
MODE_INT
,
0
)
:
mode
),
op1
);
#if 0 /* Turned off because it seems to be a kludgy method. */
#if 0 /* Turned off because it seems to be a kludgy method. */
/* If subtracting integer from pointer, and the pointer has a special mode,
/* If subtracting integer from pointer, and the pointer has a special mode,
...
@@ -341,7 +337,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -341,7 +337,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
if
((
binoptab
==
and_optab
||
binoptab
==
ior_optab
||
binoptab
==
xor_optab
)
if
((
binoptab
==
and_optab
||
binoptab
==
ior_optab
||
binoptab
==
xor_optab
)
&&
class
==
MODE_INT
&&
class
==
MODE_INT
&&
GET_MODE_SIZE
(
mode
)
>
UNITS_PER_WORD
&&
GET_MODE_SIZE
(
mode
)
>
UNITS_PER_WORD
&&
binoptab
->
handlers
[(
int
)
sub
mode
].
insn_code
!=
CODE_FOR_nothing
)
&&
binoptab
->
handlers
[(
int
)
word_
mode
].
insn_code
!=
CODE_FOR_nothing
)
{
{
int
i
;
int
i
;
rtx
insns
;
rtx
insns
;
...
@@ -358,7 +354,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -358,7 +354,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
for
(
i
=
0
;
i
<
GET_MODE_BITSIZE
(
mode
)
/
BITS_PER_WORD
;
i
++
)
for
(
i
=
0
;
i
<
GET_MODE_BITSIZE
(
mode
)
/
BITS_PER_WORD
;
i
++
)
{
{
rtx
target_piece
=
operand_subword
(
target
,
i
,
1
,
mode
);
rtx
target_piece
=
operand_subword
(
target
,
i
,
1
,
mode
);
rtx
x
=
expand_binop
(
sub
mode
,
binoptab
,
rtx
x
=
expand_binop
(
word_
mode
,
binoptab
,
operand_subword_force
(
op0
,
i
,
mode
),
operand_subword_force
(
op0
,
i
,
mode
),
operand_subword_force
(
op1
,
i
,
mode
),
operand_subword_force
(
op1
,
i
,
mode
),
target_piece
,
unsignedp
,
methods
);
target_piece
,
unsignedp
,
methods
);
...
@@ -382,10 +378,10 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -382,10 +378,10 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
if
((
binoptab
==
add_optab
||
binoptab
==
sub_optab
)
if
((
binoptab
==
add_optab
||
binoptab
==
sub_optab
)
&&
class
==
MODE_INT
&&
class
==
MODE_INT
&&
GET_MODE_SIZE
(
mode
)
>=
2
*
UNITS_PER_WORD
&&
GET_MODE_SIZE
(
mode
)
>=
2
*
UNITS_PER_WORD
&&
binoptab
->
handlers
[(
int
)
sub
mode
].
insn_code
!=
CODE_FOR_nothing
)
&&
binoptab
->
handlers
[(
int
)
word_
mode
].
insn_code
!=
CODE_FOR_nothing
)
{
{
int
i
;
int
i
;
rtx
carry_tmp
=
gen_reg_rtx
(
sub
mode
);
rtx
carry_tmp
=
gen_reg_rtx
(
word_
mode
);
optab
otheroptab
=
binoptab
==
add_optab
?
sub_optab
:
add_optab
;
optab
otheroptab
=
binoptab
==
add_optab
?
sub_optab
:
add_optab
;
int
nwords
=
GET_MODE_BITSIZE
(
mode
)
/
BITS_PER_WORD
;
int
nwords
=
GET_MODE_BITSIZE
(
mode
)
/
BITS_PER_WORD
;
rtx
carry_in
,
carry_out
;
rtx
carry_in
,
carry_out
;
...
@@ -417,7 +413,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -417,7 +413,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
rtx
x
;
rtx
x
;
/* Main add/subtract of the input operands. */
/* Main add/subtract of the input operands. */
x
=
expand_binop
(
sub
mode
,
binoptab
,
x
=
expand_binop
(
word_
mode
,
binoptab
,
op0_piece
,
op1_piece
,
op0_piece
,
op1_piece
,
target_piece
,
unsignedp
,
methods
);
target_piece
,
unsignedp
,
methods
);
if
(
x
==
0
)
if
(
x
==
0
)
...
@@ -426,11 +422,11 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -426,11 +422,11 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
if
(
i
+
1
<
nwords
)
if
(
i
+
1
<
nwords
)
{
{
/* Store carry from main add/subtract. */
/* Store carry from main add/subtract. */
carry_out
=
gen_reg_rtx
(
sub
mode
);
carry_out
=
gen_reg_rtx
(
word_
mode
);
carry_out
=
emit_store_flag
(
carry_out
,
carry_out
=
emit_store_flag
(
carry_out
,
binoptab
==
add_optab
?
LTU
:
GTU
,
binoptab
==
add_optab
?
LTU
:
GTU
,
x
,
op0_piece
,
x
,
op0_piece
,
sub
mode
,
1
,
normalizep
);
word_
mode
,
1
,
normalizep
);
if
(
!
carry_out
)
if
(
!
carry_out
)
break
;
break
;
}
}
...
@@ -438,7 +434,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -438,7 +434,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
if
(
i
>
0
)
if
(
i
>
0
)
{
{
/* Add/subtract previous carry to main result. */
/* Add/subtract previous carry to main result. */
x
=
expand_binop
(
sub
mode
,
x
=
expand_binop
(
word_
mode
,
normalizep
==
1
?
binoptab
:
otheroptab
,
normalizep
==
1
?
binoptab
:
otheroptab
,
x
,
carry_in
,
x
,
carry_in
,
target_piece
,
1
,
methods
);
target_piece
,
1
,
methods
);
...
@@ -453,9 +449,9 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -453,9 +449,9 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
binoptab
==
add_optab
binoptab
==
add_optab
?
LTU
:
GTU
,
?
LTU
:
GTU
,
x
,
carry_in
,
x
,
carry_in
,
sub
mode
,
1
,
normalizep
);
word_
mode
,
1
,
normalizep
);
/* Logical-ior the two poss. carry together. */
/* Logical-ior the two poss. carry together. */
carry_out
=
expand_binop
(
sub
mode
,
ior_optab
,
carry_out
=
expand_binop
(
word_
mode
,
ior_optab
,
carry_out
,
carry_tmp
,
carry_out
,
carry_tmp
,
carry_out
,
0
,
methods
);
carry_out
,
0
,
methods
);
if
(
!
carry_out
)
if
(
!
carry_out
)
...
@@ -486,19 +482,19 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -486,19 +482,19 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
because we are not operating on one word at a time.
because we are not operating on one word at a time.
The multiplication proceeds as follows:
The multiplication proceeds as follows:
_______________________
_______________________
[__op0_high_|__op0_low__]
[__op0_high_|__op0_low__]
_______________________
_______________________
* [__op1_high_|__op1_low__]
* [__op1_high_|__op1_low__]
_______________________________________________
_______________________________________________
_______________________
_______________________
(1) [__op0_low__*__op1_low__]
(1) [__op0_low__*__op1_low__]
_______________________
_______________________
(2a) [__op0_low__*__op1_high_]
(2a) [__op0_low__*__op1_high_]
_______________________
_______________________
(2b) [__op0_high_*__op1_low__]
(2b) [__op0_high_*__op1_low__]
_______________________
_______________________
(3) [__op0_high_*__op1_high_]
(3) [__op0_high_*__op1_high_]
This gives a 4-word result. Since we are only interested in the
This gives a 4-word result. Since we are only interested in the
...
@@ -533,8 +529,8 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -533,8 +529,8 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
if
(
binoptab
==
smul_optab
if
(
binoptab
==
smul_optab
&&
class
==
MODE_INT
&&
class
==
MODE_INT
&&
GET_MODE_SIZE
(
mode
)
==
2
*
UNITS_PER_WORD
&&
GET_MODE_SIZE
(
mode
)
==
2
*
UNITS_PER_WORD
&&
smul_optab
->
handlers
[(
int
)
sub
mode
].
insn_code
!=
CODE_FOR_nothing
&&
smul_optab
->
handlers
[(
int
)
word_
mode
].
insn_code
!=
CODE_FOR_nothing
&&
add_optab
->
handlers
[(
int
)
sub
mode
].
insn_code
!=
CODE_FOR_nothing
&&
add_optab
->
handlers
[(
int
)
word_
mode
].
insn_code
!=
CODE_FOR_nothing
&&
((
umul_widen_optab
->
handlers
[(
int
)
mode
].
insn_code
&&
((
umul_widen_optab
->
handlers
[(
int
)
mode
].
insn_code
!=
CODE_FOR_nothing
)
!=
CODE_FOR_nothing
)
||
(
smul_widen_optab
->
handlers
[(
int
)
mode
].
insn_code
||
(
smul_widen_optab
->
handlers
[(
int
)
mode
].
insn_code
...
@@ -578,32 +574,32 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -578,32 +574,32 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
rtx
wordm1
=
gen_rtx
(
CONST_INT
,
VOIDmode
,
BITS_PER_WORD
-
1
);
rtx
wordm1
=
gen_rtx
(
CONST_INT
,
VOIDmode
,
BITS_PER_WORD
-
1
);
product
=
expand_binop
(
mode
,
smul_widen_optab
,
op0_low
,
op1_low
,
product
=
expand_binop
(
mode
,
smul_widen_optab
,
op0_low
,
op1_low
,
target
,
1
,
OPTAB_DIRECT
);
target
,
1
,
OPTAB_DIRECT
);
op0_xhigh
=
expand_binop
(
sub
mode
,
lshr_optab
,
op0_low
,
wordm1
,
op0_xhigh
=
expand_binop
(
word_
mode
,
lshr_optab
,
op0_low
,
wordm1
,
0
,
1
,
OPTAB_DIRECT
);
0
,
1
,
OPTAB_DIRECT
);
if
(
op0_xhigh
)
if
(
op0_xhigh
)
op0_xhigh
=
expand_binop
(
submode
,
add_optab
,
op0_high
,
op0_x
high
,
op0_xhigh
=
expand_binop
(
word_mode
,
add_optab
,
op0_
high
,
op0_xhigh
,
0
,
OPTAB_DIRECT
);
op0_xhigh
,
op0_xhigh
,
0
,
OPTAB_DIRECT
);
else
else
{
{
op0_xhigh
=
expand_binop
(
sub
mode
,
ashr_optab
,
op0_low
,
wordm1
,
op0_xhigh
=
expand_binop
(
word_
mode
,
ashr_optab
,
op0_low
,
wordm1
,
0
,
0
,
OPTAB_DIRECT
);
0
,
0
,
OPTAB_DIRECT
);
if
(
op0_xhigh
)
if
(
op0_xhigh
)
op0_xhigh
=
expand_binop
(
sub
mode
,
sub_optab
,
op0_high
,
op0_xhigh
=
expand_binop
(
word_
mode
,
sub_optab
,
op0_high
,
op0_xhigh
,
op0_xhigh
,
0
,
op0_xhigh
,
op0_xhigh
,
0
,
OPTAB_DIRECT
);
OPTAB_DIRECT
);
}
}
op1_xhigh
=
expand_binop
(
sub
mode
,
lshr_optab
,
op1_low
,
wordm1
,
op1_xhigh
=
expand_binop
(
word_
mode
,
lshr_optab
,
op1_low
,
wordm1
,
0
,
1
,
OPTAB_DIRECT
);
0
,
1
,
OPTAB_DIRECT
);
if
(
op1_xhigh
)
if
(
op1_xhigh
)
op1_xhigh
=
expand_binop
(
SImode
,
add_optab
,
op1_high
,
op1_x
high
,
op1_xhigh
=
expand_binop
(
word_mode
,
add_optab
,
op1_
high
,
op1_xhigh
,
0
,
OPTAB_DIRECT
);
op1_xhigh
,
op1_xhigh
,
0
,
OPTAB_DIRECT
);
else
else
{
{
op1_xhigh
=
expand_binop
(
sub
mode
,
ashr_optab
,
op1_low
,
wordm1
,
op1_xhigh
=
expand_binop
(
word_
mode
,
ashr_optab
,
op1_low
,
wordm1
,
0
,
0
,
OPTAB_DIRECT
);
0
,
0
,
OPTAB_DIRECT
);
if
(
op1_xhigh
)
if
(
op1_xhigh
)
op1_xhigh
=
expand_binop
(
SI
mode
,
sub_optab
,
op1_high
,
op1_xhigh
=
expand_binop
(
word_
mode
,
sub_optab
,
op1_high
,
op1_xhigh
,
op1_xhigh
,
0
,
op1_xhigh
,
op1_xhigh
,
0
,
OPTAB_DIRECT
);
OPTAB_DIRECT
);
}
}
...
@@ -623,21 +619,21 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -623,21 +619,21 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
{
{
rtx
product_piece
;
rtx
product_piece
;
rtx
product_high
=
operand_subword
(
product
,
high
,
1
,
mode
);
rtx
product_high
=
operand_subword
(
product
,
high
,
1
,
mode
);
rtx
temp
=
expand_binop
(
sub
mode
,
binoptab
,
op0_low
,
op1_xhigh
,
0
,
rtx
temp
=
expand_binop
(
word_
mode
,
binoptab
,
op0_low
,
op1_xhigh
,
0
,
0
,
OPTAB_DIRECT
);
0
,
OPTAB_DIRECT
);
if
(
temp
)
if
(
temp
)
{
{
product_piece
=
expand_binop
(
sub
mode
,
add_optab
,
temp
,
product_piece
=
expand_binop
(
word_
mode
,
add_optab
,
temp
,
product_high
,
product_high
,
product_high
,
product_high
,
0
,
OPTAB_LIB_WIDEN
);
0
,
OPTAB_LIB_WIDEN
);
if
(
product_piece
!=
product_high
)
if
(
product_piece
!=
product_high
)
emit_move_insn
(
product_high
,
product_piece
);
emit_move_insn
(
product_high
,
product_piece
);
temp
=
expand_binop
(
sub
mode
,
binoptab
,
op1_low
,
op0_xhigh
,
0
,
temp
=
expand_binop
(
word_
mode
,
binoptab
,
op1_low
,
op0_xhigh
,
0
,
0
,
OPTAB_DIRECT
);
0
,
OPTAB_DIRECT
);
product_piece
=
expand_binop
(
sub
mode
,
add_optab
,
temp
,
product_piece
=
expand_binop
(
word_
mode
,
add_optab
,
temp
,
product_high
,
product_high
,
product_high
,
product_high
,
0
,
OPTAB_LIB_WIDEN
);
0
,
OPTAB_LIB_WIDEN
);
if
(
product_piece
!=
product_high
)
if
(
product_piece
!=
product_high
)
...
@@ -674,9 +670,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -674,9 +670,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
if the libcall is cse'd or moved. */
if the libcall is cse'd or moved. */
emit_library_call
(
binoptab
->
handlers
[(
int
)
mode
].
libfunc
,
emit_library_call
(
binoptab
->
handlers
[(
int
)
mode
].
libfunc
,
1
,
mode
,
2
,
op0
,
mode
,
op1
,
1
,
mode
,
2
,
op0
,
mode
,
op1
,
(
shift_op
(
shift_op
?
word_mode
:
mode
));
?
mode_for_size
(
BITS_PER_WORD
,
MODE_INT
,
0
)
:
mode
));
insns
=
get_insns
();
insns
=
get_insns
();
end_sequence
();
end_sequence
();
...
@@ -701,15 +695,12 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -701,15 +695,12 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
methods
=
(
methods
==
OPTAB_LIB_WIDEN
?
OPTAB_LIB
:
OPTAB_DIRECT
);
methods
=
(
methods
==
OPTAB_LIB_WIDEN
?
OPTAB_LIB
:
OPTAB_DIRECT
);
/* Widening is now independent of specific machine modes.
/* Look for a wider mode of the same class for which it appears we can do
It is assumed that widening may be performed to any
the operation. */
higher numbered mode in the same mode class. */
if
(
class
==
MODE_INT
||
class
==
MODE_FLOAT
||
class
==
MODE_COMPLEX_FLOAT
)
if
(
class
==
MODE_INT
||
class
==
MODE_FLOAT
||
class
==
MODE_COMPLEX_FLOAT
)
{
{
for
(
wider_mode
=
GET_MODE_WIDER_MODE
(
mode
);
for
(
wider_mode
=
GET_MODE_WIDER_MODE
(
mode
);
wider_mode
!=
VOIDmode
;
((
int
)
wider_mode
<
(
int
)
MAX_MACHINE_MODE
&&
GET_MODE_CLASS
(
wider_mode
)
==
class
);
wider_mode
=
GET_MODE_WIDER_MODE
(
wider_mode
))
wider_mode
=
GET_MODE_WIDER_MODE
(
wider_mode
))
{
{
if
((
binoptab
->
handlers
[(
int
)
wider_mode
].
insn_code
if
((
binoptab
->
handlers
[(
int
)
wider_mode
].
insn_code
...
@@ -720,53 +711,39 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
...
@@ -720,53 +711,39 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
rtx
xop0
=
op0
,
xop1
=
op1
;
rtx
xop0
=
op0
,
xop1
=
op1
;
int
no_extend
=
0
;
int
no_extend
=
0
;
/* For certain operations, we need not actually extend
/* For certain
integer
operations, we need not actually extend
the narrow operands, as long as we will truncate
the narrow operands, as long as we will truncate
the results to the same narrowness. */
the results to the same narrowness. */
if
(
binoptab
==
ior_optab
||
binoptab
==
and_optab
if
((
binoptab
==
ior_optab
||
binoptab
==
and_optab
||
binoptab
==
xor_optab
||
binoptab
==
xor_optab
||
binoptab
==
add_optab
||
binoptab
==
sub_optab
||
binoptab
==
add_optab
||
binoptab
==
sub_optab
||
binoptab
==
smul_optab
||
binoptab
==
smul_optab
||
binoptab
==
ashl_optab
||
binoptab
==
lshl_optab
)
||
binoptab
==
ashl_optab
||
binoptab
==
lshl_optab
)
&&
class
==
MODE_INT
)
no_extend
=
1
;
no_extend
=
1
;
if
(
GET_MODE
(
xop0
)
!=
VOIDmode
/* If an operand is a constant integer, we might as well
&&
GET_MODE_BITSIZE
(
wider_mode
)
<=
HOST_BITS_PER_INT
)
convert it since that is more efficient than using a SUBREG,
{
unlike the case for other operands. */
if
(
no_extend
)
{
if
(
no_extend
&&
GET_MODE
(
xop0
)
!=
VOIDmode
)
temp
=
force_reg
(
GET_MODE
(
xop0
),
xop0
);
xop0
=
gen_rtx
(
SUBREG
,
wider_mode
,
xop0
=
gen_rtx
(
SUBREG
,
wider_mode
,
temp
,
0
);
force_reg
(
GET_MODE
(
xop0
),
xop0
),
0
);
}
else
else
xop0
=
convert_to_mode
(
wider_mode
,
xop0
,
unsignedp
);
{
temp
=
gen_reg_rtx
(
wider_mode
);
if
(
no_extend
&&
GET_MODE
(
xop1
)
!=
VOIDmode
)
convert_move
(
temp
,
xop0
,
unsignedp
);
xop1
=
gen_rtx
(
SUBREG
,
wider_mode
,
xop0
=
temp
;
force_reg
(
GET_MODE
(
xop1
),
xop1
),
0
);
}
else
}
xop1
=
convert_to_mode
(
wider_mode
,
xop1
,
unsignedp
);
if
(
GET_MODE
(
xop1
)
!=
VOIDmode
&&
GET_MODE_BITSIZE
(
wider_mode
)
<=
HOST_BITS_PER_INT
)
{
if
(
no_extend
)
{
temp
=
force_reg
(
GET_MODE
(
xop1
),
xop1
);
xop1
=
gen_rtx
(
SUBREG
,
wider_mode
,
temp
,
0
);
}
else
{
temp
=
gen_reg_rtx
(
wider_mode
);
convert_move
(
temp
,
xop1
,
unsignedp
);
xop1
=
temp
;
}
}
temp
=
expand_binop
(
wider_mode
,
binoptab
,
xop0
,
xop1
,
0
,
temp
=
expand_binop
(
wider_mode
,
binoptab
,
xop0
,
xop1
,
0
,
unsignedp
,
methods
);
unsignedp
,
methods
);
if
(
temp
)
if
(
temp
)
{
{
if
(
class
==
MODE_FLOA
T
)
if
(
class
!=
MODE_IN
T
)
{
{
if
(
target
==
0
)
if
(
target
==
0
)
target
=
gen_reg_rtx
(
mode
);
target
=
gen_reg_rtx
(
mode
);
...
@@ -940,8 +917,7 @@ expand_twoval_binop (binoptab, op0, op1, targ0, targ1, unsignedp)
...
@@ -940,8 +917,7 @@ expand_twoval_binop (binoptab, op0, op1, targ0, targ1, unsignedp)
if
(
class
==
MODE_INT
||
class
==
MODE_FLOAT
||
class
==
MODE_COMPLEX_FLOAT
)
if
(
class
==
MODE_INT
||
class
==
MODE_FLOAT
||
class
==
MODE_COMPLEX_FLOAT
)
{
{
for
(
wider_mode
=
GET_MODE_WIDER_MODE
(
mode
);
for
(
wider_mode
=
GET_MODE_WIDER_MODE
(
mode
);
wider_mode
!=
VOIDmode
;
GET_MODE_CLASS
(
wider_mode
)
==
class
;
wider_mode
=
GET_MODE_WIDER_MODE
(
wider_mode
))
wider_mode
=
GET_MODE_WIDER_MODE
(
wider_mode
))
{
{
if
(
binoptab
->
handlers
[(
int
)
wider_mode
].
insn_code
if
(
binoptab
->
handlers
[(
int
)
wider_mode
].
insn_code
...
@@ -991,7 +967,6 @@ expand_unop (mode, unoptab, op0, target, unsignedp)
...
@@ -991,7 +967,6 @@ expand_unop (mode, unoptab, op0, target, unsignedp)
{
{
enum
mode_class
class
;
enum
mode_class
class
;
enum
machine_mode
wider_mode
;
enum
machine_mode
wider_mode
;
enum
machine_mode
submode
=
mode_for_size
(
BITS_PER_WORD
,
MODE_INT
,
0
);
register
rtx
temp
;
register
rtx
temp
;
rtx
last
=
get_last_insn
();
rtx
last
=
get_last_insn
();
rtx
pat
;
rtx
pat
;
...
@@ -1053,7 +1028,7 @@ expand_unop (mode, unoptab, op0, target, unsignedp)
...
@@ -1053,7 +1028,7 @@ expand_unop (mode, unoptab, op0, target, unsignedp)
if
(
unoptab
==
one_cmpl_optab
if
(
unoptab
==
one_cmpl_optab
&&
class
==
MODE_INT
&&
class
==
MODE_INT
&&
GET_MODE_SIZE
(
mode
)
>
UNITS_PER_WORD
&&
GET_MODE_SIZE
(
mode
)
>
UNITS_PER_WORD
&&
unoptab
->
handlers
[(
int
)
sub
mode
].
insn_code
!=
CODE_FOR_nothing
)
&&
unoptab
->
handlers
[(
int
)
word_
mode
].
insn_code
!=
CODE_FOR_nothing
)
{
{
int
i
;
int
i
;
rtx
insns
;
rtx
insns
;
...
@@ -1067,7 +1042,7 @@ expand_unop (mode, unoptab, op0, target, unsignedp)
...
@@ -1067,7 +1042,7 @@ expand_unop (mode, unoptab, op0, target, unsignedp)
for
(
i
=
0
;
i
<
GET_MODE_BITSIZE
(
mode
)
/
BITS_PER_WORD
;
i
++
)
for
(
i
=
0
;
i
<
GET_MODE_BITSIZE
(
mode
)
/
BITS_PER_WORD
;
i
++
)
{
{
rtx
target_piece
=
operand_subword
(
target
,
i
,
1
,
mode
);
rtx
target_piece
=
operand_subword
(
target
,
i
,
1
,
mode
);
rtx
x
=
expand_unop
(
sub
mode
,
unoptab
,
rtx
x
=
expand_unop
(
word_
mode
,
unoptab
,
operand_subword_force
(
op0
,
i
,
mode
),
operand_subword_force
(
op0
,
i
,
mode
),
target_piece
,
unsignedp
);
target_piece
,
unsignedp
);
if
(
target_piece
!=
x
)
if
(
target_piece
!=
x
)
...
@@ -1107,32 +1082,41 @@ expand_unop (mode, unoptab, op0, target, unsignedp)
...
@@ -1107,32 +1082,41 @@ expand_unop (mode, unoptab, op0, target, unsignedp)
if
(
class
==
MODE_INT
||
class
==
MODE_FLOAT
||
class
==
MODE_COMPLEX_FLOAT
)
if
(
class
==
MODE_INT
||
class
==
MODE_FLOAT
||
class
==
MODE_COMPLEX_FLOAT
)
{
{
for
(
wider_mode
=
GET_MODE_WIDER_MODE
(
mode
);
for
(
wider_mode
=
GET_MODE_WIDER_MODE
(
mode
);
wider_mode
!=
VOIDmode
;
GET_MODE_CLASS
(
wider_mode
)
==
class
;
wider_mode
=
GET_MODE_WIDER_MODE
(
wider_mode
))
wider_mode
=
GET_MODE_WIDER_MODE
(
wider_mode
))
{
{
if
((
unoptab
->
handlers
[(
int
)
wider_mode
].
insn_code
if
((
unoptab
->
handlers
[(
int
)
wider_mode
].
insn_code
!=
CODE_FOR_nothing
)
!=
CODE_FOR_nothing
)
||
unoptab
->
handlers
[(
int
)
wider_mode
].
libfunc
)
||
unoptab
->
handlers
[(
int
)
wider_mode
].
libfunc
)
{
{
if
(
GET_MODE
(
op0
)
!=
VOIDmode
rtx
xop0
=
op0
;
&&
GET_MODE_BITSIZE
(
wider_mode
)
<=
HOST_BITS_PER_INT
)
{
/* For certain operations, we need not actually extend
temp
=
gen_reg_rtx
(
wider_mode
);
the narrow operand, as long as we will truncate the
convert_move
(
temp
,
op0
,
unsignedp
);
results to the same narrowness. */
op0
=
temp
;
}
if
((
unoptab
==
neg_optab
||
unoptab
==
one_cmpl_optab
)
&&
class
==
MODE_INT
)
xop0
=
gen_rtx
(
SUBREG
,
wider_mode
,
force_reg
(
mode
,
xop0
),
0
);
else
xop0
=
convert_to_mode
(
wider_mode
,
xop0
,
unsignedp
);
target
=
expand_unop
(
wider_mode
,
unoptab
,
op0
,
0
,
unsignedp
);
temp
=
expand_unop
(
wider_mode
,
unoptab
,
xop0
,
0
,
unsignedp
);
if
(
class
==
MODE_FLOAT
)
if
(
temp
)
{
{
if
(
target
==
0
)
if
(
class
!=
MODE_INT
)
target
=
gen_reg_rtx
(
mode
);
{
convert_move
(
target
,
temp
,
0
);
if
(
target
==
0
)
return
target
;
target
=
gen_reg_rtx
(
mode
);
convert_move
(
target
,
temp
,
0
);
return
target
;
}
else
return
gen_lowpart
(
mode
,
temp
);
}
}
else
else
return
gen_lowpart
(
mode
,
targe
t
);
delete_insns_since
(
las
t
);
}
}
}
}
}
}
...
@@ -1563,8 +1547,7 @@ emit_cmp_insn (x, y, comparison, size, mode, unsignedp, align)
...
@@ -1563,8 +1547,7 @@ emit_cmp_insn (x, y, comparison, size, mode, unsignedp, align)
if
(
class
==
MODE_INT
||
class
==
MODE_FLOAT
||
class
==
MODE_COMPLEX_FLOAT
)
if
(
class
==
MODE_INT
||
class
==
MODE_FLOAT
||
class
==
MODE_COMPLEX_FLOAT
)
{
{
for
(
wider_mode
=
GET_MODE_WIDER_MODE
(
mode
);
for
(
wider_mode
=
GET_MODE_WIDER_MODE
(
mode
);
wider_mode
!=
VOIDmode
;
GET_MODE_CLASS
(
wider_mode
)
==
class
;
wider_mode
=
GET_MODE_WIDER_MODE
(
wider_mode
))
wider_mode
=
GET_MODE_WIDER_MODE
(
wider_mode
))
{
{
if
(
cmp_optab
->
handlers
[(
int
)
wider_mode
].
insn_code
if
(
cmp_optab
->
handlers
[(
int
)
wider_mode
].
insn_code
...
@@ -1695,8 +1678,7 @@ emit_float_lib_cmp (x, y, comparison)
...
@@ -1695,8 +1678,7 @@ emit_float_lib_cmp (x, y, comparison)
{
{
enum
machine_mode
wider_mode
;
enum
machine_mode
wider_mode
;
for
(
wider_mode
=
GET_MODE_WIDER_MODE
(
mode
);
for
(
wider_mode
=
GET_MODE_WIDER_MODE
(
mode
);
wider_mode
!=
VOIDmode
;
GET_MODE_CLASS
(
wider_mode
)
==
MODE_FLOAT
;
wider_mode
=
GET_MODE_WIDER_MODE
(
wider_mode
))
wider_mode
=
GET_MODE_WIDER_MODE
(
wider_mode
))
{
{
if
((
cmp_optab
->
handlers
[(
int
)
wider_mode
].
insn_code
if
((
cmp_optab
->
handlers
[(
int
)
wider_mode
].
insn_code
...
@@ -1863,21 +1845,18 @@ gen_move_insn (x, y)
...
@@ -1863,21 +1845,18 @@ gen_move_insn (x, y)
}
}
/* Tables of patterns for extending one integer mode to another. */
/* Tables of patterns for extending one integer mode to another. */
static
enum
insn_code
zero_extend_codes
[
MAX_MACHINE_MODE
][
MAX_MACHINE_MODE
];
static
enum
insn_code
extendtab
[
MAX_MACHINE_MODE
][
MAX_MACHINE_MODE
][
2
];
static
enum
insn_code
sign_extend_codes
[
MAX_MACHINE_MODE
][
MAX_MACHINE_MODE
];
/* Return nonzero if it's possible to extend FROM_MODE to TO_MODE.
/* Return the insn code used to extend FROM_MODE to TO_MODE.
UNSIGNEDP specifies zero-extension instead of sign-extension.
UNSIGNEDP specifies zero-extension instead of sign-extension. If
no such operation exists, CODE_FOR_nothing will be returned. */
Actually, the value is the instruction code for the extension pattern. */
enum
insn_code
int
can_extend_p
(
to_mode
,
from_mode
,
unsignedp
)
can_extend_p
(
to_mode
,
from_mode
,
unsignedp
)
enum
machine_mode
to_mode
,
from_mode
;
enum
machine_mode
to_mode
,
from_mode
;
int
unsignedp
;
int
unsignedp
;
{
{
return
((
unsignedp
?
zero_extend_codes
:
sign_extend_codes
)
return
extendtab
[(
int
)
to_mode
][(
int
)
from_mode
][
unsignedp
];
[(
int
)
to_mode
][(
int
)
from_mode
]);
}
}
/* Generate the body of an insn to extend Y (with mode MFROM)
/* Generate the body of an insn to extend Y (with mode MFROM)
...
@@ -1889,97 +1868,99 @@ gen_extend_insn (x, y, mto, mfrom, unsignedp)
...
@@ -1889,97 +1868,99 @@ gen_extend_insn (x, y, mto, mfrom, unsignedp)
enum
machine_mode
mto
,
mfrom
;
enum
machine_mode
mto
,
mfrom
;
int
unsignedp
;
int
unsignedp
;
{
{
return
(
GEN_FCN
((
unsignedp
?
zero_extend_codes
:
sign_extend_codes
)
return
(
GEN_FCN
(
extendtab
[(
int
)
mto
][(
int
)
mfrom
][
unsignedp
])
(
x
,
y
));
[(
int
)
mto
][(
int
)
mfrom
])
(
x
,
y
));
}
}
static
void
static
void
init_extends
()
init_extends
()
{
{
bzero
(
sign_extend_codes
,
sizeof
sign_extend_codes
);
enum
insn_code
*
p
;
bzero
(
zero_extend_codes
,
sizeof
zero_extend_codes
);
for
(
p
=
extendtab
[
0
][
0
];
p
<
extendtab
[
0
][
0
]
+
sizeof
extendtab
/
sizeof
extendtab
[
0
][
0
][
0
];
p
++
)
*
p
=
CODE_FOR_nothing
;
#ifdef HAVE_extendditi2
#ifdef HAVE_extendditi2
if
(
HAVE_extendditi2
)
if
(
HAVE_extendditi2
)
sign_extend_codes
[(
int
)
TImode
][(
int
)
DImode
]
=
CODE_FOR_extendditi2
;
extendtab
[(
int
)
TImode
][(
int
)
DImode
][
0
]
=
CODE_FOR_extendditi2
;
#endif
#endif
#ifdef HAVE_extendsiti2
#ifdef HAVE_extendsiti2
if
(
HAVE_extendsiti2
)
if
(
HAVE_extendsiti2
)
sign_extend_codes
[(
int
)
TImode
][(
int
)
SImode
]
=
CODE_FOR_extendsiti2
;
extendtab
[(
int
)
TImode
][(
int
)
SImode
][
0
]
=
CODE_FOR_extendsiti2
;
#endif
#endif
#ifdef HAVE_extendhiti2
#ifdef HAVE_extendhiti2
if
(
HAVE_extendhiti2
)
if
(
HAVE_extendhiti2
)
sign_extend_codes
[(
int
)
TImode
][(
int
)
HImode
]
=
CODE_FOR_extendhiti2
;
extendtab
[(
int
)
TImode
][(
int
)
HImode
][
0
]
=
CODE_FOR_extendhiti2
;
#endif
#endif
#ifdef HAVE_extendqiti2
#ifdef HAVE_extendqiti2
if
(
HAVE_extendqiti2
)
if
(
HAVE_extendqiti2
)
sign_extend_codes
[(
int
)
TImode
][(
int
)
QImode
]
=
CODE_FOR_extendqiti2
;
extendtab
[(
int
)
TImode
][(
int
)
QImode
][
0
]
=
CODE_FOR_extendqiti2
;
#endif
#endif
#ifdef HAVE_extendsidi2
#ifdef HAVE_extendsidi2
if
(
HAVE_extendsidi2
)
if
(
HAVE_extendsidi2
)
sign_extend_codes
[(
int
)
DImode
][(
int
)
SImode
]
=
CODE_FOR_extendsidi2
;
extendtab
[(
int
)
DImode
][(
int
)
SImode
][
0
]
=
CODE_FOR_extendsidi2
;
#endif
#endif
#ifdef HAVE_extendhidi2
#ifdef HAVE_extendhidi2
if
(
HAVE_extendhidi2
)
if
(
HAVE_extendhidi2
)
sign_extend_codes
[(
int
)
DImode
][(
int
)
HImode
]
=
CODE_FOR_extendhidi2
;
extendtab
[(
int
)
DImode
][(
int
)
HImode
][
0
]
=
CODE_FOR_extendhidi2
;
#endif
#endif
#ifdef HAVE_extendqidi2
#ifdef HAVE_extendqidi2
if
(
HAVE_extendqidi2
)
if
(
HAVE_extendqidi2
)
sign_extend_codes
[(
int
)
DImode
][(
int
)
QImode
]
=
CODE_FOR_extendqidi2
;
extendtab
[(
int
)
DImode
][(
int
)
QImode
][
0
]
=
CODE_FOR_extendqidi2
;
#endif
#endif
#ifdef HAVE_extendhisi2
#ifdef HAVE_extendhisi2
if
(
HAVE_extendhisi2
)
if
(
HAVE_extendhisi2
)
sign_extend_codes
[(
int
)
SImode
][(
int
)
HImode
]
=
CODE_FOR_extendhisi2
;
extendtab
[(
int
)
SImode
][(
int
)
HImode
][
0
]
=
CODE_FOR_extendhisi2
;
#endif
#endif
#ifdef HAVE_extendqisi2
#ifdef HAVE_extendqisi2
if
(
HAVE_extendqisi2
)
if
(
HAVE_extendqisi2
)
sign_extend_codes
[(
int
)
SImode
][(
int
)
QImode
]
=
CODE_FOR_extendqisi2
;
extendtab
[(
int
)
SImode
][(
int
)
QImode
][
0
]
=
CODE_FOR_extendqisi2
;
#endif
#endif
#ifdef HAVE_extendqihi2
#ifdef HAVE_extendqihi2
if
(
HAVE_extendqihi2
)
if
(
HAVE_extendqihi2
)
sign_extend_codes
[(
int
)
HImode
][(
int
)
QImode
]
=
CODE_FOR_extendqihi2
;
extendtab
[(
int
)
HImode
][(
int
)
QImode
][
0
]
=
CODE_FOR_extendqihi2
;
#endif
#endif
#ifdef HAVE_zero_extendditi2
#ifdef HAVE_zero_extendditi2
if
(
HAVE_zero_extendsiti2
)
if
(
HAVE_zero_extendsiti2
)
zero_extend_codes
[(
int
)
TImode
][(
int
)
DImode
]
=
CODE_FOR_zero_extendditi2
;
extendtab
[(
int
)
TImode
][(
int
)
DImode
][
1
]
=
CODE_FOR_zero_extendditi2
;
#endif
#endif
#ifdef HAVE_zero_extendsiti2
#ifdef HAVE_zero_extendsiti2
if
(
HAVE_zero_extendsiti2
)
if
(
HAVE_zero_extendsiti2
)
zero_extend_codes
[(
int
)
TImode
][(
int
)
SImode
]
=
CODE_FOR_zero_extendsiti2
;
extendtab
[(
int
)
TImode
][(
int
)
SImode
][
1
]
=
CODE_FOR_zero_extendsiti2
;
#endif
#endif
#ifdef HAVE_zero_extendhiti2
#ifdef HAVE_zero_extendhiti2
if
(
HAVE_zero_extendhiti2
)
if
(
HAVE_zero_extendhiti2
)
zero_extend_codes
[(
int
)
TImode
][(
int
)
HImode
]
=
CODE_FOR_zero_extendhiti2
;
extendtab
[(
int
)
TImode
][(
int
)
HImode
][
1
]
=
CODE_FOR_zero_extendhiti2
;
#endif
#endif
#ifdef HAVE_zero_extendqiti2
#ifdef HAVE_zero_extendqiti2
if
(
HAVE_zero_extendqiti2
)
if
(
HAVE_zero_extendqiti2
)
zero_extend_codes
[(
int
)
TImode
][(
int
)
QImode
]
=
CODE_FOR_zero_extendqiti2
;
extendtab
[(
int
)
TImode
][(
int
)
QImode
][
1
]
=
CODE_FOR_zero_extendqiti2
;
#endif
#endif
#ifdef HAVE_zero_extendsidi2
#ifdef HAVE_zero_extendsidi2
if
(
HAVE_zero_extendsidi2
)
if
(
HAVE_zero_extendsidi2
)
zero_extend_codes
[(
int
)
DImode
][(
int
)
SImode
]
=
CODE_FOR_zero_extendsidi2
;
extendtab
[(
int
)
DImode
][(
int
)
SImode
][
1
]
=
CODE_FOR_zero_extendsidi2
;
#endif
#endif
#ifdef HAVE_zero_extendhidi2
#ifdef HAVE_zero_extendhidi2
if
(
HAVE_zero_extendhidi2
)
if
(
HAVE_zero_extendhidi2
)
zero_extend_codes
[(
int
)
DImode
][(
int
)
HImode
]
=
CODE_FOR_zero_extendhidi2
;
extendtab
[(
int
)
DImode
][(
int
)
HImode
][
1
]
=
CODE_FOR_zero_extendhidi2
;
#endif
#endif
#ifdef HAVE_zero_extendqidi2
#ifdef HAVE_zero_extendqidi2
if
(
HAVE_zero_extendqidi2
)
if
(
HAVE_zero_extendqidi2
)
zero_extend_codes
[(
int
)
DImode
][(
int
)
QImode
]
=
CODE_FOR_zero_extendqidi2
;
extendtab
[(
int
)
DImode
][(
int
)
QImode
][
1
]
=
CODE_FOR_zero_extendqidi2
;
#endif
#endif
#ifdef HAVE_zero_extendhisi2
#ifdef HAVE_zero_extendhisi2
if
(
HAVE_zero_extendhisi2
)
if
(
HAVE_zero_extendhisi2
)
zero_extend_codes
[(
int
)
SImode
][(
int
)
HImode
]
=
CODE_FOR_zero_extendhisi2
;
extendtab
[(
int
)
SImode
][(
int
)
HImode
][
1
]
=
CODE_FOR_zero_extendhisi2
;
#endif
#endif
#ifdef HAVE_zero_extendqisi2
#ifdef HAVE_zero_extendqisi2
if
(
HAVE_zero_extendqisi2
)
if
(
HAVE_zero_extendqisi2
)
zero_extend_codes
[(
int
)
SImode
][(
int
)
QImode
]
=
CODE_FOR_zero_extendqisi2
;
extendtab
[(
int
)
SImode
][(
int
)
QImode
][
1
]
=
CODE_FOR_zero_extendqisi2
;
#endif
#endif
#ifdef HAVE_zero_extendqihi2
#ifdef HAVE_zero_extendqihi2
if
(
HAVE_zero_extendqihi2
)
if
(
HAVE_zero_extendqihi2
)
zero_extend_codes
[(
int
)
HImode
][(
int
)
QImode
]
=
CODE_FOR_zero_extendqihi2
;
extendtab
[(
int
)
HImode
][(
int
)
QImode
][
1
]
=
CODE_FOR_zero_extendqihi2
;
#endif
#endif
}
}
...
@@ -2421,7 +2402,7 @@ init_floattab ()
...
@@ -2421,7 +2402,7 @@ init_floattab ()
}
}
/* Generate code to convert FROM to floating point
/* Generate code to convert FROM to floating point
and store in TO. FROM must be fixed point.
and store in TO. FROM must be fixed point
and not VOIDmode
.
UNSIGNEDP nonzero means regard FROM as unsigned.
UNSIGNEDP nonzero means regard FROM as unsigned.
Normally this is done by correcting the final value
Normally this is done by correcting the final value
if it is negative. */
if it is negative. */
...
@@ -2435,6 +2416,10 @@ expand_float (to, from, unsignedp)
...
@@ -2435,6 +2416,10 @@ expand_float (to, from, unsignedp)
register
rtx
target
=
to
;
register
rtx
target
=
to
;
enum
machine_mode
fmode
,
imode
;
enum
machine_mode
fmode
,
imode
;
/* Crash now, because we won't be able to decide which mode to use. */
if
(
GET_MODE
(
from
)
==
VOIDmode
)
abort
();
/* Look for an insn to do the conversion. Do it in the specified
/* Look for an insn to do the conversion. Do it in the specified
modes if possible; otherwise convert either input, output or both to
modes if possible; otherwise convert either input, output or both to
wider mode. If the integer mode is wider than the mode of FROM,
wider mode. If the integer mode is wider than the mode of FROM,
...
...
gcc/print-tree.c
View file @
34e56753
/* Prints out tree in human readable form - GNU C-compiler
/* Prints out tree in human readable form - GNU C-compiler
Copyright (C) 1990 Free Software Foundation, Inc.
Copyright (C) 1990
, 1991
Free Software Foundation, Inc.
This file is part of GNU CC.
This file is part of GNU CC.
...
...
gcc/protoize.c
View file @
34e56753
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
and Computer Technology Corporation (MCC). The author's current
and Computer Technology Corporation (MCC). The author's current
E-mail address is <rfg@ncd.com>.
E-mail address is <rfg@ncd.com>.
Copyright (C) 1989, 199
1
Free Software Foundation, Inc.
Copyright (C) 1989, 199
2
Free Software Foundation, Inc.
This file is part of GNU CC.
This file is part of GNU CC.
...
@@ -34,29 +34,28 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
...
@@ -34,29 +34,28 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define VOLATILE
#define VOLATILE
#endif
#endif
/* It is incorrect to include config.h here, because this file is being
#ifndef __STDC__
compiled for the target, and hence definitions concerning only the host
#define const
do not apply. Instead we include tconfig.h, which is the xm file
#endif
*for the target*, which also includes the tm.h file *for the target*.
This way, we get definitions of POSIX, USG and VMS for the target. */
#include "
t
config.h"
#include "config.h"
/* The documentation says to use TARGET_POSIX, so check for it as well
#ifdef POSIX
/* We should be able to define _POSIX_SOURCE unconditionally,
as POSIX. */
but some systems respond in buggy ways to it,
#if defined(TARGET_POSIX) && !defined(POSIX)
including Sunos 4.1.1. Which we don't classify as POSIX. */
#define POSIX
/* In case this is a POSIX system with an ANSI C compiler,
ask for definition of all POSIX facilities. */
#define _POSIX_SOURCE
#endif
#endif
#if 0
/* Users are not supposed to use _POSIX_SOURCE to say the
system is a POSIX system. That is not what _POSIX_SOURCE means! -- rms */
/* If the user asked for POSIX via _POSIX_SOURCE, turn on POSIX code. */
/* If the user asked for POSIX via _POSIX_SOURCE, turn on POSIX code. */
#if defined(_POSIX_SOURCE) && !defined(POSIX)
#if defined(_POSIX_SOURCE) && !defined(POSIX)
#define POSIX
#define POSIX
#endif
#endif
#endif /* 0 */
/* On a POSIX system, request definition of all the POSIX facilities. */
#if defined(POSIX) && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
#include <stdio.h>
#include <stdio.h>
#include <ctype.h>
#include <ctype.h>
...
@@ -64,14 +63,15 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
...
@@ -64,14 +63,15 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/dir.h>
#include <sys/dir.h>
#if ! defined (USG) || defined (SVR4)
#include <sys/wait.h>
#include <sys/wait.h>
#endif
#include <setjmp.h>
#include <setjmp.h>
#include "gvarargs.h"
#include "gvarargs.h"
#include "getopt.h"
#include "getopt.h"
#ifndef PATH_MAX
/* <limits.h> defines this on most POSIX systems. */
#ifndef PATH_MAX
/* <limits.h> defines this on most POSIX systems. */
#include <sys/param.h>
#include <sys/param.h>
#define PATH_MAX MAXPATHLEN
/* Sometimes <sys/param.h> defines these macros. */
/* Sometimes <sys/param.h> defines these macros. */
#undef CHAR_BIT
#undef CHAR_BIT
#undef CHAR_MAX
#undef CHAR_MAX
...
@@ -95,14 +95,6 @@ extern int errno;
...
@@ -95,14 +95,6 @@ extern int errno;
extern
char
*
sys_errlist
[];
extern
char
*
sys_errlist
[];
extern
char
*
version_string
;
extern
char
*
version_string
;
#if defined(POSIX)
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <string.h>
/* Systems which are compatible only with POSIX 1003.1-1988 (but *not*
/* Systems which are compatible only with POSIX 1003.1-1988 (but *not*
with POSIX 1003.1-1990), e.g. Ultrix 4.2, might not have
with POSIX 1003.1-1990), e.g. Ultrix 4.2, might not have
const qualifiers in the prototypes in the system include files.
const qualifiers in the prototypes in the system include files.
...
@@ -110,17 +102,39 @@ extern char *version_string;
...
@@ -110,17 +102,39 @@ extern char *version_string;
calls to the following functions. To eliminate these warnings we
calls to the following functions. To eliminate these warnings we
provide the following #defines. */
provide the following #defines. */
#if (_POSIX_VERSION < 199009)
#define my_access(file,flag) access((char *)file, flag)
#define my_stat(file,pkt) stat((char *)file, pkt)
#define my_execvp(prog,argv) execvp((char *)prog, (char **)argv)
#define my_link(file1, file2) link((char *)file1, (char *)file2)
#define my_unlink(file) unlink((char *)file)
#define my_open(file, mode, flag) open((char *)file, mode, flag)
#define my_chmod(file, mode) chmod((char *)file, mode)
#if !(defined (USG) || defined (VMS) || defined (POSIX))
#define GUESSPATHLEN (MAXPATHLEN + 1)
#else
/* (defined (USG) || defined (VMS) || defined (POSIX)) */
/* We actually use this as a starting point, not a limit. */
#define GUESSPATHLEN 200
#endif
/* (defined (USG) || defined (VMS) || defined (POSIX)) */
#define access(file,flag) access((char *)file, flag)
/* Aliases for pointers to void.
#define stat(file,pkt) stat((char *)file, pkt)
These were made to facilitate compilation with other compilers. */
#define execvp(prog,argv) execvp((char *)prog, (char **)argv)
#define link(file1, file2) link((char *)file1, (char *)file2)
#define unlink(file) unlink((char *)file)
#define open(file, mode, flag) open((char *)file, mode, flag)
#define chmod(file, mode) chmod((char *)file, mode)
#endif
/* (_POSIX_VERSION < 199009) */
#ifdef __STDC__
typedef
void
*
pointer_type
;
typedef
const
void
*
const_pointer_type
;
#else
typedef
char
*
pointer_type
;
typedef
char
*
const_pointer_type
;
#endif
#if defined(POSIX)
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <string.h>
#else
/* !defined(POSIX) */
#else
/* !defined(POSIX) */
...
@@ -137,61 +151,58 @@ extern char *version_string;
...
@@ -137,61 +151,58 @@ extern char *version_string;
the few exceptions to the general rule here. */
the few exceptions to the general rule here. */
#if !(defined (USG) || defined (VMS))
#if !(defined (USG) || defined (VMS))
extern
char
*
getwd
(
char
*
);
extern
char
*
getwd
();
#define getcwd(buf,len) getwd(buf)
#define getcwd(buf,len) getwd(buf)
#else
/* (defined (USG) || defined (VMS)) */
#else
/* (defined (USG) || defined (VMS)) */
extern
char
*
getcwd
(
char
*
,
size_t
);
extern
char
*
getcwd
();
#endif
/* (defined (USG) || defined (VMS)) */
#endif
/* (defined (USG) || defined (VMS)) */
/* Declaring stat or __flsbuf with a prototype
/* Declaring stat or __flsbuf with a prototype
causes conflicts with system headers on some systems. */
causes conflicts with system headers on some systems. */
#ifndef abort
#ifndef abort
extern
VOLATILE
void
abort
(
void
);
extern
VOLATILE
void
abort
();
#endif
#endif
extern
int
kill
(
int
,
int
);
extern
int
kill
();
extern
int
creat
(
const
char
*
,
int
);
extern
int
creat
();
extern
int
open
(
const
char
*
,
int
,
...);
#if 0 /* These conflict with stdio.h on some systems. */
#if 0 /* These conflict with stdio.h on some systems. */
extern int fprintf (FILE *, const char *, ...);
extern int fprintf (FILE *, const char *, ...);
extern int printf (const char *, ...);
extern int printf (const char *, ...);
#endif /* 0 */
#endif /* 0 */
extern
void
exit
(
int
);
extern
void
exit
();
extern
void
*
malloc
(
size_t
);
extern
pointer_type
malloc
();
extern
void
*
realloc
(
void
*
,
size_t
);
extern
pointer_type
realloc
();
extern
void
free
(
void
*
);
extern
void
free
();
extern
int
read
(
int
,
void
*
,
size_t
);
extern
int
read
();
extern
int
write
(
int
,
const
void
*
,
size_t
);
extern
int
write
();
extern
int
close
(
int
);
extern
int
close
();
extern
int
link
(
const
char
*
,
const
char
*
);
extern
int
fflush
();
extern
int
unlink
(
const
char
*
);
extern
int
atoi
();
extern
int
fflush
(
FILE
*
);
extern
int
puts
();
extern
int
atoi
(
const
char
*
);
extern
int
fputs
();
extern
int
access
(
const
char
*
,
int
);
extern
int
fputc
();
extern
int
puts
(
const
char
*
);
#if 0 /* Causes trouble on some systems that define setjmp as a macro. */
extern
int
fputs
(
const
char
*
,
FILE
*
);
extern int setjmp ();
extern
int
fputc
(
int
,
FILE
*
);
extern void longjmp ();
extern
int
execvp
(
const
char
*
,
char
*
const
*
);
#endif
extern
int
setjmp
(
jmp_buf
);
extern
void
longjmp
(
jmp_buf
,
int
);
extern
char
*
strcat
();
extern
int
strcmp
();
extern
char
*
strcat
(
char
*
,
const
char
*
);
extern
char
*
strcpy
();
extern
int
strcmp
(
const
char
*
,
const
char
*
);
extern
char
*
strcpy
(
char
*
,
const
char
*
);
#if 0 /* size_t from sys/types.h may fail to match GCC.
#if 0 /* size_t from sys/types.h may fail to match GCC.
If so, we would get a warning from this.
If so, we would get a warning from this.
So do without the prototype. */
So do without the prototype. */
extern size_t strlen(const char *);
extern size_t strlen(const char *);
#endif
#endif
extern
int
strncmp
(
const
char
*
,
const
char
*
,
size_t
);
extern
int
strncmp
();
extern
char
*
strncpy
(
char
*
,
const
char
*
,
size_t
);
extern
char
*
strncpy
();
extern
char
*
strrchr
(
const
char
*
,
int
);
extern
char
*
strrchr
();
#if !(defined (USG) || defined (VMS))
#if !(defined (USG) || defined (VMS))
extern
int
vfork
(
void
);
extern
int
vfork
();
#define fork vfork
#define fork vfork
#else
#else
extern
int
fork
(
void
);
extern
int
fork
();
#endif
/* !(defined (USG) || defined (VMS)) */
#endif
/* !(defined (USG) || defined (VMS)) */
#endif
/* !defined(POSIX) */
#endif
/* !defined(POSIX) */
...
@@ -200,15 +211,13 @@ extern int fork (void);
...
@@ -200,15 +211,13 @@ extern int fork (void);
#define NONCONST
#define NONCONST
/* Aliases for pointers to void.
/* Define a STRINGIFY macro that's right for ANSI or traditional C. */
These were made to facilitate compilation with other compilers. */
typedef
void
*
pointer_type
;
typedef
const
void
*
const_pointer_type
;
/* Define a STRINGIFY macro that's right for ANSI C. */
#ifdef __STDC__
#define STRINGIFY(STRING) #STRING
#define STRINGIFY(STRING) #STRING
#else
#define STRINGIFY(STRING) "STRING"
#endif
/* POSIX systems will not have definitions for WIFEXITED or WEXITSTATUS.
/* POSIX systems will not have definitions for WIFEXITED or WEXITSTATUS.
Define them correctly and so that they work for all environments. */
Define them correctly and so that they work for all environments. */
...
@@ -471,22 +480,22 @@ static int errors = 0;
...
@@ -471,22 +480,22 @@ static int errors = 0;
/* ??? These comments should say what the flag mean as well as the options
/* ??? These comments should say what the flag mean as well as the options
that set them. */
that set them. */
static
int
version_flag
=
0
;
/* set by -V option */
static
int
version_flag
=
0
;
/* Print our version number. */
static
int
quiet_flag
=
0
;
/* set by -q option */
static
int
quiet_flag
=
0
;
/* Don't print messages normally. */
#if 0
static
int
nochange_flag
=
0
;
/* Don't convert, just say what files
static int force_flag = 0; /* set by -f option */
we would have converted. */
#endif
static
int
nosave_flag
=
0
;
/* Don't save the old version. */
static
int
nochange_flag
=
0
;
/* set by -n option */
static
int
keep_flag
=
0
;
/* Don't delete the .X files. */
static
int
nosave_flag
=
0
;
/* set by -N option */
static
const
char
**
compile_params
=
0
;
/* Option string for gcc. */
static
int
keep_flag
=
0
;
/* set by -k option */
static
const
char
**
compile_params
=
0
;
/* set by -c option */
#ifdef UNPROTOIZE
#ifdef UNPROTOIZE
static
const
char
*
indent_string
=
" "
;
/* set by -i option */
static
const
char
*
indent_string
=
" "
;
/* Indentation for newly
inserted parm decls. */
#else
/* !defined(UNPROTOIZE) */
#else
/* !defined(UNPROTOIZE) */
static
int
local_flag
=
0
;
/*
set by -l option
*/
static
int
local_flag
=
0
;
/*
Insert new local decls (when?).
*/
static
int
global_flag
=
0
;
/* set by -g option */
static
int
global_flag
=
0
;
/* set by -g option */
static
int
cplusplus_flag
=
0
;
/* set by -C option */
static
int
cplusplus_flag
=
0
;
/* Rename converted files to *.C. */
static
const
char
*
nondefault_syscalls_dir
=
0
;
/* set by -B option */
static
const
char
*
nondefault_syscalls_dir
=
0
;
/* Dir to look for
SYSCALLS.c.X in. */
#endif
/* !defined(UNPROTOIZE) */
#endif
/* !defined(UNPROTOIZE) */
/* An index into the compile_params array where we should insert the filename
/* An index into the compile_params array where we should insert the filename
...
@@ -602,16 +611,18 @@ static char * saved_repl_write_ptr;
...
@@ -602,16 +611,18 @@ static char * saved_repl_write_ptr;
/* Forward declaration. */
/* Forward declaration. */
static
const
char
*
shortpath
(
const
char
*
cwd
,
const
char
*
filename
);
static
const
char
*
shortpath
();
/* Allocate some space, but check that the allocation was successful. */
/* Allocate some space, but check that the allocation was successful. */
static
pointer_type
static
pointer_type
xmalloc
(
size_t
byte_count
)
xmalloc
(
byte_count
)
size_t
byte_count
;
{
{
pointer_type
rv
;
pointer_type
rv
;
if
((
rv
=
malloc
(
byte_count
))
==
NULL
)
rv
=
malloc
(
byte_count
);
if
(
rv
==
NULL
)
{
{
fprintf
(
stderr
,
"
\n
%s: fatal error: can't allocate %u more bytes of memory
\n
"
,
fprintf
(
stderr
,
"
\n
%s: fatal error: can't allocate %u more bytes of memory
\n
"
,
pname
,
byte_count
);
pname
,
byte_count
);
...
@@ -625,11 +636,14 @@ xmalloc (size_t byte_count)
...
@@ -625,11 +636,14 @@ xmalloc (size_t byte_count)
/* Reallocate some space, but check that the reallocation was successful. */
/* Reallocate some space, but check that the reallocation was successful. */
static
pointer_type
static
pointer_type
xrealloc
(
pointer_type
old_space
,
size_t
byte_count
)
xrealloc
(
old_space
,
byte_count
)
pointer_type
old_space
;
size_t
byte_count
;
{
{
pointer_type
rv
;
pointer_type
rv
;
if
((
rv
=
realloc
(
old_space
,
byte_count
))
==
NULL
)
rv
=
realloc
(
old_space
,
byte_count
);
if
(
rv
==
NULL
)
{
{
fprintf
(
stderr
,
"
\n
%s: fatal error: can't allocate %u more bytes of memory
\n
"
,
fprintf
(
stderr
,
"
\n
%s: fatal error: can't allocate %u more bytes of memory
\n
"
,
pname
,
byte_count
);
pname
,
byte_count
);
...
@@ -645,7 +659,8 @@ xrealloc (pointer_type old_space, size_t byte_count)
...
@@ -645,7 +659,8 @@ xrealloc (pointer_type old_space, size_t byte_count)
is non-null. */
is non-null. */
static
void
static
void
xfree
(
const_pointer_type
p
)
xfree
(
p
)
const_pointer_type
p
;
{
{
if
(
p
)
if
(
p
)
free
((
NONCONST
pointer_type
)
p
);
free
((
NONCONST
pointer_type
)
p
);
...
@@ -654,7 +669,9 @@ xfree (const_pointer_type p)
...
@@ -654,7 +669,9 @@ xfree (const_pointer_type p)
/* Make a copy of a string INPUT with size SIZE. */
/* Make a copy of a string INPUT with size SIZE. */
static
char
*
static
char
*
savestring
(
const
char
*
input
,
int
size
)
savestring
(
input
,
size
)
const
char
*
input
;
int
size
;
{
{
char
*
output
=
(
char
*
)
xmalloc
(
size
+
1
);
char
*
output
=
(
char
*
)
xmalloc
(
size
+
1
);
strcpy
(
output
,
input
);
strcpy
(
output
,
input
);
...
@@ -674,7 +691,8 @@ fancy_abort ()
...
@@ -674,7 +691,8 @@ fancy_abort ()
/* Make a duplicate of a given string in a newly allocated area. */
/* Make a duplicate of a given string in a newly allocated area. */
static
char
*
static
char
*
dupstr
(
const
char
*
s
)
dupstr
(
s
)
const
char
*
s
;
{
{
return
strcpy
((
char
*
)
xmalloc
(
strlen
(
s
)
+
1
),
s
);
return
strcpy
((
char
*
)
xmalloc
(
strlen
(
s
)
+
1
),
s
);
}
}
...
@@ -683,7 +701,9 @@ dupstr (const char *s)
...
@@ -683,7 +701,9 @@ dupstr (const char *s)
allocated area. */
allocated area. */
static
char
*
static
char
*
dupnstr
(
const
char
*
s
,
size_t
n
)
dupnstr
(
s
,
n
)
const
char
*
s
;
size_t
n
;
{
{
char
*
ret_val
=
strncpy
((
char
*
)
xmalloc
(
n
+
1
),
s
,
n
);
char
*
ret_val
=
strncpy
((
char
*
)
xmalloc
(
n
+
1
),
s
,
n
);
...
@@ -695,7 +715,9 @@ dupnstr (const char *s, size_t n)
...
@@ -695,7 +715,9 @@ dupnstr (const char *s, size_t n)
does not occur within s1. Assume neither s1 nor s2 are null pointers. */
does not occur within s1. Assume neither s1 nor s2 are null pointers. */
static
const
char
*
static
const
char
*
substr
(
const
char
*
s1
,
const
char
*
const
s2
)
substr
(
s1
,
s2
)
const
char
*
s1
;
const
char
*
const
s2
;
{
{
for
(;
*
s1
;
s1
++
)
for
(;
*
s1
;
s1
++
)
{
{
...
@@ -716,7 +738,7 @@ outer:
...
@@ -716,7 +738,7 @@ outer:
/* Get setup to recover in case the edit we are about to do goes awry. */
/* Get setup to recover in case the edit we are about to do goes awry. */
void
void
save_pointers
(
void
)
save_pointers
()
{
{
saved_clean_read_ptr
=
clean_read_ptr
;
saved_clean_read_ptr
=
clean_read_ptr
;
saved_repl_write_ptr
=
repl_write_ptr
;
saved_repl_write_ptr
=
repl_write_ptr
;
...
@@ -726,7 +748,7 @@ save_pointers (void)
...
@@ -726,7 +748,7 @@ save_pointers (void)
too confusing in the source code we are trying to edit. */
too confusing in the source code we are trying to edit. */
void
void
restore_pointers
(
void
)
restore_pointers
()
{
{
clean_read_ptr
=
saved_clean_read_ptr
;
clean_read_ptr
=
saved_clean_read_ptr
;
repl_write_ptr
=
saved_repl_write_ptr
;
repl_write_ptr
=
saved_repl_write_ptr
;
...
@@ -734,8 +756,9 @@ restore_pointers (void)
...
@@ -734,8 +756,9 @@ restore_pointers (void)
/* Return true if the given character is a legal identifier character. */
/* Return true if the given character is a legal identifier character. */
inline
static
int
static
int
is_id_char
(
char
ch
)
is_id_char
(
ch
)
char
ch
;
{
{
return
(
isalnum
(
ch
)
||
(
ch
==
'_'
)
||
(
ch
==
'$'
));
return
(
isalnum
(
ch
)
||
(
ch
==
'_'
)
||
(
ch
==
'$'
));
}
}
...
@@ -744,7 +767,7 @@ is_id_char (char ch)
...
@@ -744,7 +767,7 @@ is_id_char (char ch)
exit with non-zero status. */
exit with non-zero status. */
static
void
static
void
usage
(
void
)
usage
()
{
{
#ifdef UNPROTOIZE
#ifdef UNPROTOIZE
fprintf
(
stderr
,
"%s: usage '%s [ -VqfnkN ] [ -i <istring> ] [ filename ... ]'
\n
"
,
fprintf
(
stderr
,
"%s: usage '%s [ -VqfnkN ] [ -i <istring> ] [ filename ... ]'
\n
"
,
...
@@ -761,7 +784,8 @@ usage (void)
...
@@ -761,7 +784,8 @@ usage (void)
include directories. */
include directories. */
static
int
static
int
in_system_include_dir
(
const
char
*
path
)
in_system_include_dir
(
path
)
const
char
*
path
;
{
{
struct
default_include
*
p
;
struct
default_include
*
p
;
...
@@ -785,7 +809,7 @@ file_could_be_converted (const char *path)
...
@@ -785,7 +809,7 @@ file_could_be_converted (const char *path)
{
{
char *const dir_name = (char *) alloca (strlen (path) + 1);
char *const dir_name = (char *) alloca (strlen (path) + 1);
if (access (path, R_OK))
if (
my_
access (path, R_OK))
return 0;
return 0;
{
{
...
@@ -799,7 +823,7 @@ file_could_be_converted (const char *path)
...
@@ -799,7 +823,7 @@ file_could_be_converted (const char *path)
abort (); /* Should have been an absolutized filename. */
abort (); /* Should have been an absolutized filename. */
}
}
if (access (path, W_OK))
if (
my_
access (path, W_OK))
return 0;
return 0;
return 1;
return 1;
...
@@ -833,7 +857,7 @@ file_normally_convertable (const char *path)
...
@@ -833,7 +857,7 @@ file_normally_convertable (const char *path)
abort (); /* Should have been an absolutized filename. */
abort (); /* Should have been an absolutized filename. */
}
}
if (access (path, R_OK))
if (
my_
access (path, R_OK))
{
{
if (!quiet_flag)
if (!quiet_flag)
fprintf (stderr, "%s: warning: no read access for file `%s'\n",
fprintf (stderr, "%s: warning: no read access for file `%s'\n",
...
@@ -841,7 +865,7 @@ file_normally_convertable (const char *path)
...
@@ -841,7 +865,7 @@ file_normally_convertable (const char *path)
return 0;
return 0;
}
}
if (access (path, W_OK))
if (
my_
access (path, W_OK))
{
{
if (!quiet_flag)
if (!quiet_flag)
fprintf (stderr, "%s: warning: no write access for file `%s'\n",
fprintf (stderr, "%s: warning: no write access for file `%s'\n",
...
@@ -849,7 +873,7 @@ file_normally_convertable (const char *path)
...
@@ -849,7 +873,7 @@ file_normally_convertable (const char *path)
return 0;
return 0;
}
}
if (access (dir_name, W_OK))
if (
my_
access (dir_name, W_OK))
{
{
if (!quiet_flag)
if (!quiet_flag)
fprintf (stderr, "%s: warning: no write access for dir containing `%s'\n",
fprintf (stderr, "%s: warning: no write access for dir containing `%s'\n",
...
@@ -867,7 +891,8 @@ file_normally_convertable (const char *path)
...
@@ -867,7 +891,8 @@ file_normally_convertable (const char *path)
file. Return false otherwise. */
file. Return false otherwise. */
static
int
static
int
is_syscalls_file
(
const
file_info
*
fi_p
)
is_syscalls_file
(
fi_p
)
const
file_info
*
fi_p
;
{
{
return
(
substr
(
fi_p
->
hash_entry
->
symbol
,
syscalls_filename
)
!=
NULL
);
return
(
substr
(
fi_p
->
hash_entry
->
symbol
,
syscalls_filename
)
!=
NULL
);
}
}
...
@@ -884,7 +909,8 @@ is_syscalls_file (const file_info *fi_p)
...
@@ -884,7 +909,8 @@ is_syscalls_file (const file_info *fi_p)
by connect_defs_and_decs(). */
by connect_defs_and_decs(). */
static
int
static
int
needs_to_be_converted
(
const
file_info
*
file_p
)
needs_to_be_converted
(
file_p
)
const
file_info
*
file_p
;
{
{
const
def_dec_info
*
ddp
;
const
def_dec_info
*
ddp
;
...
@@ -922,7 +948,8 @@ needs_to_be_converted (const file_info *file_p)
...
@@ -922,7 +948,8 @@ needs_to_be_converted (const file_info *file_p)
that should be converted. */
that should be converted. */
static
int
static
int
directory_specified_p
(
const
char
*
name
)
directory_specified_p
(
name
)
const
char
*
name
;
{
{
struct
string_list
*
p
;
struct
string_list
*
p
;
...
@@ -937,7 +964,8 @@ directory_specified_p (const char *name)
...
@@ -937,7 +964,8 @@ directory_specified_p (const char *name)
/* Return 1 if the file named NAME should be excluded from conversion. */
/* Return 1 if the file named NAME should be excluded from conversion. */
static
int
static
int
file_excluded_p
(
const
char
*
name
)
file_excluded_p
(
name
)
const
char
*
name
;
{
{
struct
string_list
*
p
;
struct
string_list
*
p
;
int
len
=
strlen
(
name
);
int
len
=
strlen
(
name
);
...
@@ -954,9 +982,13 @@ file_excluded_p (const char *name)
...
@@ -954,9 +982,13 @@ file_excluded_p (const char *name)
STRING is the new element value, and REST holds the remaining elements. */
STRING is the new element value, and REST holds the remaining elements. */
static
struct
string_list
*
static
struct
string_list
*
string_list_cons
(
char
*
string
,
struct
string_list
*
rest
)
string_list_cons
(
string
,
rest
)
char
*
string
;
struct
string_list
*
rest
;
{
{
struct
string_list
*
temp
=
xmalloc
(
sizeof
(
struct
string_list
));
struct
string_list
*
temp
=
(
struct
string_list
*
)
xmalloc
(
sizeof
(
struct
string_list
));
temp
->
next
=
rest
;
temp
->
next
=
rest
;
temp
->
name
=
string
;
temp
->
name
=
string
;
return
temp
;
return
temp
;
...
@@ -972,7 +1004,9 @@ string_list_cons (char *string, struct string_list *rest)
...
@@ -972,7 +1004,9 @@ string_list_cons (char *string, struct string_list *rest)
argument. */
argument. */
static
void
static
void
visit_each_hash_node
(
const
hash_table_entry
*
hash_tab_p
,
void
(
*
func
)
(
const
hash_table_entry
*
))
visit_each_hash_node
(
hash_tab_p
,
func
)
const
hash_table_entry
*
hash_tab_p
;
void
(
*
func
)();
{
{
const
hash_table_entry
*
primary
;
const
hash_table_entry
*
primary
;
...
@@ -993,7 +1027,9 @@ visit_each_hash_node (const hash_table_entry *hash_tab_p, void (*func) (const ha
...
@@ -993,7 +1027,9 @@ visit_each_hash_node (const hash_table_entry *hash_tab_p, void (*func) (const ha
called. */
called. */
static
hash_table_entry
*
static
hash_table_entry
*
add_symbol
(
hash_table_entry
*
p
,
const
char
*
s
)
add_symbol
(
p
,
s
)
hash_table_entry
*
p
;
const
char
*
s
;
{
{
p
->
hash_next
=
NULL
;
p
->
hash_next
=
NULL
;
p
->
symbol
=
dupstr
(
s
);
p
->
symbol
=
dupstr
(
s
);
...
@@ -1008,7 +1044,9 @@ add_symbol (hash_table_entry *p, const char *s)
...
@@ -1008,7 +1044,9 @@ add_symbol (hash_table_entry *p, const char *s)
hash table entry for the given name. */
hash table entry for the given name. */
static
hash_table_entry
*
static
hash_table_entry
*
lookup
(
hash_table_entry
*
hash_tab_p
,
const
char
*
search_symbol
)
lookup
(
hash_tab_p
,
search_symbol
)
hash_table_entry
*
hash_tab_p
;
const
char
*
search_symbol
;
{
{
int
hash_value
=
0
;
int
hash_value
=
0
;
const
char
*
search_symbol_char_p
=
search_symbol
;
const
char
*
search_symbol_char_p
=
search_symbol
;
...
@@ -1038,8 +1076,9 @@ lookup (hash_table_entry *hash_tab_p, const char *search_symbol)
...
@@ -1038,8 +1076,9 @@ lookup (hash_table_entry *hash_tab_p, const char *search_symbol)
Also, since we are not using this record anymore, free up all of the
Also, since we are not using this record anymore, free up all of the
stuff it pointed to. */
stuff it pointed to. */
inline
static
void
static
void
free_def_dec
(
def_dec_info
*
p
)
free_def_dec
(
p
)
def_dec_info
*
p
;
{
{
xfree
(
p
->
ansi_decl
);
xfree
(
p
->
ansi_decl
);
...
@@ -1065,7 +1104,8 @@ free_def_dec (def_dec_info *p)
...
@@ -1065,7 +1104,8 @@ free_def_dec (def_dec_info *p)
return a pointer to the unexpanded copy. Otherwise return NULL. */
return a pointer to the unexpanded copy. Otherwise return NULL. */
static
char
*
static
char
*
unexpand_if_needed
(
const
char
*
aux_info_line
)
unexpand_if_needed
(
aux_info_line
)
const
char
*
aux_info_line
;
{
{
static
char
*
line_buf
=
0
;
static
char
*
line_buf
=
0
;
static
int
line_buf_size
=
0
;
static
int
line_buf_size
=
0
;
...
@@ -1147,7 +1187,9 @@ continue_outer: ;
...
@@ -1147,7 +1187,9 @@ continue_outer: ;
NULL. */
NULL. */
static
char
*
static
char
*
abspath
(
const
char
*
cwd
,
const
char
*
rel_filename
)
abspath
(
cwd
,
rel_filename
)
const
char
*
cwd
;
const
char
*
rel_filename
;
{
{
/* Setup the current working directory as needed. */
/* Setup the current working directory as needed. */
const
char
*
cwd2
=
(
cwd
)
?
cwd
:
cwd_buffer
;
const
char
*
cwd2
=
(
cwd
)
?
cwd
:
cwd_buffer
;
...
@@ -1250,7 +1292,9 @@ abspath (const char *cwd, const char *rel_filename)
...
@@ -1250,7 +1292,9 @@ abspath (const char *cwd, const char *rel_filename)
subpart of the original filename is actually a symbolic link. */
subpart of the original filename is actually a symbolic link. */
static
const
char
*
static
const
char
*
shortpath
(
const
char
*
cwd
,
const
char
*
filename
)
shortpath
(
cwd
,
filename
)
const
char
*
cwd
;
const
char
*
filename
;
{
{
char
*
rel_buffer
;
char
*
rel_buffer
;
char
*
rel_buf_p
;
char
*
rel_buf_p
;
...
@@ -1302,12 +1346,10 @@ shortpath (const char *cwd, const char *filename)
...
@@ -1302,12 +1346,10 @@ shortpath (const char *cwd, const char *filename)
--
rel_buf_p
;
--
rel_buf_p
;
if
(
*
(
rel_buf_p
-
1
)
==
'/'
)
if
(
*
(
rel_buf_p
-
1
)
==
'/'
)
*--
rel_buf_p
=
'\0'
;
*--
rel_buf_p
=
'\0'
;
if
(
strlen
(
rel_buffer
)
>
strlen
(
filename
))
if
(
strlen
(
rel_buffer
)
>
(
unsigned
)
strlen
(
filename
))
strcpy
(
rel_buffer
,
filename
);
strcpy
(
rel_buffer
,
filename
);
return
rel_buffer
;
return
rel_buffer
;
}
}
/* NOTREACHED */
return
0
;
/* Prevent warnings for old versions of GCC. */
}
}
/* Lookup the given filename in the hash table for filenames. If it is a
/* Lookup the given filename in the hash table for filenames. If it is a
...
@@ -1316,7 +1358,9 @@ shortpath (const char *cwd, const char *filename)
...
@@ -1316,7 +1358,9 @@ shortpath (const char *cwd, const char *filename)
that record with some reasonable values. */
that record with some reasonable values. */
static
file_info
*
static
file_info
*
find_file
(
char
*
filename
,
int
do_not_stat
)
find_file
(
filename
,
do_not_stat
)
char
*
filename
;
int
do_not_stat
;
/* FILENAME was const, but that causes a warning on AIX when calling stat.
/* FILENAME was const, but that causes a warning on AIX when calling stat.
That is probably a bug in AIX, but might as well avoid the warning. */
That is probably a bug in AIX, but might as well avoid the warning. */
{
{
...
@@ -1337,7 +1381,7 @@ find_file (char *filename, int do_not_stat)
...
@@ -1337,7 +1381,7 @@ find_file (char *filename, int do_not_stat)
stat_buf
.
st_mtime
=
(
time_t
)
0
;
stat_buf
.
st_mtime
=
(
time_t
)
0
;
else
else
{
{
if
(
stat
(
filename
,
&
stat_buf
)
==
-
1
)
if
(
my_
stat
(
filename
,
&
stat_buf
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't get status of `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't get status of `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
filename
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
filename
),
sys_errlist
[
errno
]);
...
@@ -1357,7 +1401,7 @@ find_file (char *filename, int do_not_stat)
...
@@ -1357,7 +1401,7 @@ find_file (char *filename, int do_not_stat)
messed up. */
messed up. */
static
void
static
void
aux_info_corrupted
(
void
)
aux_info_corrupted
()
{
{
fprintf
(
stderr
,
"
\n
%s: fatal error: aux info file corrupted at line %d
\n
"
,
fprintf
(
stderr
,
"
\n
%s: fatal error: aux info file corrupted at line %d
\n
"
,
pname
,
current_aux_info_lineno
);
pname
,
current_aux_info_lineno
);
...
@@ -1367,8 +1411,9 @@ aux_info_corrupted (void)
...
@@ -1367,8 +1411,9 @@ aux_info_corrupted (void)
/* ??? This comment is vague. Say what the condition is for. */
/* ??? This comment is vague. Say what the condition is for. */
/* Check to see that a condition is true. This is kind of like an assert(). */
/* Check to see that a condition is true. This is kind of like an assert(). */
inline
static
void
static
void
check_aux_info
(
int
cond
)
check_aux_info
(
cond
)
int
cond
;
{
{
if
(
!
cond
)
if
(
!
cond
)
aux_info_corrupted
();
aux_info_corrupted
();
...
@@ -1379,7 +1424,8 @@ check_aux_info (int cond)
...
@@ -1379,7 +1424,8 @@ check_aux_info (int cond)
return a pointer to it. */
return a pointer to it. */
static
const
char
*
static
const
char
*
find_corresponding_lparen
(
const
char
*
p
)
find_corresponding_lparen
(
p
)
const
char
*
p
;
{
{
const
char
*
q
;
const
char
*
q
;
int
paren_depth
;
int
paren_depth
;
...
@@ -1405,7 +1451,9 @@ find_corresponding_lparen (const char *p)
...
@@ -1405,7 +1451,9 @@ find_corresponding_lparen (const char *p)
file was created. If so, return non-zero, else return zero. */
file was created. If so, return non-zero, else return zero. */
static
int
static
int
referenced_file_is_newer
(
const
char
*
l
,
time_t
aux_info_mtime
)
referenced_file_is_newer
(
l
,
aux_info_mtime
)
const
char
*
l
;
time_t
aux_info_mtime
;
{
{
const
char
*
p
;
const
char
*
p
;
file_info
*
fi_p
;
file_info
*
fi_p
;
...
@@ -1451,7 +1499,9 @@ referenced_file_is_newer (const char *l, time_t aux_info_mtime)
...
@@ -1451,7 +1499,9 @@ referenced_file_is_newer (const char *l, time_t aux_info_mtime)
pertaining to this particular function name. */
pertaining to this particular function name. */
static
void
static
void
save_def_or_dec
(
const
char
*
l
,
int
is_syscalls
)
save_def_or_dec
(
l
,
is_syscalls
)
const
char
*
l
;
int
is_syscalls
;
{
{
const
char
*
p
;
const
char
*
p
;
const
char
*
semicolon_p
;
const
char
*
semicolon_p
;
...
@@ -1638,7 +1688,7 @@ save_def_or_dec (const char *l, int is_syscalls)
...
@@ -1638,7 +1688,7 @@ save_def_or_dec (const char *l, int is_syscalls)
/* p now points to the leftmost character of the function name. */
/* p now points to the leftmost character of the function name. */
{
{
char
fn_string
[
past_fn
-
p
+
1
]
;
char
*
fn_string
=
(
char
*
)
alloca
(
past_fn
-
p
+
1
)
;
strncpy
(
fn_string
,
p
,
(
size_t
)
(
past_fn
-
p
));
strncpy
(
fn_string
,
p
,
(
size_t
)
(
past_fn
-
p
));
fn_string
[
past_fn
-
p
]
=
'\0'
;
fn_string
[
past_fn
-
p
]
=
'\0'
;
...
@@ -1827,9 +1877,10 @@ save_def_or_dec (const char *l, int is_syscalls)
...
@@ -1827,9 +1877,10 @@ save_def_or_dec (const char *l, int is_syscalls)
adding a final group of options like '-fgen-aux-info -S -o /dev/null'. */
adding a final group of options like '-fgen-aux-info -S -o /dev/null'. */
static
void
static
void
munge_compile_params
(
const
char
*
params_list
)
munge_compile_params
(
params_list
)
const
char
*
params_list
;
{
{
c
onst
char
*
temp_params
[
strlen
(
params_list
)
+
10
]
;
c
har
**
temp_params
=
(
char
**
)
alloca
(
strlen
(
params_list
)
+
10
)
;
int
param_count
=
0
;
int
param_count
=
0
;
const
char
*
param
;
const
char
*
param
;
...
@@ -1881,7 +1932,8 @@ munge_compile_params (const char *params_list)
...
@@ -1881,7 +1932,8 @@ munge_compile_params (const char *params_list)
/* Make a copy of the compile_params in heap space. */
/* Make a copy of the compile_params in heap space. */
compile_params
=
xmalloc
(
sizeof
(
char
*
)
*
(
param_count
+
1
));
compile_params
=
(
char
**
)
xmalloc
(
sizeof
(
char
*
)
*
(
param_count
+
1
));
memcpy
(
compile_params
,
temp_params
,
sizeof
(
char
*
)
*
param_count
);
memcpy
(
compile_params
,
temp_params
,
sizeof
(
char
*
)
*
param_count
);
}
}
...
@@ -1889,7 +1941,8 @@ munge_compile_params (const char *params_list)
...
@@ -1889,7 +1941,8 @@ munge_compile_params (const char *params_list)
file to go with a specific base source file. */
file to go with a specific base source file. */
static
int
static
int
gen_aux_info_file
(
const
char
*
base_filename
)
gen_aux_info_file
(
base_filename
)
const
char
*
base_filename
;
{
{
int
child_pid
;
int
child_pid
;
...
@@ -1948,7 +2001,7 @@ gen_aux_info_file (const char *base_filename)
...
@@ -1948,7 +2001,7 @@ gen_aux_info_file (const char *base_filename)
}
}
else
else
{
{
if
(
execvp
(
compile_params
[
0
],
(
char
*
const
*
)
compile_params
))
if
(
my_
execvp
(
compile_params
[
0
],
(
char
*
const
*
)
compile_params
))
{
{
fprintf
(
stderr
,
"%s: error: execvp returned: %s
\n
"
,
fprintf
(
stderr
,
"%s: error: execvp returned: %s
\n
"
,
pname
,
sys_errlist
[
errno
]);
pname
,
sys_errlist
[
errno
]);
...
@@ -1962,7 +2015,10 @@ gen_aux_info_file (const char *base_filename)
...
@@ -1962,7 +2015,10 @@ gen_aux_info_file (const char *base_filename)
Save all of the important stuff for later. */
Save all of the important stuff for later. */
static
void
static
void
process_aux_info_file
(
const
char
*
base_source_filename
,
int
keep_it
,
int
is_syscalls
)
process_aux_info_file
(
base_source_filename
,
keep_it
,
is_syscalls
)
const
char
*
base_source_filename
;
int
keep_it
;
int
is_syscalls
;
{
{
char
*
const
aux_info_filename
char
*
const
aux_info_filename
=
(
char
*
)
alloca
(
strlen
(
base_source_filename
)
=
(
char
*
)
alloca
(
strlen
(
base_source_filename
)
...
@@ -1987,7 +2043,7 @@ start_over: ;
...
@@ -1987,7 +2043,7 @@ start_over: ;
int
retries
=
0
;
int
retries
=
0
;
retry
:
retry
:
if
(
access
(
aux_info_filename
,
R_OK
)
==
-
1
)
if
(
my_
access
(
aux_info_filename
,
R_OK
)
==
-
1
)
{
{
if
(
errno
==
ENOENT
&&
retries
==
0
)
if
(
errno
==
ENOENT
&&
retries
==
0
)
{
{
...
@@ -2018,7 +2074,7 @@ retry:
...
@@ -2018,7 +2074,7 @@ retry:
/* Get some status information about this aux_info file. */
/* Get some status information about this aux_info file. */
if
(
stat
(
aux_info_filename
,
&
stat_buf
)
==
-
1
)
if
(
my_
stat
(
aux_info_filename
,
&
stat_buf
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't get status of aux info file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't get status of aux info file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_filename
),
pname
,
shortpath
(
NULL
,
aux_info_filename
),
...
@@ -2045,7 +2101,7 @@ retry:
...
@@ -2045,7 +2101,7 @@ retry:
/* Open the aux_info file. */
/* Open the aux_info file. */
if
((
aux_info_file
=
open
(
aux_info_filename
,
O_RDONLY
,
0444
))
==
-
1
)
if
((
aux_info_file
=
my_
open
(
aux_info_filename
,
O_RDONLY
,
0444
))
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't open aux info file `%s' for reading: %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't open aux info file `%s' for reading: %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_filename
),
pname
,
shortpath
(
NULL
,
aux_info_filename
),
...
@@ -2088,7 +2144,7 @@ retry:
...
@@ -2088,7 +2144,7 @@ retry:
fails for some reason, don't even worry about it. */
fails for some reason, don't even worry about it. */
if
(
!
keep_it
)
if
(
!
keep_it
)
if
(
unlink
(
aux_info_filename
)
==
-
1
)
if
(
my_
unlink
(
aux_info_filename
)
==
-
1
)
fprintf
(
stderr
,
"%s: error: can't delete aux info file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't delete aux info file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_filename
),
pname
,
shortpath
(
NULL
,
aux_info_filename
),
sys_errlist
[
errno
]);
sys_errlist
[
errno
]);
...
@@ -2136,7 +2192,7 @@ retry:
...
@@ -2136,7 +2192,7 @@ retry:
if
(
referenced_file_is_newer
(
aux_info_p
,
aux_info_mtime
))
if
(
referenced_file_is_newer
(
aux_info_p
,
aux_info_mtime
))
{
{
free
(
aux_info_base
);
free
(
aux_info_base
);
if
(
unlink
(
aux_info_filename
)
==
-
1
)
if
(
my_
unlink
(
aux_info_filename
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't delete file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't delete file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_filename
),
pname
,
shortpath
(
NULL
,
aux_info_filename
),
...
@@ -2191,7 +2247,8 @@ retry:
...
@@ -2191,7 +2247,8 @@ retry:
function implements the -C option. */
function implements the -C option. */
static
void
static
void
rename_c_file
(
const
hash_table_entry
*
hp
)
rename_c_file
(
hp
)
const
hash_table_entry
*
hp
;
{
{
const
char
*
filename
=
hp
->
symbol
;
const
char
*
filename
=
hp
->
symbol
;
int
last_char_index
=
strlen
(
filename
)
-
1
;
int
last_char_index
=
strlen
(
filename
)
-
1
;
...
@@ -2209,7 +2266,7 @@ rename_c_file (const hash_table_entry *hp)
...
@@ -2209,7 +2266,7 @@ rename_c_file (const hash_table_entry *hp)
strcpy
(
new_filename
,
filename
);
strcpy
(
new_filename
,
filename
);
new_filename
[
last_char_index
]
=
'C'
;
new_filename
[
last_char_index
]
=
'C'
;
if
(
link
(
filename
,
new_filename
)
==
-
1
)
if
(
my_
link
(
filename
,
new_filename
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: warning: can't link file `%s' to `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: warning: can't link file `%s' to `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
filename
),
pname
,
shortpath
(
NULL
,
filename
),
...
@@ -2218,7 +2275,7 @@ rename_c_file (const hash_table_entry *hp)
...
@@ -2218,7 +2275,7 @@ rename_c_file (const hash_table_entry *hp)
return
;
return
;
}
}
if
(
unlink
(
filename
)
==
-
1
)
if
(
my_
unlink
(
filename
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: warning: can't delete file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: warning: can't delete file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
filename
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
filename
),
sys_errlist
[
errno
]);
...
@@ -2238,7 +2295,8 @@ rename_c_file (const hash_table_entry *hp)
...
@@ -2238,7 +2295,8 @@ rename_c_file (const hash_table_entry *hp)
order here. */
order here. */
static
void
static
void
reverse_def_dec_list
(
const
hash_table_entry
*
hp
)
reverse_def_dec_list
(
hp
)
const
hash_table_entry
*
hp
;
{
{
file_info
*
file_p
=
hp
->
fip
;
file_info
*
file_p
=
hp
->
fip
;
const
def_dec_info
*
prev
=
NULL
;
const
def_dec_info
*
prev
=
NULL
;
...
@@ -2279,7 +2337,9 @@ reverse_def_dec_list (const hash_table_entry *hp)
...
@@ -2279,7 +2337,9 @@ reverse_def_dec_list (const hash_table_entry *hp)
contains all of the correct prototypes for system functions. */
contains all of the correct prototypes for system functions. */
static
const
def_dec_info
*
static
const
def_dec_info
*
find_extern_def
(
const
def_dec_info
*
head
,
const
def_dec_info
*
user
)
find_extern_def
(
head
,
user
)
const
def_dec_info
*
head
;
const
def_dec_info
*
user
;
{
{
const
def_dec_info
*
dd_p
;
const
def_dec_info
*
dd_p
;
const
def_dec_info
*
extern_def_p
=
NULL
;
const
def_dec_info
*
extern_def_p
=
NULL
;
...
@@ -2408,13 +2468,13 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
...
@@ -2408,13 +2468,13 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
{
{
/* Why copy this string into `needed' at all?
/* Why copy this string into `needed' at all?
Why not just use user->ansi_decl without copying? */
Why not just use user->ansi_decl without copying? */
char
needed
[
strlen
(
user
->
ansi_decl
)
+
1
]
;
char
*
needed
=
(
char
*
)
alloca
(
strlen
(
user
->
ansi_decl
)
+
1
)
;
char
*
p
;
char
*
p
;
strcpy
(
needed
,
user
->
ansi_decl
);
strcpy
(
needed
,
user
->
ansi_decl
);
p
=
(
NONCONST
char
*
)
substr
(
needed
,
user
->
hash_entry
->
symbol
)
p
=
(
NONCONST
char
*
)
substr
(
needed
,
user
->
hash_entry
->
symbol
)
+
strlen
(
user
->
hash_entry
->
symbol
)
+
2
;
+
strlen
(
user
->
hash_entry
->
symbol
)
+
2
;
strcpy
(
p
,
"???);"
);
strcpy
(
p
,
"??
\
?);"
);
fprintf
(
stderr
,
"%s: %d: `%s' used but missing from SYSCALLS
\n
"
,
fprintf
(
stderr
,
"%s: %d: `%s' used but missing from SYSCALLS
\n
"
,
shortpath
(
NULL
,
file
),
user
->
line
,
shortpath
(
NULL
,
file
),
user
->
line
,
...
@@ -2434,7 +2494,8 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
...
@@ -2434,7 +2494,8 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
from the def_dec_info record pointer which is passed in. */
from the def_dec_info record pointer which is passed in. */
static
const
def_dec_info
*
static
const
def_dec_info
*
find_static_definition
(
const
def_dec_info
*
user
)
find_static_definition
(
user
)
const
def_dec_info
*
user
;
{
{
const
def_dec_info
*
head
=
user
->
hash_entry
->
ddip
;
const
def_dec_info
*
head
=
user
->
hash_entry
->
ddip
;
const
def_dec_info
*
dd_p
;
const
def_dec_info
*
dd_p
;
...
@@ -2483,7 +2544,8 @@ find_static_definition (const def_dec_info *user)
...
@@ -2483,7 +2544,8 @@ find_static_definition (const def_dec_info *user)
more details. */
more details. */
static
void
static
void
connect_defs_and_decs
(
const
hash_table_entry
*
hp
)
connect_defs_and_decs
(
hp
)
const
hash_table_entry
*
hp
;
{
{
const
def_dec_info
*
dd_p
;
const
def_dec_info
*
dd_p
;
const
def_dec_info
*
extern_def_p
=
NULL
;
const
def_dec_info
*
extern_def_p
=
NULL
;
...
@@ -2607,7 +2669,8 @@ connect_defs_and_decs (const hash_table_entry *hp)
...
@@ -2607,7 +2669,8 @@ connect_defs_and_decs (const hash_table_entry *hp)
original source line number that the given pointer points into. */
original source line number that the given pointer points into. */
static
int
static
int
identify_lineno
(
const
char
*
clean_p
)
identify_lineno
(
clean_p
)
const
char
*
clean_p
;
{
{
int
line_num
=
1
;
int
line_num
=
1
;
const
char
*
scan_p
;
const
char
*
scan_p
;
...
@@ -2621,7 +2684,8 @@ identify_lineno (const char *clean_p)
...
@@ -2621,7 +2684,8 @@ identify_lineno (const char *clean_p)
/* Issue an error message and give up on doing this particular edit. */
/* Issue an error message and give up on doing this particular edit. */
static
void
static
void
declare_source_confusing
(
const
char
*
clean_p
)
declare_source_confusing
(
clean_p
)
const
char
*
clean_p
;
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
{
{
...
@@ -2640,8 +2704,10 @@ declare_source_confusing (const char *clean_p)
...
@@ -2640,8 +2704,10 @@ declare_source_confusing (const char *clean_p)
code is in fact true. If not, issue an error message and give up on
code is in fact true. If not, issue an error message and give up on
converting this particular source file. */
converting this particular source file. */
inline
static
void
static
void
check_source
(
int
cond
,
const
char
*
clean_p
)
check_source
(
cond
,
clean_p
)
int
cond
;
const
char
*
clean_p
;
{
{
if
(
!
cond
)
if
(
!
cond
)
declare_source_confusing
(
clean_p
);
declare_source_confusing
(
clean_p
);
...
@@ -2663,7 +2729,8 @@ check_source (int cond, const char *clean_p)
...
@@ -2663,7 +2729,8 @@ check_source (int cond, const char *clean_p)
of the in-core cleaned buffer again. */
of the in-core cleaned buffer again. */
static
const
char
*
static
const
char
*
seek_to_line
(
int
n
)
seek_to_line
(
n
)
int
n
;
{
{
if
(
n
<
last_known_line_number
)
if
(
n
<
last_known_line_number
)
abort
();
abort
();
...
@@ -2682,7 +2749,8 @@ seek_to_line (int n)
...
@@ -2682,7 +2749,8 @@ seek_to_line (int n)
to the next non-whitepace character which follows it. */
to the next non-whitepace character which follows it. */
static
const
char
*
static
const
char
*
forward_to_next_token_char
(
const
char
*
ptr
)
forward_to_next_token_char
(
ptr
)
const
char
*
ptr
;
{
{
for
(
++
ptr
;
isspace
(
*
ptr
);
check_source
(
++
ptr
<
clean_text_limit
,
0
))
for
(
++
ptr
;
isspace
(
*
ptr
);
check_source
(
++
ptr
<
clean_text_limit
,
0
))
continue
;
continue
;
...
@@ -2694,7 +2762,9 @@ forward_to_next_token_char (const char *ptr)
...
@@ -2694,7 +2762,9 @@ forward_to_next_token_char (const char *ptr)
buffer ultimately go through here. */
buffer ultimately go through here. */
static
void
static
void
output_bytes
(
const
char
*
str
,
size_t
len
)
output_bytes
(
str
,
len
)
const
char
*
str
;
size_t
len
;
{
{
if
((
repl_write_ptr
+
1
)
+
len
>=
repl_text_limit
)
if
((
repl_write_ptr
+
1
)
+
len
>=
repl_text_limit
)
{
{
...
@@ -2713,7 +2783,8 @@ output_bytes (const char *str, size_t len)
...
@@ -2713,7 +2783,8 @@ output_bytes (const char *str, size_t len)
the current output buffer. */
the current output buffer. */
static
void
static
void
output_string
(
const
char
*
str
)
output_string
(
str
)
const
char
*
str
;
{
{
output_bytes
(
str
,
strlen
(
str
));
output_bytes
(
str
,
strlen
(
str
));
}
}
...
@@ -2738,7 +2809,8 @@ output_string (const char *str)
...
@@ -2738,7 +2809,8 @@ output_string (const char *str)
byte pointed to by the argument pointer `p'. */
byte pointed to by the argument pointer `p'. */
static
void
static
void
output_up_to
(
const
char
*
p
)
output_up_to
(
p
)
const
char
*
p
;
{
{
size_t
copy_length
=
(
size_t
)
(
p
-
clean_read_ptr
);
size_t
copy_length
=
(
size_t
)
(
p
-
clean_read_ptr
);
const
char
*
copy_start
=
orig_text_base
+
(
clean_read_ptr
-
clean_text_base
)
+
1
;
const
char
*
copy_start
=
orig_text_base
+
(
clean_read_ptr
-
clean_text_base
)
+
1
;
...
@@ -2757,7 +2829,8 @@ output_up_to (const char *p)
...
@@ -2757,7 +2829,8 @@ output_up_to (const char *p)
otherwise. */
otherwise. */
static
int
static
int
other_variable_style_function
(
const
char
*
ansi_header
)
other_variable_style_function
(
ansi_header
)
const
char
*
ansi_header
;
{
{
#ifdef UNPROTOIZE
#ifdef UNPROTOIZE
...
@@ -2795,8 +2868,9 @@ other_variable_style_function (const char *ansi_header)
...
@@ -2795,8 +2868,9 @@ other_variable_style_function (const char *ansi_header)
below. */
below. */
static
void
static
void
edit_fn_declaration
(
const
def_dec_info
*
def_dec_p
,
edit_fn_declaration
(
def_dec_p
,
clean_text_p
)
const
char
*
volatile
clean_text_p
)
const
def_dec_info
*
def_dec_p
;
const
char
*
VOLATILE
clean_text_p
;
{
{
const
char
*
start_formals
;
const
char
*
start_formals
;
const
char
*
end_formals
;
const
char
*
end_formals
;
...
@@ -3010,7 +3084,10 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
...
@@ -3010,7 +3084,10 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
function doesn't match the one expected). */
function doesn't match the one expected). */
static
int
static
int
edit_formals_lists
(
const
char
*
end_formals
,
unsigned
f_list_count
,
const
def_dec_info
*
def_dec_p
)
edit_formals_lists
(
end_formals
,
f_list_count
,
def_dec_p
)
const
char
*
end_formals
;
unsigned
int
f_list_count
;
const
def_dec_info
*
def_dec_p
;
{
{
const
char
*
start_formals
;
const
char
*
start_formals
;
int
depth
;
int
depth
;
...
@@ -3117,7 +3194,8 @@ edit_formals_lists (const char *end_formals, unsigned f_list_count, const def_de
...
@@ -3117,7 +3194,8 @@ edit_formals_lists (const char *end_formals, unsigned f_list_count, const def_de
*/
*/
static
const
char
*
static
const
char
*
find_rightmost_formals_list
(
const
char
*
clean_text_p
)
find_rightmost_formals_list
(
clean_text_p
)
const
char
*
clean_text_p
;
{
{
const
char
*
end_formals
;
const
char
*
end_formals
;
...
@@ -3145,10 +3223,41 @@ find_rightmost_formals_list (const char *clean_text_p)
...
@@ -3145,10 +3223,41 @@ find_rightmost_formals_list (const char *clean_text_p)
continue
;
continue
;
end_formals
--
;
end_formals
--
;
#ifdef UNPROTOIZE
/* Now scan backwards while looking for the right end of the rightmost
/* Now scan backwards while looking for the right end of the rightmost
formals list associated with this function definition. */
formals list associated with this function definition. */
for
(;;)
{
char
ch
;
const
char
*
l_brace_p
;
/* Look leftward and try to find a right-paren. */
while
(
*
end_formals
!=
')'
)
{
if
(
isspace
(
*
end_formals
))
while
(
isspace
(
*
end_formals
))
check_source
(
--
end_formals
>
clean_read_ptr
,
0
);
else
check_source
(
--
end_formals
>
clean_read_ptr
,
0
);
}
ch
=
*
(
l_brace_p
=
forward_to_next_token_char
(
end_formals
));
/* Since we are unprotoizing an ANSI-style (prototyped) function
definition, there had better not be anything (except whitespace)
between the end of the ANSI formals list and the beginning of the
function body (i.e. the '{'). */
check_source
(
ch
==
'{'
,
l_brace_p
);
}
#else
/* !defined(UNPROTOIZE) */
/* Now scan backwards while looking for the right end of the rightmost
formals list associated with this function definition. */
while
(
1
)
{
{
char
ch
;
char
ch
;
const
char
*
l_brace_p
;
const
char
*
l_brace_p
;
...
@@ -3166,18 +3275,6 @@ find_rightmost_formals_list (const char *clean_text_p)
...
@@ -3166,18 +3275,6 @@ find_rightmost_formals_list (const char *clean_text_p)
ch
=
*
(
l_brace_p
=
forward_to_next_token_char
(
end_formals
));
ch
=
*
(
l_brace_p
=
forward_to_next_token_char
(
end_formals
));
#ifdef UNPROTOIZE
/* Since we are unprotoizing an ANSI-style (prototyped) function
definition, there had better not be anything (except whitespace)
between the end of the ANSI formals list and the beginning of the
function body (i.e. the '{'). */
check_source
(
ch
==
'{'
,
l_brace_p
);
break
;
#else
/* !defined(UNPROTOIZE) */
/* Since it is possible that we found a right paren before the starting
/* Since it is possible that we found a right paren before the starting
'{' of the body which IS NOT the one at the end of the real K&R
'{' of the body which IS NOT the one at the end of the real K&R
formals list (say for instance, we found one embedded inside one of
formals list (say for instance, we found one embedded inside one of
...
@@ -3196,11 +3293,10 @@ find_rightmost_formals_list (const char *clean_text_p)
...
@@ -3196,11 +3293,10 @@ find_rightmost_formals_list (const char *clean_text_p)
looking. */
looking. */
check_source
(
--
end_formals
>
clean_read_ptr
,
0
);
check_source
(
--
end_formals
>
clean_read_ptr
,
0
);
}
#endif
/* !defined(UNPROTOIZE) */
#endif
/* !defined(UNPROTOIZE) */
}
return
end_formals
;
return
end_formals
;
}
}
...
@@ -3216,7 +3312,9 @@ find_rightmost_formals_list (const char *clean_text_p)
...
@@ -3216,7 +3312,9 @@ find_rightmost_formals_list (const char *clean_text_p)
parameter type checking. */
parameter type checking. */
static
void
static
void
add_local_decl
(
const
def_dec_info
*
def_dec_p
,
const
char
*
clean_text_p
)
add_local_decl
(
def_dec_p
,
clean_text_p
)
const
def_dec_info
*
def_dec_p
;
const
char
*
clean_text_p
;
{
{
const
char
*
start_of_block
;
const
char
*
start_of_block
;
const
char
*
function_to_edit
=
def_dec_p
->
hash_entry
->
symbol
;
const
char
*
function_to_edit
=
def_dec_p
->
hash_entry
->
symbol
;
...
@@ -3322,7 +3420,9 @@ add_local_decl (const def_dec_info *def_dec_p, const char *clean_text_p)
...
@@ -3322,7 +3420,9 @@ add_local_decl (const def_dec_info *def_dec_p, const char *clean_text_p)
and then insert the new explicit declaration at that point in the file. */
and then insert the new explicit declaration at that point in the file. */
static
void
static
void
add_global_decls
(
const
file_info
*
file_p
,
const
char
*
clean_text_p
)
add_global_decls
(
file_p
,
clean_text_p
)
const
file_info
*
file_p
;
const
char
*
clean_text_p
;
{
{
const
def_dec_info
*
dd_p
;
const
def_dec_info
*
dd_p
;
const
char
*
scan_p
;
const
char
*
scan_p
;
...
@@ -3411,7 +3511,9 @@ add_global_decls (const file_info *file_p, const char *clean_text_p)
...
@@ -3411,7 +3511,9 @@ add_global_decls (const file_info *file_p, const char *clean_text_p)
separate routine above. */
separate routine above. */
static
void
static
void
edit_fn_definition
(
const
def_dec_info
*
def_dec_p
,
const
char
*
clean_text_p
)
edit_fn_definition
(
def_dec_p
,
clean_text_p
)
const
def_dec_info
*
def_dec_p
;
const
char
*
clean_text_p
;
{
{
const
char
*
end_formals
;
const
char
*
end_formals
;
const
char
*
function_to_edit
=
def_dec_p
->
hash_entry
->
symbol
;
const
char
*
function_to_edit
=
def_dec_p
->
hash_entry
->
symbol
;
...
@@ -3553,7 +3655,9 @@ edit_fn_definition (const def_dec_info *def_dec_p, const char *clean_text_p)
...
@@ -3553,7 +3655,9 @@ edit_fn_definition (const def_dec_info *def_dec_p, const char *clean_text_p)
into whitespace. Also, whiteout string and character literals. */
into whitespace. Also, whiteout string and character literals. */
static
void
static
void
do_cleaning
(
char
*
new_clean_text_base
,
char
*
new_clean_text_limit
)
do_cleaning
(
new_clean_text_base
,
new_clean_text_limit
)
char
*
new_clean_text_base
;
char
*
new_clean_text_limit
;
{
{
char
*
scan_p
;
char
*
scan_p
;
int
non_whitespace_since_newline
=
0
;
int
non_whitespace_since_newline
=
0
;
...
@@ -3653,7 +3757,8 @@ regular:
...
@@ -3653,7 +3757,8 @@ regular:
and return a pointer to it. */
and return a pointer to it. */
static
const
char
*
static
const
char
*
careful_find_l_paren
(
const
char
*
p
)
careful_find_l_paren
(
p
)
const
char
*
p
;
{
{
const
char
*
q
;
const
char
*
q
;
int
paren_depth
;
int
paren_depth
;
...
@@ -3691,7 +3796,8 @@ careful_find_l_paren (const char *p)
...
@@ -3691,7 +3796,8 @@ careful_find_l_paren (const char *p)
I will probably try to do this in a later version though. */
I will probably try to do this in a later version though. */
static
void
static
void
scan_for_missed_items
(
const
file_info
*
file_p
)
scan_for_missed_items
(
file_p
)
const
file_info
*
file_p
;
{
{
static
const
char
*
scan_p
;
static
const
char
*
scan_p
;
const
char
*
limit
=
clean_text_limit
-
3
;
const
char
*
limit
=
clean_text_limit
-
3
;
...
@@ -3747,7 +3853,7 @@ scan_for_missed_items (const file_info *file_p)
...
@@ -3747,7 +3853,7 @@ scan_for_missed_items (const file_info *file_p)
goto
not_missed
;
goto
not_missed
;
{
{
char
func_name
[
id_length
+
1
]
;
char
*
func_name
=
(
char
*
)
alloca
(
id_length
+
1
)
;
static
const
char
*
const
stmt_keywords
[]
static
const
char
*
const
stmt_keywords
[]
=
{
"if"
,
"while"
,
"for"
,
"switch"
,
"return"
,
0
};
=
{
"if"
,
"while"
,
"for"
,
"switch"
,
"return"
,
0
};
const
char
*
const
*
stmt_keyword
;
const
char
*
const
*
stmt_keyword
;
...
@@ -3805,7 +3911,8 @@ scan_for_missed_items (const file_info *file_p)
...
@@ -3805,7 +3911,8 @@ scan_for_missed_items (const file_info *file_p)
preprocessor directives make the editing a whole lot easier. */
preprocessor directives make the editing a whole lot easier. */
static
void
static
void
edit_file
(
const
hash_table_entry
*
hp
)
edit_file
(
hp
)
const
hash_table_entry
*
hp
;
{
{
struct
stat
stat_buf
;
struct
stat
stat_buf
;
const
file_info
*
file_p
=
hp
->
fip
;
const
file_info
*
file_p
=
hp
->
fip
;
...
@@ -3848,18 +3955,17 @@ edit_file (const hash_table_entry *hp)
...
@@ -3848,18 +3955,17 @@ edit_file (const hash_table_entry *hp)
/* Let the user know what we are up to. */
/* Let the user know what we are up to. */
if
(
nochange_flag
)
if
(
nochange_flag
)
puts
(
shortpath
(
NULL
,
convert_filename
));
fprintf
(
stderr
,
"%s: would convert file `%s'
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
));
else
else
{
fprintf
(
stderr
,
"%s: converting file `%s'
\n
"
,
fprintf
(
stderr
,
"%s: converting file `%s'
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
));
pname
,
shortpath
(
NULL
,
convert_filename
));
fflush
(
stderr
);
fflush
(
stderr
);
}
/* Find out the size (in bytes) of the original file. */
/* Find out the size (in bytes) of the original file. */
/* The cast avoids an erroneous warning on AIX. */
/* The cast avoids an erroneous warning on AIX. */
if
(
stat
((
char
*
)
convert_filename
,
&
stat_buf
)
==
-
1
)
if
(
my_
stat
((
char
*
)
convert_filename
,
&
stat_buf
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't get status for file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't get status for file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
...
@@ -3893,7 +3999,7 @@ edit_file (const hash_table_entry *hp)
...
@@ -3893,7 +3999,7 @@ edit_file (const hash_table_entry *hp)
/* Open the file to be converted in READ ONLY mode. */
/* Open the file to be converted in READ ONLY mode. */
if
((
input_file
=
open
(
convert_filename
,
O_RDONLY
,
0444
))
==
-
1
)
if
((
input_file
=
my_
open
(
convert_filename
,
O_RDONLY
,
0444
))
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't open file `%s' for reading: %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't open file `%s' for reading: %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
),
pname
,
shortpath
(
NULL
,
convert_filename
),
...
@@ -4038,7 +4144,7 @@ edit_file (const hash_table_entry *hp)
...
@@ -4038,7 +4144,7 @@ edit_file (const hash_table_entry *hp)
strcpy
(
new_filename
,
convert_filename
);
strcpy
(
new_filename
,
convert_filename
);
strcat
(
new_filename
,
save_suffix
);
strcat
(
new_filename
,
save_suffix
);
if
(
link
(
convert_filename
,
new_filename
)
==
-
1
)
if
(
my_
link
(
convert_filename
,
new_filename
)
==
-
1
)
{
{
if
(
errno
==
EEXIST
)
if
(
errno
==
EEXIST
)
{
{
...
@@ -4060,7 +4166,7 @@ edit_file (const hash_table_entry *hp)
...
@@ -4060,7 +4166,7 @@ edit_file (const hash_table_entry *hp)
}
}
}
}
if
(
unlink
(
convert_filename
)
==
-
1
)
if
(
my_
unlink
(
convert_filename
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't delete file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't delete file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
...
@@ -4103,7 +4209,7 @@ edit_file (const hash_table_entry *hp)
...
@@ -4103,7 +4209,7 @@ edit_file (const hash_table_entry *hp)
/* Change the mode of the output file to match the original file. */
/* Change the mode of the output file to match the original file. */
/* The cast avoids an erroneous warning on AIX. */
/* The cast avoids an erroneous warning on AIX. */
if
(
chmod
((
char
*
)
convert_filename
,
stat_buf
.
st_mode
)
==
-
1
)
if
(
my_
chmod
((
char
*
)
convert_filename
,
stat_buf
.
st_mode
)
==
-
1
)
fprintf
(
stderr
,
"%s: error: can't change mode of file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't change mode of file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
...
@@ -4118,7 +4224,7 @@ edit_file (const hash_table_entry *hp)
...
@@ -4118,7 +4224,7 @@ edit_file (const hash_table_entry *hp)
in the command line. */
in the command line. */
static
void
static
void
do_processing
(
void
)
do_processing
()
{
{
const
char
*
const
*
base_pp
;
const
char
*
const
*
base_pp
;
const
char
*
const
*
const
end_pps
const
char
*
const
*
const
end_pps
...
@@ -4145,18 +4251,18 @@ do_processing (void)
...
@@ -4145,18 +4251,18 @@ do_processing (void)
{
{
syscalls_absolute_filename
syscalls_absolute_filename
=
(
char
*
)
xmalloc
(
strlen
(
nondefault_syscalls_dir
)
=
(
char
*
)
xmalloc
(
strlen
(
nondefault_syscalls_dir
)
+
strlen
(
syscalls_filename
)
+
1
);
+
strlen
(
syscalls_filename
)
+
2
);
strcpy
(
syscalls_absolute_filename
,
nondefault_syscalls_dir
);
strcpy
(
syscalls_absolute_filename
,
nondefault_syscalls_dir
);
}
}
else
else
{
{
syscalls_absolute_filename
syscalls_absolute_filename
=
(
char
*
)
xmalloc
(
strlen
(
default_syscalls_dir
)
=
(
char
*
)
xmalloc
(
strlen
(
default_syscalls_dir
)
+
strlen
(
syscalls_filename
)
+
1
);
+
strlen
(
syscalls_filename
)
+
2
);
strcpy
(
syscalls_absolute_filename
,
default_syscalls_dir
);
strcpy
(
syscalls_absolute_filename
,
default_syscalls_dir
);
}
}
syscalls_len
=
strlen
(
syscalls_filename
);
syscalls_len
=
strlen
(
syscalls_
absolute_
filename
);
if
(
*
(
syscalls_absolute_filename
+
syscalls_len
-
1
)
!=
'/'
)
if
(
*
(
syscalls_absolute_filename
+
syscalls_len
-
1
)
!=
'/'
)
{
{
*
(
syscalls_absolute_filename
+
syscalls_len
++
)
=
'/'
;
*
(
syscalls_absolute_filename
+
syscalls_len
++
)
=
'/'
;
...
@@ -4232,7 +4338,9 @@ static struct option longopts[] =
...
@@ -4232,7 +4338,9 @@ static struct option longopts[] =
};
};
int
int
main
(
int
argc
,
char
**
const
argv
)
main
(
argc
,
argv
)
int
argc
;
char
**
const
argv
;
{
{
int
longind
;
int
longind
;
int
c
;
int
c
;
...
@@ -4242,7 +4350,7 @@ main (int argc, char **const argv)
...
@@ -4242,7 +4350,7 @@ main (int argc, char **const argv)
pname
=
pname
?
pname
+
1
:
argv
[
0
];
pname
=
pname
?
pname
+
1
:
argv
[
0
];
/* Read the working directory, avoiding arbitrary limit. */
/* Read the working directory, avoiding arbitrary limit. */
size
=
100
;
size
=
GUESSPATHLEN
;
while
(
1
)
while
(
1
)
{
{
char
*
value
;
char
*
value
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment