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]
Other format: [Raw text]

[PATCH] Support #pragma pack(reset) for z/TPF


Hello,

when porting z/TPF applications to GCC, one compatibility issue that
came up is that the z/OS IBM xlc compiler supports
  #pragma pack(reset)
to restore default alignment, like GCC's #pragma pack().

As a compatibility aid, the following patch provided by Jim Tison 
of the TPF team adds GCC support for this pragma.  This support
is guarded by a new target macro HANDLE_PRAGMA_PACK_RESET, analogous
to the existing HANDLE_PRAGMA_PACK_PUSH_POP macro.

Tested on s390x-ibm-tpf by the TPF team.
OK for mainline?

Bye,
Ulrich


2005-10-10  Jim Tison  <jtison@us.ibm.com>

	* c-pragma.c (handle_pragma_pack): Support #pragma pack(reset)
	as an option, guarded by HANDLE_PRAGMA_PACK_RESET.
	* config/s390/tpf.h (HANDLE_PRAGMA_PACK_RESET): Define.
	* doc/tm.texi: Document HANDLE_PRAGMA_PACK_RESET.
	* doc/extend.texi: Add z/TPF section.  Document #pragma pack(reset).

Index: gcc/c-pragma.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/c-pragma.c,v
retrieving revision 1.91
diff -u -p -r1.91 c-pragma.c
--- gcc/c-pragma.c	19 Jul 2005 20:19:12 -0000	1.91
+++ gcc/c-pragma.c	10 Oct 2005 15:47:56 -0000
@@ -176,6 +176,13 @@ handle_pragma_pack (cpp_reader * ARG_UNU
 	action = push;
       else if (!strcmp (op, "pop"))
 	action = pop;
+#ifdef HANDLE_PRAGMA_PACK_RESET
+      else if (!strcmp (op, "reset")) 
+        {
+        action = set;
+        align = initial_max_fld_align;
+        }
+#endif      
       else
 	GCC_BAD2 ("unknown action %qs for %<#pragma pack%> - ignored", op);
 
Index: gcc/config/s390/tpf.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/s390/tpf.h,v
retrieving revision 1.10
diff -u -p -r1.10 tpf.h
--- gcc/config/s390/tpf.h	13 Jul 2005 18:15:43 -0000	1.10
+++ gcc/config/s390/tpf.h	10 Oct 2005 15:48:00 -0000
@@ -33,6 +33,7 @@ Software Foundation, 51 Franklin Street,
 #define ASM_APP_OFF "#NO_APP\n"
 #define NO_IMPLICIT_EXTERN_C
 #define TARGET_POSIX_IO
+#define HANDLE_PRAGMA_PACK_RESET
 
 #undef  SIZE_TYPE
 #define SIZE_TYPE ("long unsigned int")
Index: gcc/doc/extend.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/extend.texi,v
retrieving revision 1.268
diff -u -p -r1.268 extend.texi
--- gcc/doc/extend.texi	5 Oct 2005 08:27:44 -0000	1.268
+++ gcc/doc/extend.texi	10 Oct 2005 15:48:11 -0000
@@ -9201,6 +9201,7 @@ for further explanation.
 * Symbol-Renaming Pragmas::
 * Structure-Packing Pragmas::
 * Weak Pragmas::
+* z/TPF Pragmas::
 @end menu
 
 @node ARM Pragmas
@@ -9439,6 +9440,25 @@ either its first use or its definition. 
 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
 It is an error if @var{symbol2} is not defined in the current
 translation unit.
+@end table
+
+@node z/TPF Pragmas
+@subsection z/TPF Pragmas
+
+For compatibility with C code written for TPF 4.1 and earlier, the 
+following pragmas are supported to ease code portablity to GCC:
+
+@table @code
+@item #pragma pack(reset)
+@cindex pragma, pack(reset)
+This pragma is the functional equivalent of and alias for GCC's 
+@samp{#pragma pack()}, and is added as a code portability aid.
+The z/OS xlc compiler treats a @samp{#pragma pack()} as if it meant
+@samp{#pragma pack(4)}. GCC does no such thing. Instead, 
+@samp{#pragma pack(reset)} 
+causes a reset of packing practice to what it was when compilation 
+was started. z/OS xlc handles @samp{#pragma pack(reset)} as causing
+a return to natural alignment.
 @end table
 
 @node Unnamed Fields
Index: gcc/doc/tm.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.446
diff -u -p -r1.446 tm.texi
--- gcc/doc/tm.texi	19 Aug 2005 21:16:20 -0000	1.446
+++ gcc/doc/tm.texi	10 Oct 2005 15:48:22 -0000
@@ -9138,6 +9138,15 @@ This must be a value that would also val
 @samp{#pragma pack()} (that is, a small power of two).
 @end defmac
 
+@findex #pragma
+@findex pragma
+@defmac HANDLE_PRAGMA_PACK_RESET
+Define this macro (value not relevant) if you want to support the 
+z/OS xlc definition of @samp{#pragma pack(reset)}. If enabled,
+this pragma behaves identically to @samp{#pragma pack()}, which acts
+to restore natural alignment.
+@end defmac
+
 @defmac DOLLARS_IN_IDENTIFIERS
 Define this macro to control use of the character @samp{$} in
 identifier names for the C family of languages.  0 means @samp{$} is
-- 
  Dr. Ulrich Weigand
  Linux on zSeries Development
  Ulrich.Weigand@de.ibm.com


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