Package: neko / 2.0.0-3

hurd.diff Patch series | 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
Description: Fix compile errors on hurd-i386.
 The following are the issues I found (and how I fixed them), and
 other changes needed:
  * __MACH__ identifies the Mach microkernel which both Mac OSX and
    Hurd use (well, different versions/forks of it), so do not use it
    for identifying Mac OSX.
  * Introduce new NEKO_HURD and OS_HURD defines, making them being
    considered as POSIX (as Hurd is).
  * realpath: we don't have PATH_MAX on Hurd (since we have no limits
    on paths); given that glibc's realpath has, since years, the POSIX
    2008 behaviour (i.e. if called with NULL as second argument,
    return a newly allocated buffer), then make use of it in
    glibc-based OSes.
  * /proc/self is a Linux-specific feature, so limit its usage (in two
    places) to just Linux, providing a fallback for the remaining
    cases (which include Hurd).
Author: Pino Toscano <toscano.pino@tiscali.it>
Origin: debian-hurd@lists.debian.org
Bug-Debian: http://bugs.debian.org/626260
Forwarded: Nicolas Cannasse <ncannasse@motion-twin.com>
Last-Update: 2011-05-15

Index: b/vm/neko.h
===================================================================
--- a/vm/neko.h
+++ b/vm/neko.h
@@ -27,7 +27,7 @@
 #	define NEKO_WINDOWS
 #endif
 
-#if defined(__APPLE__) || defined(__MACH__) || defined(macintosh)
+#if defined(__APPLE__) || defined(macintosh)
 #	define NEKO_MAC
 #endif
 
@@ -43,6 +43,10 @@
 #	define NEKO_BSD
 #endif
 
+#if defined(__GNU__)
+#	define NEKO_HURD
+#endif
+
 // COMPILER/PROCESSOR FLAGS
 #if defined(__GNUC__)
 #	define NEKO_GCC
@@ -70,7 +74,7 @@
 #	define NEKO_64BITS
 #endif
 
-#if defined(NEKO_LINUX) || defined(NEKO_MAC) || defined(NEKO_BSD) || defined(NEKO_GNUKBSD)
+#if defined(NEKO_LINUX) || defined(NEKO_MAC) || defined(NEKO_BSD) || defined(NEKO_GNUKBSD) || defined(NEKO_HURD)
 #	define NEKO_POSIX
 #endif
 
Index: b/libs/std/sys.c
===================================================================
--- a/libs/std/sys.c
+++ b/libs/std/sys.c
@@ -200,6 +200,8 @@
 	return alloc_string("BSD");
 #elif defined(NEKO_MAC)
 	return alloc_string("Mac");
+#elif defined(NEKO_HURD)
+	return alloc_string("GNU/Hurd");
 #else
 #error Unknow system string
 #endif
@@ -537,6 +539,14 @@
 	if( GetFullPathName(val_string(path),MAX_PATH+1,buf,NULL) == 0 )
 		neko_error();
 	return alloc_string(buf);
+#elif defined(__GLIBC__)
+	val_check(path,string);
+	char *buf = realpath(val_string(path), NULL);
+	if( buf == NULL )
+		neko_error();
+	value ret = alloc_string(buf);
+	free(buf);
+	return ret;
 #else
 	char buf[PATH_MAX];
 	val_check(path,string);
@@ -562,7 +572,7 @@
 	if( _NSGetExecutablePath(path, &path_len) )
 		neko_error();
 	return alloc_string(path);
-#else
+#elif defined(NEKO_LINUX)
 	const char *p = getenv("_");
 	if( p != NULL )
 		return alloc_string(p);
@@ -574,6 +584,11 @@
 	    path[length] = '\0';
 		return alloc_string(path);
 	}
+#else
+	const char *p = getenv("_");
+	if( p != NULL )
+		return alloc_string(p);
+	neko_error();
 #endif
 }
 
Index: b/libs/common/osdef.h
===================================================================
--- a/libs/common/osdef.h
+++ b/libs/common/osdef.h
@@ -26,7 +26,7 @@
 #	define OS_WINDOWS
 #endif
 
-#if defined(__APPLE__) || defined(__MACH__) || defined(macintosh)
+#if defined(__APPLE__) || defined(macintosh)
 #	define OS_MAC
 #endif
 
@@ -38,7 +38,11 @@
 #	define OS_BSD
 #endif
 
-#if defined(NEKO_LINUX) || defined(NEKO_MAC) || defined(NEKO_BSD) || defined(NEKO_GNUKBSD)
+#if defined(__GNU__)
+#	define OS_HURD
+#endif
+
+#if defined(NEKO_LINUX) || defined(NEKO_MAC) || defined(NEKO_BSD) || defined(NEKO_GNUKBSD) || defined(NEKO_HURD)
 #	define OS_POSIX
 #endif
 
Index: b/vm/main.c
===================================================================
--- a/vm/main.c
+++ b/vm/main.c
@@ -79,7 +79,7 @@
 	}
 	path[length] = '\0';
 	return path;
-#else
+#elif defined(NEKO_LINUX)
 	static char path[1024];
 	int length = readlink("/proc/self/exe", path, sizeof(path));
 	if( length < 0 || length >= 1024 ) {
@@ -90,6 +90,8 @@
 	}
 	path[length] = '\0';
 	return path;
+#else
+	return getenv("_");
 #endif
 }