[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc_bugs

Title:DEC C Problem Reporting Forum
Notice:Report DEC C++ problems in TURRIS::C_PLUS_PLUS
Moderator:CXXC::REPETETCHEON
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1299
Total number of notes:6249

1256.0. "4.0B Unix unaligned access problem" by COMICS::EDWARDSN (Dulce et decorum est pro PDP program) Wed Jan 22 1997 05:50

T.RTitleUserPersonal
Name
DateLines
1256.1The development compiler exhibits the same problemCXXC::REINIGThis too shall changeWed Jan 22 1997 10:065
1256.2CXXC::REINIGThis too shall changeWed Jan 22 1997 12:054
1256.3DECCXL::MARIOWed Jan 22 1997 15:1120
1256.4Unique to (constant << unknown) in an addressWIBBIN::NOYCEPulling weeds, pickin&#039; stonesWed Jan 22 1997 15:2310
1256.5examples?MUCTEC::BECKERHartmut B., VMS &amp; Languages, MunichThu Jan 23 1997 03:5913
1256.6TLE::PHILLIPSThu Jan 23 1997 09:3941
1256.7my exampleMUCTEC::BECKERHartmut B., VMS &amp; Languages, MunichFri Jan 24 1997 05:4391
                                Source Listing                  24-Jan-1997 11:33:29    DEC C V5.2-023                  Page 1 	    
                                                                24-Jan-1997 11:33:03    foo.c

	      1 extern char	globalString[8];
	      2 
	      3 void bar (int*);
	      4 
	      5 void foo (char *parameterString) {
	      6 
	      7 	int	i;
	      8 
	      9 	i= *(__unaligned int*)globalString;
	     10 	bar (&i);
	     11 
	     12 	i= *(__unaligned int*)parameterString;
	     13 	bar (&i);
	     14 }

                                Machine Code Listing            24-Jan-1997 11:33:29    DEC C V5.2-023                  Page 2 	    
                                foo                             24-Jan-1997 11:33:03    foo.c

				.section .text, OCTA, exe, nord, nowrt
	     0000	foo::												    ; 000005
27BB0001     0000		ldah	gp, foo					; gp, (r27)
23BD8090     0004		lda	gp, foo					; gp, (gp)
23DEFFE0     0008		lda	sp, -32(sp)				; sp, -32(sp)
A43D8018     000C		ldq	r1, globalString			; r1, 8(gp)				    ; 000009
A77D8010     0010		ldq	r27, bar				; r27, (gp)				    ; 000010
B53E0008     0014		stq	r9, 8(sp)				; r9, 8(sp)				    ; 000005
A0210000     0018		ldl	r1, globalString			; r1, (r1)				    ; 000009
47F00409     001C		mov	r16, parameterString			; r16, r9				    ; 000005
B75E0000     0020		stq	r26, (sp)				; r26, (sp)
221E0010     0024		lda	r16, i					; r16, 16(sp)				    ; 000010
B03E0010     0028		stl	r1, i					; r1, 16(sp)				    ; 000009
6B5B4000     002C		jsr	r26, bar				; r26, r27				    ; 000010
27BA0001     0030		ldah	gp, foo					; gp, (r26)
2C290000     0034		ldq_u	r1, (r9)				; r1, (r9)				    ; 000012
2C490003     0038		ldq_u	r2, 3(r9)				; r2, 3(r9)
23BD8090     003C		lda	gp, foo					; gp, (gp)				    ; 000010
221E0010     0040		lda	r16, i					; r16, 16(sp)				    ; 000013
A77D8010     0044		ldq	r27, bar				; r27, (gp)
482904C1     0048		extll	r1, r9, r1				; r1, r9, r1				    ; 000012
48490D42     004C		extlh	r2, r9, r2				; r2, r9, r2
44220400     0050		bis	r1, r2, r0				; r1, r2, r0
B01E0010     0054		stl	r0, i					; r0, 16(sp)
6B5B4000     0058		jsr	r26, bar				; r26, r27				    ; 000013
27BA0001     005C		ldah	gp, foo					; gp, (r26)
A75E0000     0060		ldq	r26, (sp)				; r26, (sp)				    ; 000014
23BD8090     0064		lda	gp, foo					; gp, (gp)				    ; 000013
A53E0008     0068		ldq	r9, 8(sp)				; r9, 8(sp)				    ; 000014
23DE0020     006C		lda	sp, 32(sp)				; sp, 32(sp)
6BFA8001     0070		ret	r26					; r26

Routine Size: 116 bytes,    Routine Base: .text + 0000


				.section .lita, QUAD, noexe, rd, nowrt
00000000     0000		.address  bar
00000000     0008		.address  globalString

				.section .xdata, QUAD, noexe, nord, nowrt

	     0000		; Procedure descriptor foo
				; flags :short
				; rsa_offset           : 0
				; imask                : 0x02
				; fmask                : 0x00
				; frame_size           : 4
				; sp_set               : 2
				; entry_length         : 6

				.section .pdata, QUAD, noexe, nord, nowrt

	     0000		; Code range descriptor for foo
00000000			beginaddress	    : 0
00000000			rpd_offset	    : 0
00000000			flags: - no flags set


                                Source Listing                  24-Jan-1997 11:33:29    DEC C V5.2-023                  Page 3 	    
                                                                24-Jan-1997 11:33:03    foo.c

Command Line
------- ----

cc -noansi_alias -no_ansi_args -double -g0 -assume notrusted_short_alignment
 -writable_strings -source_listing -machine_code -member_alignment -object
 -O4 -tune generic -show header -show source -signed -std0 -weak_volatile
 -D__LANGUAGE_C__ -D__unix__ -D__osf__ -D__alpha -D_SYSTYPE_BSD -D_LONGLONG
 -DLANGUAGE_C -Dunix -DSYSTYPE_BSD
 -I/usr/include
1256.8GEMEVN::GLOSSOPOnly the paranoid surviveFri Jan 24 1997 11:2720
There are 2 types of alignment:

    - definite - storage allocated in the local stack frame, globals, statics,
      etc., where the run-time allocation can't wind up being unaligned
      as the result of programmer action - like taking an address partway
      into an array or some other method of creating an unaligned pointer.

    - probable - storage referenced in a way that the actual allocation
      can't be determined at compile time - typically pointer accessed
      or the equivalent.

Definite is stronger information than simply probable.  "__unaligned"
states that the probable alignment is only byte, but that does not prevent
the compiler from (for example) allocating a local variable on a more
strongly aligned boundary and using that knowledge, using knowledge
that globals are quad aligned and padded (on Unix and NT only), etc.
(i.e. __unaligned is just like every other description in the program -
it's something that has to be done *unless* the compiler knows there
is a functionally equivalent thing that is an improvement - e.g. dead
code removal, a wide variety of optimization transforms, etc.)