l4-hurd
[Top][All Lists]
Advanced

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

Re: Some libl4 patches


From: Matthieu Lemerre
Subject: Re: Some libl4 patches
Date: Fri, 07 Jan 2005 16:59:10 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)


Hi,

I wrote all the files you requested and gathered them in this email,
assorted with their appropriate Changelog:

*the ia32 vregs.h patch:

2005-01-07  Matthieu Lemerre  <address@hidden>

        * powerpc/l4/bits/vregs.h: (_L4_load_br, _L4_store_br)
        (_L4_load_brs, _L4_store_brs): upward/downward bugs fixed

--- 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_store_br (int nr, _L4_word_t *data)
 {
   _L4_word_t *br = _L4_utcb () + _L4_UTCB_BR0;
 
-  *data = br[nr];
+  *data = br[-nr];
 }
 
 
@@ -399,7 +399,7 @@ _L4_store_brs (int start, int count, _L4
   _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_load_br (int nr, _L4_word_t data)
 {
   _L4_word_t *br = _L4_utcb () + _L4_UTCB_BR0;
 
-  br[nr] = data;
+  br[-nr] = data;
 }
 
 
@@ -422,5 +422,5 @@ _L4_load_brs (int start, int count, _L4_
   _L4_word_t *br = _L4_utcb () + _L4_UTCB_BR0 - start;
 
   while (count--)
-    *(br--) = *(data--);
+    *(br--) = *(data++);
 }
*the powerpc vregs.h patch: (untested)

2005-01-07  Matthieu Lemerre  <address@hidden>

        * powerpc/l4/bits/vregs.h: (_L4_load_br, _L4_store_br)
        (_L4_load_brs, _L4_store_brs): upward/downward bugs fixed

--- hurd-l4-string//libl4/powerpc/l4/bits/vregs.h       2004-08-03 
13:48:56.000000000 +0200
+++ hurd-l4/libl4/powerpc/l4/bits/vregs.h       2005-01-07 15:58:54.000000000 
+0100
@@ -368,7 +368,7 @@ _L4_load_br (int nr, _L4_word_t data)
 {
   _L4_word_t *br = _L4_utcb () + _L4_UTCB_BR0;
 
-  br[nr] = data;
+  br[-nr] = data;
 }
 
 
@@ -381,7 +381,7 @@ _L4_load_brs (int start, int count, _L4_
   _L4_word_t *br = _L4_utcb () + _L4_UTCB_BR0 - start;
 
   while (count--)
-    *(br--) = *(data--);
+    *(br--) = *(data++);
 }
 
 
@@ -392,7 +392,7 @@ _L4_store_br (int nr, _L4_word_t *data)
 {
   _L4_word_t *br = _L4_utcb () + _L4_UTCB_BR0;
 
-  *data = br[nr];
+  *data = br[-nr];
 }
 
 
@@ -404,5 +404,5 @@ _L4_store_brs (int start, int count, _L4
   _L4_word_t *br = _L4_utcb () + _L4_UTCB_BR0 - start;
 
   while (count--)
-    *(data--) = *(br--);
+    *(data++) = *(br--);
 }
*the ipc.h string buffer patches:

-This one add the l4_string_item (int length, void *address)
 function to the GNU interface

2005-01-07  Matthieu Lemerre  <address@hidden>

        * l4/gnu/ipc.h: (l4_string_buffer): New function.

--- hurd-l4/libl4/l4/gnu/ipc.h  2004-10-28 21:20:04.000000000 +0200
+++ hurd-l4-string/libl4/l4/gnu/ipc.h   2005-01-07 15:50:14.000000000 +0100
@@ -214,6 +214,14 @@ typedef _L4_cache_allocation_hint_t l4_c
 #define L4_use_default_cache_line_allocation \
   _L4_use_default_cache_line_allocation
 
+static inline _L4_string_item_t
+_L4_attribute_always_inline
+l4_string_item (int length, void *address)
+{
+  return _L4_string_item (length, address);
+}
+
+
 static inline bool
 _L4_attribute_always_inline
 l4_is_string_item (l4_string_item_t *string_item)

Adding substrings to a a string item was "working": 
the code of _L4_add_substring_address_to is (basically) the same as
the one of _L4_msg_buffer_append_simple_rcv_string, but we use it
differently: we start with an empty msg_buffer, whereas we start with
a yet initialised string_item when adding compound strings (so we
don't have the "first append" problem)

But there was some other problems:

-The functions _L4_add_substring_address_to and _L4_add_substring_to
 were "inversed" (each was doing the other's job). They were inversed
 in ipc.h and gnu/ipc.h, but not in the compatibility interface.
-There was an additional +1 in _L4_add_substring_address_to (that is,
 the new _L4_add_substring_address_to :)), which should't have been
 here.

this patch corrects them.

2005-01-07  Matthieu Lemerre  <address@hidden>

        * l4/ipc.h (_L4_add_substring_to, _L4_add_substring_address_to):
        Exchanged the two functions, and corrected a range bug in the new
        add_substring_to.
        * l4/gnu/ipc.h (l4_add_substring_to, l4_add_substring_address_to):
        Exchanged the two functions.

--- hurd-l4/libl4/l4/gnu/ipc.h  2004-10-28 21:20:04.000000000 +0200
+++ hurd-l4-string/libl4/l4/gnu/ipc.h   2005-01-07 15:50:14.000000000 +0100
@@ -248,8 +256,7 @@ l4_substring (l4_string_item_t *string_i
 
 static inline l4_string_item_t *
 _L4_attribute_always_inline
-l4_add_substring_address_to (l4_string_item_t *string_item,
-                            l4_string_item_t *source)
+l4_add_substring_address_to (l4_string_item_t *string_item, void *source)
 {
   return _L4_add_substring_address_to (string_item, source);
 }
@@ -257,7 +264,8 @@ l4_add_substring_address_to (l4_string_i
 
 static inline l4_string_item_t *
 _L4_attribute_always_inline
-l4_add_substring_to (l4_string_item_t *string_item, void *source)
+l4_add_substring_to (l4_string_item_t *string_item,
+                    l4_string_item_t *source)
 {
   return _L4_add_substring_to (string_item, source);
 }
diff -Naurp /home/racin/src/hurd/hurd-l4-bak/libl4/l4/ipc.h 
/home/racin/src/hurd/hurd-l4-string/libl4/l4/ipc.h
--- hurd-l4/libl4/l4/ipc.h      2004-10-08 01:02:26.000000000 +0200
+++ hurd-l4-string/libl4/l4/ipc.h       2005-01-07 15:39:16.000000000 +0100
@@ -377,7 +377,7 @@ _L4_substring (_L4_string_item_t *string
    described by string item STRING_ITEM.  */
 static inline _L4_string_item_t *
 _L4_attribute_always_inline
-_L4_add_substring_address_to (_L4_string_item_t *string_item,
+_L4_add_substring_to (_L4_string_item_t *string_item,
                              _L4_string_item_t *source)
 {
   __L4_string_item_t *target = (__L4_string_item_t *) string_item;
@@ -413,7 +413,7 @@ _L4_add_substring_address_to (_L4_string
    (of the same length) to the string item STRING_ITEM.  */
 static inline _L4_string_item_t *
 _L4_attribute_always_inline
-_L4_add_substring_to (_L4_string_item_t *string_item, void *source)
+_L4_add_substring_address_to (_L4_string_item_t *string_item, void *source)
 {
   __L4_string_item_t *target = (__L4_string_item_t *) string_item;
 
@@ -424,7 +424,7 @@ _L4_add_substring_to (_L4_string_item_t 
 
   /* Now add the source substring.  */
   target->nr_substrings++;
-  target->string[target->nr_substrings + 1] = (_L4_word_t) source;
+  target->string[target->nr_substrings] = (_L4_word_t) source;
 
   return string_item;
 }

I now better understand the string_item things, and finally I realize
that teh interface functions are sufficient to create any string item
you want (I was thinking you had to create it by the hand before).

-Finally, here is the patch to the msg_buffer_append functions

2005-01-07  Matthieu Lemerre  <address@hidden>

        * l4/ipc.h: (_L4_msg_buffer_clear)
        (_L4_msg_buffer_append_simple_rcv_string)
        (_L4_msg_buffer_append_rcv_string): Looks the 2nd element of a
        msg_buffer for knowing where to append strings.

diff -Naurp hurd-l4/libl4/l4/ipc.h hurd-l4-string/libl4/l4/ipc.h
--- hurd-l4/libl4/l4/ipc.h      2004-10-08 01:02:26.000000000 +0200
+++ hurd-l4-string/libl4/l4/ipc.h       2005-01-07 15:39:16.000000000 +0100
@@ -635,7 +635,7 @@ static inline void
 _L4_attribute_always_inline
 _L4_msg_buffer_clear (_L4_msg_buffer_t msg_buffer)
 {
-  msg_buffer[0] = 0;
+  msg_buffer[0] = msg_buffer[2] = 0;
 }
 
 
@@ -650,15 +650,22 @@ _L4_msg_buffer_append_simple_rcv_string
 
   _string_item.raw = string_item;
 
-  do
+  if (msg_buffer[0] == 0 && msg_buffer[2] == 0)
     {
-      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);
+      msg_buffer[2] = ~0;
+    }
+  else
+    {
+      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;
@@ -676,17 +683,25 @@ _L4_msg_buffer_append_rcv_string (_L4_ms
   _L4_word_t *brp;
   int cont;
 
-  /* Find the end of the message buffer.  */
-  do
+  /* Check whether the message buffer is empty */
+  if (msg_buffer[0] == 0 && msg_buffer[2] == 0)
     {
-      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);
+      msg_buffer[2] = ~0;
     }
-  while (cont);
-
+  else
+    {
+      /* Find the end of the message buffer.  */
+      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);
+    }
+  
   brp = (_L4_word_t *) target;
 
   /* Copy the source string.  */


*I also included a libl4 test file I wrote (not very beautiful code or
 design, but it's a beginning)

#include <config.h>
#include <l4.h>
#include <assert.h>



/* Message Tags */

/* Functions : 

l4_is_msg_tag_equal
l4_is_msg_tag_not_equal
l4_label
l4_untyped_words
l4_typed_words
l4_msg_tag_add_label
l4_msg_tag_add_label_to
l4_msg_tag_set_label
l4_msg_tag_set_untyped_words 
l4_msg_tag_set_typed_words 
l4_msg_tag
l4_set_msg_tag

*/


/* Map items.  */

/* Functions : 

l4_map_item
l4_is_map_item
l4_map_item_snd_fpage
l4_map_item_snd_base

*/

/* Grant items.  */

/* Functions :
   
l4_grant_item
l4_is_grant_item
l4_grant_item_snd_fpage
l4_grant_item_snd_base

*/

/* String items.  */

/* Functions:

l4_string_item
l4_is_string_item
l4_compound_string
l4_substrings
l4_substring
l4_add_substring_address_to 
l4_add_substring_to
l4_add_cache_allocation_hint 
l4_add_cache_allocation_hint_to 

*/

void test_string_items()
{
  char *string_test = "test", *string_test2 = "test2", *string_test3 = "test3";
  l4_string_item_t string_item, string_item2;
  l4_string_item_t compound_string_item[3];
  l4_cache_allocation_hint_t hint;

  /* Simple string tests */
  
  string_item = l4_string_item (sizeof("test"), string_test);
  
  assert (l4_is_string_item (&string_item));
  assert (l4_substrings (&string_item) == 1);
  assert (l4_substring (&string_item,0) == string_test);
  assert (l4_compound_string (&string_item) == 0);

  /* Compound string tests */
  
  *compound_string_item = l4_string_item (sizeof("test2"), string_test2);
  l4_add_substring_address_to (compound_string_item, string_test3);
  l4_add_substring_to (compound_string_item, &string_item);

  assert (l4_compound_string (compound_string_item) == 1);
  assert (l4_substring (compound_string_item, 0) == string_test2);
  assert (l4_substring (compound_string_item, 1) == string_test3);
  /* We have to skip the new length word */
  assert (l4_substring (compound_string_item, 3) == string_test);

  
  /* Allocation hint tests */
  
  hint = l4_cache_allocation_hint (string_item);
  
  string_item2 = l4_add_cache_allocation_hint (string_item, 0);
  assert (l4_cache_allocation_hint (string_item2) == 0);
  
  assert (l4_add_cache_allocation_hint (string_item, hint) == string_item);

  l4_add_cache_allocation_hint_to (&string_item, 3);
  assert (l4_cache_allocation_hint (string_item) == 3);
}


/* Acceptors and message buffers.  */

/* Functions :

l4_map_grant_items
l4_add_acceptor
l4_add_acceptor_to
l4_remove_acceptor
l4_remove_acceptor_from
l4_has_string_items
l4_has_map_grant_items
l4_rcv_window
l4_accept
l4_accept_strings
l4_accepted
l4_msg_buffer_clear
l4_msg_buffer_append_simple_rcv_string 
l4_msg_buffer_append_rcv_string 

*/

void test_acceptors_msg_buffers()
{

  /* Message buffers tests */
  
  l4_msg_buffer_t msg_buffer;
  l4_msg_buffer_clear (msg_buffer);

  char *string_test = "test", *string_test2 = "test2", *string_test3 = "test3";
  l4_string_item_t string_item, string_item2, string_item3;

  string_item = _L4_string_item (sizeof("test"), string_test);
  string_item2 = _L4_string_item (sizeof("test2"), string_test2);
  string_item3 = _L4_string_item (sizeof("test3"), string_test3);
  
  __L4_string_item_t ptr;
  ptr.raw = string_item;
  l4_msg_buffer_append_simple_rcv_string (msg_buffer, string_item);
  l4_msg_buffer_append_simple_rcv_string (msg_buffer, string_item2);
  l4_msg_buffer_append_simple_rcv_string (msg_buffer, string_item3);
  
  
  /* We add the continuation flag to the string item, hence the | 1 */
  assert ( (ptr.mr[0] | 1) == msg_buffer[0] && ptr.mr[1] == msg_buffer[1]);
  ptr.raw = string_item2;
  assert ( (ptr.mr[0] | 1) == msg_buffer[2] && ptr.mr[1] == msg_buffer[3]);
  ptr.raw = string_item3;
  assert ( ptr.mr[0] == msg_buffer[4] && ptr.mr[1] == msg_buffer[5]);
  
  /* Test of adding compound string items */

  

  //
  //l4_msg_buffer_append_simple_rcv_string (msg_buffer, string_item);
  //l4_msg_buffer_append_simple_rcv_string (msg_buffer, string_item);
  //printf("message buffer: 0:%x 1:%x 2:%x 3:%x\n", msg_buffer[0], 
msg_buffer[1], msg_buffer[2], msg_buffer[3]);
  //msg
}



/* Message composition.  */

/* Functions :

l4_msg_put 
l4_msg_get
l4_msg_msg_tag
l4_set_msg_msg_tag
l4_msg_label
l4_set_msg_label
l4_msg_load
l4_msg_store
l4_msg_clear
l4_msg_append_word
l4_msg_append_map_item
l4_msg_append_grant_item
l4_msg_append_simple_string_item 
l4_msg_append_string_item
l4_msg_put_word
l4_msg_put_map_item
l4_msg_put_grant_item
l4_msg_put_simple_string_item 
l4_msg_put_string_item 
l4_msg_word
l4_msg_get_word 
l4_msg_get_map_item
l4_msg_get_grant_item
l4_msg_get_string_item 

*/


/* IPC interface.  */

/* Functions :
   
l4_timeouts
l4_ipc 
l4_lipc 
l4_call_timeouts 
l4_call
l4_send_timeout
l4_send
l4_reply
l4_receive_timeout
l4_receive
l4_wait_timeout
l4_wait
l4_reply_wait_timeout 
l4_reply_wait
l4_sleep
l4_lcall
l4_lreply_wait
l4_ipc_succeeded
l4_ipc_failed
l4_ipc_propagated
l4_ipc_redirected
l4_ipc_xcpu
l4_set_propagation
l4_clear_propagation

*/





int
main (int argc, char *argv[])
{
  test_string_items();
  test_acceptors_msg_buffers();
}
Now, if you have something else to keep me busy, I'll take it :)

Thanks,
Matthieu

reply via email to

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