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