Package: neko Version: 1.8.1-5 Severity: important Tags: patch User: debian-h...@lists.debian.org Usertags: hurd
Hi, currently[1] neko does not compile 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) This patch is based on the current Debian patches. [1] https://buildd.debian.org/status/fetch.php?pkg=neko&arch=hurd-i386&ver=1.8.1-5&stamp=1266575027 Thanks, -- Pino
--- a/vm/neko.h +++ b/vm/neko.h @@ -22,7 +22,7 @@ # define NEKO_WINDOWS #endif -#if defined(__APPLE__) || defined(__MACH__) || defined(macintosh) +#if defined(__APPLE__) || defined(macintosh) # define NEKO_MAC #endif @@ -38,6 +38,10 @@ # define NEKO_BSD #endif +#if defined(__GNU__) +# define NEKO_HURD +#endif + // COMPILER/PROCESSOR FLAGS #if defined(__GNUC__) # define NEKO_GCC @@ -63,7 +67,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 --- a/libs/std/sys.c +++ b/libs/std/sys.c @@ -194,6 +194,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 @@ -504,6 +506,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); @@ -529,7 +539,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); @@ -541,6 +551,11 @@ path[length] = '\0'; return alloc_string(path); } +#else + const char *p = getenv("_"); + if( p != NULL ) + return alloc_string(p); + neko_error(); #endif } --- a/libs/common/osdef.h +++ b/libs/common/osdef.h @@ -25,7 +25,7 @@ # define OS_WINDOWS #endif -#if defined(__APPLE__) || defined(__MACH__) || defined(macintosh) +#if defined(__APPLE__) || defined(macintosh) # define OS_MAC #endif @@ -37,7 +37,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 --- a/vm/main.c +++ b/vm/main.c @@ -74,7 +74,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 ) { @@ -85,6 +85,8 @@ } path[length] = '\0'; return path; +#else + return getenv("_"); #endif }