chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] Add chicken.platform module (partially)


From: John Cowan
Subject: Re: [Chicken-hackers] [PATCH] Add chicken.platform module (partially)
Date: Sat, 22 Apr 2017 20:21:30 -0400


On Sat, Apr 22, 2017 at 4:29 PM, Peter Bex <address@hidden> wrote:

For example, we also define "machine-type" in chicken.platform, which  to
me is a bit confusing: how does machine-type differ from the "processor"
entry in system-information's list?  And why do we need the hostname
to be in both get-host-name and system-information?  On Windows it's
identical, but perhaps on Unix, gethostname() can return a different
name than uname()'s nodename?

The Linux manpage for uname(2) says:

       Note that there is no standard that says that the
       hostname set by sethostname(2) is the same string as the nodename
       field of the struct returned by uname() (indeed, some systems allow a
       256-byte hostname and an 8-byte nodename), but this is true on Linux.

And for gethostname(2) it says:

       The GNU C library does not employ the gethostname() system call;
       instead, it implements gethostname() as a library function that calls
       uname(2) and copies up to len bytes from the returned nodename field
       into name.  Having performed the copy, the function then checks if
       the length of the nodename was greater than or equal to len, and if
       it is, then the function returns -1 with errno set to ENAMETOOLONG;
       in this case, a terminating null byte is not included in the returned
       name.

So on Linux at least we don't have to worry about it.  In BSD, they are both library routines, but no relationship between them is documented.  I would be astonished, however, if a different value were returned on any of the systems Chicken supports.

--
John Cowan          http://vrici.lojban.org/~cowan        address@hidden
"Your honour puts yourself to much trouble correcting my English and
doubtless the final letter will be much better literature; but it will
go from me Mukherji to him Bannerji, and he Bannerji will understand it a
great deal better as I Mukherji write it than as your honour corrects it."
        --19th-century Indian civil servant to his British superior




reply via email to

[Prev in Thread] Current Thread [Next in Thread]