Use libm_alias_float for x86_64.
[glibc.git] / libio / bug-fopena+.c
blob5446de15925d25cff8f0ff56ec77f384a4c1f72f
1 #include <fcntl.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <unistd.h>
6 static int fd;
7 static char *fname;
10 static void prepare (void);
11 #define PREPARE(argc, argv) prepare ()
14 #define TEST_FUNCTION do_test ()
15 static int do_test (void);
16 #include "../test-skeleton.c"
19 static void
20 prepare (void)
22 fd = create_temp_file ("wrewind.", &fname);
23 if (fd == -1)
24 exit (3);
28 static int
29 do_test (void)
31 char buf[100];
32 FILE *fp;
33 int result = 0;
35 fp = fdopen (fd, "w");
36 if (fp == NULL)
38 puts ("cannot create file");
39 exit (1);
42 if (fputs ("one\n", fp) == EOF || fputs ("two\n", fp) == EOF)
44 puts ("cannot create filec content");
45 exit (1);
48 fclose (fp);
50 fp = fopen (fname, "a+");
51 if (fp == NULL)
53 puts ("cannot fopen a+");
54 exit (1);
57 if (fgets (buf, sizeof (buf), fp) == NULL)
59 puts ("cannot read after fopen a+");
60 exit (1);
63 if (strcmp (buf, "one\n") != 0)
65 puts ("read after fopen a+ produced wrong result");
66 result = 1;
69 fclose (fp);
71 fd = open (fname, O_RDWR);
72 if (fd == -1)
74 puts ("open failed");
75 exit (1);
78 fp = fdopen (fd, "a+");
79 if (fp == NULL)
81 puts ("fopen after open failed");
82 exit (1);
85 if (fgets (buf, sizeof (buf), fp) == NULL)
87 puts ("cannot read after fdopen a+");
88 exit (1);
91 if (strcmp (buf, "one\n") != 0)
93 puts ("read after fdopen a+ produced wrong result");
94 result = 1;
97 fclose (fp);
99 return result;