/[rtmk]/rtmk/rig/be-c.c
ViewVC logotype

Diff of /rtmk/rig/be-c.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by jrydberg, Thu Feb 21 20:14:42 2002 UTC revision 1.9 by jrydberg, Sat Feb 23 01:41:01 2002 UTC
# Line 40  char *native_types[] = { Line 40  char *native_types[] = {
40  };  };
41    
42  size_t native_sizes[] = {  size_t native_sizes[] = {
43    4,    32,
44    1,    8,
45    4,    32,
46    4,    32,
47    4,    32,
48    4,    32,
49    4,    32,
50    4    32
51  };  };
52    
53  /* When generating prototypes, don't generate PARAMS () */  /* When generating prototypes, don't generate PARAMS () */
# Line 65  extern int is_subsystem; Line 65  extern int is_subsystem;
65     describing TYPE. NAME is the name of the argument that this     describing TYPE. NAME is the name of the argument that this
66     type belongs to.  */     type belongs to.  */
67  static void  static void
68  write_msg_type_header (type, name)  write_msg_type_header (type, name, long_p)
69       struct type *type;       struct type *type;
70       char *name;       char *name;
71         int long_p;
72  {  {
73    output ("static struct rtmk_msg_type __%s_type = {\n", name);    if (long_p)
74    indent_add ();      {
75            output ("static struct rtmk_msg_type_long __%s_type = { {\n", name);
76    output ("%s,\n", native_types [type->type]);    /* type */        indent_add ();
77    if (type->array > 0)        indent_add ();
78      output ("%d*%d\n", type->array, native_sizes [type->type]);        output ("%s,\n", native_types [type->type]);      /* type */
79    else        output ("%d,\n", native_sizes [type->type]);      /* length */
80      output ("%d,\n", native_sizes [type->type]); /* length */        output ("%d,\n", type->attrs & OUTOFLINE ? 0 : 1); /* inline */
81    if (type->attrs & OUTOFLINE)        output ("1,\n");                                  /* long format */
82      output ("FALSE,\n");                    /* inline */        output ("%d,\n", type->attrs & DEALLOCATE ? 1 : 0); /* dealloc */
83          output ("0 },\n");                                /* reserved */
84          indent_sub ();
85          output ("%d\n", type->array ?: 1);                /* number */
86          indent_sub ();
87        }
88    else    else
89      output ("TRUE,\n");                     /* inline */      {
90          output ("static struct rtmk_msg_type __%s_type = {\n", name);
91          indent_add ();
92    
93    if (type->attrs & DEALLOCATE)  #if 1
94      output ("TRUE\n");                      /* deallocate */        output ("%s,\n", native_types [type->type]);      /* type */
95    else        output ("%d,\n", native_sizes [type->type]);      /* length */
96      output ("FALSE\n");                     /* deallocate */        output ("%d,\n", type->attrs & OUTOFLINE ? 0 : 1); /* inline */
97            output ("0,\n");                                  /* long format */
98    indent_sub ();        output ("%d,\n", type->attrs & DEALLOCATE ? 1 : 0); /* dealloc */
99          output ("0,\n");                                  /* reserved */
100          output ("%d\n", type->array ?: 1);                /* number */
101    #else
102          output ("%s,\n", native_types [type->type]);    /* type */
103          if (type->array > 0)
104            output ("%d*%d\n", type->array, native_sizes [type->type]);
105          else
106            output ("%d,\n", native_sizes [type->type]); /* length */
107          if (type->attrs & OUTOFLINE)
108            output ("FALSE,\n");                    /* inline */
109          else
110            output ("TRUE,\n");                     /* inline */
111          
112          if (type->attrs & DEALLOCATE)
113            output ("TRUE\n");                      /* deallocate */
114          else
115            output ("FALSE\n");                     /* deallocate */
116    #endif
117          indent_sub ();
118        }
119    output ("};\n\n");    output ("};\n\n");
120  }  }
121    
# Line 191  write_spec_structure (name, offset, type Line 219  write_spec_structure (name, offset, type
219  {  {
220    output ("struct __%d_%s_spec {\n", offset, name);    output ("struct __%d_%s_spec {\n", offset, name);
221    indent_add();    indent_add();
222    output ("struct rtmk_msg_type __m_type;\n");  
223      if (type->attrs || type->array > 1024)
224        output ("struct rtmk_msg_type_long __m_type;\n");
225      else
226        output ("struct rtmk_msg_type __m_type;\n");
227                
228    if (type->attrs & NO_FIXED_LENGTH)    if (type->attrs & NO_FIXED_LENGTH)
229      {      {
# Line 248  target_in_decode_arg (rt, arg, side) Line 280  target_in_decode_arg (rt, arg, side)
280          }          }
281        else if (arg->type->attrs & NO_FIXED_LENGTH)        else if (arg->type->attrs & NO_FIXED_LENGTH)
282          {          {
283            output ("__rig_memcpy (%s, &__s->__m_data, __s->__m_type.msgt_length);\n",            output ("__rig_memcpy (%s, &__s->__m_data, __s->__m_type.msgtl_number);\n",
284                    arg->cname);                    arg->cname);
285          }          }
286        else        else
# Line 277  target_in_decode_arg (rt, arg, side) Line 309  target_in_decode_arg (rt, arg, side)
309    /* step forward */    /* step forward */
310    if (arg->type->attrs & NO_FIXED_LENGTH)    if (arg->type->attrs & NO_FIXED_LENGTH)
311      {      {
312        output ("\n__msgt = (struct rtmk_msg_type *) ((int) (__s + 1) + __s->__m_type.msgt_length);\n");        output ("\n__msgt = (struct rtmk_msg_type *) ((int) (__s + 1) + __s->__m_type.msgtl_number);\n");
313      }      }
314    else    else
315      {      {
# Line 293  target_out_encode_arg (rt, arg, side) Line 325  target_out_encode_arg (rt, arg, side)
325       struct argument *arg;       struct argument *arg;
326       enum side side;       enum side side;
327  {  {
328    write_msg_type_header (arg->type, arg->cname);    write_msg_type_header (arg->type, arg->cname,  /* ??? value below?  */
329                             arg->type->attrs || (arg->type->array > 1024));
330    
331    /* write a structure */    /* write a structure */
332    output ("struct __%d_%s_spec *__s = (struct __%d_%s_spec *) __msgt;\n\n",    output ("struct __%d_%s_spec *__s = (struct __%d_%s_spec *) __msgt;\n\n",
# Line 308  target_out_encode_arg (rt, arg, side) Line 341  target_out_encode_arg (rt, arg, side)
341          {          {
342            output ("__rig_strncpy (&__s->__m_data, %s, __rig_strlen (%s) + 1);\n",            output ("__rig_strncpy (&__s->__m_data, %s, __rig_strlen (%s) + 1);\n",
343                    arg->cname, arg->cname);                    arg->cname, arg->cname);
344            output ("__s->__m_type.msgt_length = __rig_strlen (%s) + 1;\n",            output ("__s->__m_type.msgtl_number = __rig_strlen (%s) + 1;\n",
345                    arg->cname);                    arg->cname);
346          }          }
347        else if (arg->type->attrs & NO_FIXED_LENGTH)        else if (arg->type->attrs & NO_FIXED_LENGTH)
# Line 322  target_out_encode_arg (rt, arg, side) Line 355  target_out_encode_arg (rt, arg, side)
355    
356                output ("__rig_memcpy (&__s->__m_data, %s, %s%s%s);\n",                output ("__rig_memcpy (&__s->__m_data, %s, %s%s%s);\n",
357                        arg->cname, star, arg->cname, TARGET_LENGTH_SUFIX);                        arg->cname, star, arg->cname, TARGET_LENGTH_SUFIX);
358                output ("__s->__m_type.msgt_length = %s%s%s;\n",                output ("__s->__m_type.msgtl_number = %s%s%s;\n",
359                        star, arg->cname, TARGET_LENGTH_SUFIX);                        star, arg->cname, TARGET_LENGTH_SUFIX);
360              }              }
361            else            else
362              {              {
363                output ("__rig_memcpy (&__s->__m_data, %s, %s%s);\n",                output ("__rig_memcpy (&__s->__m_data, %s, %s%s);\n",
364                        arg->cname, arg->cname, TARGET_LENGTH_SUFIX);                        arg->cname, arg->cname, TARGET_LENGTH_SUFIX);
365                output ("__s->__m_type.msgt_length = %s%s;\n",                output ("__s->__m_type.msgtl_number = %s%s;\n",
366                        arg->cname, TARGET_LENGTH_SUFIX, arg->type->cname);                        arg->cname, TARGET_LENGTH_SUFIX, arg->type->cname);
367              }              }
368          }          }
# Line 372  target_out_encode_arg (rt, arg, side) Line 405  target_out_encode_arg (rt, arg, side)
405              }              }
406            else            else
407              {              {
408                output ("\n__msgt = (struct rtmk_msg_type *) ((int) (__s + 1) + __s->__m_type.msgt_length);\n");                output ("\n__msgt = (struct rtmk_msg_type *) ((int) (__s + 1) + __s->__m_type.msgtl_number);\n");
409              }              }
410          }          }
411        else        else

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26