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