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
37static int create_Result_file(void)
38{
39
40	int i, nbVal;
41	double tabR[20000], Inc;
42	char *F_name;
43	int fp;
44
45	F_name = "log_out.ref2";
46	nbVal = 20000;
47
48	Inc = exp(1) / 10;
49
50	for (i = 0; i < nbVal; i++)
51		tabR[i] = log((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
68static 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 = "log_inp.ref";
76	nbVal = 20000;
77
78	Inc = exp(1) / 10;
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
97int main(int argc, char *argv[])
98{
99
100	if (argc > 1) {
101		switch (atoi(argv[1])) {
102		case 1:
103			if (create_Data_file() == 0)
104				printf("Data file created\n");
105			else
106				printf("problem during %s data file creation\n",
107				       argv[0]);
108			break;
109
110		case 2:
111			if (create_Result_file() == 0)
112				printf("Result file created\n");
113			else
114				printf
115				    ("problem during %s result file creation\n",
116				     argv[0]);
117			break;
118		default:
119			printf("Bad arglist code for: '%s'\n", argv[0]);
120			return -1;
121			break;
122		}
123	} else {
124		if (create_Data_file() != 0)
125			printf("problem during %s data file creation\n",
126			       argv[0]);
127		if (create_Result_file() != 0)
128			printf("problem during %s result file creation\n",
129			       argv[0]);
130	}
131
132	return (0);
133
134}
135