1 /*
2 * Copyright (C) Bull S.A. 2001
3 * Copyright (c) International Business Machines Corp., 2001
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 /******************************************************************************/
21 /* */
22 /* Dec-03-2001 Created: Jacky Malcles & Jean Noel Cordenner */
23 /* These tests are adapted from AIX float PVT tests. */
24 /* */
25 /******************************************************************************/
26 #include <float.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <errno.h>
31 #include <limits.h>
32 #include <unistd.h>
33 #include <fcntl.h>
34 #include <errno.h>
35 #include <sys/signal.h>
36 #include <math.h>
37
38 #define M_PIl 3.1415926535897932384626433832795029L
39
create_Result_file(void)40 static int create_Result_file(void)
41 {
42
43 int i, nbVal;
44 double tabRtan[20000], Inc;
45 char *F_name;
46 int fp;
47
48 F_name = "rtan";
49 nbVal = 20000;
50
51 Inc = (2 * M_PIl) / nbVal; /* condering a period of 2 pi rad */
52
53 for (i = 0; i < nbVal; i++) {
54 if ((Inc * i) != (M_PIl / 2))
55 tabRtan[i] = tan(Inc * i);
56 else
57 tabRtan[i] = tan(0);
58 }
59
60 fp = open(F_name, O_RDWR | O_CREAT | O_TRUNC, 0777);
61 if (!fp) {
62 printf("error opening file");
63 close(fp);
64 return -1;
65 } else {
66 for (i = 0; i < nbVal; i++) {
67 write(fp, &tabRtan[i], sizeof(double));
68 }
69
70 close(fp);
71 return 0;
72 }
73 }
74
create_Data_file(void)75 static int create_Data_file(void)
76 {
77 int i, nbVal;
78 double tabDtan[20000], Inc;
79 char *F_name;
80 int fp;
81
82 F_name = "dtan";
83 nbVal = 20000;
84
85 Inc = (2 * M_PIl) / nbVal; /* condering a period of 2 pi rad */
86
87 for (i = 0; i < nbVal; i++) {
88 if ((Inc * i) != (M_PIl / 2))
89 tabDtan[i] = (Inc * i);
90 else
91 tabDtan[i] = 0;
92 }
93
94 fp = open(F_name, O_RDWR | O_CREAT | O_TRUNC, 0777);
95 if (!fp) {
96 printf("error opening file");
97 close(fp);
98 return -1;
99 } else {
100 for (i = 0; i < nbVal; i++) {
101 write(fp, &tabDtan[i], sizeof(double));
102 }
103 close(fp);
104 return 0;
105 }
106 }
107
main(int argc,char * argv[])108 int main(int argc, char *argv[])
109 {
110
111 if (argc > 1) {
112 switch (atoi(argv[1])) {
113 case 1:
114 if (create_Data_file() == 0)
115 printf("Data file created\n");
116 else
117 printf
118 ("problem during tan data file creation\n");
119 break;
120
121 case 2:
122 if (create_Result_file() == 0)
123 printf("Result file created\n");
124 else
125 printf
126 ("problem during tan result file creation\n");
127 break;
128 default:
129 printf("Bad arglist code for: '%s'\n", argv[0]);
130 return -1;
131 break;
132 }
133 } else {
134 if (create_Data_file() != 0)
135 printf("problem during tan data file creation\n");
136 if (create_Result_file() != 0)
137 printf("problem during tan result file creation\n");
138 }
139
140 return (0);
141
142 }
143