bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Use word_size instead of 4.


From: Flavio Cruz
Subject: [PATCH] Use word_size instead of 4.
Date: Sun, 3 Apr 2016 02:27:23 +0200
User-agent: Mutt/1.5.24 (2015-08-30)

* server.c: Use word_size and update comments.
* type.c: Use word_size to compute padding.
* user.c: Use word_size and update comments.
---
 server.c | 20 ++++++++++----------
 type.c   |  2 +-
 user.c   | 22 +++++++++++-----------
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/server.c b/server.c
index 37cb6e0..1d10093 100644
--- a/server.c
+++ b/server.c
@@ -479,7 +479,7 @@ WriteCheckArgSize(FILE *file, const argument_t *arg)
                arg->argLongForm ? ".msgtl_header" : "");
     }
 
-    if (btype->itTypeSize % 4 != 0)
+    if (btype->itTypeSize % word_size != 0)
        fprintf(file, "(");
 
     if (multiplier > 1)
@@ -487,10 +487,10 @@ WriteCheckArgSize(FILE *file, const argument_t *arg)
 
     fprintf(file, "In%dP->%s", arg->argRequestPos, count->argMsgField);
 
-    /* If the base type size of the data field isn`t a multiple of 4,
+    /* If the base type size of the data field isn`t a multiple of word_size,
        we have to round up. */
-    if (btype->itTypeSize % 4 != 0)
-       fprintf(file, " + 3) & ~3");
+    if (btype->itTypeSize % word_size != 0)
+       fprintf(file, " + %d) & ~%d", word_size - 1, word_size - 1);
 
     if (ptype->itIndefinite) {
        fprintf(file, " : sizeof(%s *)", FetchServerType(btype));
@@ -526,8 +526,8 @@ WriteCheckMsgSize(FILE *file, const argument_t *arg)
        boolean_t LastVarArg = arg->argRequestPos+1 == rt->rtNumRequestVar;
 
        /* calculate the actual size in bytes of the data field.  note
-          that this quantity must be a multiple of four.  hence, if
-          the base type size isn't a multiple of four, we have to
+          that this quantity must be a multiple of word_size.  hence, if
+          the base type size isn't a multiple of word_size, we have to
           round up.  note also that btype->itNumber must
           divide btype->itTypeSize (see itCalculateSizeInfo). */
 
@@ -1083,7 +1083,7 @@ WriteArgSize(FILE *file, const argument_t *arg)
                arg->argLongForm ? ".msgtl_header" : "");
     }
 
-    if (bsize % 4 != 0)
+    if (bsize % word_size != 0)
        fprintf(file, "(");
 
     if (bsize > 1)
@@ -1096,11 +1096,11 @@ WriteArgSize(FILE *file, const argument_t *arg)
        fprintf(file, "%s", count->argVarName);
 
     /*
-     * If the base type size is not a multiple of sizeof(int) [4],
+     * If the base type size is not a multiple of word_size,
      * we have to round up.
      */
-    if (bsize % 4 != 0)
-       fprintf(file, " + 3) & ~3");
+    if (bsize % word_size != 0)
+       fprintf(file, " + %d) & ~%d", word_size - 1, word_size - 1);
 
     if (ptype->itIndefinite) {
        fprintf(file, " : sizeof(%s *)",
diff --git a/type.c b/type.c
index 26a39b7..6e2319e 100644
--- a/type.c
+++ b/type.c
@@ -155,7 +155,7 @@ itCalculateSizeInfo(ipc_type_t *it)
     if (it->itInLine)
     {
        u_int bytes = (it->itNumber * it->itSize + 7) / 8;
-       u_int padding = (4 - bytes%4)%4;
+       u_int padding = (word_size - bytes % word_size) % word_size;
 
        it->itTypeSize = bytes;
        it->itPadSize = padding;
diff --git a/user.c b/user.c
index 66859f0..8cf04a0 100644
--- a/user.c
+++ b/user.c
@@ -497,7 +497,7 @@ WriteArgSize(FILE *file, const argument_t *arg)
        fprintf(file, "(InP->%s%s.msgt_inline) ? ",
                arg->argTTName, arg->argLongForm ? ".msgtl_header" : "");
     }
-    if (bsize % 4 != 0)
+    if (bsize % word_size != 0)
        fprintf(file, "(");
 
     if (bsize > 1)
@@ -513,11 +513,11 @@ WriteArgSize(FILE *file, const argument_t *arg)
                count->argVarName);
 
     /*
-     * If the base type size is not a multiple of sizeof(int) [4],
+     * If the base type size is not a multiple of word_size,
      * we have to round up.
      */
-    if (bsize % 4 != 0)
-       fprintf(file, " + 3) & ~3");
+    if (bsize % word_size != 0)
+       fprintf(file, " + %d) & ~%d", word_size - 1, word_size - 1);
 
     if (ptype->itIndefinite) {
        fprintf(file, " : sizeof(%s *)",
@@ -821,7 +821,7 @@ WriteCheckArgSize(FILE *file, const argument_t *arg)
                arg->argTTName, arg->argLongForm ? ".msgtl_header" : "");
     }
 
-    if (btype->itTypeSize % 4 != 0)
+    if (btype->itTypeSize % word_size != 0)
        fprintf(file, "(");
 
     if (multiplier > 1)
@@ -829,10 +829,10 @@ WriteCheckArgSize(FILE *file, const argument_t *arg)
 
     fprintf(file, "OutP->%s", count->argMsgField);
 
-    /* If the base type size of the data field isn`t a multiple of 4,
+    /* If the base type size of the data field isn`t a multiple of word_size,
        we have to round up. */
-    if (btype->itTypeSize % 4 != 0)
-       fprintf(file, " + 3) & ~3");
+    if (btype->itTypeSize % word_size != 0)
+       fprintf(file, " + %d) & ~%d", word_size - 1, word_size - 1);
 
     if (ptype->itIndefinite)
        fprintf(file, " : sizeof(%s *)", FetchUserType(btype));
@@ -867,8 +867,8 @@ WriteCheckMsgSize(FILE *file, const argument_t *arg)
        boolean_t LastVarArg = arg->argReplyPos+1 == rt->rtNumReplyVar;
 
        /* calculate the actual size in bytes of the data field.  note
-          that this quantity must be a multiple of four.  hence, if
-          the base type size isn't a multiple of four, we have to
+          that this quantity must be a multiple of word_size.  hence, if
+          the base type size isn't a multiple of word_size, we have to
           round up.  note also that btype->itNumber must
           divide btype->itTypeSize (see itCalculateSizeInfo). */
 
@@ -1116,7 +1116,7 @@ WriteReturnValue(FILE *file, const routine_t *rt)
 /*************************************************************
  *  Writes the elements of the message type declaration: the
  *  msg_type structure, the argument itself and any padding
- *  that is required to make the argument a multiple of 4 bytes.
+ *  that is required to make the argument a multiple of word_size bytes.
  *  Called by WriteRoutine for all the arguments in the request
  *  message first and then the reply message.
  *************************************************************/
-- 
2.7.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]