--- mplayer/configure
+++ mplayer/configure
@@ -2953,12 +2953,28 @@ echores "$_fast_inttypes"
 
 echocheck "word size"
 _mp_wordsize="#undef MP_WORDSIZE"
-cat > $TMPC << EOF
-#include <stdio.h>
+_wordsize=0
+while true; do
+  cat > $TMPC << EOF
+#include <stdlib.h>
 #include <sys/types.h>
-int main(void) { printf("%d\n", sizeof(size_t)*8); return 0; }
+int main(void) {
+  static int test_array [1 - 2 * !(((long int) (sizeof (size_t))) <= $_wordsize)];
+  test_array [0] = 0;
+  return 0;
+}
 EOF
-cc_check && _wordsize=`$TMPEXE` && _mp_wordsize="#define MP_WORDSIZE $_wordsize"
+  if cc_check; then
+    break
+  fi
+  # sanity check
+  if test $_wordsize -gt 20; then
+    _wordsize=""
+    break
+  fi
+  _wordsize=`expr $_wordsize + 1`
+done
+[ -n "$_wordsize" ] && _mp_wordsize="#define MP_WORDSIZE $_wordsize"
 echores "$_wordsize"
 
 
