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

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Aug 14 12:42:34 CEST 2005


Hi,
On Sun, Aug 14, 2005 at 05:20:20AM -0400, a.guru at sympatico.ca wrote:
> 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'd say say if MinGW supports it we can safely assume it to work
everywhere *g*

> I was thinking of renaming my new macros PRIdOFF
> and PRIXOFF to follow that same pattern.

Ok, but you should probably check that they aren't already defined.

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

Yes, it does. But the problem is that if you want to do this, you must
make sure inttypes.h is included before you define that :-(
mp_msg.h might be the right place in that case.

> > 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?

With your patch, probably yes. Currently no, since off_t can be 32 bit,
too.

> 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.

Exactly. Though we would have to test if your patch can correctly detect
the size under MinGW. I guess using sizeof is not possible in the
preprocessor macro?
But actually there would be a different possibility: always use PRId64
and cast the offsets to int64_t. Because finding the right place for the
#ifdefs is non-trivial, as well as detecting the size of off_t I
actually think this might be the more "stable"/portable way.

> > >      // 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.

That would be prefered, esp. since you did not explain it :-)

Greetings,
Reimar Döffinger




More information about the MPlayer-dev-eng mailing list