xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ditch redundant integer types
@ 2017-03-03 15:53 Jan Beulich
  2017-03-03 15:58 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2017-03-03 15:53 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan

[-- Attachment #1: Type: text/plain, Size: 6214 bytes --]

The very few uses can easily be replaced by more standard ones.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/common/lib.c
+++ b/xen/common/lib.c
@@ -110,7 +110,8 @@ union uu {
 /*
  * Extract high and low shortwords from longword, and move low shortword of
  * longword to upper half of long, i.e., produce the upper longword of
- * ((quad_t)(x) << (number_of_bits_in_long/2)).  (`x' must actually be u_long.)
+ * ((quad_t)(x) << (number_of_bits_in_long/2)).  (`x' must actually be
+ * unsigned long.)
  *
  * These are used in the multiply code, to split a longword into upper
  * and lower halves, and to reassemble a product as a quad_t, shifted left
@@ -127,10 +128,10 @@ union uu {
 #define B (1 << HALF_BITS) /* digit base */
 
 /* Combine two `digits' to make a single two-digit number. */
-#define COMBINE(a, b) (((u_long)(a) << HALF_BITS) | (b))
+#define COMBINE(a, b) (((unsigned long)(a) << HALF_BITS) | (b))
 
 /* select a type for digits in base B */
-typedef u_long digit;
+typedef unsigned long digit;
 
 /*
  * Shift p[0]..p[len] left `sh' bits, ignoring any bits that
@@ -150,8 +151,8 @@ static void shl(register digit *p, regis
  * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v.
  *
  * We do this in base 2-sup-HALF_BITS, so that all intermediate products
- * fit within u_long.  As a consequence, the maximum length dividend and
- * divisor are 4 `digits' in this base (they are shorter if they have
+ * fit within unsigned long.  As a consequence, the maximum length dividend
+ * and divisor are 4 `digits' in this base (they are shorter if they have
  * leading zeros).
  */
 u64 __qdivrem(u64 uq, u64 vq, u64 *arq)
@@ -159,7 +160,7 @@ u64 __qdivrem(u64 uq, u64 vq, u64 *arq)
     union uu tmp;
     digit *u, *v, *q;
     register digit v1, v2;
-    u_long qhat, rhat, t;
+    unsigned long qhat, rhat, t;
     int m, n, d, j, i;
     digit uspace[5], vspace[5], qspace[5];
 
@@ -210,7 +211,7 @@ u64 __qdivrem(u64 uq, u64 vq, u64 *arq)
     v[4] = LHALF(tmp.ul[L]);
     for (n = 4; v[1] == 0; v++) {
         if (--n == 1) {
-            u_long rbj; /* r*B+u[j] (not root boy jim) */
+            unsigned long rbj; /* r*B+u[j] (not root boy jim) */
             digit q1, q2, q3, q4;
 
             /*
@@ -286,7 +287,8 @@ u64 __qdivrem(u64 uq, u64 vq, u64 *arq)
             rhat = uj1;
             goto qhat_too_big;
         } else {
-            u_long nn = COMBINE(uj0, uj1);
+            unsigned long nn = COMBINE(uj0, uj1);
+
             qhat = nn / v1;
             rhat = nn % v1;
         }
--- a/xen/crypto/rijndael.c
+++ b/xen/crypto/rijndael.c
@@ -1236,7 +1236,7 @@ rijndaelDecrypt(const u32 rk[/*4*(Nr + 1
 
 /* setup key context for encryption only */
 int
-rijndael_set_key_enc_only(rijndael_ctx *ctx, const u_char *key, int bits)
+rijndael_set_key_enc_only(rijndael_ctx *ctx, const unsigned char *key, int bits)
 {
 	int rounds;
 
@@ -1252,7 +1252,7 @@ rijndael_set_key_enc_only(rijndael_ctx *
 
 /* setup key context for both encryption and decryption */
 int
-rijndael_set_key(rijndael_ctx *ctx, const u_char *key, int bits)
+rijndael_set_key(rijndael_ctx *ctx, const unsigned char *key, int bits)
 {
 	int rounds;
 
@@ -1269,13 +1269,13 @@ rijndael_set_key(rijndael_ctx *ctx, cons
 }
 
 void
-rijndael_decrypt(rijndael_ctx *ctx, const u_char *src, u_char *dst)
+rijndael_decrypt(rijndael_ctx *ctx, const unsigned char *src, unsigned char *dst)
 {
 	rijndaelDecrypt(ctx->dk, ctx->Nr, src, dst);
 }
 
 void
-rijndael_encrypt(rijndael_ctx *ctx, const u_char *src, u_char *dst)
+rijndael_encrypt(rijndael_ctx *ctx, const unsigned char *src, unsigned char *dst)
 {
 	rijndaelEncrypt(ctx->ek, ctx->Nr, src, dst);
 }
--- a/xen/include/crypto/rijndael.h
+++ b/xen/include/crypto/rijndael.h
@@ -45,10 +45,10 @@ typedef struct {
 	u32	dk[4*(AES_MAXROUNDS + 1)];	/* decrypt key schedule */
 } rijndael_ctx;
 
-int	 rijndael_set_key(rijndael_ctx *, const u_char *, int);
-int	 rijndael_set_key_enc_only(rijndael_ctx *, const u_char *, int);
-void	 rijndael_decrypt(rijndael_ctx *, const u_char *, u_char *);
-void	 rijndael_encrypt(rijndael_ctx *, const u_char *, u_char *);
+int	 rijndael_set_key(rijndael_ctx *, const unsigned char *, int);
+int	 rijndael_set_key_enc_only(rijndael_ctx *, const unsigned char *, int);
+void	 rijndael_decrypt(rijndael_ctx *, const unsigned char *, unsigned char *);
+void	 rijndael_encrypt(rijndael_ctx *, const unsigned char *, unsigned char *);
 
 int	rijndaelKeySetupEnc(unsigned int [], const unsigned char [], int);
 int	rijndaelKeySetupDec(unsigned int [], const unsigned char [], int);
--- a/xen/include/xen/elfstructs.h
+++ b/xen/include/xen/elfstructs.h
@@ -361,7 +361,7 @@ typedef struct {
 
 #define	ELF64_R_SYM(info)	((info) >> 32)
 #define	ELF64_R_TYPE(info)	((info) & 0xFFFFFFFF)
-#define ELF64_R_INFO(s,t) 	(((s) << 32) + (u_int32_t)(t))
+#define ELF64_R_INFO(s,t) 	(((s) << 32) + (uint32_t)(t))
 
 /*
  * Relocation types for x86_64 and ARM 64. We list only the ones Live Patch
--- a/xen/include/xen/types.h
+++ b/xen/include/xen/types.h
@@ -30,32 +30,16 @@
 #define LONG_MIN        (-LONG_MAX - 1)
 #define ULONG_MAX       (~0UL)
 
-/* bsd */
-typedef unsigned char           u_char;
-typedef unsigned short          u_short;
-typedef unsigned int            u_int;
-typedef unsigned long           u_long;
-
-/* sysv */
-typedef unsigned char           unchar;
-typedef unsigned short          ushort;
-typedef unsigned int            uint;
-typedef unsigned long           ulong;
-
 typedef         __u8            uint8_t;
-typedef         __u8            u_int8_t;
 typedef         __s8            int8_t;
 
 typedef         __u16           uint16_t;
-typedef         __u16           u_int16_t;
 typedef         __s16           int16_t;
 
 typedef         __u32           uint32_t;
-typedef         __u32           u_int32_t;
 typedef         __s32           int32_t;
 
 typedef         __u64           uint64_t;
-typedef         __u64           u_int64_t;
 typedef         __s64           int64_t;
 
 struct domain;



[-- Attachment #2: ditch-u_int-and-alike.patch --]
[-- Type: text/plain, Size: 6243 bytes --]

ditch redundant integer types

The very few uses can easily be replaced by more standard ones.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/common/lib.c
+++ b/xen/common/lib.c
@@ -110,7 +110,8 @@ union uu {
 /*
  * Extract high and low shortwords from longword, and move low shortword of
  * longword to upper half of long, i.e., produce the upper longword of
- * ((quad_t)(x) << (number_of_bits_in_long/2)).  (`x' must actually be u_long.)
+ * ((quad_t)(x) << (number_of_bits_in_long/2)).  (`x' must actually be
+ * unsigned long.)
  *
  * These are used in the multiply code, to split a longword into upper
  * and lower halves, and to reassemble a product as a quad_t, shifted left
@@ -127,10 +128,10 @@ union uu {
 #define B (1 << HALF_BITS) /* digit base */
 
 /* Combine two `digits' to make a single two-digit number. */
-#define COMBINE(a, b) (((u_long)(a) << HALF_BITS) | (b))
+#define COMBINE(a, b) (((unsigned long)(a) << HALF_BITS) | (b))
 
 /* select a type for digits in base B */
-typedef u_long digit;
+typedef unsigned long digit;
 
 /*
  * Shift p[0]..p[len] left `sh' bits, ignoring any bits that
@@ -150,8 +151,8 @@ static void shl(register digit *p, regis
  * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v.
  *
  * We do this in base 2-sup-HALF_BITS, so that all intermediate products
- * fit within u_long.  As a consequence, the maximum length dividend and
- * divisor are 4 `digits' in this base (they are shorter if they have
+ * fit within unsigned long.  As a consequence, the maximum length dividend
+ * and divisor are 4 `digits' in this base (they are shorter if they have
  * leading zeros).
  */
 u64 __qdivrem(u64 uq, u64 vq, u64 *arq)
@@ -159,7 +160,7 @@ u64 __qdivrem(u64 uq, u64 vq, u64 *arq)
     union uu tmp;
     digit *u, *v, *q;
     register digit v1, v2;
-    u_long qhat, rhat, t;
+    unsigned long qhat, rhat, t;
     int m, n, d, j, i;
     digit uspace[5], vspace[5], qspace[5];
 
@@ -210,7 +211,7 @@ u64 __qdivrem(u64 uq, u64 vq, u64 *arq)
     v[4] = LHALF(tmp.ul[L]);
     for (n = 4; v[1] == 0; v++) {
         if (--n == 1) {
-            u_long rbj; /* r*B+u[j] (not root boy jim) */
+            unsigned long rbj; /* r*B+u[j] (not root boy jim) */
             digit q1, q2, q3, q4;
 
             /*
@@ -286,7 +287,8 @@ u64 __qdivrem(u64 uq, u64 vq, u64 *arq)
             rhat = uj1;
             goto qhat_too_big;
         } else {
-            u_long nn = COMBINE(uj0, uj1);
+            unsigned long nn = COMBINE(uj0, uj1);
+
             qhat = nn / v1;
             rhat = nn % v1;
         }
--- a/xen/crypto/rijndael.c
+++ b/xen/crypto/rijndael.c
@@ -1236,7 +1236,7 @@ rijndaelDecrypt(const u32 rk[/*4*(Nr + 1
 
 /* setup key context for encryption only */
 int
-rijndael_set_key_enc_only(rijndael_ctx *ctx, const u_char *key, int bits)
+rijndael_set_key_enc_only(rijndael_ctx *ctx, const unsigned char *key, int bits)
 {
 	int rounds;
 
@@ -1252,7 +1252,7 @@ rijndael_set_key_enc_only(rijndael_ctx *
 
 /* setup key context for both encryption and decryption */
 int
-rijndael_set_key(rijndael_ctx *ctx, const u_char *key, int bits)
+rijndael_set_key(rijndael_ctx *ctx, const unsigned char *key, int bits)
 {
 	int rounds;
 
@@ -1269,13 +1269,13 @@ rijndael_set_key(rijndael_ctx *ctx, cons
 }
 
 void
-rijndael_decrypt(rijndael_ctx *ctx, const u_char *src, u_char *dst)
+rijndael_decrypt(rijndael_ctx *ctx, const unsigned char *src, unsigned char *dst)
 {
 	rijndaelDecrypt(ctx->dk, ctx->Nr, src, dst);
 }
 
 void
-rijndael_encrypt(rijndael_ctx *ctx, const u_char *src, u_char *dst)
+rijndael_encrypt(rijndael_ctx *ctx, const unsigned char *src, unsigned char *dst)
 {
 	rijndaelEncrypt(ctx->ek, ctx->Nr, src, dst);
 }
--- a/xen/include/crypto/rijndael.h
+++ b/xen/include/crypto/rijndael.h
@@ -45,10 +45,10 @@ typedef struct {
 	u32	dk[4*(AES_MAXROUNDS + 1)];	/* decrypt key schedule */
 } rijndael_ctx;
 
-int	 rijndael_set_key(rijndael_ctx *, const u_char *, int);
-int	 rijndael_set_key_enc_only(rijndael_ctx *, const u_char *, int);
-void	 rijndael_decrypt(rijndael_ctx *, const u_char *, u_char *);
-void	 rijndael_encrypt(rijndael_ctx *, const u_char *, u_char *);
+int	 rijndael_set_key(rijndael_ctx *, const unsigned char *, int);
+int	 rijndael_set_key_enc_only(rijndael_ctx *, const unsigned char *, int);
+void	 rijndael_decrypt(rijndael_ctx *, const unsigned char *, unsigned char *);
+void	 rijndael_encrypt(rijndael_ctx *, const unsigned char *, unsigned char *);
 
 int	rijndaelKeySetupEnc(unsigned int [], const unsigned char [], int);
 int	rijndaelKeySetupDec(unsigned int [], const unsigned char [], int);
--- a/xen/include/xen/elfstructs.h
+++ b/xen/include/xen/elfstructs.h
@@ -361,7 +361,7 @@ typedef struct {
 
 #define	ELF64_R_SYM(info)	((info) >> 32)
 #define	ELF64_R_TYPE(info)	((info) & 0xFFFFFFFF)
-#define ELF64_R_INFO(s,t) 	(((s) << 32) + (u_int32_t)(t))
+#define ELF64_R_INFO(s,t) 	(((s) << 32) + (uint32_t)(t))
 
 /*
  * Relocation types for x86_64 and ARM 64. We list only the ones Live Patch
--- a/xen/include/xen/types.h
+++ b/xen/include/xen/types.h
@@ -30,32 +30,16 @@
 #define LONG_MIN        (-LONG_MAX - 1)
 #define ULONG_MAX       (~0UL)
 
-/* bsd */
-typedef unsigned char           u_char;
-typedef unsigned short          u_short;
-typedef unsigned int            u_int;
-typedef unsigned long           u_long;
-
-/* sysv */
-typedef unsigned char           unchar;
-typedef unsigned short          ushort;
-typedef unsigned int            uint;
-typedef unsigned long           ulong;
-
 typedef         __u8            uint8_t;
-typedef         __u8            u_int8_t;
 typedef         __s8            int8_t;
 
 typedef         __u16           uint16_t;
-typedef         __u16           u_int16_t;
 typedef         __s16           int16_t;
 
 typedef         __u32           uint32_t;
-typedef         __u32           u_int32_t;
 typedef         __s32           int32_t;
 
 typedef         __u64           uint64_t;
-typedef         __u64           u_int64_t;
 typedef         __s64           int64_t;
 
 struct domain;

[-- Attachment #3: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ditch redundant integer types
  2017-03-03 15:53 [PATCH] ditch redundant integer types Jan Beulich
@ 2017-03-03 15:58 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2017-03-03 15:58 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Tim Deegan,
	Ian Jackson

On 03/03/17 15:53, Jan Beulich wrote:
> The very few uses can easily be replaced by more standard ones.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-03 15:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-03 15:53 [PATCH] ditch redundant integer types Jan Beulich
2017-03-03 15:58 ` Andrew Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).