File: Fix-compilation-for-GNU-Hurd.patch

package info (click to toggle)
casacore 3.8.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 51,912 kB
  • sloc: cpp: 471,569; fortran: 16,372; ansic: 7,416; yacc: 4,714; lex: 2,346; sh: 1,865; python: 629; perl: 531; sed: 499; csh: 201; makefile: 32
file content (234 lines) | stat: -rw-r--r-- 7,303 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
From: Ole Streicher <olebole@debian.org>
Date: Wed, 30 Nov 2016 14:25:19 +0100
Subject: Fix compilation for GNU Hurd

However, the tests still fail.
---
 casa/OS/HostInfo.cc                          |  7 ++++
 casa/OS/{HostInfoDarwin.h => HostInfoHurd.h} | 62 ++++++----------------------
 casa/OS/Path.cc                              |  6 ++-
 casa/OS/malloc.cc                            |  2 +-
 casa/aipsenv.h                               |  7 ++++
 mirlib/bug.c                                 |  2 +-
 6 files changed, 32 insertions(+), 54 deletions(-)
 copy casa/OS/{HostInfoDarwin.h => HostInfoHurd.h} (65%)

diff --git a/casa/OS/HostInfo.cc b/casa/OS/HostInfo.cc
index 56662be..b2f253c 100644
--- a/casa/OS/HostInfo.cc
+++ b/casa/OS/HostInfo.cc
@@ -234,6 +234,13 @@ namespace casacore { //# NAMESPACE CASACORE - BEGIN
 HOSTINFO_IMPLEMENT_MEMBERS
 } //# NAMESPACE CASACORE - END
 
+#elif defined(AIPS_HURD)
+#include <casacore/casa/OS/HostInfoHurd.h>
+namespace casacore { //# NAMESPACE CASACORE - BEGIN
+
+HOSTINFO_IMPLEMENT_MEMBERS
+} //# NAMESPACE CASACORE - END
+
 #else
 namespace casacore { //# NAMESPACE CASACORE - BEGIN
 
diff --git a/casa/OS/HostInfoDarwin.h b/casa/OS/HostInfoHurd.h
similarity index 65%
copy from casa/OS/HostInfoDarwin.h
copy to casa/OS/HostInfoHurd.h
index d116617..41be38f 100644
--- a/casa/OS/HostInfoDarwin.h
+++ b/casa/OS/HostInfoHurd.h
@@ -4,9 +4,7 @@
 **  mechanics of finding various system details. The copyright details
 **  follow.
 **
-**  This is a modified version of the osf1 version. Initially, I tried
-**  to use the m_macosx.c version by Andrew S. Townley, but ran into
-**  problems...
+**  This is a modified version of the osf1 version.
 **
 **  --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 **
@@ -37,8 +35,8 @@
 **
 */
 
-#ifndef CASA_HOSTINFODARWIN_H
-#define CASA_HOSTINFODARWIN_H
+#ifndef CASA_HOSTINFOHURD_H
+#define CASA_HOSTINFOHURD_H
 
 # if defined(HOSTINFO_DO_IMPLEMENT)
 
@@ -47,12 +45,14 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+extern "C" {
 #include <mach/mach.h>
+}
 
 namespace casacore { //# NAMESPACE CASACORE - BEGIN
 
 // <summary>
-// HostInfo for Darwin machines.
+// HostInfo for GNU HURD machines.
 // </summary>
 
 // <use visibility=local>
@@ -65,7 +65,7 @@ namespace casacore { //# NAMESPACE CASACORE - BEGIN
 // </prerequisite>
 
 // <synopsis> 
-// This file provides the Linux specific functions for HostInfo.
+// This file provides the GNU HURD specific functions for HostInfo.
 // It is selectively included by HostInfo.cc.
 // </synopsis>
 //
@@ -107,10 +107,10 @@ HostMachineInfo::HostMachineInfo( ) : valid(1) {
 
     kern_return_t ret;
     struct host_basic_info basic_info;
-    unsigned int count = HOST_BASIC_INFO_COUNT;
+    mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
 
-    /* get the page size with portable sysconf and calculate pageshift from it */
-    pagesize_ = pagesize = sysconf(_SC_PAGESIZE);
+    /* get the page size with "getpagesize" and calculate pageshift from it */
+    pagesize_ = pagesize = getpagesize();
     pageshift = 0;
     while (pagesize > 1)
     {
@@ -121,65 +121,27 @@ HostMachineInfo::HostMachineInfo( ) : valid(1) {
     /* we only need the amount of log(2)1024 for our conversion */
     pageshift -= LOG1024;
 
-#ifdef AIPS_64B
-       ret = host_info( mach_host_self(), HOST_BASIC_INFO, (host_info64_t) &basic_info, &count );
-#else
        ret = host_info( mach_host_self(), HOST_BASIC_INFO, (host_info_t) &basic_info, &count );
-#endif
     if ( ret != KERN_SUCCESS ) {
 	valid = 0;
     } else {
-#ifdef AIPS_64B
-	memory_total = basic_info.max_mem / 1024;
-#else
 	memory_total = basic_info.memory_size / 1024;
-#endif
 	cpus = basic_info.avail_cpus;
     }
 }
 
 void HostMachineInfo::update_info( ) {
 
-#ifdef AIPS_64B
-    struct vm_statistics64 vmstats;
-#else
-    struct vm_statistics vmstats;
-#endif
+    vm_statistics_data_t vmstats;
     kern_return_t kr;
-    unsigned int count;
 
     /* memory information */
-    /* this is possibly bogus - we work out total # pages by */
-    /* adding up the free, active, inactive, wired down, and */
-    /* zero filled. Anyone who knows a better way, TELL ME!  */
-    /* Change: dont use zero filled. */
-    count = sizeof(vmstats)/sizeof(integer_t);
-
-#ifdef AIPS_64B
-       kr = host_statistics64( mach_host_self(), HOST_VM_INFO64, (host_info64_t) &vmstats, &count );
-#else
-       kr = host_statistics( mach_host_self(), HOST_VM_INFO, (host_info_t) &vmstats, &count );
-#endif
+    kr = vm_statistics( mach_task_self(), &vmstats);
     if ( kr != KERN_SUCCESS ) {
       valid = 0;
       return;
     }
 
-//     /* thanks DEC for the table() command. No thanks at all for   */
-//     /* omitting the man page for it from OSF/1 1.2, and failing   */
-//     /* to document SWAPINFO in the 1.3 man page. Lets hear it for */
-//     /* include files. */
-//     i=0;
-//     while(table(TBL_SWAPINFO,i,&swbuf,1,sizeof(struct tbl_swapinfo))>0) {
-// 	swappages += swbuf.size;
-// 	swapfree  += swbuf.free;
-// 	i++;
-//     }
-// 
-//     swap_used = pagetok(swappages - swapfree);
-//     swap_free = pagetok(swapfree);
-//     swap_total = pagetok(swappages);
-
     memory_used = pagetok(vmstats.active_count + vmstats.wire_count);
     memory_free = memory_total - memory_used;
     swap_used = pagetok( vmstats.active_count + vmstats.inactive_count + vmstats.wire_count );
diff --git a/casa/OS/Path.cc b/casa/OS/Path.cc
index 10f59db..6243e7b 100644
--- a/casa/OS/Path.cc
+++ b/casa/OS/Path.cc
@@ -142,12 +142,14 @@ const String& Path::absoluteName() const
 
 String Path::resolvedName() const
 {
-    char name[PATH_MAX+1];
-    char* ptr = realpath (absoluteName().c_str(), name);
+    char* ptr = realpath (absoluteName().c_str(), NULL);
     if (ptr == 0) {
         throw AipsError("resolvedName(" + absoluteName() + ") failed: " +
                         strerror(errno));
     }
+    char name[strlen(ptr)+1];
+    strcpy(name, ptr);
+    free(ptr);
     return String(name);
 }
 
diff --git a/casa/OS/malloc.cc b/casa/OS/malloc.cc
index 2eb92fa..1a1af8c 100644
--- a/casa/OS/malloc.cc
+++ b/casa/OS/malloc.cc
@@ -27,7 +27,7 @@
 
 #if !defined(AIPS_NO_LEA_MALLOC)
 
-#if !defined(AIPS_LINUX)
+#if !defined(AIPS_LINUX) && !defined(AIPS_HURD) && !defined(__FreeBSD_kernel__)
 /* Ignore for linux since it already uses gnu malloc! */
 
 /*
diff --git a/casa/aipsenv.h b/casa/aipsenv.h
index 38fb2dd..5f77fc7 100644
--- a/casa/aipsenv.h
+++ b/casa/aipsenv.h
@@ -131,6 +131,13 @@ namespace casacore { //# NAMESPACE CASACORE - BEGIN
 #define AIPS_NOLARGEFILE
 #endif
 
+#if defined(AIPS_HURD)
+#undef AIPS_HURD
+#endif
+#if defined(__gnu_hurd__)
+#define AIPS_HURD
+#endif
+
 #if defined(AIPS_LINUX)
 #undef AIPS_LINUX
 #endif
diff --git a/mirlib/bug.c b/mirlib/bug.c
index be527d4..da99726 100644
--- a/mirlib/bug.c
+++ b/mirlib/bug.c
@@ -333,7 +333,7 @@ char *errmsg_c(int n)
  * this should be removed in favor of HAVE_STRERROR once
  * is only supported using autotools/configure
  */
-#if defined(linux) || (defined(HAVE_STRERROR) && HAVE_STRERROR)
+#if defined(linux) || defined(__GNU__) || (defined(HAVE_STRERROR) && HAVE_STRERROR)
   /* new POSIX.1 style, 20 years old now... (1988) */
   if(n == -1)
     return "End of file detected";