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 38int create_Result_file(void) 39{ 40 int i, nbVal; 41 double tabR[20000], Val; 42 char *F_name, *F_naminp; 43 int fp, fpi; 44 45 F_name = "fabs_out.ref"; 46 F_naminp = "fabs_inp.ref"; 47 nbVal = 20000; 48 49 fpi = open(F_naminp, O_RDONLY, 0777); 50 if (!fpi) { 51 printf("error opening file"); 52 close(fpi); 53 return -1; 54 } else { 55 for (i = 0; i < nbVal; i++) { 56 read(fpi, &Val, sizeof(double)); 57 tabR[i] = fabs(Val); 58 } 59 close(fpi); 60 61 fp = open(F_name, O_RDWR | O_CREAT | O_TRUNC, 0777); 62 if (!fp) { 63 printf("error opening file"); 64 close(fp); 65 return -1; 66 } else { 67 for (i = 0; i < nbVal; i++) { 68 write(fp, &tabR[i], sizeof(double)); 69 } 70 71 close(fp); 72 return 0; 73 } 74 } 75} 76 77int 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 = "fabs_inp.ref"; 85 nbVal = 20000; 86 87 Inc = exp(1) / 10; 88 89 for (i = 0; i < nbVal; i++) 90 tabD[i] = log((Inc * i) + Inc); 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} 105 106int main(int argc, char *argv[]) 107{ 108 if (argc > 1) { 109 switch (atoi(argv[1])) { 110 case 1: 111 if (create_Data_file() == 0) 112 printf("Data file created\n"); 113 else 114 printf("problem during %s data file creation\n", 115 argv[0]); 116 break; 117 118 case 2: 119 if (create_Result_file() == 0) 120 printf("Result file created\n"); 121 else 122 printf 123 ("problem during %s result file creation\n", 124 argv[0]); 125 break; 126 default: 127 printf("Bad arglist code for: '%s'\n", argv[0]); 128 return -1; 129 break; 130 } 131 } else { 132 if (create_Data_file() != 0) 133 printf("problem during %s data file creation\n", 134 argv[0]); 135 if (create_Result_file() != 0) 136 printf("problem during %s result file creation\n", 137 argv[0]); 138 } 139 140 return 0; 141} 142