Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* 00002 00003 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2005, 2007, 2009 John W. Eaton 00004 00005 This file is part of Octave. 00006 00007 Octave is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 Octave is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Octave; see the file COPYING. If not, see 00019 <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #if !defined (octave_sun_utils_h) 00024 #define octave_sun_utils_h 1 00025 00026 // This is only needed to dereference pointers to doubles if mixing 00027 // GCC and Sun SPARC f77/cc compiled code. See the GCC manual (where the 00028 // function access_double() is described) and the Sun f77 manual, 00029 // which explains that doubles are not always aligned on 8 byte 00030 // boundaries. 00031 00032 #if defined (__sparc) && defined (__GNUC__) 00033 00034 inline double 00035 access_double (double *unaligned_ptr) 00036 { 00037 union d2i { double d; int i[2]; }; 00038 00039 union d2i *p = (union d2i *) unaligned_ptr; 00040 union d2i u; 00041 00042 u.i[0] = p->i[0]; 00043 u.i[1] = p->i[1]; 00044 00045 return u.d; 00046 } 00047 00048 inline void 00049 assign_double (double *unaligned_ptr, double value) 00050 { 00051 union d2i { double d; int i[2]; }; 00052 00053 double *ptr = &value; 00054 union d2i *v = (union d2i *) ptr; 00055 union d2i *p = (union d2i *) unaligned_ptr; 00056 00057 p->i[0] = v->i[0]; 00058 p->i[1] = v->i[1]; 00059 } 00060 00061 #endif 00062 #endif 00063 00064 /* 00065 ;;; Local Variables: *** 00066 ;;; mode: C *** 00067 ;;; page-delimiter: "^/\\*" *** 00068 ;;; End: *** 00069 */