[MPlayer-dev-eng] libmpdemux/cache2.c: correct format strings given _FILE_OFFSET_BITS

a.guru at sympatico.ca a.guru at sympatico.ca
Sun Aug 14 11:20:20 CEST 2005


* On Sunday 2005-08-14 at 10:20:00 +0200, Reimar Döffinger wrote:
> 
> > --- libmpdemux/cache2.c.orig-1.0pre7	2004-07-26 18:06:30 -0400
> > +++ libmpdemux/cache2.c	2005-08-13 18:24:59 -0400
> > @@ -27,6 +27,13 @@ static DWORD WINAPI ThreadProc(void* s);
> >  #endif
> >  
> >  #include "mp_msg.h"
> > +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
> > +# define OFD "lld"
> > +# define OFX "llX"
> > +#else
> > +# define OFD "d"
> > +# define OFX "X"
> > +#endif
> 
> If you get that a better name,

Standard <inttypes.h> already defines macros with
names such as PRId32, PRId64, PRIX32, and PRIX64.

Thoughout the MPlayer source code, using
<inttypes.h> without verifying its very presence
on the system seems to be a given.

Can we assume, however, that the system's
<inttypes.h> will systematically be
recent/standard enough (is it C99?) to have
these specific macros defined?

I was thinking of renaming my new macros PRIdOFF
and PRIXOFF to follow that same pattern.
A quick web search seems to reveal that only
NetBSD's gzip (which is *not* GNU's) uses that
same idea so far.


> put it into config.h and most importantly
> find a proper way to fix it for MinGW (that does not support lld but
> only e.g. I64d),

I am not familiar with MinGW, but here's the
obvious question:  does its <inttypes.h> already
define PRId64 as "I64d"?

Otherwise, does it pre-define any other
preprocessor macro as "I64d" that we could pick
up on?


> that would be a nice patch - especially if you add
> another define that helps us get rid of the #ifdef in
> libmpdemux/network.c (lld vs. I64d)...

I don't think the type-casts in front of pos,
there, are really necessary.  Isn't the fact
that pos' type is already off_t sufficient?

Or maybe that's to cover the 32-bit off_t case.
That would no longer be necessary given a PRIdOFF
macro that would be properly defined in sync
with the current typedef for off_t.

 
> >      // wait until cache is filled at least prefill_init %
> > -    mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %d [%d] %d  pre:%d  eof:%d  \n",
> > +    mp_msg(
> > +	MSGT_CACHE, MSGL_V,
> > +	"CACHE: size=%d min=%d prefill=%d buffer_size=%d fill_limit=%d prefill=%d\n",
> > +	size, min, prefill,
> > +	s->buffer_size, s->fill_limit, s->prefill);
> 
> Adding this messages seems to be an independant part...

Agreed.
I can easily re-submit that separately later.




More information about the MPlayer-dev-eng mailing list