bug-gnulib
[Top][All Lists]
Advanced

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

Re: declare sethostname if unistd.h doesn't


From: Ben Walton
Subject: Re: declare sethostname if unistd.h doesn't
Date: Sun, 20 Nov 2011 20:21:11 -0500
User-agent: Sup/git

Excerpts from Bruno Haible's message of Sun Nov 20 09:12:55 -0500 2011:

Hi Bruno,

Thanks for the detailed rundown on this patch.  It's nice to get such
good feedback.

> Yes, the declaration is missing in the Solaris 10 header files, but
> also on other platforms that have the function: AIX and OSF/1.
> 
> The usual approach in gnulib is to have the header file module
> ('unistd' in this case) provide the types and C macros that ought to
> be present in that header file, while functions declarations and
> function definitions go into a module per function.

Ok, thanks.  I did read the docs but as I wasn't (at the time) doing a
separate module, I thought the declarations could go directly in the
header.

> And when we provide the function module, we try to fix as many
> problems as reasonably possible. This would mean, provide code for
> the function on Minix 3.1.8, AIX 5.1, Cygwin, mingw, MSVC 9, Interix
> 3.5, BeOS.  Even if, in the worst case, the function just sets errno
> to ENOSYS.

Fair enough.  I was scratching a particular itch but I agree that
solving the problem entirely is much better.

> Here, please use one of the templates from
> build-aux/snippet/c++defs.h.  These templates make sure that C++
> programs will see the right declarations too.

Again, this is something that I wasn't clear on, so I appreciate the
pointers.

> Also, please, Gnulib uses spaces for indentation in most
> files. Exceptions are ChangeLog, Makefile snippets in module
> descriptions, and Makefiles.

Sorry about that.  I'll drop some directory local emacs config in
place.

> Now, how to implement sethostname() on platforms that don't have it?
> 
> - On Cygwin and native Windows, SetComputerNameEx [1] seems to be
>   the best suited primitive.
> 
> - On AIX 5.1, sethostname() actually exists; only this can't be seen
>   by using "nm /lib/libc.a" as I had done.
> 
> - On Minix 3.1.8, sethostname() should write the hostname into
>   /etc/hostname.file, followed by a newline.
> 
> - On other systems, just use errno = ENOSYS; as fallback.
> 
> Can you implement this?

I'm going to give it a shot.  As long as you're not expecting it
'tomorrow', I'll work on it over the next few days.

Thanks
-Ben
--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302




reply via email to

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