Skip to content

Commit 423bfe2

Browse files
committed
Modernize the C style of those autoconf tests.
The intent is to produce fewer warnings when configuring with -verbose. Note that the warning on "implicit declaration of function" remains, for relatively good reasons. git-svn-id: http://caml.inria.fr/svn/ocaml/branches/cc-optim@16330 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1 parent d9ab3bd commit 423bfe2

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

config/auto-aux/dblalign.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#include <signal.h>
1616
#include <setjmp.h>
1717

18-
double foo;
18+
volatile double foo;
1919

20-
void access_double(double *p)
20+
void access_double(volatile double *p)
2121
{
2222
foo = *p;
2323
}
@@ -38,8 +38,8 @@ int main(void)
3838
signal(SIGBUS, sig_handler);
3939
#endif
4040
if(setjmp(failure) == 0) {
41-
access_double((double *) n);
42-
access_double((double *) (n+1));
41+
access_double((volatile double *) n);
42+
access_double((volatile double *) (n+1));
4343
res = 0;
4444
} else {
4545
res = 1;
@@ -48,5 +48,5 @@ int main(void)
4848
#ifdef SIGBUS
4949
signal(SIGBUS, SIG_DFL);
5050
#endif
51-
exit(res);
51+
return res;
5252
}

config/auto-aux/endian.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/* */
1212
/***********************************************************************/
1313

14+
#include <string.h>
1415
#include "m.h"
1516

1617
#ifndef ARCH_SIXTYFOUR
@@ -23,7 +24,7 @@ char * bigendian = "ABCDEFGH";
2324
char * littleendian = "HGFEDCBA";
2425
#endif
2526

26-
main(void)
27+
int main(void)
2728
{
2829
long n[2];
2930
char * p;
@@ -32,8 +33,8 @@ main(void)
3233
n[1] = 0;
3334
p = (char *) n;
3435
if (strcmp(p, bigendian) == 0)
35-
exit(0);
36+
return 0;
3637
if (strcmp(p, littleendian) == 0)
37-
exit(1);
38-
exit(2);
38+
return 1;
39+
return 2;
3940
}

config/auto-aux/hasgot

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ while : ; do
3030
shift
3131
done
3232

33-
(echo "main() {"
33+
(echo "int main() {"
3434
for f in $*; do echo " $f();"; done
35-
echo "}") >> hasgot.c
35+
echo " return 0; }") >> hasgot.c
3636

3737
if test "$verbose" = yes; then
3838
echo "hasgot $args: $cc $opts -o tst hasgot.c $libs" >&2

config/auto-aux/hasgot2

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ while : ; do
3030
shift
3131
done
3232

33-
(echo "main() {"
33+
(echo "int main() {"
3434
for f in $*; do echo " (void) & $f;"; done
35-
echo "}") >> hasgot.c
35+
echo " return 0; }") >> hasgot.c
3636

3737
if test "$verbose" = yes; then
3838
echo "hasgot2 $args: $cc $opts -o tst hasgot.c $libs" >&2

config/auto-aux/int64align.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ typedef long long int64_t;
2626
#error "No 64-bit integer type available"
2727
#endif
2828

29-
int64_t foo;
29+
volatile int64_t foo;
3030

31-
void access_int64(int64_t *p)
31+
void access_int64(volatile int64_t *p)
3232
{
3333
foo = *p;
3434
}
@@ -49,8 +49,8 @@ int main(void)
4949
signal(SIGBUS, sig_handler);
5050
#endif
5151
if(setjmp(failure) == 0) {
52-
access_int64((int64_t *) n);
53-
access_int64((int64_t *) (n+1));
52+
access_int64((volatile int64_t *) n);
53+
access_int64((volatile int64_t *) (n+1));
5454
res = 0;
5555
} else {
5656
res = 1;
@@ -59,5 +59,5 @@ int main(void)
5959
#ifdef SIGBUS
6060
signal(SIGBUS, SIG_DFL);
6161
#endif
62-
exit(res);
62+
return res;
6363
}

config/auto-aux/sizes.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
int main(int argc, char **argv)
1717
{
1818
printf("%d %d %d %d %d\n",
19-
sizeof(int), sizeof(long), sizeof(long *), sizeof(short),
20-
sizeof(long long));
19+
(int) sizeof(int),
20+
(int) sizeof(long),
21+
(int) sizeof(long *),
22+
(int) sizeof(short),
23+
(int) sizeof(long long));
2124
return 0;
2225
}

0 commit comments

Comments
 (0)