Andreas Voegele <voegelas@gmx.net> writes:
> Martin Gasbichler writes:
>
>> Andreas Voegele <voegelas@gmx.net> writes:
>>
>>> I've modified s48_get_host_name() so that the host name is temporarily
>>> stored in a dynamically allocated variable. The attached patch is
>>> based on code from libinetutils/localhost.c (see
>>> http://www.gnu.org/software/inetutils/).
>>
>> I know about this patch and I am certainly willing to apply it if
>> there is a complete port to Hurd.
>
> I am working on the port to the Hurd but I do not think that I will be
> able to provide a tested patch before next week. Currently, I'm
> trying to figure out what code to put into waitcodes.scm.
>
> On the Hurd, most things seem to be similar to BSD but the header
> files sys/wait.h and bits/waitstatus.h are identical to the Linux
> versions. The comment in waitcodes.scm reads:
>
> ;;; To port these to a new OS, consult /usr/include/sys/wait.h,
> ;;; and check the WIFEXITED, WEXITSTATUS, WIFSTOPPED, WSTOPSIG,
> ;;; WIFSIGNALED, and WTERMSIG macros for the magic fields they use.
>
> But this comment does not tell me which Scheme functions correspond to
> which macros. On the Hurd as well as Linux, bits/waitstatus.h
> contains the following macros:
>
> #define __WIFEXITED(status) (__WTERMSIG(status) == 0)
> #define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
> #define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
> #define __WSTOPSIG(status) __WEXITSTATUS(status)
> #define __WIFSIGNALED(status) (!__WIFSTOPPED(status) && !__WIFEXITED(status))
> #define __WTERMSIG(status) ((status) & 0x7f)
>
> In contrast to the BSD status:exit-val function, which looks like
> this...
>
> ; bsd
> (define (status:exit-val status)
> (and (zero? (bitwise-and #x7F status))
> (arithmetic-shift status -8)))
>
> ...the Linux version contains an additional expression beginning with
> not:
>
> ; linux
> (define (status:exit-val status)
> (and (not (= (bitwise-and #xFF status) #x7F))
> (zero? (bitwise-and #x7F status))
> (bitwise-and #xFF (arithmetic-shift status -8))))
>
> This expression seems to correspond to !WIFSTOPPED(status). Why was
> it put into status:exit-val?
I think this is just an additional check that could be omitted.
>
> Can anybody give me the C pseudo code that corresponds to the Scheme
> functions status:exit-val, status:stop-sig and status:term-sig?
>
I never looked at this code but I don't see any magic going on here:
s48_value s48_statusCexit_val (int status){
if (!WIFEXITED (status)) return S48_FALSE;
else return s48_enter_fixnum (WEXITSTATUS (status));
}
s48_value s48_statusCstop_sig (int status){
if (!WIFSTOPPED (status)) return S48_FALSE;
else return s48_enter_fixnum (WSTOPSIG (status));
}
s48_value s48_statusCterm_sig (int status){
if (!WIFSIGNALED (status)) return S48_FALSE;
else return s48_enter_fixnum (WTERMSIG (status));
}
I would have defined this in C in the first place but that's probably
a matter of taste.
--
Martin
|