3
|
1 /* |
|
2 |
1883
|
3 Copyright (C) 1996 John W. Eaton |
3
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
3
|
20 |
|
21 */ |
|
22 |
382
|
23 #if !defined (octave_sun_utils_h) |
|
24 #define octave_sun_utils_h 1 |
|
25 |
2401
|
26 // I think that this is really only needed if linking to Fortran |
|
27 // compiled libraries on a Sun. It also seems to be needed on |
|
28 // Linux/ELF systems with g77. It should never be called. |
3
|
29 |
2401
|
30 #if defined (sun) |
|
31 extern "C" int MAIN_ (); |
|
32 #elif defined (linux) && defined (__ELF__) |
|
33 extern "C" int MAIN__ (); |
|
34 #endif |
3
|
35 |
1359
|
36 // This is only needed to dereference pointers to doubles if mixing |
|
37 // GCC and Sun f77/cc compiled code. See the GCC manual (where the |
|
38 // function access_double() is described) and the Sun f77 manual, |
|
39 // which explains that doubles are not always aligned on 8 byte |
|
40 // boundaries. |
3
|
41 |
2401
|
42 #if defined (sun) && defined (__GNUC__) |
3
|
43 |
|
44 inline double |
|
45 access_double (double *unaligned_ptr) |
|
46 { |
|
47 union d2i { double d; int i[2]; }; |
|
48 |
|
49 union d2i *p = (union d2i *) unaligned_ptr; |
|
50 union d2i u; |
|
51 |
|
52 u.i[0] = p->i[0]; |
|
53 u.i[1] = p->i[1]; |
|
54 |
|
55 return u.d; |
|
56 } |
|
57 |
|
58 inline void |
|
59 assign_double (double *unaligned_ptr, double value) |
|
60 { |
|
61 union d2i { double d; int i[2]; }; |
|
62 |
|
63 double *ptr = &value; |
|
64 union d2i *v = (union d2i *) ptr; |
|
65 union d2i *p = (union d2i *) unaligned_ptr; |
|
66 |
|
67 p->i[0] = v->i[0]; |
|
68 p->i[1] = v->i[1]; |
|
69 } |
|
70 |
|
71 #endif |
|
72 #endif |
|
73 |
|
74 /* |
|
75 ;;; Local Variables: *** |
1994
|
76 ;;; mode: C *** |
3
|
77 ;;; page-delimiter: "^/\\*" *** |
|
78 ;;; End: *** |
|
79 */ |