l4-hurd
[Top][All Lists]
Advanced

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

Some libl4 patches


From: Matthieu Lemerre
Subject: Some libl4 patches
Date: Thu, 06 Jan 2005 00:51:29 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)

Hello,

I had to make some patches to libl4 to get string message passing works:

in ia32/vregs.h: There was some problem with Buffer register
loading/storing (basically, it didn't worked because the data were
processed backward)


in ipc.h:

functions _L4_msg_buffer_append_simple_rcv_string and
_L4_msg_buffer_append_rcv_string:

There was a single | instead of ||, and , as || is yet used in
_L4_accept_strings, I put || to normalize.

They also did not work because of a do ... while done instead of a
while: the first bytes of the message buffer were never used.

So I propose the folowing: a call to l4_msg_buffer_clear would set
both the first and the second word to 0, and we test whether the
second word is set or not for knowing whether or not there is already
a string item in the message buffer (because putting one would set
this second word to the address of the string or substring ptr, thus
overriding the 0)

However, there is a problem if we can use the null pointer as the send
or receive address of a string.

I didn't checked, but I wonder if _L4_add_substring_to hasn't the same
problem.

I also wonder if we shouldn't add a l4_string_item "creator" function
in the GNU interface to libl4; this function is useful (at least, it
was useful for me).

BTW: Thank you Bas for answering about root capability

Thanks,
Matthieu

PS: I received the legal papers, I will send them back tomorrow.

--- hurd-l4/libl4/ia32/l4/bits/vregs.h  2004-03-19 20:00:18.000000000 +0100
+++ hurd-l4-string/libl4/ia32/l4/bits/vregs.h   2005-01-05 03:55:38.000000000 
+0100
@@ -387,7 +387,7 @@
 {
   _L4_word_t *br = _L4_utcb () + _L4_UTCB_BR0;
 
-  *data = br[nr];
+  *data = br[-nr];
 }
 
 
@@ -399,7 +399,7 @@
   _L4_word_t *br = _L4_utcb () + _L4_UTCB_BR0 - start;
 
   while (count--)
-    *(data--) = *(br--);
+    *(data++) = *(br--);
 }
 
 /* Set message register NR to DATA.  */
@@ -409,7 +409,7 @@
 {
   _L4_word_t *br = _L4_utcb () + _L4_UTCB_BR0;
 
-  br[nr] = data;
+  br[-nr] = data;
 }
 
 
@@ -422,5 +422,5 @@
   _L4_word_t *br = _L4_utcb () + _L4_UTCB_BR0 - start;
 
   while (count--)
-    *(br--) = *(data--);
+    *(br--) = *(data++);
 }
--- hurd-l4/libl4/l4/ipc.h      2004-10-08 01:02:26.000000000 +0200
+++ hurd-l4-string/libl4/l4/ipc.h       2005-01-06 00:31:59.000000000 +0100
@@ -635,7 +635,7 @@
 _L4_attribute_always_inline
 _L4_msg_buffer_clear (_L4_msg_buffer_t msg_buffer)
 {
-  msg_buffer[0] = 0;
+  msg_buffer[0] = msg_buffer[1] = 0;
 }
 
 
@@ -650,15 +650,18 @@
 
   _string_item.raw = string_item;
 
-  do
+  if(msg_buffer[1])
     {
-      int nr = 1 + target->nr_substrings + 1;
-      cont = target->cont | target->not_last;
-      if (!cont)
-       target->not_last = 1;
-      target = (__L4_string_item_t *) (((_L4_word_t *) target) + nr);
+      do
+       {
+         int nr = 1 + target->nr_substrings + 1;
+         cont = target->cont || target->not_last;
+         if (!cont)
+           target->not_last = 1;
+         target = (__L4_string_item_t *) (((_L4_word_t *) target) + nr);
+       }
+      while (cont);
     }
-  while (cont);
 
   _string_item.not_last = 0;
   _string_item.nr_substrings = 0;
@@ -677,16 +680,19 @@
   int cont;
 
   /* Find the end of the message buffer.  */
-  do
+  if(msg_buffer[1])
     {
-      int nr = 1 + target->nr_substrings + 1;
-      cont = target->cont | target->not_last;
-      if (!cont)
-       target->not_last = 1;
-      target = (__L4_string_item_t *) (((_L4_word_t *) target) + nr);
+      do
+       {
+         int nr = 1 + target->nr_substrings + 1;
+         cont = target->cont || target->not_last;
+         if (!cont)
+           target->not_last = 1;
+         target = (__L4_string_item_t *) (((_L4_word_t *) target) + nr);
+       }
+      while (cont);
     }
-  while (cont);
-
+  
   brp = (_L4_word_t *) target;
 
   /* Copy the source string.  */

reply via email to

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