[AGENT++] Problem with *_r functions

Jochen Katz katz at agentpp.com
Mon Jan 19 22:56:39 CET 2004


Hi,

> I am trying to migrate my app from SNMP++ v3.2.7 to 3.2.10 and I faced 
> those warnings:
> 
> Threads_defined_but_no_reentrant_LOCALTIME_function
> Threads_defined_but_no_reentrant_GETHOSTBYADDR_function
> Threads_defined_but_no_reentrant_GETHOSTBYNAME_function

on any "unknown" OS/Compiler you will get these warnings. This should be 
reported, so the necessary #defines can be added.

> As far as I understood, I can ignore them, but, as stated in 
> config_snmp_pp.h, I report my OS and compiler here:

from http://www.calpoly.edu/cgi-bin/man-cgi?ctime+3 and
http://www.calpoly.edu/cgi-bin/man-cgi?gethostbyname+3
I would assume that for HPUX 11 we should use localtime_r(), 
gethostbyaddr() and gethostbyname().

> HPUX 11,
> aCC: HP ANSI C++ B3910B A.03.37
> 
> it does not have gethostbyname_r function, for example...
> Thus, I cannot define __GNU__

As __HP_aCC is automatically defined from aCC, this define can be used.

Regards,
   Jochen

// can we use the reentrant version of these functions or
// are the standard functions thread safe
#ifdef __GNUC__
#define HAVE_GETHOSTBYNAME_R
#define HAVE_LOCALTIME_R
#define HAVE_GETHOSTBYADDR_R
#elif __HP_aCC
#define HAVE_REENTRANT_GETHOSTBYNAME
#define HAVE_LOCALTIME_R
#define HAVE_REENTRANT_GETHOSTBYADDR
#elif _MSC_VER
#define HAVE_REENTRANT_GETHOSTBYNAME
#define HAVE_REENTRANT_LOCALTIME
#define HAVE_REENTRANT_GETHOSTBYADDR
#endif

///////////////////////////////////////////////////////////////////////
// Changes below this line should not be necessary
///////////////////////////////////////////////////////////////////////

#ifndef _NO_THREADS

#ifndef HAVE_REENTRANT_LOCALTIME
#ifndef HAVE_LOCALTIME_R
// If you see this warning, and your system has a reentrant localtime
// or localtime_r function report your compiler, OS,... to the authors
// of this library, so that these settings can be changed
#warning Threads_defined_but_no_reentrant_LOCALTIME_function
#endif
#endif

#ifndef HAVE_GETHOSTBYADDR_R
#ifndef HAVE_REENTRANT_GETHOSTBYADDR
// If you see this warning, and your system has a reentrant localtime
// or localtime_r function report your compiler, OS,... to the authors
// of this library, so that these settings can be changed
#warning Threads_defined_but_no_reentrant_GETHOSTBYADDR_function
#endif
#endif

#ifndef HAVE_GETHOSTBYNAME_R
#ifndef HAVE_REENTRANT_GETHOSTBYNAME
// If you see this warning, and your system has a reentrant localtime
// or localtime_r function report your compiler, OS,... to the authors
// of this library, so that these settings can be changed
#warning Threads_defined_but_no_reentrant_GETHOSTBYNAME_function
#endif
#endif

#endif // _NO_THREADS





More information about the AGENTPP mailing list