• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
create_Result_file(void)38 int create_Result_file(void)
39 {
40 	int i, nbVal;
41 	double tabR[20000], Inc;
42 	char *F_name;
43 	int fp;
44 
45 	F_name = "floor_out.ref";
46 	nbVal = 20000;
47 
48 	Inc = exp(1);
49 
50 	for (i = 0; i < nbVal; i++)
51 		tabR[i] = floor((Inc * i) + Inc);
52 
53 	fp = open(F_name, O_RDWR | O_CREAT | O_TRUNC, 0777);
54 	if (!fp) {
55 		printf("error opening file");
56 		close(fp);
57 		return -1;
58 	} else {
59 		for (i = 0; i < nbVal; i++) {
60 			write(fp, &tabR[i], sizeof(double));
61 		}
62 
63 		close(fp);
64 		return 0;
65 	}
66 }
67 
create_Data_file(void)68 int create_Data_file(void)
69 {
70 	int i, nbVal;
71 	double tabD[20000], Inc;
72 	char *F_name;
73 	int fp;
74 
75 	F_name = "floor_inp.ref";
76 	nbVal = 20000;
77 
78 	Inc = exp(1);
79 
80 	for (i = 0; i < nbVal; i++)
81 		tabD[i] = (Inc * i) + Inc;
82 
83 	fp = open(F_name, O_RDWR | O_CREAT | O_TRUNC, 0777);
84 	if (!fp) {
85 		printf("error opening file");
86 		close(fp);
87 		return -1;
88 	} else {
89 		for (i = 0; i < nbVal; i++) {
90 			write(fp, &tabD[i], sizeof(double));
91 		}
92 		close(fp);
93 		return 0;
94 	}
95 }
96 
main(int argc,char * argv[])97 int main(int argc, char *argv[])
98 {
99 	if (argc > 1) {
100 		switch (atoi(argv[1])) {
101 		case 1:
102 			if (create_Data_file() == 0)
103 				printf("Data file created\n");
104 			else
105 				printf("problem during %s data file creation\n",
106 				       argv[0]);
107 			break;
108 
109 		case 2:
110 			if (create_Result_file() == 0)
111 				printf("Result file created\n");
112 			else
113 				printf
114 				    ("problem during %s result file creation\n",
115 				     argv[0]);
116 			break;
117 		default:
118 			printf("Bad arglist code for: '%s'\n", argv[0]);
119 			return -1;
120 			break;
121 		}
122 	} else {
123 		if (create_Data_file() != 0)
124 			printf("problem during %s data file creation\n",
125 			       argv[0]);
126 		if (create_Result_file() != 0)
127 			printf("problem during %s result file creation\n",
128 			       argv[0]);
129 	}
130 
131 	return 0;
132 }
133