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