mailing list of musl libc
 help / color / mirror / code / Atom feed
* apr and time.h
@ 2013-06-06 17:42 Jens
  2013-06-06 20:38 ` Szabolcs Nagy
  0 siblings, 1 reply; 3+ messages in thread
From: Jens @ 2013-06-06 17:42 UTC (permalink / raw)
  To: musl


apr wont build (for me) with the following part of time.h (musl-0.9.10):

#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
#define tm_gmtoff __tm_gmtoff
#define tm_zone __tm_zone
#endif

apr implements a struct with a member named tm_gmtoff.

Removing the above makes apr build.

Regards,
Jens


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: apr and time.h
  2013-06-06 17:42 apr and time.h Jens
@ 2013-06-06 20:38 ` Szabolcs Nagy
  2013-06-07  1:13   ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Szabolcs Nagy @ 2013-06-06 20:38 UTC (permalink / raw)
  To: musl

* Jens <jensl@laas.mine.nu> [2013-06-06 19:42:39 +0200]:
> apr wont build (for me) with the following part of time.h (musl-0.9.10):
> 
> #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
> #define tm_gmtoff __tm_gmtoff
> #define tm_zone __tm_zone
> #endif
> 
> apr implements a struct with a member named tm_gmtoff.
> 

you gotta love "portability runtime" libraries..

tm_ is in the reserved namespace of posix,
but time.h is specified by iso c as well
which does not have such restriction
so in this case they are not strictly wrong

the correct behaviour of musl would be
to only expose iso c interfaces by default
but then all the codes in the world break..
(including apr most likely)

an ugly workaround that does less namespace
pollution (no tm_* macro):

#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
#define __tm_gmtoff tm_gmtoff
#define __tm_zone tm_zone
#define _FIX(x) x
#else
#define _FIX(x) __##x
#endif

struct tm {
	/*...*/
	long _FIX(tm_gmtoff);
	const char *_FIX(tm_zone);
};

either this or fix apr so it does not collide
with the posix namespace..


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: apr and time.h
  2013-06-06 20:38 ` Szabolcs Nagy
@ 2013-06-07  1:13   ` Rich Felker
  0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2013-06-07  1:13 UTC (permalink / raw)
  To: musl

On Thu, Jun 06, 2013 at 10:38:37PM +0200, Szabolcs Nagy wrote:
> * Jens <jensl@laas.mine.nu> [2013-06-06 19:42:39 +0200]:
> > apr wont build (for me) with the following part of time.h (musl-0.9.10):
> > 
> > #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
> > #define tm_gmtoff __tm_gmtoff
> > #define tm_zone __tm_zone
> > #endif
> > 
> > apr implements a struct with a member named tm_gmtoff.
> > 
> 
> you gotta love "portability runtime" libraries..
> 
> tm_ is in the reserved namespace of posix,
> but time.h is specified by iso c as well
> which does not have such restriction
> so in this case they are not strictly wrong
> 
> the correct behaviour of musl would be
> to only expose iso c interfaces by default
> but then all the codes in the world break..
> (including apr most likely)
> 
> an ugly workaround that does less namespace
> pollution (no tm_* macro):
> 
> #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
> #define __tm_gmtoff tm_gmtoff
> #define __tm_zone tm_zone
> #define _FIX(x) x
> #else
> #define _FIX(x) __##x
> #endif
> 
> struct tm {
> 	/*...*/
> 	long _FIX(tm_gmtoff);
> 	const char *_FIX(tm_zone);
> };
> 
> either this or fix apr so it does not collide
> with the posix namespace..

This is ugly. I would just put the #if right inside the struct
definition. Any objections to this change? If I'm not mistaken it's
the way glibc and other libraries do it.

Rich


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-06-07  1:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-06 17:42 apr and time.h Jens
2013-06-06 20:38 ` Szabolcs Nagy
2013-06-07  1:13   ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).