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