Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Apr 2014 20:52:39 +0000 (UTC)
From:      Mark Murray <markm@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r265109 - projects/random_number_generator/sys/dev/random
Message-ID:  <201404292052.s3TKqdmQ034590@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markm
Date: Tue Apr 29 20:52:39 2014
New Revision: 265109
URL: http://svnweb.freebsd.org/changeset/base/265109

Log:
  Fix a printf to work with a ssize_t variable.
  
  Fix the 128-bit code to use an available macro to detect compiler-native 128-bit integers. Thanks to John Baldwin for the clue.

Modified:
  projects/random_number_generator/sys/dev/random/random_adaptors.c
  projects/random_number_generator/sys/dev/random/uint128.h

Modified: projects/random_number_generator/sys/dev/random/random_adaptors.c
==============================================================================
--- projects/random_number_generator/sys/dev/random/random_adaptors.c	Tue Apr 29 20:51:57 2014	(r265108)
+++ projects/random_number_generator/sys/dev/random/random_adaptors.c	Tue Apr 29 20:52:39 2014	(r265109)
@@ -281,7 +281,7 @@ random_adaptor_write(struct cdev *dev __
 	void *random_buf;
 
 #ifdef RANDOM_DEBUG
-	printf("random: %s %ld\n", __func__, uio->uio_resid);
+	printf("random: %s %zd\n", __func__, uio->uio_resid);
 #endif
 
 	KASSERT(random_adaptor != NULL, ("No active random adaptor in %s", __func__));

Modified: projects/random_number_generator/sys/dev/random/uint128.h
==============================================================================
--- projects/random_number_generator/sys/dev/random/uint128.h	Tue Apr 29 20:51:57 2014	(r265108)
+++ projects/random_number_generator/sys/dev/random/uint128.h	Tue Apr 29 20:52:39 2014	(r265109)
@@ -34,23 +34,16 @@
  * Everyone knows you always need the __uint128_t types!
  */
 
-#if !defined(__arm__) && !defined(__mips__) && !defined(__i386__) && !defined(__pc98__) && !defined(__powerpc__)
-/* We do have an inbuilt __uint128_t type */
-
+#ifdef __SIZEOF_INT128__
 typedef __uint128_t uint128_t;
-#define USE_128_BIT
-
 #else
-
-/* There is no inbuilt __uint128_t type */
 typedef uint64_t uint128_t[2];
-
 #endif
 
 static __inline void
 uint128_clear(uint128_t *big_uint)
 {
-#ifdef USE_128_BIT
+#ifdef __SIZEOF_INT128__
 	(*big_uint) = 0ULL;
 #else
 	(*big_uint)[0] = (*big_uint)[1] = 0UL;
@@ -60,7 +53,7 @@ uint128_clear(uint128_t *big_uint)
 static __inline void
 uint128_increment(uint128_t *big_uint)
 {
-#ifdef USE_128_BIT
+#ifdef __SIZEOF_INT128__
 	(*big_uint)++;
 #else
 	(*big_uint)[0]++;
@@ -72,7 +65,7 @@ uint128_increment(uint128_t *big_uint)
 static __inline int
 uint128_is_zero(uint128_t big_uint)
 {
-#ifdef USE_128_BIT
+#ifdef __SIZEOF_INT128__
 	return (big_uint == 0ULL);
 #else
 	return (big_uint[0] == 0UL && big_uint[1] == 0UL);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404292052.s3TKqdmQ034590>