[Python-bugs-list] [ python-Bugs-505427 ] socket module fails to build on HPUX10
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 22 Jan 2002 01:41:47 -0800
Bugs item #505427, was opened at 2002-01-18 08:12
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=505427&group_id=5470
Category: Build
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Eddy De Greef (edg)
Assigned to: Nobody/Anonymous (nobody)
Summary: socket module fails to build on HPUX10
Initial Comment:
On HPUX10, the variable h_errno is undeclared.
Modules/socketmodule.c, line 1975:
PyH_Err(h_errno);
unless _XOPEN_SOURCE_EXTENDED is defined before
netdb.h is included.
Another option is to add an external declaration:
#ifdef __hpux
extern int h_errno;
#endif
----------------------------------------------------------------------
>Comment By: Eddy De Greef (edg)
Date: 2002-01-22 01:41
Message:
Logged In: YES
user_id=73597
On HPUX-10, the man page states the following:
SYNOPSIS
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
extern int h_errno;
struct hostent *gethostent(void);
int gethostent_r(struct hostent *result,
struct hostent_data *buffer);
struct hostent *gethostbyname(const char *name);
int gethostbyname_r(const char *name,
struct hostent *result,
struct hostent_data *buffer);
struct hostent *gethostbyaddr(const char *addr,
int len,
int type);
_XOPEN_SOURCE_EXTENDED only
struct hostent *gethostbyaddr(const void *addr,
size_t len,
int type);
int gethostbyaddr_r(const char *addr,
int len,
int type,
struct hostent *result,
struct hostent_data *buffer);
int sethostent(int stayopen);
int sethostent_r(int stayopen,
struct hostent_data *buffer);
int endhostent(void);
int endhostent_r(struct hostent_data *buffer);
_XOPEN_SOURCE_EXTENDED only
void sethostent(int stayopen);
void endhostent(void);
...
ERRORS
If the name server is being used and
gethostbyname() or gethostbyaddr() returns a NULL
pointer, the external integer h_errno contains one
of the following values:
HOST_NOT_FOUND
No such host is known.
TRY_AGAIN
This is usually a temporary error. The local
server did not receive a response from an
authoritative server. A retry at some later
time may succeed.
NO_RECOVERY
This is a non-recoverable error.
NO_ADDRESS
The requested name is valid but does not
have an IP address; this is not a temporary
error. This means another type of request
to the name server will result in an
answer.
If the name server is not being used, the value of
h_errno may not be meaningful.
/usr/include/netdb.h includes the following fragment:
#ifdef _XOPEN_SOURCE_EXTENDED
extern int h_errno;
#endif
So, although this is not mentioned in the man page,
_XOPEN_SOURCE_EXTENDED must be defined to include
the declaration.
On HPUX11, the man pages says more or less the same,
but adds the following:
WARNINGS
Programs that use the interfaces described in
this manpage cannot be linked statically because
the implementations of these functions employ
dynamic loading and linking of shared objects at
run time.
h_errno is referenced as an extern int for single
thread applications and is defined as function
call macro for multithreaded applications in file
/usr/include/netdb.h. Applications that reference
h_errno need to include /usr/include/netdb.h.
/usr/include/netdb.h contains the following:
/*
* Error return codes from gethostbyname() and
gethostbyaddr()
*/
#ifndef h_ERRNO_KT_DEFINED
#define h_ERRNO_KT_DEFINED
#ifdef _REENTRANT
#ifdef _PROTOTYPES /* 64 bit: add _PROTOTYPES */
extern int *__h_errno(void); /* 64 bit: add _PROTOTYPES */
#else /* _PROTOTYPES */ /* 64 bit: add _PROTOTYPES */
extern int *__h_errno();
#endif /* _PROTOTYPES */ /* 64 bit: add _PROTOTYPES */
#define h_errno (*__h_errno())
#else /* _REENTRANT */
extern int h_errno;
#endif /* REENTRANT */
#endif /* ! h_ERRNO_KT_DEFINED */
#endif /* _NETDB_INCLUDED */
So, the only safe way to get things working on HPUX-10 and
HPUX-11 is to define _XOPEN_SOURCE_EXTENDED before netdb.h
is included. The hardcoded declaration I mentioned before
isn't safe.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-01-18 13:09
Message:
Logged In: YES
user_id=21627
s/HPUX/HPUX11/
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-01-18 13:09
Message:
Logged In: YES
user_id=21627
Does the second version of your patch also work on HPUX? Can
you point to official documentation on that matter?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=505427&group_id=5470