home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / patches / gcc-2_95_2-x86-win32-patches.zi / gcc-2.95.2-patches / broken-down / gcc-2.95.2-win32-shared-seg.diff < prev    next >
Encoding:
Text File  |  1999-11-08  |  3.3 KB  |  87 lines

  1. Sat Aug  7 00:38:21 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  2.     
  3.     * i386/winnt.c (i386_pe_valid_decl_attribute_p): Recognize
  4.     shared as a valid attribute.
  5.     * i386/cygwin.h (ASM_OUTPUT_SECTION): Handle shared attribute.
  6.     * extend.texi: Document `shared' variable attribute.
  7.  
  8. Index: gcc-2.95.2/gcc/extend.texi
  9. ===================================================================
  10. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/extend.texi,v
  11. retrieving revision 1.1.1.1
  12. diff -u -3 -p -r1.1.1.1 extend.texi
  13. --- gcc-2.95.2/gcc/extend.texi    1999/11/05 01:09:42    1.1.1.1
  14. +++ gcc-2.95.2/gcc/extend.texi    1999/11/05 08:11:35
  15. @@ -1998,6 +1998,32 @@ attribute is not available on all platfo
  16.  If you need to map the entire contents of a module to a particular
  17.  section, consider using the facilities of the linker instead.
  18.  
  19. +@item shared
  20. +@cindex @code{shared} variable attribute
  21. +On Windows NT, in addition to nputting variable definitions in a named 
  22. +section, the section can also be shared among all running copies of an 
  23. +executable or DLL. For example, this small program defines shared data 
  24. +by putting it in a named section "shared" and marking the section 
  25. +shareable:
  26. +
  27. +@smallexample
  28. +int foo __attribute__((section ("shared"), shared)) = 0;
  29. +
  30. +int
  31. +main()
  32. +@{
  33. +  /* Read and write foo. All running copies see the same value. */
  34. +  return 0;
  35. +@}
  36. +@end smallexample
  37. +
  38. +@noindent
  39. +You may only use the @code{shared} attribute along with @code{section}
  40. +attribute with a fully initialized global definition because of the way 
  41. +linkers work.  See @code{section} attribute for more information.
  42. +
  43. +The @code{shared} attribute is only available on Windows NT.
  44. +
  45.  @item transparent_union
  46.  This attribute, attached to a function parameter which is a union, means
  47.  that the corresponding argument may have the type of any union member,
  48. Index: gcc-2.95.2/gcc/config/i386/cygwin.h
  49. ===================================================================
  50. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/config/i386/cygwin.h,v
  51. retrieving revision 1.3
  52. diff -u -3 -p -r1.3 cygwin.h
  53. --- gcc-2.95.2/gcc/config/i386/cygwin.h    1999/11/05 08:11:20    1.3
  54. +++ gcc-2.95.2/gcc/config/i386/cygwin.h    1999/11/05 08:11:35
  55. @@ -404,7 +404,14 @@ do {                                    \
  56.    else if (DECL && DECL_READONLY_SECTION (DECL, RELOC))            \
  57.      type = SECT_RO, mode = "";                        \
  58.    else                                    \
  59. -    type = SECT_RW, mode = "w";                        \
  60. +    {                                    \
  61. +      type = SECT_RW;                            \
  62. +      if (TREE_CODE (DECL) == VAR_DECL                    \
  63. +          && lookup_attribute ("shared", DECL_MACHINE_ATTRIBUTES (DECL))) \
  64. +        mode = "ws";                            \
  65. +      else                                \
  66. +        mode = "w";                            \
  67. +    }                                    \
  68.                                      \
  69.    if (s == 0)                                \
  70.      {                                    \
  71. Index: gcc-2.95.2/gcc/config/i386/winnt.c
  72. ===================================================================
  73. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/config/i386/winnt.c,v
  74. retrieving revision 1.2
  75. diff -u -3 -p -r1.2 winnt.c
  76. --- gcc-2.95.2/gcc/config/i386/winnt.c    1999/11/05 05:42:40    1.2
  77. +++ gcc-2.95.2/gcc/config/i386/winnt.c    1999/11/05 08:11:35
  78. @@ -56,6 +56,8 @@ i386_pe_valid_decl_attribute_p (decl, at
  79.      return 1;
  80.        if (is_attribute_p ("dllimport", attr))
  81.      return 1;
  82. +      if (is_attribute_p ("shared", attr))
  83. +    return TREE_CODE (decl) == VAR_DECL;
  84.      }
  85.  
  86.    return i386_valid_decl_attribute_p (decl, attributes, attr, args);
  87.