00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2.1 of the GNU Lesser General Public License 00007 as published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this program; if not, write the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00023 USA. 00024 00025 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00026 Mountain View, CA 94043, or: 00027 00028 http://www.sgi.com 00029 00030 For further information regarding this notice, see: 00031 00032 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00033 00034 */ 00035 00036 00037 #pragma ident "@(#) libf/pxf/pxfucompare.c 92.1 06/29/99 11:36:06" 00038 00039 00040 #include <errno.h> 00041 #include <liberrno.h> 00042 #include <fortran.h> 00043 00044 /* 00045 * PXFUCOMPARE -- unsigned comparison 00046 * (section 8.11.1 of Posix 1003.9-1992) 00047 * 00048 * Synopsis: 00049 * 00050 * SUBROUTINE PXFUCOMPARE(I1, I2, ICMPR, IDIFF) 00051 * INTEGER I1, I2, ICMPR, IDIFF 00052 * 00053 * Variable arguements: 00054 * 00055 * I1 is an input integer variable for a C unsigned integer. 00056 * 00057 * I2 is an input integer variable for a C unsigned integer. 00058 * 00059 * ICMPR is an output integer variable that on return from the 00060 * routine contains one of these values: 00061 * 00062 * -1 if I1 < I2. 00063 * 0 if I1 equals I2. 00064 * 1 if I1 > I2. 00065 * 00066 * All of the comparisons are made using C unsigned integer 00067 * comparisons. 00068 * 00069 * IDIFF is an output integer variable that on return from the 00070 * routine contains the absolute value of the difference 00071 * of I1 and I2. Since the values are C unsigned integers 00072 * and Fortran 77 does not directly support unsigned integers 00073 * the value may be negative, which indicates the value 00074 * is beyond the maximum positive value of a Fortran 77 00075 * integer. 00076 * 00077 */ 00078 00079 00080 #ifdef _UNICOS 00081 void 00082 PXFUCOMPARE( 00083 #else 00084 void 00085 _PXFUCOMPARE( 00086 #endif 00087 _f_int *I1, 00088 _f_int *I2, 00089 _f_int *ICMPR, 00090 _f_int *IDIFF 00091 ) 00092 { 00093 if (((unsigned)*I1) < ((unsigned)*I2)) { 00094 *ICMPR = -1; 00095 *IDIFF = ((unsigned)*I2) - ((unsigned)*I1); 00096 } else if (((unsigned)*I1) == ((unsigned)*I2)) { 00097 *ICMPR = 0; 00098 *IDIFF = 0; 00099 } else if (((unsigned)*I1) > ((unsigned)*I2)) { 00100 *ICMPR = 1; 00101 *IDIFF = ((unsigned)*I1) - ((unsigned)*I2); 00102 } 00103 00104 } 00105 00106 #ifndef _UNICOS 00107 void 00108 pxfucompare_( 00109 _f_int *I1, 00110 _f_int *I2, 00111 _f_int *ICMPR, 00112 _f_int *IDIFF 00113 ) 00114 { 00115 _PXFUCOMPARE(I1, I2, ICMPR, IDIFF); 00116 } 00117 #endif
1.5.6