Index: libgfortran/m4/iforeach.m4
===================================================================
--- libgfortran/m4/iforeach.m4	(Revision 178930)
+++ libgfortran/m4/iforeach.m4	(Arbeitskopie)
@@ -2,15 +2,18 @@ dnl Support macro file for intrinsic functions.
 dnl Contains the generic sections of the array functions.
 dnl This file is part of the GNU Fortran 95 Runtime Library (libgfortran)
 dnl Distributed under the GNU GPL with exception.  See COPYING for details.
+define(`slen_proto',`ifelse(atype_letter,s,`, int')')dnl
+define(`slen_def',`ifelse(atype_letter,s,`, int slen')')dnl
+define(`slen_use',`ifelse(atype_letter,s,`, slen')')dnl
 define(START_FOREACH_FUNCTION,
 `
 extern void name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 
-	atype * const restrict array);
+	atype * const restrict array`'slen_proto`');
 export_proto(name`'rtype_qual`_'atype_code);
 
 void
 name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 
-	atype * const restrict array)
+	atype * const restrict array`'slen_def`')
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
@@ -104,13 +107,13 @@ define(FINISH_FOREACH_FUNCTION,
 define(START_MASKED_FOREACH_FUNCTION,
 `
 extern void `m'name`'rtype_qual`_'atype_code (rtype * const restrict, 
-	atype * const restrict, gfc_array_l1 * const restrict);
+	atype * const restrict, gfc_array_l1 * const restrict`'slen_proto`');
 export_proto(`m'name`'rtype_qual`_'atype_code);
 
 void
 `m'name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 
 	atype * const restrict array,
-	gfc_array_l1 * const restrict mask)
+	gfc_array_l1 * const restrict mask`'slen_def`')
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
@@ -235,13 +238,13 @@ FINISH_MASKED_FOREACH_FUNCTION')dnl
 define(SCALAR_FOREACH_FUNCTION,
 `
 extern void `s'name`'rtype_qual`_'atype_code (rtype * const restrict, 
-	atype * const restrict, GFC_LOGICAL_4 *);
+	atype * const restrict, GFC_LOGICAL_4 *`'slen_proto`');
 export_proto(`s'name`'rtype_qual`_'atype_code);
 
 void
 `s'name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 
 	atype * const restrict array,
-	GFC_LOGICAL_4 * mask)
+	GFC_LOGICAL_4 * mask`'slen_def`')
 {
   index_type rank;
   index_type dstride;
@@ -250,7 +253,7 @@ void
 
   if (*mask)
     {
-      name`'rtype_qual`_'atype_code (retarray, array);
+      name`'rtype_qual`_'atype_code (retarray, array`'slen_use`');
       return;
     }
 
Index: libgfortran/m4/iparm.m4
===================================================================
--- libgfortran/m4/iparm.m4	(Revision 178930)
+++ libgfortran/m4/iparm.m4	(Arbeitskopie)
@@ -4,7 +4,7 @@ dnl This file is part of the GNU Fortran 95 Runtim
 dnl Distributed under the GNU GPL with exception.  See COPYING for details.
 dnl M4 macro file to get type names from filenames
 define(get_typename2, `GFC_$1_$2')dnl
-define(get_typename, `get_typename2(ifelse($1,i,INTEGER,ifelse($1,r,REAL,ifelse($1,l,LOGICAL,ifelse($1,c,COMPLEX,unknown)))),`$2')')dnl
+define(get_typename, `get_typename2(ifelse($1,i,INTEGER,ifelse($1,r,REAL,ifelse($1,l,LOGICAL,ifelse($1,s,UINTEGER,ifelse($1,c,COMPLEX,unknown))))),`$2')')dnl
 define(get_arraytype, `gfc_array_$1$2')dnl
 define(define_type, `dnl
 ifelse(regexp($2,`^[0-9]'),-1,`dnl
Index: libgfortran/m4/ifunction.m4
===================================================================
--- libgfortran/m4/ifunction.m4	(Revision 178930)
+++ libgfortran/m4/ifunction.m4	(Arbeitskopie)
@@ -17,16 +17,19 @@ dnl atype_name and rtype_name respectively.
 dnl Execution should be allowed to continue to the end of the block.
 dnl You should not return or break from the inner loop of the implementation.
 dnl Care should also be taken to avoid using the names defined in iparm.m4
+define(`slen_proto',`ifelse(atype_letter,s,`, int')')dnl
+define(`slen_def',`ifelse(atype_letter,s,`, int slen')')dnl
+define(`slen_use',`ifelse(atype_letter,s,`, slen')')dnl
 define(START_ARRAY_FUNCTION,
 `
 extern void name`'rtype_qual`_'atype_code (rtype * const restrict, 
-	atype * const restrict, const index_type * const restrict);
+	atype * const restrict, const index_type * const restrict`'slen_proto`');
 export_proto(name`'rtype_qual`_'atype_code);
 
 void
 name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 
 	atype * const restrict array, 
-	const index_type * const restrict pdim)
+	const index_type * const restrict pdim`'slen_def`')
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
@@ -177,14 +180,14 @@ define(START_MASKED_ARRAY_FUNCTION,
 `
 extern void `m'name`'rtype_qual`_'atype_code (rtype * const restrict, 
 	atype * const restrict, const index_type * const restrict,
-	gfc_array_l1 * const restrict);
+	gfc_array_l1 * const restrict`'slen_proto`');
 export_proto(`m'name`'rtype_qual`_'atype_code);
 
 void
 `m'name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 
 	atype * const restrict array, 
 	const index_type * const restrict pdim, 
-	gfc_array_l1 * const restrict mask)
+	gfc_array_l1 * const restrict mask`'slen_def`')
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
@@ -360,14 +363,14 @@ define(SCALAR_ARRAY_FUNCTION,
 `
 extern void `s'name`'rtype_qual`_'atype_code (rtype * const restrict, 
 	atype * const restrict, const index_type * const restrict,
-	GFC_LOGICAL_4 *);
+	GFC_LOGICAL_4 *`'slen_def`');
 export_proto(`s'name`'rtype_qual`_'atype_code);
 
 void
 `s'name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 
 	atype * const restrict array, 
 	const index_type * const restrict pdim, 
-	GFC_LOGICAL_4 * mask)
+	GFC_LOGICAL_4 * mask`'slen_def`')
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
@@ -380,7 +383,7 @@ void
 
   if (*mask)
     {
-      name`'rtype_qual`_'atype_code (retarray, array, pdim);
+      name`'rtype_qual`_'atype_code (retarray, array, pdim`'slen_use`');
       return;
     }
   /* Make dim zero based to avoid confusion.  */
Index: libgfortran/gfortran.map
===================================================================
--- libgfortran/gfortran.map	(Revision 178930)
+++ libgfortran/gfortran.map	(Arbeitskopie)
@@ -1187,6 +1187,50 @@ GFORTRAN_1.4 {
     _gfortran_cshift0_16_char4;
     _gfortran_eoshift0_16_char4;
     _gfortran_eoshift2_16_char4;
+    _gfortran_maxloc0_1_s1;
+    _gfortran_maxloc0_2_s1;
+    _gfortran_maxloc0_4_s1;
+    _gfortran_maxloc0_8_s1;
+    _gfortran_maxloc0_16_s1;
+    _gfortran_maxloc0_1_s4;
+    _gfortran_maxloc0_2_s4;
+    _gfortran_maxloc0_4_s4;
+    _gfortran_maxloc0_8_s4;
+    _gfortran_maxloc0_16_s4;
+    _gfortran_minloc0_1_s1;
+    _gfortran_minloc0_2_s1;
+    _gfortran_minloc0_4_s1;
+    _gfortran_minloc0_8_s1;
+    _gfortran_minloc0_16_s1;
+    _gfortran_minloc0_1_s4;
+    _gfortran_minloc0_2_s4;
+    _gfortran_minloc0_4_s4;
+    _gfortran_minloc0_8_s4;
+    _gfortran_minloc0_16_s4;
+    _gfortran_maxloc1_1_s1;
+    _gfortran_maxloc1_2_s1;
+    _gfortran_maxloc1_4_s1;
+    _gfortran_maxloc1_8_s1;
+    _gfortran_maxloc1_16_s1;
+    _gfortran_maxloc1_1_s4;
+    _gfortran_maxloc1_2_s4;
+    _gfortran_maxloc1_4_s4;
+    _gfortran_maxloc1_8_s4;
+    _gfortran_maxloc1_16_s4;
+    _gfortran_minloc1_1_s1;
+    _gfortran_minloc1_2_s1;
+    _gfortran_minloc1_4_s1;
+    _gfortran_minloc1_8_s1;
+    _gfortran_minloc1_16_s1;
+    _gfortran_minloc1_1_s4;
+    _gfortran_minloc1_2_s4;
+    _gfortran_minloc1_4_s4;
+    _gfortran_minloc1_8_s4;
+    _gfortran_minloc1_16_s4;
+    _gfortran_maxval_s1;
+    _gfortran_maxval_s4;
+    _gfortran_minval_s1;
+    _gfortran_minval_s4;
 } GFORTRAN_1.3; 
 
 F2C_1.0 {
Index: libgfortran/libgfortran.h
===================================================================
--- libgfortran/libgfortran.h	(Revision 178930)
+++ libgfortran/libgfortran.h	(Arbeitskopie)
@@ -339,6 +339,8 @@ struct {\
 /* Commonly used array descriptor types.  */
 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) gfc_array_void;
 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, char) gfc_array_char;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_UINTEGER_1) gfc_array_s1;
+typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_UINTEGER_4) gfc_array_s4;
 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_1) gfc_array_i1;
 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_2) gfc_array_i2;
 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_4) gfc_array_i4;
Index: libgfortran/Makefile.am
===================================================================
--- libgfortran/Makefile.am	(Revision 178930)
+++ libgfortran/Makefile.am	(Arbeitskopie)
@@ -248,6 +248,18 @@ $(srcdir)/generated/maxloc0_4_r16.c \
 $(srcdir)/generated/maxloc0_8_r16.c \
 $(srcdir)/generated/maxloc0_16_r16.c
 
+i_maxloc0s_c = \
+$(srcdir)/generated/maxloc0_1_s1.c \
+$(srcdir)/generated/maxloc0_1_s4.c \
+$(srcdir)/generated/maxloc0_2_s1.c \
+$(srcdir)/generated/maxloc0_2_s4.c \
+$(srcdir)/generated/maxloc0_4_s1.c \
+$(srcdir)/generated/maxloc0_4_s4.c \
+$(srcdir)/generated/maxloc0_8_s1.c \
+$(srcdir)/generated/maxloc0_8_s4.c \
+$(srcdir)/generated/maxloc0_16_s1.c \
+$(srcdir)/generated/maxloc0_16_s4.c
+
 i_maxloc1_c= \
 $(srcdir)/generated/maxloc1_4_i1.c \
 $(srcdir)/generated/maxloc1_8_i1.c \
@@ -277,6 +289,18 @@ $(srcdir)/generated/maxloc1_4_r16.c \
 $(srcdir)/generated/maxloc1_8_r16.c \
 $(srcdir)/generated/maxloc1_16_r16.c
 
+i_maxloc1s_c = \
+$(srcdir)/generated/maxloc1_1_s1.c \
+$(srcdir)/generated/maxloc1_1_s4.c \
+$(srcdir)/generated/maxloc1_2_s1.c \
+$(srcdir)/generated/maxloc1_2_s4.c \
+$(srcdir)/generated/maxloc1_4_s1.c \
+$(srcdir)/generated/maxloc1_4_s4.c \
+$(srcdir)/generated/maxloc1_8_s1.c \
+$(srcdir)/generated/maxloc1_8_s4.c \
+$(srcdir)/generated/maxloc1_16_s1.c \
+$(srcdir)/generated/maxloc1_16_s4.c
+
 i_maxval_c= \
 $(srcdir)/generated/maxval_i1.c \
 $(srcdir)/generated/maxval_i2.c \
@@ -288,6 +312,10 @@ $(srcdir)/generated/maxval_r8.c \
 $(srcdir)/generated/maxval_r10.c \
 $(srcdir)/generated/maxval_r16.c
 
+i_maxvals_c= \
+$(srcdir)/generated/maxval_s1.c \
+$(srcdir)/generated/maxval_s4.c
+
 i_minloc0_c= \
 $(srcdir)/generated/minloc0_4_i1.c \
 $(srcdir)/generated/minloc0_8_i1.c \
@@ -317,6 +345,18 @@ $(srcdir)/generated/minloc0_4_r16.c \
 $(srcdir)/generated/minloc0_8_r16.c \
 $(srcdir)/generated/minloc0_16_r16.c
 
+i_minloc0s_c = \
+$(srcdir)/generated/minloc0_1_s1.c \
+$(srcdir)/generated/minloc0_1_s4.c \
+$(srcdir)/generated/minloc0_2_s1.c \
+$(srcdir)/generated/minloc0_2_s4.c \
+$(srcdir)/generated/minloc0_4_s1.c \
+$(srcdir)/generated/minloc0_4_s4.c \
+$(srcdir)/generated/minloc0_8_s1.c \
+$(srcdir)/generated/minloc0_8_s4.c \
+$(srcdir)/generated/minloc0_16_s1.c \
+$(srcdir)/generated/minloc0_16_s4.c
+
 i_minloc1_c= \
 $(srcdir)/generated/minloc1_4_i1.c \
 $(srcdir)/generated/minloc1_8_i1.c \
@@ -346,6 +386,18 @@ $(srcdir)/generated/minloc1_4_r16.c \
 $(srcdir)/generated/minloc1_8_r16.c \
 $(srcdir)/generated/minloc1_16_r16.c
 
+i_minloc1s_c = \
+$(srcdir)/generated/minloc1_1_s1.c \
+$(srcdir)/generated/minloc1_1_s4.c \
+$(srcdir)/generated/minloc1_2_s1.c \
+$(srcdir)/generated/minloc1_2_s4.c \
+$(srcdir)/generated/minloc1_4_s1.c \
+$(srcdir)/generated/minloc1_4_s4.c \
+$(srcdir)/generated/minloc1_8_s1.c \
+$(srcdir)/generated/minloc1_8_s4.c \
+$(srcdir)/generated/minloc1_16_s1.c \
+$(srcdir)/generated/minloc1_16_s4.c
+
 i_minval_c= \
 $(srcdir)/generated/minval_i1.c \
 $(srcdir)/generated/minval_i2.c \
@@ -357,6 +409,10 @@ $(srcdir)/generated/minval_r8.c \
 $(srcdir)/generated/minval_r10.c \
 $(srcdir)/generated/minval_r16.c
 
+i_minvals_c= \
+$(srcdir)/generated/minval_s1.c \
+$(srcdir)/generated/minval_s4.c
+
 i_norm2_c= \
 $(srcdir)/generated/norm2_r4.c \
 $(srcdir)/generated/norm2_r8.c \
@@ -646,7 +702,8 @@ gfor_built_src= $(i_all_c) $(i_any_c) $(i_count_c)
     $(i_exponent_c) $(i_fraction_c) $(i_nearest_c) $(i_set_exponent_c) \
     $(i_pow_c) $(i_rrspacing_c) $(i_spacing_c) $(i_pack_c) $(i_unpack_c) \
     $(i_spread_c) selected_int_kind.inc selected_real_kind.inc kinds.h \
-    $(i_cshift0_c) kinds.inc c99_protos.inc fpu-target.h
+    $(i_cshift0_c) kinds.inc c99_protos.inc fpu-target.h $(i_maxloc0s_c) \
+    $(i_minloc0s_c) $(i_maxloc1s_c) $(i_minloc1s_c) $(i_maxvals_c) $(i_minvals_c)
 
 # Machine generated specifics
 gfor_built_specific_src= \
@@ -848,6 +905,7 @@ I_M4_DEPS=m4/iparm.m4
 I_M4_DEPS0=$(I_M4_DEPS) m4/iforeach.m4
 I_M4_DEPS1=$(I_M4_DEPS) m4/ifunction.m4
 I_M4_DEPS2=$(I_M4_DEPS) m4/ifunction_logical.m4
+I_M4_DEPS3=$(I_M4_DEPS) m4/ifunction-s.m4
 
 kinds.h: $(srcdir)/mk-kinds-h.sh
 	$(SHELL) $(srcdir)/mk-kinds-h.sh '$(FCCOMPILE)' > $@ || rm $@
@@ -895,21 +953,39 @@ $(i_iparity_c): m4/iparity.m4 $(I_M4_DEPS)
 $(i_maxloc0_c): m4/maxloc0.m4 $(I_M4_DEPS0)
 	$(M4) -Dfile=$@ -I$(srcdir)/m4 maxloc0.m4 > $@
 
+$(i_maxloc0s_c) : m4/maxloc0s.m4 $(I_M4_DEPS0)
+	$(M4) -Dfile=$@ -I$(srcdir)/m4 maxloc0s.m4 > $@
+
 $(i_maxloc1_c): m4/maxloc1.m4 $(I_M4_DEPS1)
 	$(M4) -Dfile=$@ -I$(srcdir)/m4 maxloc1.m4 > $@
 
+$(i_maxloc1s_c): m4/maxloc1s.m4 $(I_M4_DEPS1)
+	$(M4) -Dfile=$@ -I$(srcdir)/m4 maxloc1s.m4 > $@
+
 $(i_maxval_c): m4/maxval.m4 $(I_M4_DEPS1)
 	$(M4) -Dfile=$@ -I$(srcdir)/m4 maxval.m4 > $@
 
+$(i_maxvals_c): m4/maxvals.m4 $(I_M4_DEPS3)
+	$(M4) -Dfile=$@ -I$(srcdir)/m4 maxvals.m4 > $@
+
 $(i_minloc0_c): m4/minloc0.m4 $(I_M4_DEPS0)
 	$(M4) -Dfile=$@ -I$(srcdir)/m4 minloc0.m4 > $@
 
+$(i_minloc0s_c) : m4/minloc0s.m4 $(I_M4_DEPS0)
+	$(M4) -Dfile=$@ -I$(srcdir)/m4 minloc0s.m4 > $@
+
 $(i_minloc1_c): m4/minloc1.m4 $(I_M4_DEPS1)
 	$(M4) -Dfile=$@ -I$(srcdir)/m4 minloc1.m4 > $@
 
+$(i_minloc1s_c): m4/minloc1s.m4 $(I_M4_DEPS1)
+	$(M4) -Dfile=$@ -I$(srcdir)/m4 minloc1s.m4 > $@
+
 $(i_minval_c): m4/minval.m4 $(I_M4_DEPS1)
 	$(M4) -Dfile=$@ -I$(srcdir)/m4 minval.m4 > $@
 
+$(i_minvals_c): m4/minvals.m4 $(I_M4_DEPS3)
+	$(M4) -Dfile=$@ -I$(srcdir)/m4 minvals.m4 > $@
+
 $(i_product_c): m4/product.m4 $(I_M4_DEPS1)
 	$(M4) -Dfile=$@ -I$(srcdir)/m4 product.m4 > $@
 
Index: libgfortran/mk-kinds-h.sh
===================================================================
--- libgfortran/mk-kinds-h.sh	(Revision 178930)
+++ libgfortran/mk-kinds-h.sh	(Arbeitskopie)
@@ -34,6 +34,7 @@ for k in $possible_integer_kinds; do
     echo "typedef GFC_INTEGER_${k} GFC_LOGICAL_${k};"
     echo "#define HAVE_GFC_LOGICAL_${k}"
     echo "#define HAVE_GFC_INTEGER_${k}"
+    echo "#define HAVE_GFC_UINTEGER_${k}"
     echo ""
   fi
   rm -f tmp$$.*
