This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3] Merge parts of <sys/time.h> from FreeBSD


On Thu, 2015-03-19 at 09:18 +0100, Corinna Vinschen wrote:

> Neither on Cygwin, but in both cases it's probably a difference in the
> headers pulled in indirectly.
> 
> > >Does it help to s/uint64_t/__uint64_t/ in sys/time.h?
> > 
> > Since we define uint64_t in terms of __uint64_t in <stdint.h> this should be
> > fine.
> 
> I think so, too, but I'd like to hear if it actually fixes Steve's
> build problem.
> 
> 
> Thanks,
> Corinna

Yes, this fixed the problem.  I also changed uses of uint32_t to
__uint32_t.  Here is the complete patch that I tested and that built for
me with my mips-mti-elf toolchain.

Steve Ellcey
sellcey@imgtec.com



2015-03-19  Steve Ellcey  <sellcey@imgtec.com>

	* libc/include/sys/time.h: Replace uint32_t and uint64_t
	with __uint32_t and __uint64_t.


diff --git a/newlib/libc/include/sys/time.h b/newlib/libc/include/sys/time.h
index ce8cad6..e659104 100644
--- a/newlib/libc/include/sys/time.h
+++ b/newlib/libc/include/sys/time.h
@@ -57,13 +57,13 @@ struct timezone {
 #if __BSD_VISIBLE
 struct bintime {
 	time_t	sec;
-	uint64_t frac;
+	__uint64_t frac;
 };
 
 static __inline void
-bintime_addx(struct bintime *_bt, uint64_t _x)
+bintime_addx(struct bintime *_bt, __uint64_t _x)
 {
-	uint64_t _u;
+	__uint64_t _u;
 
 	_u = _bt->frac;
 	_bt->frac += _x;
@@ -74,7 +74,7 @@ bintime_addx(struct bintime *_bt, uint64_t _x)
 static __inline void
 bintime_add(struct bintime *_bt, const struct bintime *_bt2)
 {
-	uint64_t _u;
+	__uint64_t _u;
 
 	_u = _bt->frac;
 	_bt->frac += _bt2->frac;
@@ -86,7 +86,7 @@ bintime_add(struct bintime *_bt, const struct bintime *_bt2)
 static __inline void
 bintime_sub(struct bintime *_bt, const struct bintime *_bt2)
 {
-	uint64_t _u;
+	__uint64_t _u;
 
 	_u = _bt->frac;
 	_bt->frac -= _bt2->frac;
@@ -98,7 +98,7 @@ bintime_sub(struct bintime *_bt, const struct bintime *_bt2)
 static __inline void
 bintime_mul(struct bintime *_bt, u_int _x)
 {
-	uint64_t _p1, _p2;
+	__uint64_t _p1, _p2;
 
 	_p1 = (_bt->frac & 0xffffffffull) * _x;
 	_p2 = (_bt->frac >> 32) * _x + (_p1 >> 32);
@@ -117,7 +117,7 @@ bintime_shift(struct bintime *_bt, int _exp)
 		_bt->frac <<= _exp;
 	} else if (_exp < 0) {
 		_bt->frac >>= -_exp;
-		_bt->frac |= (uint64_t)_bt->sec << (64 + _exp);
+		_bt->frac |= (__uint64_t)_bt->sec << (64 + _exp);
 		_bt->sec >>= -_exp;
 	}
 }
@@ -179,8 +179,8 @@ bintime2timespec(const struct bintime *_bt, struct timespec *_ts)
 {
 
 	_ts->tv_sec = _bt->sec;
-	_ts->tv_nsec = ((uint64_t)1000000000 *
-	    (uint32_t)(_bt->frac >> 32)) >> 32;
+	_ts->tv_nsec = ((__uint64_t)1000000000 *
+	    (__uint32_t)(_bt->frac >> 32)) >> 32;
 }
 
 static __inline void
@@ -189,7 +189,7 @@ timespec2bintime(const struct timespec *_ts, struct bintime *_bt)
 
 	_bt->sec = _ts->tv_sec;
 	/* 18446744073 = int(2^64 / 1000000000) */
-	_bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL;
+	_bt->frac = _ts->tv_nsec * (__uint64_t)18446744073LL;
 }
 
 static __inline void
@@ -197,7 +197,7 @@ bintime2timeval(const struct bintime *_bt, struct timeval *_tv)
 {
 
 	_tv->tv_sec = _bt->sec;
-	_tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(_bt->frac >> 32)) >> 32;
+	_tv->tv_usec = ((__uint64_t)1000000 * (__uint32_t)(_bt->frac >> 32)) >> 32;
 }
 
 static __inline void
@@ -206,7 +206,7 @@ timeval2bintime(const struct timeval *_tv, struct bintime *_bt)
 
 	_bt->sec = _tv->tv_sec;
 	/* 18446744073709 = int(2^64 / 1000000) */
-	_bt->frac = _tv->tv_usec * (uint64_t)18446744073709LL;
+	_bt->frac = _tv->tv_usec * (__uint64_t)18446744073709LL;
 }
 
 static __inline struct timespec
@@ -215,7 +215,7 @@ sbttots(sbintime_t _sbt)
 	struct timespec _ts;
 
 	_ts.tv_sec = _sbt >> 32;
-	_ts.tv_nsec = ((uint64_t)1000000000 * (uint32_t)_sbt) >> 32;
+	_ts.tv_nsec = ((__uint64_t)1000000000 * (__uint32_t)_sbt) >> 32;
 	return (_ts);
 }
 
@@ -224,7 +224,7 @@ tstosbt(struct timespec _ts)
 {
 
 	return (((sbintime_t)_ts.tv_sec << 32) +
-	    (_ts.tv_nsec * (((uint64_t)1 << 63) / 500000000) >> 32));
+	    (_ts.tv_nsec * (((__uint64_t)1 << 63) / 500000000) >> 32));
 }
 
 static __inline struct timeval
@@ -233,7 +233,7 @@ sbttotv(sbintime_t _sbt)
 	struct timeval _tv;
 
 	_tv.tv_sec = _sbt >> 32;
-	_tv.tv_usec = ((uint64_t)1000000 * (uint32_t)_sbt) >> 32;
+	_tv.tv_usec = ((__uint64_t)1000000 * (__uint32_t)_sbt) >> 32;
 	return (_tv);
 }
 
@@ -242,7 +242,7 @@ tvtosbt(struct timeval _tv)
 {
 
 	return (((sbintime_t)_tv.tv_sec << 32) +
-	    (_tv.tv_usec * (((uint64_t)1 << 63) / 500000) >> 32));
+	    (_tv.tv_usec * (((__uint64_t)1 << 63) / 500000) >> 32));
 }
 #endif /* __BSD_VISIBLE */
 
@@ -390,7 +390,7 @@ int	tvtohz(struct timeval *tv);
 #define	TC_DEFAULTPERC		5
 
 #define	BT2FREQ(bt)                                                     \
-	(((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) /           \
+	(((__uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) /           \
 	    ((bt)->frac >> 1))
 
 #define	SBT2FREQ(sbt)	((SBT_1S + ((sbt) >> 1)) / (sbt))
@@ -398,7 +398,7 @@ int	tvtohz(struct timeval *tv);
 #define	FREQ2BT(freq, bt)                                               \
 {									\
 	(bt)->sec = 0;                                                  \
-	(bt)->frac = ((uint64_t)0x8000000000000000  / (freq)) << 1;     \
+	(bt)->frac = ((__uint64_t)0x8000000000000000  / (freq)) << 1;     \
 }
 
 #define	TIMESEL(sbt, sbt2)						\



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]