]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gprofng/testsuite/gprofng.display/synprog/endcases.c
1 /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
25 #include "stopwatch.h"
27 /* endcases - examine some wierd endcases of programming style
28 * test cases for inlined code, macros, #included code, ...
34 void inc_middle (int);
36 void macro_code (int);
37 void ext_macro_code (int);
38 void xinline_code (int);
39 static void s_inline_code (int);
40 void ext_inline_code (int);
43 void xinline_code () __attribute__ ((always_inline
));
44 void s_inline_code () __attribute__ ((always_inline
));
47 #include "inc_inline.h"
54 /* define a macro that burns CPU time */
57 for (j = 0; j < (nn * x8M); j++) { \
64 hrtime_t start
= gethrtime ();
65 hrtime_t vstart
= gethrvtime ();
68 wlog ("start of endcases", NULL
);
85 /* test various cases of #include'd code */
94 while (start
+ testtime
* 1e9
> gethrtime ());
96 fprintf (stderr
, " Performed %lld while-loop iterations\n", count
);
97 whrvlog (gethrtime () - start
, gethrvtime () - vstart
, "endcases", NULL
);
101 /* spend time in a inline locally-defined */
107 for (int j
= 0; j
< jmax
; j
++)
110 printf ("ERROR: inline_code(): x < 0 (x=%ld)\n", x
);
113 /* spend time in a static inline locally-defined */
115 s_inline_code (int n
)
119 for (int j
= 0; j
< jmax
; j
++)
122 printf ("ERROR: s_inline_code(): x < 0 (x=%ld)\n", x
);
125 /* spend time in a macro locally-defined */
133 printf ("ERROR: macro_code(): x < 0 (x=%ld)\n", x
);
136 /* spend time in a macro externally-defined */
137 #include "inc_macro.h"
140 ext_macro_code (int n
)
146 printf ("ERROR: ext_macro_code(): x < 0 (x=%ld)\n", x
);
149 #include "inc_func.h"
153 #include "inc_brace.h"
157 #include "inc_body.h"
162 #include "inc_entry.h"
165 volatile float x
= 0.0;
166 for (int j
= 0; j
< jmax
; j
++)
169 printf ("ERROR: inc_entry(): x < 0 (x=%f)\n", x
);
178 volatile float x
= 0.0;
179 for (int j
= 0; j
< jmax
; j
++)
182 printf ("ERROR: inc_middle(): loop 1: x < 0 (x=%f)\n", x
);
184 #include "inc_body.h"
187 volatile float x
= 0.0;
188 for (int j
= 0; j
< jmax
; j
++)
191 printf ("ERROR: inc_middle(): loop 2: x < 0 (x=%f)\n", x
);
200 volatile float x
= 0.0;
201 for (int j
= 0; j
< jmax
; j
++)
204 printf ("ERROR: inc_exit(): x < 0 (x=%f)\n", x
);
207 #include "inc_exit.h"