Commit 4148ee08 authored by Xavier Leroy's avatar Xavier Leroy
Browse files

Set/clear CR6 before calling an unprototyped function.

A function declared without a prototype could be implemented by a
vararg function (even though this is undefined behavior in C99).
Be nice in this case.
parent 7c361e1b
......@@ -427,11 +427,12 @@ let expand_builtin_inline name args res =
(* Calls to variadic functions: condition bit 6 must be set
if at least one argument is a float; clear otherwise.
Note that variadic functions cannot have arguments of type Tsingle. *)
For compatibility with other compilers, do the same if the called
function is unprototyped. *)
let set_cr6 sg =
if sg.sig_cc.cc_vararg then begin
if List.mem Tfloat sg.sig_args
if sg.sig_cc.cc_vararg || sg.sig_cc.cc_unproto then begin
if List.exists (function Tfloat | Tsingle -> true | _ -> false) sg.sig_args
then emit (Pcreqv(CRbit_6, CRbit_6, CRbit_6))
else emit (Pcrxor(CRbit_6, CRbit_6, CRbit_6))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment