This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch for include the option " -fno-rtti " (C++ & DirectX finally!!!)


Hello,

Finally I got!!! With this patch it is possible to compile programs in C++
that are used of DirectX without having to reformulate its calls for C (Who
programs games it will like). Para that this is possible, is enough to
increase the options " -fno-rtti -fvtable-thunks " when it will compile the
files sources that make use of the functions of DirectX (Any part of API
Win32 that works in the same way of DirectX will also be benefitted). I just
know Linux and Windows and I cannot affirm anything on benefits that this
will bring for another systems.

I already compiled several examples in C++ for DirectX and everybody worked
without any alteration in the code.

Antonio Mendes de Oliveira Neto (anmendes@cruzeironet.com.br)

Page with binary of the project for Wn32 and tools GNU and starting from
08/03 with the files of headers for programming with DirectX already
adjusted for they work with C++.
http://www.geocities.com/SiliconValley/Sector/6364/

* cp/decl2.c : -fno-rtti (new option for C++)
* class.c : Alterations for elimination of code object when the option
" -fno-rtti " is used.

==========================================================================
--- egcs-19980721-old/gcc/cp/class.c Sat Jul 18 08:05:41 1998
+++ egcs-19980721/gcc/cp/class.c Sat Aug 01 19:24:47 1998
@@ -650,7 +650,8 @@ set_rtti_entry (virtuals, offset, type)
   if (flag_rtti)
     vfn = build1 (ADDR_EXPR, vfunc_ptr_type_node, get_tinfo_fn (type));
   else
-    vfn = build1 (NOP_EXPR, vfunc_ptr_type_node, size_zero_node);
+    return;
+/*    vfn = build1 (NOP_EXPR, vfunc_ptr_type_node, size_zero_node);*/
   TREE_CONSTANT (vfn) = 1;

   if (! flag_vtable_thunks)
@@ -1014,7 +1015,7 @@ add_virtual_function (pv, phv, has_virtu

       /* If we are using thunks, use two slots at the front, one
   for the offset pointer, one for the tdesc pointer.  */
-      if (*has_virtual == 0 && flag_vtable_thunks)
+      if (*has_virtual == 0 && flag_vtable_thunks && flag_rtti)
  {
    *has_virtual = 1;
  }
@@ -1023,8 +1024,13 @@ add_virtual_function (pv, phv, has_virtu
       {
  static tree index_table[256];
  tree idx;
- /* We skip a slot for the offset/tdesc entry.  */
- int i = ++(*has_virtual);
+        int i;
+
+        if (flag_rtti)
+          /* We skip a slot for the offset/tdesc entry.  */
+     i = ++(*has_virtual);
+        else
+     i = (*has_virtual)++;

  if (i >= 256 || index_table[i] == 0)
    {
@@ -2352,18 +2358,21 @@ skip_rtti_stuff (virtuals)
   int n;

   n = 0;
-  if (*virtuals)
-    {
-      /* We always reserve a slot for the offset/tdesc entry.  */
-      ++n;
-      *virtuals = TREE_CHAIN (*virtuals);
-    }
-  if (flag_vtable_thunks && *virtuals)
+  if (flag_rtti)
     {
-      /* The second slot is reserved for the tdesc pointer when thunks
-         are used.  */
-      ++n;
-      *virtuals = TREE_CHAIN (*virtuals);
+      if (*virtuals)
+        {
+          /* We always reserve a slot for the offset/tdesc entry.  */
+          ++n;
+          *virtuals = TREE_CHAIN (*virtuals);
+        }
+      if (flag_vtable_thunks && *virtuals)
+        {
+          /* The second slot is reserved for the tdesc pointer when thunks
+             are used.  */
+          ++n;
+          *virtuals = TREE_CHAIN (*virtuals);
+        }
     }
   return n;
 }
@@ -3983,14 +3992,15 @@ finish_struct_1 (t, warn_anon)
       if (first_vfn_base_index < 0)
  {
    /* The second slot is for the tdesc pointer when thunks are used.  */
-   if (flag_vtable_thunks)
-     pending_virtuals = tree_cons (NULL_TREE, NULL_TREE, pending_virtuals);
+   if (flag_vtable_thunks && flag_rtti)
+            pending_virtuals = tree_cons (NULL_TREE, NULL_TREE,
pending_virtuals);

-   /* The first slot is for the rtti offset.  */
-   pending_virtuals = tree_cons (NULL_TREE, NULL_TREE, pending_virtuals);
+          /* The first slot is for the rtti offset.  */
+          if (flag_rtti)
+     pending_virtuals = tree_cons (NULL_TREE, NULL_TREE, pending_virtuals);


-   set_rtti_entry (pending_virtuals, integer_zero_node, t);
-   build_vtable (NULL_TREE, t);
+          set_rtti_entry (pending_virtuals, integer_zero_node, t);
+          build_vtable (NULL_TREE, t);
  }
       else
  {
--- egcs-19980721-old/gcc/cp/decl2.c Sat Jul 18 08:05:45 1998
+++ egcs-19980721/gcc/cp/decl2.c Sat Aug 01 19:28:39 1998
@@ -488,6 +488,7 @@ static struct { char *string; int *varia
   {"enum-int-equiv", &flag_int_enum_equivalence, 1},
   {"honor-std", &flag_honor_std, 1},
   {"rtti", &flag_rtti, 1},
+  {"no-rtti", &flag_rtti, 0},
   {"xref", &flag_gnu_xref, 1},
   {"nonnull-objects", &flag_assume_nonnull_objects, 1},
   {"implement-inlines", &flag_implement_inlines, 1},



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]