Skip to content

Commit

Permalink
2008-04-13 Thomas Koenig <[email protected]>
Browse files Browse the repository at this point in the history
	Francois-Xavier Coudert  <[email protected]>

	PR libfortran/32972
	PR libfortran/32512
	configure.ac:  Add test for uintptr_t.
	configure:  Regenerated.
	config.h.in:  Regenerated.
	* libgfortran.h: GFC_DTYPE_DERIVED_1:  New macro.
	GFC_DTYPE_DERIVED_2:  New macro.
	GFC_DTYPE_DERIVED_4:  New macro.
	GFC_DTYPE_DERIVED_8:  New macro.
	GFC_DTYPE_DERIVED_16:  New macro.
	GFC_UNALIGNED_2:  New macro.
	GFC_UNALIGNED_4:  New macro.
	GFC_UNALIGNED_8:  New macro.
	GFC_UNALIGNED_16:  New macro.
	intptr_t:  Define if we don't have it.
	uintptr_t:  Likewise.
	* runtime/backtrace.c (show_backtrace):  Use intptr_t.
	* intrinsics/signal.c (signal_sub):  Likewise.
	(signal_sub_int):  Likewise.
	(alarm_sub_int_i4):  Likewise.
	* intrinsics/spread_generic.c (spread):  Use the integer
	routines for handling derived types of sizes 1, 2, 4, 8 and 16
	if the alignment of all pointers is correct.
	(spread_scalar):  Likewise.
	* intrinsics/pack_generic.c (pack):  Likewise.
	Use GFD_DTYPE_TYPE_SIZE to avoid nested switch statements.
	* intrinsics/unpack_generic.c (unpack1):  Likewise.
	(unpack0):  Likewise.
	* runtime/in_pack_generic.c (internal_pack):  Likewise.
	* runtime/in_unpack_generic.c (internal_unpack):  Likewise.

2008-04-13  Thomas Koenig  <[email protected]>

	PR libfortran/32972
	PR libfortran/32512
	* gfortran.dg/internal_pack_1.f90:  Add test for derived type.
	* gfortran.dg/intrinsic_spread_1.f90:  Likewise.
	* gfortran.dg/intrinsic_pack_1.f90:  Likewise.
	* gfortran.dg/intrinsic_unpack_1.f90:  Likewise.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134245 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
tkoenig committed Apr 13, 2008
1 parent 5207e71 commit ed3634f
Show file tree
Hide file tree
Showing 17 changed files with 830 additions and 341 deletions.
9 changes: 9 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2008-04-13 Thomas Koenig <[email protected]>

PR libfortran/32972
PR libfortran/32512
* gfortran.dg/internal_pack_1.f90: Add test for derived type.
* gfortran.dg/intrinsic_spread_1.f90: Likewise.
* gfortran.dg/intrinsic_pack_1.f90: Likewise.
* gfortran.dg/intrinsic_unpack_1.f90: Likewise.

2008-04-13 Samuel Tardieu <[email protected]>

PR ada/17985
Expand Down
21 changes: 21 additions & 0 deletions gcc/testsuite/gfortran.dg/internal_pack_1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ program main
real(kind=8), dimension(3) :: r8
complex(kind=4), dimension(3) :: c4
complex(kind=8), dimension(3) :: c8
type i8_t
sequence
integer(kind=8) :: v
end type i8_t
type(i8_t), dimension(3) :: d_i8

i1 = (/ -1, 1, -3 /)
call sub_i1(i1(1:3:2))
Expand Down Expand Up @@ -46,6 +51,10 @@ program main
if (any(real(c8) /= (/ 3.0_4, 1.0_4, 2.0_4/))) call abort
if (any(aimag(c8) /= 0._4)) call abort

d_i8%v = (/ -1, 1, -3 /)
call sub_d_i8(d_i8(1:3:2))
if (any(d_i8%v /= (/ 3, 1, 2 /))) call abort

end program main

subroutine sub_i1(i)
Expand Down Expand Up @@ -113,3 +122,15 @@ subroutine sub_c4(r)
r(1) = 3._4
r(2) = 2._4
end subroutine sub_c4

subroutine sub_d_i8(i)
type i8_t
sequence
integer(kind=8) :: v
end type i8_t
type(i8_t), dimension(2) :: i
if (i(1)%v /= -1) call abort
if (i(2)%v /= -3) call abort
i(1)%v = 3
i(2)%v = 2
end subroutine sub_d_i8
28 changes: 28 additions & 0 deletions gcc/testsuite/gfortran.dg/intrinsic_pack_1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@ program main
integer(kind=8), dimension(9) :: vi8
integer(kind=8), dimension(9) :: ri8

type i1_t
integer(kind=1) :: v
end type i1_t
type(i1_t), dimension(3,3) :: d_i1
type(i1_t), dimension(9) :: d_vi1
type(i1_t), dimension(9) :: d_ri1

type i4_t
integer(kind=4) :: v
end type i4_t
type(i4_t), dimension(3,3) :: d_i4
type(i4_t), dimension(9) :: d_vi4
type(i4_t), dimension(9) :: d_ri4

d_vi1%v = (/(i+10,i=1,9)/)
d_i1%v = reshape((/1_1, -1_1, 2_1, -2_1, 3_1, -3_1, 4_1, &
& -4_1, 5_1/), shape(i1))
d_ri1 = pack(d_i1,d_i1%v>0,d_vi1)
if (any(d_ri1%v /= (/1_1, 2_1, 3_1, 4_1, 5_1, 16_1, 17_1, 18_1, 19_1/))) &
& call abort

d_vi4%v = (/(i+10,i=1,9)/)
d_i4%v = reshape((/1_4, -1_4, 2_4, -2_4, 3_4, -3_4, 4_4, &
& -4_4, 5_4/), shape(d_i4))
d_ri4 = pack(d_i4,d_i4%v>0,d_vi4)
if (any(d_ri4%v /= (/1_4, 2_4, 3_4, 4_4, 5_4, 16_4, 17_4, 18_4, 19_4/))) &
& call abort

vr4 = (/(i+10,i=1,9)/)
r4 = reshape((/1.0_4, -3.0_4, 2.1_4, -4.21_4, 1.2_4, 0.98_4, -1.2_4, &
& -7.1_4, -9.9_4, 0.3_4 /), shape(r4))
Expand Down
19 changes: 19 additions & 0 deletions gcc/testsuite/gfortran.dg/intrinsic_spread_1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ program foo
complex(kind=8), dimension (10) :: c_8
complex(kind=8), dimension (2, 3) :: ac_8
complex(kind=8), dimension (2, 2, 3) :: bc_8
type i4_t
integer(kind=4) :: v
end type i4_t
type(i4_t), dimension (10) :: it_4
type(i4_t), dimension (2, 3) :: at_4
type(i4_t), dimension (2, 2, 3) :: bt_4
type(i4_t) :: iv_4

character (len=200) line1, line2, line3

a_1 = reshape ((/1_1, 2_1, 3_1, 4_1, 5_1, 6_1/), (/2, 3/))
Expand Down Expand Up @@ -159,6 +167,17 @@ program foo
c_8 = spread((1._8,-1._8),1,10)
if (any(c_8 /= (1._8,-1._8))) call abort


at_4%v = reshape ((/1_4, 2_4, 3_4, 4_4, 5_4, 6_4/), (/2, 3/))
bt_4 = spread (at_4, 1, 2)
if (any (bt_4%v .ne. reshape ((/1_4, 1_4, 2_4, 2_4, 3_4, 3_4, 4_4, &
& 4_4, 5_4, 5_4, 6_4, 6_4/), (/2, 2, 3/)))) &
call abort
iv_4%v = 123_4
it_4 = spread(iv_4,1,10)
if (any(it_4%v /= 123_4)) call abort


9000 format(12I3)
9010 format(12F7.3)
9020 format(25F7.3)
Expand Down
16 changes: 16 additions & 0 deletions gcc/testsuite/gfortran.dg/intrinsic_unpack_1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ program intrinsic_unpack
real(kind=8), dimension(3,3) :: ar8, br8
complex(kind=4), dimension(3,3) :: ac4, bc4
complex(kind=8), dimension(3,3) :: ac8, bc8
type i4_t
integer(kind=4) :: v
end type i4_t
type(i4_t), dimension(3,3) :: at4, bt4
type(i4_t), dimension(3) :: vt4

logical, dimension(3, 3) :: mask
character(len=500) line1, line2
integer i
Expand Down Expand Up @@ -116,4 +122,14 @@ program intrinsic_unpack
mask, ac8)
if (line1 .ne. line2) call abort

at4%v = reshape ((/1, 0, 0, 0, 1, 0, 0, 0, 1/), (/3, 3/));
vt4%v = (/2_4, 3_4, 4_4/)
bt4 = unpack (vt4, mask, at4)
if (any (bt4%v .ne. reshape ((/1, 2, 0, 3, 1, 0, 0, 0, 4/), (/3, 3/)))) &
call abort
bt4%v = -1
bt4 = unpack (vt4, mask, i4_t(0_4))
if (any (bt4%v .ne. reshape ((/0, 2, 0, 3, 0, 0, 0, 0, 4/), (/3, 3/)))) &
call abort

end program
34 changes: 34 additions & 0 deletions libgfortran/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
2008-04-13 Thomas Koenig <[email protected]>
Francois-Xavier Coudert <[email protected]>

PR libfortran/32972
PR libfortran/32512
configure.ac: Add test for uintptr_t.
configure: Regenerated.
config.h.in: Regenerated.
* libgfortran.h: GFC_DTYPE_DERIVED_1: New macro.
GFC_DTYPE_DERIVED_2: New macro.
GFC_DTYPE_DERIVED_4: New macro.
GFC_DTYPE_DERIVED_8: New macro.
GFC_DTYPE_DERIVED_16: New macro.
GFC_UNALIGNED_2: New macro.
GFC_UNALIGNED_4: New macro.
GFC_UNALIGNED_8: New macro.
GFC_UNALIGNED_16: New macro.
intptr_t: Define if we don't have it.
uintptr_t: Likewise.
* runtime/backtrace.c (show_backtrace): Use intptr_t.
* intrinsics/signal.c (signal_sub): Likewise.
(signal_sub_int): Likewise.
(alarm_sub_int_i4): Likewise.
* intrinsics/spread_generic.c (spread): Use the integer
routines for handling derived types of sizes 1, 2, 4, 8 and 16
if the alignment of all pointers is correct.
(spread_scalar): Likewise.
* intrinsics/pack_generic.c (pack): Likewise.
Use GFD_DTYPE_TYPE_SIZE to avoid nested switch statements.
* intrinsics/unpack_generic.c (unpack1): Likewise.
(unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.

2008-04-09 Jakub Jelinek <[email protected]>

* io/list_read.c (snprintf): Define if HAVE_SNPRINTF isn't defined.
Expand Down
15 changes: 9 additions & 6 deletions libgfortran/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@
/* Define to 1 if you have the `ttyname' function. */
#undef HAVE_TTYNAME

/* Define to 1 if the system has the type `uintptr_t'. */
#undef HAVE_UINTPTR_T

/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H

Expand Down Expand Up @@ -805,19 +808,19 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION

/* The size of `char', as computed by sizeof. */
/* The size of a `char', as computed by sizeof. */
#undef SIZEOF_CHAR

/* The size of `int', as computed by sizeof. */
/* The size of a `int', as computed by sizeof. */
#undef SIZEOF_INT

/* The size of `long', as computed by sizeof. */
/* The size of a `long', as computed by sizeof. */
#undef SIZEOF_LONG

/* The size of `short', as computed by sizeof. */
/* The size of a `short', as computed by sizeof. */
#undef SIZEOF_SHORT

/* The size of `void *', as computed by sizeof. */
/* The size of a `void *', as computed by sizeof. */
#undef SIZEOF_VOID_P

/* Define to 1 if you have the ANSI C header files. */
Expand All @@ -835,5 +838,5 @@
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES

/* Define to `long int' if <sys/types.h> does not define. */
/* Define to `long' if <sys/types.h> does not define. */
#undef off_t
65 changes: 65 additions & 0 deletions libgfortran/configure
Original file line number Diff line number Diff line change
Expand Up @@ -18815,6 +18815,71 @@ cat >>confdefs.h <<_ACEOF
_ACEOF


fi

echo "$as_me:$LINENO: checking for uintptr_t" >&5
echo $ECHO_N "checking for uintptr_t... $ECHO_C" >&6
if test "${ac_cv_type_uintptr_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
if ((uintptr_t *) 0)
return 0;
if (sizeof (uintptr_t))
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_type_uintptr_t=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

ac_cv_type_uintptr_t=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_type_uintptr_t" >&5
echo "${ECHO_T}$ac_cv_type_uintptr_t" >&6
if test $ac_cv_type_uintptr_t = yes; then

cat >>confdefs.h <<_ACEOF
#define HAVE_UINTPTR_T 1
_ACEOF


fi


Expand Down
1 change: 1 addition & 0 deletions libgfortran/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ AC_CHECK_FUNCS(backtrace backtrace_symbols)

# Check for types
AC_CHECK_TYPES([intptr_t])
AC_CHECK_TYPES([uintptr_t])

# Check libc for getgid, getpid, getuid
AC_CHECK_LIB([c],[getgid],[AC_DEFINE([HAVE_GETGID],[1],[libc includes getgid])])
Expand Down
Loading

0 comments on commit ed3634f

Please sign in to comment.