[U-Boot] Including stdlib.h / ldiv_t

Simon Glass sjg at chromium.org
Mon Sep 26 22:23:01 CEST 2011


Hi,

Before I forget, in my travels recently I found this little bit of
code in disk/part_mac.c:

/* stdlib.h causes some compatibility problems; should fixe these! -- wd */
#ifndef __ldiv_t_defined
typedef struct {
	long int quot;		/* Quotient	*/
	long int rem;		/* Remainder	*/
} ldiv_t;
extern ldiv_t ldiv (long int __numer, long int __denom);
# define __ldiv_t_defined	1
#endif


There are 4 other places which define this structure also. Also there
is div64.{c,h}.

At the moment including stdlib and including common.h are mutually
exclusive. This probably makes some sense (why would anyone include
stdlib.h in U-Boot except with hostcc?), but in that case we should
try to replace any need for stdlib with our own definitions. Does that
sounds right?

For this particular case, I wonder whether we should:
- create a single header like ldiv.h containing div64.h, ldiv_t and
the prototype for the 32-bit version, ldiv
- modify source files to include that instead
- or is this moving us too far away from Linux?
- or is this a complete waste of time?

Comments?

Regards,
Simon


More information about the U-Boot mailing list