OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /or1k/trunk/gdb-5.0/gdb/testsuite/gdb.threads
    from Rev 107 to Rev 1765
    Reverse comparison

Rev 107 → Rev 1765

/configure
0,0 → 1,1098
#! /bin/sh
 
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.12.1
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
 
# Defaults:
ac_help=
ac_default_prefix=/usr/local
# Any additions from configure.in:
 
# Initialize some variables set by options.
# The variables have the same names as the options, with
# dashes changed to underlines.
build=NONE
cache_file=./config.cache
exec_prefix=NONE
host=NONE
no_create=
nonopt=NONE
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
target=NONE
verbose=
x_includes=NONE
x_libraries=NONE
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datadir='${prefix}/share'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
libdir='${exec_prefix}/lib'
includedir='${prefix}/include'
oldincludedir='/usr/include'
infodir='${prefix}/info'
mandir='${prefix}/man'
 
# Initialize some other variables.
subdirs=
MFLAGS= MAKEFLAGS=
SHELL=${CONFIG_SHELL-/bin/sh}
# Maximum number of lines to put in a shell here document.
ac_max_here_lines=12
 
ac_prev=
for ac_option
do
 
# If the previous option needs an argument, assign it.
if test -n "$ac_prev"; then
eval "$ac_prev=\$ac_option"
ac_prev=
continue
fi
 
case "$ac_option" in
-*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) ac_optarg= ;;
esac
 
# Accept the important Cygnus configure options, so we can diagnose typos.
 
case "$ac_option" in
 
-bindir | --bindir | --bindi | --bind | --bin | --bi)
ac_prev=bindir ;;
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
bindir="$ac_optarg" ;;
 
-build | --build | --buil | --bui | --bu)
ac_prev=build ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
build="$ac_optarg" ;;
 
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
ac_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
cache_file="$ac_optarg" ;;
 
-datadir | --datadir | --datadi | --datad | --data | --dat | --da)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
| --da=*)
datadir="$ac_optarg" ;;
 
-disable-* | --disable-*)
ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
{ echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
fi
ac_feature=`echo $ac_feature| sed 's/-/_/g'`
eval "enable_${ac_feature}=no" ;;
 
-enable-* | --enable-*)
ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
{ echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
fi
ac_feature=`echo $ac_feature| sed 's/-/_/g'`
case "$ac_option" in
*=*) ;;
*) ac_optarg=yes ;;
esac
eval "enable_${ac_feature}='$ac_optarg'" ;;
 
-exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
| --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
| --exec | --exe | --ex)
ac_prev=exec_prefix ;;
-exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
| --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
| --exec=* | --exe=* | --ex=*)
exec_prefix="$ac_optarg" ;;
 
-gas | --gas | --ga | --g)
# Obsolete; use --with-gas.
with_gas=yes ;;
 
-help | --help | --hel | --he)
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat << EOF
Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
--cache-file=FILE cache test results in FILE
--help print this message
--no-create do not create output files
--quiet, --silent do not print \`checking...' messages
--version print the version of autoconf that created configure
Directory and file names:
--prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[same as prefix]
--bindir=DIR user executables in DIR [EPREFIX/bin]
--sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
--libexecdir=DIR program executables in DIR [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data in DIR
[PREFIX/share]
--sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data in DIR
[PREFIX/com]
--localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
--libdir=DIR object code libraries in DIR [EPREFIX/lib]
--includedir=DIR C header files in DIR [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
--infodir=DIR info documentation in DIR [PREFIX/info]
--mandir=DIR man documentation in DIR [PREFIX/man]
--srcdir=DIR find the sources in DIR [configure dir or ..]
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM
run sed PROGRAM on installed program names
EOF
cat << EOF
Host type:
--build=BUILD configure for building on BUILD [BUILD=HOST]
--host=HOST configure for HOST [guessed]
--target=TARGET configure for TARGET [TARGET=HOST]
Features and packages:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--x-includes=DIR X include files are in DIR
--x-libraries=DIR X library files are in DIR
EOF
if test -n "$ac_help"; then
echo "--enable and --with options recognized:$ac_help"
fi
exit 0 ;;
 
-host | --host | --hos | --ho)
ac_prev=host ;;
-host=* | --host=* | --hos=* | --ho=*)
host="$ac_optarg" ;;
 
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
ac_prev=includedir ;;
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
| --includ=* | --inclu=* | --incl=* | --inc=*)
includedir="$ac_optarg" ;;
 
-infodir | --infodir | --infodi | --infod | --info | --inf)
ac_prev=infodir ;;
-infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
infodir="$ac_optarg" ;;
 
-libdir | --libdir | --libdi | --libd)
ac_prev=libdir ;;
-libdir=* | --libdir=* | --libdi=* | --libd=*)
libdir="$ac_optarg" ;;
 
-libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
| --libexe | --libex | --libe)
ac_prev=libexecdir ;;
-libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
| --libexe=* | --libex=* | --libe=*)
libexecdir="$ac_optarg" ;;
 
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst \
| --locals | --local | --loca | --loc | --lo)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* \
| --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
localstatedir="$ac_optarg" ;;
 
-mandir | --mandir | --mandi | --mand | --man | --ma | --m)
ac_prev=mandir ;;
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
mandir="$ac_optarg" ;;
 
-nfp | --nfp | --nf)
# Obsolete; use --without-fp.
with_fp=no ;;
 
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c)
no_create=yes ;;
 
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
no_recursion=yes ;;
 
-oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
| --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
| --oldin | --oldi | --old | --ol | --o)
ac_prev=oldincludedir ;;
-oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
| --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
| --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
oldincludedir="$ac_optarg" ;;
 
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
prefix="$ac_optarg" ;;
 
-program-prefix | --program-prefix | --program-prefi | --program-pref \
| --program-pre | --program-pr | --program-p)
ac_prev=program_prefix ;;
-program-prefix=* | --program-prefix=* | --program-prefi=* \
| --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
program_prefix="$ac_optarg" ;;
 
-program-suffix | --program-suffix | --program-suffi | --program-suff \
| --program-suf | --program-su | --program-s)
ac_prev=program_suffix ;;
-program-suffix=* | --program-suffix=* | --program-suffi=* \
| --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
program_suffix="$ac_optarg" ;;
 
-program-transform-name | --program-transform-name \
| --program-transform-nam | --program-transform-na \
| --program-transform-n | --program-transform- \
| --program-transform | --program-transfor \
| --program-transfo | --program-transf \
| --program-trans | --program-tran \
| --progr-tra | --program-tr | --program-t)
ac_prev=program_transform_name ;;
-program-transform-name=* | --program-transform-name=* \
| --program-transform-nam=* | --program-transform-na=* \
| --program-transform-n=* | --program-transform-=* \
| --program-transform=* | --program-transfor=* \
| --program-transfo=* | --program-transf=* \
| --program-trans=* | --program-tran=* \
| --progr-tra=* | --program-tr=* | --program-t=*)
program_transform_name="$ac_optarg" ;;
 
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
 
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
| --sbi=* | --sb=*)
sbindir="$ac_optarg" ;;
 
-sharedstatedir | --sharedstatedir | --sharedstatedi \
| --sharedstated | --sharedstate | --sharedstat | --sharedsta \
| --sharedst | --shareds | --shared | --share | --shar \
| --sha | --sh)
ac_prev=sharedstatedir ;;
-sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
| --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
| --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
| --sha=* | --sh=*)
sharedstatedir="$ac_optarg" ;;
 
-site | --site | --sit)
ac_prev=site ;;
-site=* | --site=* | --sit=*)
site="$ac_optarg" ;;
 
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
ac_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
srcdir="$ac_optarg" ;;
 
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
| --syscon | --sysco | --sysc | --sys | --sy)
ac_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
sysconfdir="$ac_optarg" ;;
 
-target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
target="$ac_optarg" ;;
 
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
 
-version | --version | --versio | --versi | --vers)
echo "configure generated by autoconf version 2.12.1"
exit 0 ;;
 
-with-* | --with-*)
ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
{ echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
fi
ac_package=`echo $ac_package| sed 's/-/_/g'`
case "$ac_option" in
*=*) ;;
*) ac_optarg=yes ;;
esac
eval "with_${ac_package}='$ac_optarg'" ;;
 
-without-* | --without-*)
ac_package=`echo $ac_option|sed -e 's/-*without-//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
{ echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
fi
ac_package=`echo $ac_package| sed 's/-/_/g'`
eval "with_${ac_package}=no" ;;
 
--x)
# Obsolete; use --with-x.
with_x=yes ;;
 
-x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
| --x-incl | --x-inc | --x-in | --x-i)
ac_prev=x_includes ;;
-x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
| --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
x_includes="$ac_optarg" ;;
 
-x-libraries | --x-libraries | --x-librarie | --x-librari \
| --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
ac_prev=x_libraries ;;
-x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
x_libraries="$ac_optarg" ;;
 
-*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
;;
 
*)
if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
echo "configure: warning: $ac_option: invalid host type" 1>&2
fi
if test "x$nonopt" != xNONE; then
{ echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
fi
nonopt="$ac_option"
;;
 
esac
done
 
if test -n "$ac_prev"; then
{ echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
fi
 
trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
 
# File descriptor usage:
# 0 standard input
# 1 file creation
# 2 errors and warnings
# 3 some systems may open it to /dev/tty
# 4 used on the Kubota Titan
# 6 checking for... messages and results
# 5 compiler messages saved in config.log
if test "$silent" = yes; then
exec 6>/dev/null
else
exec 6>&1
fi
exec 5>./config.log
 
echo "\
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
" 1>&5
 
# Strip out --no-create and --no-recursion so they do not pile up.
# Also quote any args containing shell metacharacters.
ac_configure_args=
for ac_arg
do
case "$ac_arg" in
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c) ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
*" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
ac_configure_args="$ac_configure_args '$ac_arg'" ;;
*) ac_configure_args="$ac_configure_args $ac_arg" ;;
esac
done
 
# NLS nuisances.
# Only set these to C if already set. These must not be set unconditionally
# because not all systems understand e.g. LANG=C (notably SCO).
# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
# Non-C LC_CTYPE values break the ctype check.
if test "${LANG+set}" = set; then LANG=C; export LANG; fi
if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
 
# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -rf conftest* confdefs.h
# AIX cpp loses on an empty file, so make sure it contains at least a newline.
echo > confdefs.h
 
# A filename unique to this package, relative to the directory that
# configure is in, which we can look for to find out if srcdir is correct.
ac_unique_file=pthreads.exp
 
# Find the source files, if location was not specified.
if test -z "$srcdir"; then
ac_srcdir_defaulted=yes
# Try the directory containing this script, then its parent.
ac_prog=$0
ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
srcdir=$ac_confdir
if test ! -r $srcdir/$ac_unique_file; then
srcdir=..
fi
else
ac_srcdir_defaulted=no
fi
if test ! -r $srcdir/$ac_unique_file; then
if test "$ac_srcdir_defaulted" = yes; then
{ echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
else
{ echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
fi
fi
srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
 
# Prefer explicitly selected file to automatically selected ones.
if test -z "$CONFIG_SITE"; then
if test "x$prefix" != xNONE; then
CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
else
CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
fi
fi
for ac_site_file in $CONFIG_SITE; do
if test -r "$ac_site_file"; then
echo "loading site script $ac_site_file"
. "$ac_site_file"
fi
done
 
if test -r "$cache_file"; then
echo "loading cache $cache_file"
. $cache_file
else
echo "creating cache $cache_file"
> $cache_file
fi
 
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
 
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
ac_n= ac_c='
' ac_t=' '
else
ac_n=-n ac_c= ac_t=
fi
else
ac_n= ac_c='\c' ac_t=
fi
 
 
 
 
CC=${CC-cc}
 
ac_aux_dir=
for ac_dir in `cd $srcdir;pwd`/../../.. $srcdir/`cd $srcdir;pwd`/../../..; do
if test -f $ac_dir/install-sh; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/install-sh -c"
break
elif test -f $ac_dir/install.sh; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/install.sh -c"
break
fi
done
if test -z "$ac_aux_dir"; then
{ echo "configure: error: can not find install-sh or install.sh in `cd $srcdir;pwd`/../../.. $srcdir/`cd $srcdir;pwd`/../../.." 1>&2; exit 1; }
fi
ac_config_guess=$ac_aux_dir/config.guess
ac_config_sub=$ac_aux_dir/config.sub
ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
 
 
# Do some error checking and defaulting for the host and target type.
# The inputs are:
# configure --host=HOST --target=TARGET --build=BUILD NONOPT
#
# The rules are:
# 1. You are not allowed to specify --host, --target, and nonopt at the
# same time.
# 2. Host defaults to nonopt.
# 3. If nonopt is not specified, then host defaults to the current host,
# as determined by config.guess.
# 4. Target and build default to nonopt.
# 5. If nonopt is not specified, then target and build default to host.
 
# The aliases save the names the user supplied, while $host etc.
# will get canonicalized.
case $host---$target---$nonopt in
NONE---*---* | *---NONE---* | *---*---NONE) ;;
*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
esac
 
 
# Make sure we can run config.sub.
if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
 
echo $ac_n "checking host system type""... $ac_c" 1>&6
echo "configure:574: checking host system type" >&5
 
host_alias=$host
case "$host_alias" in
NONE)
case $nonopt in
NONE)
if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
fi ;;
*) host_alias=$nonopt ;;
esac ;;
esac
 
host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$host" 1>&6
 
echo $ac_n "checking target system type""... $ac_c" 1>&6
echo "configure:595: checking target system type" >&5
 
target_alias=$target
case "$target_alias" in
NONE)
case $nonopt in
NONE) target_alias=$host_alias ;;
*) target_alias=$nonopt ;;
esac ;;
esac
 
target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$target" 1>&6
 
echo $ac_n "checking build system type""... $ac_c" 1>&6
echo "configure:613: checking build system type" >&5
 
build_alias=$build
case "$build_alias" in
NONE)
case $nonopt in
NONE) build_alias=$host_alias ;;
*) build_alias=$nonopt ;;
esac ;;
esac
 
build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$build" 1>&6
 
test "$host_alias" != "$target_alias" &&
test "$program_prefix$program_suffix$program_transform_name" = \
NONENONEs,x,x, &&
program_prefix=${target_alias}-
 
 
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:637: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# This must be in double quotes, not single quotes, because CPP may get
# substituted into the Makefile and "${CC-cc}" will confuse make.
CPP="${CC-cc} -E"
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 652 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:658: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 669 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:675: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
CPP=/lib/cpp
fi
rm -f conftest*
fi
rm -f conftest*
ac_cv_prog_CPP="$CPP"
fi
CPP="$ac_cv_prog_CPP"
else
ac_cv_prog_CPP="$CPP"
fi
echo "$ac_t""$CPP" 1>&6
 
for ac_hdr in pthread.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:701: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 706 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:711: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <<EOF
#define $ac_tr_hdr 1
EOF
else
echo "$ac_t""no" 1>&6
fi
done
 
 
trap '' 1 2 15
cat > confcache <<\EOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs. It is not useful on other systems.
# If it contains results you don't want to keep, you may remove or edit it.
#
# By default, configure uses ./config.cache as the cache file,
# creating it if it does not exist already. You can give configure
# the --cache-file=FILE option to use a different cache file; that is
# what configure does when it calls configure scripts in
# subdirectories, so they share the cache.
# Giving --cache-file=/dev/null disables caching, for debugging configure.
# config.status only pays attention to the cache file if you give it the
# --recheck option to rerun configure.
#
EOF
# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, don't put newlines in cache variables' values.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(set) 2>&1 |
case `(ac_space=' '; set) 2>&1 | grep ac_space` in
*ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote substitution
# turns \\\\ into \\, and sed turns \\ into \).
sed -n \
-e "s/'/'\\\\''/g" \
-e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
;;
*)
# `set' quotes correctly as required by POSIX, so do not add quotes.
sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
;;
esac >> confcache
if cmp -s $cache_file confcache; then
:
else
if test -w $cache_file; then
echo "updating cache $cache_file"
cat confcache > $cache_file
else
echo "not updating unwritable cache $cache_file"
fi
fi
rm -f confcache
 
trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
 
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
 
# Any assignment to VPATH causes Sun make to only execute
# the first set of double-colon rules, so remove it if not needed.
# If there is a colon in the path, we need to keep it.
if test "x$srcdir" = x.; then
ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
fi
 
trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
 
DEFS=-DHAVE_CONFIG_H
 
# Without the "./", some shells look in PATH for config.status.
: ${CONFIG_STATUS=./config.status}
 
echo creating $CONFIG_STATUS
rm -f $CONFIG_STATUS
cat > $CONFIG_STATUS <<EOF
#! /bin/sh
# Generated automatically by configure.
# Run this file to recreate the current configuration.
# This directory was configured as follows,
# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
#
# $0 $ac_configure_args
#
# Compiler output produced by configure, useful for debugging
# configure, is in ./config.log if it exists.
 
ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
for ac_option
do
case "\$ac_option" in
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
echo "$CONFIG_STATUS generated by autoconf version 2.12.1"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;;
*) echo "\$ac_cs_usage"; exit 1 ;;
esac
done
 
ac_given_srcdir=$srcdir
 
trap 'rm -fr `echo "Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
 
# Protect against being on the right side of a sed subst in config.status.
sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
$ac_vpsub
$extrasub
s%@SHELL@%$SHELL%g
s%@CFLAGS@%$CFLAGS%g
s%@CPPFLAGS@%$CPPFLAGS%g
s%@CXXFLAGS@%$CXXFLAGS%g
s%@DEFS@%$DEFS%g
s%@LDFLAGS@%$LDFLAGS%g
s%@LIBS@%$LIBS%g
s%@exec_prefix@%$exec_prefix%g
s%@prefix@%$prefix%g
s%@program_transform_name@%$program_transform_name%g
s%@bindir@%$bindir%g
s%@sbindir@%$sbindir%g
s%@libexecdir@%$libexecdir%g
s%@datadir@%$datadir%g
s%@sysconfdir@%$sysconfdir%g
s%@sharedstatedir@%$sharedstatedir%g
s%@localstatedir@%$localstatedir%g
s%@libdir@%$libdir%g
s%@includedir@%$includedir%g
s%@oldincludedir@%$oldincludedir%g
s%@infodir@%$infodir%g
s%@mandir@%$mandir%g
s%@CC@%$CC%g
s%@host@%$host%g
s%@host_alias@%$host_alias%g
s%@host_cpu@%$host_cpu%g
s%@host_vendor@%$host_vendor%g
s%@host_os@%$host_os%g
s%@target@%$target%g
s%@target_alias@%$target_alias%g
s%@target_cpu@%$target_cpu%g
s%@target_vendor@%$target_vendor%g
s%@target_os@%$target_os%g
s%@build@%$build%g
s%@build_alias@%$build_alias%g
s%@build_cpu@%$build_cpu%g
s%@build_vendor@%$build_vendor%g
s%@build_os@%$build_os%g
s%@CPP@%$CPP%g
 
CEOF
EOF
 
cat >> $CONFIG_STATUS <<\EOF
 
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
ac_file=1 # Number of current file.
ac_beg=1 # First line for current file.
ac_end=$ac_max_sed_cmds # Line after last line for current file.
ac_more_lines=:
ac_sed_cmds=""
while $ac_more_lines; do
if test $ac_beg -gt 1; then
sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
else
sed "${ac_end}q" conftest.subs > conftest.s$ac_file
fi
if test ! -s conftest.s$ac_file; then
ac_more_lines=false
rm -f conftest.s$ac_file
else
if test -z "$ac_sed_cmds"; then
ac_sed_cmds="sed -f conftest.s$ac_file"
else
ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
fi
ac_file=`expr $ac_file + 1`
ac_beg=$ac_end
ac_end=`expr $ac_end + $ac_max_sed_cmds`
fi
done
if test -z "$ac_sed_cmds"; then
ac_sed_cmds=cat
fi
EOF
 
cat >> $CONFIG_STATUS <<EOF
 
CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
EOF
cat >> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case "$ac_file" in
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
*) ac_file_in="${ac_file}.in" ;;
esac
 
# Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
 
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
# The file is in a subdirectory.
test ! -d "$ac_dir" && mkdir "$ac_dir"
ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
# A "../" for each directory in $ac_dir_suffix.
ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
else
ac_dir_suffix= ac_dots=
fi
 
case "$ac_given_srcdir" in
.) srcdir=.
if test -z "$ac_dots"; then top_srcdir=.
else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
/*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
*) # Relative path.
srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
top_srcdir="$ac_dots$ac_given_srcdir" ;;
esac
 
 
echo creating "$ac_file"
rm -f "$ac_file"
configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
case "$ac_file" in
*Makefile*) ac_comsub="1i\\
# $configure_input" ;;
*) ac_comsub= ;;
esac
 
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
sed -e "$ac_comsub
s%@configure_input@%$configure_input%g
s%@srcdir@%$srcdir%g
s%@top_srcdir@%$top_srcdir%g
" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
fi; done
rm -f conftest.s*
 
# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
# NAME is the cpp macro being defined and VALUE is the value it is being given.
#
# ac_d sets the value in "#define NAME VALUE" lines.
ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
ac_dC='\3'
ac_dD='%g'
# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
ac_uB='\([ ]\)%\1#\2define\3'
ac_uC=' '
ac_uD='\4%g'
# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
ac_eB='$%\1#\2define\3'
ac_eC=' '
ac_eD='%g'
 
if test "${CONFIG_HEADERS+set}" != set; then
EOF
cat >> $CONFIG_STATUS <<EOF
CONFIG_HEADERS="config.h:config.in"
EOF
cat >> $CONFIG_STATUS <<\EOF
fi
for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case "$ac_file" in
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
*) ac_file_in="${ac_file}.in" ;;
esac
 
echo creating $ac_file
 
rm -f conftest.frag conftest.in conftest.out
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
cat $ac_file_inputs > conftest.in
 
EOF
 
# Transform confdefs.h into a sed script conftest.vals that substitutes
# the proper values into config.h.in to produce config.h. And first:
# Protect against being on the right side of a sed subst in config.status.
# Protect against being in an unquoted here document in config.status.
rm -f conftest.vals
cat > conftest.hdr <<\EOF
s/[\\&%]/\\&/g
s%[\\$`]%\\&%g
s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
s%ac_d%ac_u%gp
s%ac_u%ac_e%gp
EOF
sed -n -f conftest.hdr confdefs.h > conftest.vals
rm -f conftest.hdr
 
# This sed command replaces #undef with comments. This is necessary, for
# example, in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
cat >> conftest.vals <<\EOF
s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
EOF
 
# Break up conftest.vals because some shells have a limit on
# the size of here documents, and old seds have small limits too.
 
rm -f conftest.tail
while :
do
ac_lines=`grep -c . conftest.vals`
# grep -c gives empty output for an empty file on some AIX systems.
if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
# Write a limited-size here document to conftest.frag.
echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
echo 'CEOF
sed -f conftest.frag conftest.in > conftest.out
rm -f conftest.in
mv conftest.out conftest.in
' >> $CONFIG_STATUS
sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
rm -f conftest.vals
mv conftest.tail conftest.vals
done
rm -f conftest.vals
 
cat >> $CONFIG_STATUS <<\EOF
rm -f conftest.frag conftest.h
echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
cat conftest.in >> conftest.h
rm -f conftest.in
if cmp -s $ac_file conftest.h 2>/dev/null; then
echo "$ac_file is unchanged"
rm -f conftest.h
else
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
# The file is in a subdirectory.
test ! -d "$ac_dir" && mkdir "$ac_dir"
fi
rm -f $ac_file
mv conftest.h $ac_file
fi
fi; done
 
EOF
cat >> $CONFIG_STATUS <<EOF
 
EOF
cat >> $CONFIG_STATUS <<\EOF
 
exit 0
EOF
chmod +x $CONFIG_STATUS
rm -fr confdefs* $ac_clean_files
test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
 
configure Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: linux-dp.c =================================================================== --- linux-dp.c (nonexistent) +++ linux-dp.c (revision 1765) @@ -0,0 +1,205 @@ +/* linux-dp.c --- dining philosophers, on LinuxThreads + Jim Blandy --- March 1999 */ + +/* It's okay to edit this file and shift line numbers around. The + tests use gdb_get_line_number to find source locations, so they + don't depend on having certain line numbers in certain places. */ + +#include +#include +#include +#include +#include +#include + +/* The number of philosophers at the table. */ +int num_philosophers; + +/* Mutex ordering - + If you want to lock a mutex M, all the mutexes you have locked + already must appear before M on this list. + + fork_mutex[0] + fork_mutex[1] + ... + fork_mutex[num_philosophers - 1] + stdout_mutex + random_mutex +*/ + +/* You must hold this mutex while writing to stdout. */ +pthread_mutex_t stdout_mutex; + +/* You must hold this mutex while calling any of the random number + generation routines. */ +pthread_mutex_t random_mutex; + +/* array of mutexes, one for each fork; fork_mutex[i] is to the left + of philosopher i. A philosopher is holding fork i iff his/her + thread has locked fork_mutex[i]. */ +pthread_mutex_t *fork_mutex; + +/* array of threads, one representing each philosopher. */ +pthread_t *philosophers; + +void * +xmalloc (size_t n) +{ + void *p = malloc (n); + + if (! p) + { + fprintf (stderr, "out of memory\n"); + exit (2); + } + + return p; +} + +void +shared_printf (char *format, ...) +{ + va_list ap; + + va_start (ap, format); + pthread_mutex_lock (&stdout_mutex); + vprintf (format, ap); + pthread_mutex_unlock (&stdout_mutex); + va_end (ap); +} + +int +shared_random () +{ + static unsigned int seed; + int result; + + pthread_mutex_lock (&random_mutex); + result = rand_r (&seed); + pthread_mutex_unlock (&random_mutex); + return result; +} + +void +my_usleep (long usecs) +{ + struct timeval timeout; + + timeout.tv_sec = usecs / 1000000; + timeout.tv_usec = usecs % 1000000; + + select (0, 0, 0, 0, &timeout); +} + +void +random_delay () +{ + my_usleep ((shared_random () % 2000) * 100); +} + +void +print_philosopher (int n, char left, char right) +{ + int i; + + shared_printf ("%*s%c %d %c\n", (n * 4) + 2, "", left, n, right); +} + +void * +philosopher (void *data) +{ + int n = * (int *) data; + + print_philosopher (n, '_', '_'); + +#if 1 + if (n == num_philosophers - 1) + for (;;) + { + /* The last philosopher is different. He goes for his right + fork first, so there is no cycle in the mutex graph. */ + + /* Grab the right fork. */ + pthread_mutex_lock (&fork_mutex[(n + 1) % num_philosophers]); + print_philosopher (n, '_', '!'); + random_delay (); + + /* Then grab the left fork. */ + pthread_mutex_lock (&fork_mutex[n]); + print_philosopher (n, '!', '!'); + random_delay (); + + print_philosopher (n, '_', '_'); + pthread_mutex_unlock (&fork_mutex[n]); + pthread_mutex_unlock (&fork_mutex[(n + 1) % num_philosophers]); + random_delay (); + } + else +#endif + for (;;) + { + /* Grab the left fork. */ + pthread_mutex_lock (&fork_mutex[n]); + print_philosopher (n, '!', '_'); + random_delay (); + + /* Then grab the right fork. */ + pthread_mutex_lock (&fork_mutex[(n + 1) % num_philosophers]); + print_philosopher (n, '!', '!'); + random_delay (); + + print_philosopher (n, '_', '_'); + pthread_mutex_unlock (&fork_mutex[n]); + pthread_mutex_unlock (&fork_mutex[(n + 1) % num_philosophers]); + random_delay (); + } +} + +int +main (int argc, char **argv) +{ + num_philosophers = 5; + + /* Set up the mutexes. */ + { + pthread_mutexattr_t ma; + int i; + + pthread_mutexattr_init (&ma); + pthread_mutex_init (&stdout_mutex, &ma); + pthread_mutex_init (&random_mutex, &ma); + fork_mutex = xmalloc (num_philosophers * sizeof (fork_mutex[0])); + for (i = 0; i < num_philosophers; i++) + pthread_mutex_init (&fork_mutex[i], &ma); + pthread_mutexattr_destroy (&ma); + } + + /* Set off the threads. */ + { + int i; + int *numbers = xmalloc (num_philosophers * sizeof (*numbers)); + pthread_attr_t ta; + + philosophers = xmalloc (num_philosophers * sizeof (*philosophers)); + + pthread_attr_init (&ta); + + for (i = 0; i < num_philosophers; i++) + { + numbers[i] = i; + /* linuxthreads.exp: create philosopher */ + pthread_create (&philosophers[i], &ta, philosopher, &numbers[i]); + } + + pthread_attr_destroy (&ta); + } + + /* linuxthreads.exp: info threads 2 */ + sleep (1000000); + + /* Drink yourself into oblivion. */ + for (;;) + sleep (1000000); + + return 0; +} Index: Makefile.in =================================================================== --- Makefile.in (nonexistent) +++ Makefile.in (revision 1765) @@ -0,0 +1,31 @@ +VPATH = @srcdir@ +srcdir = @srcdir@ + +EXECUTABLES = pthreads + +all: + @echo "Nothing to be done for all..." + +info: +install-info: +dvi: +install: +uninstall: force +installcheck: +check: + +clean mostlyclean: + -rm -f *~ *.o a.out xgdb *.x *.ci *.tmp core* $(EXECUTABLES) + +distclean maintainer-clean realclean: clean + -rm -f Makefile config.status config.log config.h + +Makefile : $(srcdir)/Makefile.in $(srcdir)/configure.in + $(SHELL) ./config.status --recheck + +config.h: stamp-h ; @true +stamp-h: config.in config.status + CONFIG_HEADERS=config.h:config.in $(SHELL) config.status + +config.status: configure + $(SHELL) config.status --recheck Index: pthreads.exp =================================================================== --- pthreads.exp (nonexistent) +++ pthreads.exp (revision 1765) @@ -0,0 +1,335 @@ +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Fred Fish. (fnf@cygnus.com) + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +# This only works with native configurations +if ![isnative] then { + return +} + +set testfile "pthreads" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +# regexp for "horizontal" text (i.e. doesn't include newline or +# carriage return) +set horiz "\[^\n\r\]*" + +set built_binfile 0 +if [istarget "*-*-linux"] then { + set target_cflags "-D_MIT_POSIX_THREADS" +} else { + set target_cflags "" +} +set why_msg "unrecognized error" +foreach lib {-lpthreads -lpthread -lthread} { + set options "debug" + lappend options "incdir=${objdir}/${subdir}" + lappend options "libs=$lib" + set ccout [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $options] + switch -regexp -- $ccout { + ".*no posix threads support.*" { + set why_msg "missing threads include file" + break + } + ".*cannot open -lpthread.*" { + set why_msg "missing runtime threads library" + } + ".*Can't find library for -lpthread.*" { + set why_msg "missing runtime threads library" + } + {^$} { + pass "successfully compiled posix threads test case" + set built_binfile 1 + break + } + } +} +if {$built_binfile == "0"} { + unsupported "Couldn't compile ${srcfile}, ${why_msg}" + return -1 +} + +# Now we can proceed with the real testing. + +# Start with a fresh gdb. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_test "set print sevenbit-strings" "" +#gdb_test "set print address off" "" +gdb_test "set width 0" "" + +# We'll need this when we send_gdb a ^C to GDB. Need to do it before we +# run the program and gdb starts saving and restoring tty states. +# On Ultrix, we don't need it and it is really slow (because shell_escape +# doesn't use vfork). +if ![istarget "*-*-ultrix*"] then { + gdb_test "shell stty intr '^C'" "" +} + +proc all_threads_running {} { + global gdb_prompt + global srcfile + + # Reset all the counters to zero. + gdb_test "set var common_routine::hits=0" "" + gdb_test "set var common_routine::from_thread1=0" "" + gdb_test "set var common_routine::from_thread2=0" "" + gdb_test "set var common_routine::from_main=0" "" + gdb_test "set var common_routine::full_coverage=0" "" + + # Disable all breakpoints. + gdb_test "disable" "" + + # Set up a breakpoint that will cause us to stop when we have + # been called 15 times. This should be plenty of time to allow + # every thread to run at least once, since each thread sleeps for + # one second between calls to common_routine. + gdb_test "tbreak common_routine if hits >= 15" "" + + # Start all the threads running again and wait for the inferior + # to stop. Since no other breakpoints are set at this time + # we should stop only when we have been previously called 15 times. + + send_gdb "continue\n" + gdb_expect { + -re "Continuing.*common_routine.*at.*$srcfile.*$gdb_prompt $" {} + default { + fail "continue until common routine run 15 times" + return 0 + } + timeout { + fail "continue until common routine run 15 times (timeout)" + return 0 + } + } + + # Check that we stopped when we actually expected to stop, by + # verifying that there have been 15 previous hits. + + # NOTE: Because of synchronization behavior, it is possible for + # more than one thread to increment "hits" between one breakpoint + # trap and the next. So stopping after 16 or 17 hits should be + # considered acceptable. + + send_gdb "p common_routine::hits\n" + gdb_expect { + -re ".*= 15\r\n$gdb_prompt $" {} + -re ".*= 16\r\n$gdb_prompt $" {} + -re ".*= 17\r\n$gdb_prompt $" {} + default { + fail "stopped before calling common_routine 15 times" + return 0 + } + -re ".*$gdb_prompt $" { + fail "stopped before calling common_routine 15 times" + return 0 + } + timeout { + fail "stopped before calling common_routine 15 times (timeout)" + return 0 + } + } + + # Also check that all of the threads have run, which will only be true + # if the full_coverage variable is set. + + send_gdb "p common_routine::full_coverage\n" + gdb_expect { + -re ".*= 1\r\n$gdb_prompt $" {} + default { + fail "some threads didn't run" + return 0 + } + timeout { + fail "some threads didn't run (timeout)" + return 0 + } + } + + # Looks fine, return success. + return 1 +} + +proc test_startup {} { + global srcdir srcfile gdb_prompt expect_out + global horiz + global main_id thread1_id thread2_id + + # We should be able to do an info threads before starting any others. + send_gdb "info threads\n" + gdb_expect { + -re ".*Thread.*LWP.*main.*$gdb_prompt $" { + pass "info threads" + } + -re "\r\n$gdb_prompt $" { + pass "info threads" + setup_xfail "*-*-*" + fail "gdb does not support pthreads for this machine" + return 0 + } + } + + # Extract the thread id number of main thread from "info threads" output. + send_gdb "info threads\n" + gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}main.*)($gdb_prompt $)" + set main_id $expect_out(1,string) + + # Check that we can continue and create the first thread. + gdb_test "break thread1" "Breakpoint .* file .*$srcdir.*" + gdb_test "continue" \ + "Continuing.*Breakpoint .*, thread1 \\(arg=0xfeedface\\).*at.*$srcfile.*" \ + "Continue to creation of first thread" + gdb_test "disable" "" + + # Extract the thread id number of thread 1 from "info threads" output. + send_gdb "info threads\n" + gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}thread1.*)($gdb_prompt $)" + set thread1_id $expect_out(1,string) + + # Check that we can continue and create the second thread, + # ignoring the first thread for the moment. + gdb_test "break thread2" "Breakpoint .* file .*$srcdir.*" + gdb_test "continue" \ + "Continuing.*Breakpoint .*, thread2 \\(arg=0xdeadbeef\\).*at.*$srcfile.*" \ + "Continue to creation of second thread" + + # Extract the thread id number of thread 2 from "info threads" output. + send_gdb "info threads\n" + gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}thread2.*)($gdb_prompt $)" + set thread2_id $expect_out(1,string) + + return 1 +} + +proc check_control_c {} { + global gdb_prompt + + # Verify that all threads are running. + if [all_threads_running] then { + pass "All threads running after startup" + } + + # Send a continue followed by ^C to the process to stop it. + send_gdb "continue\n" + set description "Stopped with a ^C" + after 1000 [send_gdb "\003"] + gdb_expect { + -re "Program received signal SIGINT.*$gdb_prompt $" { + pass $description + } + -re "Quit.*$gdb_prompt $" { + pass $description + } + timeout { + fail "$description (timeout)" + } + } + gdb_test "bt" "" + + # Verify that all threads can be run again after a ^C stop. + if [all_threads_running] then { + pass "All threads running after continuing from ^C stop" + } +} + +proc check_backtraces {} { + global gdb_prompt main_id thread1_id thread2_id + + # Check that the "thread apply N backtrace" command works + + gdb_test "thread apply $main_id backtrace" \ + ".* in main \\(argc=.*, argv=.*\\).*" \ + "check backtrace from main thread" + gdb_test "thread apply $thread1_id backtrace" \ + ".* in thread1 \\(arg=0xfeedface\\).*" \ + "check backtrace from thread 1" + gdb_test "thread apply $thread2_id backtrace" \ + ".* in thread2 \\(arg=0xdeadbeef\\).*" \ + "check backtrace from thread 2" + + # Check that we can apply the backtrace command to all + # three threads with a single gdb command + + gdb_test "thread apply $main_id $thread1_id $thread2_id bt" \ + ".* in main .* in thread1 .* in thread2.*" \ + "apply backtrace command to all three threads" + + # Check that we can do thread specific backtraces + # This also tests that we can do thread specific breakpoints. + + gdb_test "break common_routine thread $thread2_id" \ + "Breakpoint .* at 0x.* file .* line .*" \ + "set break at common_routine in thread 2" + + send_gdb "continue\n" + gdb_expect { + -re "Breakpoint .* common_routine \\(arg=2\\).*" { + send_gdb "backtrace\n" + gdb_expect { + -re "#0.*common_routine \\(arg=2\\).*#1.*thread2.*" { + pass "backtrace from thread 2 bkpt in common_routine" + } + default { + fail "backtrace from thread 2 bkpt in common_routine" + } + timeout { + fail "backtrace from thread 2 bkpt in common_routine (timeout)" + } + } + } + -re "Breakpoint .* common_routine \\(arg=0\\).*" { + fail "stopped in main thread at breakpoint for thread 2" + } + -re "Breakpoint .* common_routine \\(arg=1\\).*" { + fail "stopped in main thread at breakpoint for thread 1" + } + -re ".*$gdb_prompt" { + fail "continue to bkpt at common_routine in thread 2" + } + default { + fail "continue to bkpt at common_routine in thread 2" + } + timeout { + fail "continue to bkpt at common_routine in thread 2 (timeout)" + } + } +} + +setup_xfail "alpha-*-osf*" +if [runto_main] then { + clear_xfail "alpha-*-osf*" + if [test_startup] then { + check_control_c + check_backtraces + } +} +clear_xfail "alpha-*-osf*" Index: configure.in =================================================================== --- configure.in (nonexistent) +++ configure.in (revision 1765) @@ -0,0 +1,18 @@ +dnl Process this file file with autoconf to produce a configure script. +dnl This file is a shell script fragment that supplies the information +dnl necessary to tailor a template configure script into the configure +dnl script appropriate for this directory. For more information, check +dnl any existing configure script. + +AC_PREREQ(2.5) +AC_INIT(pthreads.exp) +AC_CONFIG_HEADER(config.h:config.in) + +CC=${CC-cc} +AC_SUBST(CC) +AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../../..) +AC_CANONICAL_SYSTEM + +AC_CHECK_HEADERS(pthread.h) + +AC_OUTPUT(Makefile) Index: step.exp =================================================================== --- step.exp (nonexistent) +++ step.exp (revision 1765) @@ -0,0 +1,200 @@ +# step.exp -- Expect script to test gdb with step.c +# Copyright (C) 1992, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Hiro Sugawara. (hiro@lynx.com) +# +# This test really needs some major surgery to be acceptable, but +# I'm just about burnt out on lynx work, so I'm not doing it now. +# +# * The test has an indeterminate number of pass/fails +# for each run (it runs a small group of tests until +# it's timer kicks off). This is very bad for nightly +# automated regression testing. +# +# * It tries to "step" from withint he prologue of a +# function. This isn't support in gdb (it's going +# to act like a continue). +# +# * This test rarely check that it stopped in sensible +# places. (see previous bullet -- this test doesn't +# catch the fact it continued rather than stepped) + + +if $tracelevel then { + strace $tracelevel +} + +set program_exited 0 + +proc set_bp { where } { + global gdb_prompt + + send_gdb "break $where\n" + # The first regexp is what we get with -g, the second without -g. + gdb_expect { + -re "Break.* at .*: file .*, line \[0-9\]*.*$gdb_prompt $" {} + -re "Breakpoint \[0-9\]* at 0x\[0-9a-f\]*.*$gdb_prompt $" {} + -re "$gdb_prompt $" { fail "setting breakpoint at $where" ; return 0 } + timeout { fail "setting breakpoint at $where (timeout)" ; return 0 } + } + pass "set_bp" +} + +proc step_it { cmd } { + global gdb_prompt + global program_exited + + send_gdb "$cmd\n" + gdb_expect { + -re "0x\[0-9A-Fa-f\]* *in.*\r\n$gdb_prompt $" { pass "step_it"; return 0 } + -re "0x\[0-9A-Fa-f\]* *\[0-9\]*.*\r\n$gdb_prompt $" { pass "step_it"; return 1 } + -re "Program exited .*\n$gdb_prompt $" { + set program_exited 1 + return -1 + } + -re "$gdb_prompt $" { fail "single-stepping ($cmd).\n" ; return -1 } + timeout { fail "single-stepping ($cmd) timout.\n" ; return -1 } + } +} + +proc step_inst {} { + step_it "stepi" +} + +proc step_source {} { + step_it "step" +} + +proc continue_all {} { + global gdb_prompt + + send_gdb "continue\n" + gdb_expect { + -re "Breakpoint \[0-9\]*, thread\[0-9\]* .*$gdb_prompt $" { + pass "continue_all" + return 0 + } + -re "Program exited .*\n$gdb_prompt $" { + set program_exited 1 + return 1; + } + -re "$gdb_prompt $" { fail "continue" ; return -1 } + timeout { fail "continue (timeout)" ; return -1 } + } +} + +proc check_threads { num_threads } { + global gdb_prompt + + set curr_thread 0 + send_gdb "info threads\n" + while { $num_threads > 0 } { + gdb_expect { + -re "\\* *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" { + incr curr_thread + set num_threads [expr $num_threads - 1] + } + -re " *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" { + set num_threads [expr $num_threads - 1] + } + -re "$gdb_prompt $" { + if { $num_threads < 0 } { + fail "check_threads (too many)" ; return -1 + } + break + } + timeout { fail "check_threads (timeout)" ; return -1 } + } + } + + if { $curr_thread == 0 } { + fail "check_threads (no current thread)\n" + return -1 + } + if { $curr_thread > 1 } { + fail "check_threads (more than one current thread)\n" + return -1 + } + return 0 +} + +proc test_cond_wait {} { + global program_exited + + set_bp 135 + runto 179 + while { 1 } { + set stepi_counter 0 + while { [step_inst] } { + if { $program_exited } { break } + incr stepi_counter + if { $stepi_counter > 30 } { + fail "too many stepi's per line\n" + return -1 + } + } + if { $program_exited } { break } + step_source + if { $program_exited } { break } + continue_all + if { $program_exited } { break } + check_threads 3 + } +} + +proc do_tests {} { + global prms_id + global bug_id + global subdir + global objdir + global srcdir + global binfile + global gdb_prompt + + set prms_id 0 + set bug_id 0 + + # Start with a fresh gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $objdir/$subdir/$binfile + + send_gdb "set width 0\n" + gdb_expect -re "$gdb_prompt $" + + test_cond_wait +} + +# Check to see if we have an executable to test. If not, then either we +# haven't tried to compile one, or the compilation failed for some reason. +# In either case, just notify the user and skip the tests in this file. + +set binfile "step" +set srcfile "step.c" + +if ![file exists $objdir/$subdir/$binfile] then { + if $all_flag then { + warning "$binfile does not exist; tests suppressed." + } +} else { + do_tests +} Index: step2.exp =================================================================== --- step2.exp (nonexistent) +++ step2.exp (revision 1765) @@ -0,0 +1,150 @@ +# step2.exp -- Expect script to test gdb step.c +# Copyright (C) 1992, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Jeff Law. (law@cygnus.com) +# + + +if $tracelevel then { + strace $tracelevel +} + +set program_exited 0 + +# A simple and crude test to see that we can step two threads independently +proc test_multi_threaded_stepping {} { + global gdb_prompt + global hex + global srcfile + global decimal + + # Set breakpoints in code that we know is executed in only + # thread of control. + gdb_test "break thread1" \ + "Break.* at $hex: file .*$srcfile, line $decimal\\." + gdb_test "break thread2" \ + "Break.* at $hex: file .*$srcfile, line $decimal\\." + + # the order in which things happen is indeterminate. So we basically + # look for a set of events and note that each one happens and that + # all of the required events have happened when we're done. + # + # Right now we only verify that both threads start and that they + # both call pthread_cond_wait twice. + set thread1started 0 + set thread1condwait 0 + set thread2started 0 + set thread2condwait 0 + + send_gdb "run\n" + gdb_expect { + -re "The program .* has been started already.*y or n. $" { + send_gdb "y\n" + exp_continue + } + -re ".*Breakpoint \[0-9\]+,.*thread1.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" { + if { $thread1started != 0 } then { + fail "thread1 started" + return + } else { + set thread1started 1 + pass "thread1 started" + } + send_gdb "step\n" + exp_continue + } + -re ".*Breakpoint \[0-9\]+,.*thread2.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" { + if { $thread2started != 0 } then { + fail "thread2 started" + return + } else { + set thread2started 1 + pass "thread2 started" + } + send_gdb "step\n" + exp_continue + } + -re ".*pthread_cond_wait.*cv_a.*$gdb_prompt" { + if { $thread1started == 0 } then { + fail "thread1 condwait" + return + } + if { $thread1condwait < 2 } then { + pass "thread1 condwait" + incr thread1condwait + } + if { $thread2condwait == 2 } then { + pass "multi threaded stepping" + return + } + send_gdb "step\n" + exp_continue + } + + -re ".*pthread_cond_wait.*cv_b.*$gdb_prompt" { + if { $thread2started == 0 } then { + fail "thread2 condwait" + return + } + if { $thread2condwait < 2 } then { + pass "thread2 condwait" + incr thread2condwait + } + if { $thread1condwait == 2 } then { + pass "multi threaded stepping" + return + } + send_gdb "step\n" + exp_continue + } + + -re "$gdb_prompt" { + send_gdb "step\n" + exp_continue + } + default { fail "multi threaded stepping" } + } +} + +# Check to see if we have an executable to test. If not, then either we +# haven't tried to compile one, or the compilation failed for some reason. +# In either case, just notify the user and skip the tests in this file. + +set binfile "step" +set srcfile "step.c" + +if ![file exists $objdir/$subdir/$binfile] then { + if $all_flag then { + warning "$binfile does not exist; tests suppressed." + } + return +} + +set prms_id 0 +set bug_id 0 + +# Start with a fresh gdb. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load $objdir/$subdir/$binfile + +test_multi_threaded_stepping Index: config.in =================================================================== --- config.in (nonexistent) +++ config.in (revision 1765) @@ -0,0 +1,4 @@ +/* config.in. Generated automatically from configure.in by autoheader. */ + +/* Define if you have the header file. */ +#undef HAVE_PTHREAD_H Index: linux-dp.exp =================================================================== --- linux-dp.exp (nonexistent) +++ linux-dp.exp (revision 1765) @@ -0,0 +1,204 @@ +# Copyright (C) 1999 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@gnu.org + +#### Dining Philosophers, on LinuxThreads - Jim Blandy +#### +#### At the moment, GDB's support for LinuxThreads is pretty +#### idiosyncratic --- GDB's output doesn't look much like the output +#### it produces for other thread implementations, messages appear at +#### different times, etc. So these tests are specific to LinuxThreads. +#### +#### However, if all goes well, Linux will soon have a libthread_db +#### interface, and GDB will manage it the same way it does other +#### libthread_db-based systems. Then, we can adjust this file to +#### work with any such system. + +### Other things we ought to test: +### stepping a thread while others are running +### killing and restarting +### quitting gracefully + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +# This only works with Linux configurations. +if ![istarget *-*-linux-gnu] then { + return +} + +set testfile "linux-dp" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug libs=-lpthread}] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} +send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $" +runto_main + +# There should be no threads initially. +gdb_test "info threads" "" "info threads 1" + +# Try stepping over the thread creation function. +gdb_breakpoint [gdb_get_line_number "linuxthreads.exp: create philosopher"] +for {set i 0} {$i < 5} {incr i} { + gdb_continue_to_breakpoint "about to create philosopher: $i" + send_gdb "next\n" + gdb_expect { + -re "\\\[New .*\\\].*$gdb_prompt $" { + pass "create philosopher: $i" + } + -re "Program received signal.*(Unknown signal|SIGUSR).*$gdb_prompt $" { + # It would be nice if we could catch the message that GDB prints + # when it first notices that the thread library doesn't support + # debugging, or if we could explicitly ask GDB somehow. + unsupported "This GDB does not support threads on this system." + return -1 + } + -re "$gdb_prompt $" { + fail "create philosopher: $i" + } + timeout { + fail "(timeout) create philosopher: $i" + } + } +} + +# Run until there are some threads. +gdb_breakpoint [gdb_get_line_number "linuxthreads.exp: info threads 2"] +gdb_continue_to_breakpoint "main thread's sleep" +gdb_test "info threads" "7 Thread .*6 Thread .*5 Thread .*4 Thread .*3 Thread .*2 Thread .*1 Thread .*" "info threads 2" + +# Try setting a thread-specific breakpoint. +gdb_breakpoint "print_philosopher thread 5" +gdb_continue_to_breakpoint "thread 5's print" +gdb_test "where" "print_philosopher.*philosopher.*pthread_start_thread.*" \ + "first thread-specific breakpoint hit" + +# Make sure it's catching the right thread. Try hitting the +# breakpoint ten times, and make sure we don't get anyone else. +set only_five 1 +for {set i 0} {$only_five > 0 && $i < 10} {incr i} { + gdb_continue_to_breakpoint "thread 5's print, pass: $i" + send_gdb "info threads\n" + gdb_expect { + -re "\\* 5 Thread .* print_philosopher .*\r\n$gdb_prompt $" { + # Okay this time. + } + -re ".*$gdb_prompt $" { + set only_five 0 + } + timeout { + set only_five -1 + } + } +} + +set name "thread-specific breakpoint is thread-specific" +if {$only_five == 1} { pass $name } +if {$only_five == 0} { fail $name } +if {$only_five == -1} { fail "$name (timeout)" } + + +### Select a particular thread. +proc select_thread {thread} { + global gdb_prompt + + send_gdb "thread $thread\n" + gdb_expect { + -re "\\\[Switching to thread .*\\\].*\r\n$gdb_prompt $" { + pass "selected thread: $thread" + } + -re "$gdb_prompt $" { + fail "selected thread: $thread" + } + timeout { + fail "selected thread: $thread (timeout)" + } + } +} + +### Select THREAD, check for a plausible backtrace, and make sure +### we're actually selecting a different philosopher each time. +### Return true if the thread had a stack which was not only +### acceptable, but interesting. SEEN should be an array in which +### SEEN(N) exists iff we have found philosopher number N before. +proc check_philosopher_stack {thread seen_name} { + global gdb_prompt + upvar $seen_name seen + + set name "philosopher is distinct: $thread" + set interesting 0 + + select_thread $thread + send_gdb "where\n" + gdb_expect { + -re ".* in philosopher \\(data=(0x\[0-9a-f\]+).*\r\n$gdb_prompt $" { + set data $expect_out(1,string) + if {[info exists seen($data)]} { + fail $name + } else { + pass $name + set seen($data) yep + } + set interesting 1 + } + -re "pthread_start_thread.*\r\n$gdb_prompt $" { + ## Maybe the thread hasn't started yet. + pass $name + } + -re " in \\?\\?.*\r\n$gdb_prompt $" { + ## Sometimes we can't get a backtrace. I'm going to call + ## this a pass, since we do verify that at least one + ## thread was interesting, so we can get more consistent + ## test suite totals. But in my heart, I think it should + ## be an xfail. + pass $name + } + -re "$gdb_prompt $" { + fail $name + } + timeout { + fail "$name (timeout)" + } + } + + return $interesting +} + +set any_interesting 0 +array set seen {} +for {set i 3} {$i <= 7} {incr i} { + if [check_philosopher_stack $i seen] { + set any_interesting 1 + } +} + +if {$any_interesting} { + pass "found an interesting thread" +} else { + fail "found an interesting thread" +} Index: pthreads.c =================================================================== --- pthreads.c (nonexistent) +++ pthreads.c (revision 1765) @@ -0,0 +1,168 @@ +#include + +#include "config.h" + +#ifndef HAVE_PTHREAD_H + +/* Don't even try to compile. In fact, cause a syntax error that we can + look for as a compiler error message and know that we have no pthread + support. In that case we can just suppress the test completely. */ + +#error "no posix threads support" + +#else + +/* OK. We have the right header. If we try to compile this and fail, then + there is something wrong and the user should know about it so the testsuite + should issue an ERROR result.. */ + +#ifdef __linux__ +#define _MIT_POSIX_THREADS 1 /* Linux (or at least RedHat 4.0) needs this */ +#endif + +#include + +/* Under OSF 2.0 & 3.0 and HPUX 10, the second arg of pthread_create + is prototyped to be just a "pthread_attr_t", while under Solaris it + is a "pthread_attr_t *". Arg! */ + +#if defined (__osf__) || defined (__hpux__) +#define PTHREAD_CREATE_ARG2(arg) arg +#define PTHREAD_CREATE_NULL_ARG2 null_attr +static pthread_attr_t null_attr; +#else +#define PTHREAD_CREATE_ARG2(arg) &arg +#define PTHREAD_CREATE_NULL_ARG2 NULL +#endif + +static int verbose = 0; + +static void +common_routine (arg) + int arg; +{ + static int from_thread1; + static int from_thread2; + static int from_main; + static int hits; + static int full_coverage; + + if (verbose) printf("common_routine (%d)\n", arg); + hits++; + switch (arg) + { + case 0: + from_main++; + break; + case 1: + from_thread1++; + break; + case 2: + from_thread2++; + break; + } + if (from_main && from_thread1 && from_thread2) + full_coverage = 1; +} + +static void * +thread1 (void *arg) +{ + int i; + int z = 0; + + if (verbose) printf ("thread1 (%0x) ; pid = %d\n", arg, getpid ()); + for (i=1; i <= 10000000; i++) + { + if (verbose) printf("thread1 %d\n", pthread_self ()); + z += i; + common_routine (1); + sleep(1); + } +} + +static void * +thread2 (void * arg) +{ + int i; + int k = 0; + + if (verbose) printf ("thread2 (%0x) ; pid = %d\n", arg, getpid ()); + for (i=1; i <= 10000000; i++) + { + if (verbose) printf("thread2 %d\n", pthread_self ()); + k += i; + common_routine (2); + sleep(1); + } + sleep(100); +} + +int +foo (a, b, c) + int a, b, c; +{ + int d, e, f; + + if (verbose) printf("a=%d\n", a); +} + +main(argc, argv) + int argc; + char **argv; +{ + pthread_t tid1, tid2; + int j; + int t = 0; + void (*xxx) (); + pthread_attr_t attr; + + if (verbose) printf ("pid = %d\n", getpid()); + + foo (1, 2, 3); + +#ifndef __osf__ + if (pthread_attr_init (&attr)) + { + perror ("pthread_attr_init 1"); + exit (1); + } +#endif + +#ifdef PTHREAD_SCOPE_SYSTEM + if (pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM)) + { + perror ("pthread_attr_setscope 1"); + exit (1); + } +#endif + + if (pthread_create (&tid1, PTHREAD_CREATE_ARG2(attr), thread1, (void *) 0xfeedface)) + { + perror ("pthread_create 1"); + exit (1); + } + if (verbose) printf ("Made thread %d\n", tid1); + sleep (1); + + if (pthread_create (&tid2, PTHREAD_CREATE_NULL_ARG2, thread2, (void *) 0xdeadbeef)) + { + perror ("pthread_create 2"); + exit (1); + } + if (verbose) printf("Made thread %d\n", tid2); + + sleep (1); + + for (j = 1; j <= 10000000; j++) + { + if (verbose) printf("top %d\n", pthread_self ()); + common_routine (0); + sleep(1); + t += j; + } + + exit(0); +} + +#endif /* ifndef HAVE_PTHREAD_H */ Index: step.c =================================================================== --- step.c (nonexistent) +++ step.c (revision 1765) @@ -0,0 +1,221 @@ +/* step.c for step.exp */ +#include +#include +#include +#include +#include + +void alarm_handler (); +void alarm_handler1 (); +void alarm_handler2 (); +void thread1 (); +void thread2 (); + +#define TIME_LIMIT 30 + + +int count1 = 0; +int count2 = 0; + +pthread_t tid1, tid2; +pthread_attr_t attr1, attr2; + +pthread_mutex_t mut; +pthread_mutexattr_t mut_attr; + +pthread_condattr_t cv_attr_a, cv_attr_b; +pthread_cond_t cv_a, cv_b; + +struct cv_struct + { + char a; + char b; + } +test_struct; + +main () +{ + /*init la struct */ + test_struct.a = 0; + test_struct.b = 1; + + /* create le mutex */ + if (pthread_mutexattr_create (&mut_attr) == -1) + { + perror ("mutexattr_create"); + exit (1); + } + + + if (pthread_mutex_init (&mut, mut_attr) == -1) + { + perror ("mutex_init"); + exit (1); + } + + /* create 2 cv */ + if (pthread_condattr_create (&cv_attr_a) == -1) + { + perror ("condattr_create(1)"); + exit (1); + } + + if (pthread_cond_init (&cv_a, cv_attr_a) == -1) + { + perror ("cond_init(1)"); + exit (1); + } + + if (pthread_condattr_create (&cv_attr_b) == -1) + { + perror ("condattr_create(2)"); + exit (1); + } + + if (pthread_cond_init (&cv_b, cv_attr_b) == -1) + { + perror ("cond_init(2)"); + exit (1); + } + + /* create 2 threads of execution */ + if (pthread_attr_create (&attr1) == -1) + { + perror ("attr_create(1)"); + exit (1); + } + + if (pthread_create (&tid1, attr1, thread1, &count1) == -1) + { + perror ("pthread_create(1)"); + exit (1); + } + + if (pthread_attr_create (&attr2) == -1) + { + perror ("attr_create(2)"); + exit (1); + } + + if (pthread_create (&tid2, attr2, thread2, &count2) == -1) + { + perror ("pthread_create(2)"); + exit (1); + } + + /* set alarm to print out data and exit */ + signal (SIGALRM, alarm_handler); + alarm (TIME_LIMIT); + + for (;;) + pause (); +} + +void +thread1 (count) + int *count; +{ + tid_t tid; + + tid = getstid (); + printf ("Thread1 tid 0x%x (%d) \n", tid, tid); + printf ("Thread1 @tid=0x%x \n", &tid); + signal (SIGALRM, alarm_handler1); + + for (;;) + { + if (pthread_mutex_lock (&mut) == -1) + { + perror ("pthread_mutex_lock(1)"); + pthread_exit ((void *) 0); + } + + while (test_struct.a == 0) + { + if (pthread_cond_wait (&cv_a, &mut) == -1) + { + perror ("pthread_cond_wait(1)"); + pthread_exit ((void *) -1); + } + } + + (*count)++; + printf ("*******thread1 count %d\n", *count); + + test_struct.a = 0; + + test_struct.b = 1; + pthread_cond_signal (&cv_b); + + if (pthread_mutex_unlock (&mut) == -1) + { + perror ("pthread_mutex_unlock(1)"); + pthread_exit ((void *) -1); + } + } +} + +void +thread2 (count) + int *count; +{ + tid_t tid; + + tid = getstid (); + printf ("Thread2 tid 0x%x (%d) \n", tid, tid); + printf ("Thread1 @tid=0x%x \n", &tid); + signal (SIGALRM, alarm_handler2); + + for (;;) + { + if (pthread_mutex_lock (&mut) == -1) + { + perror ("pthread_mutex_lock(2)"); + pthread_exit ((void *) 0); + } + + while (test_struct.b == 0) + { + if (pthread_cond_wait (&cv_b, &mut) == -1) + { + perror ("pthread_cond_wait(2)"); + pthread_exit ((void *) -1); + } + } + + (*count)++; + printf ("*******thread2 count %d\n", *count); + + test_struct.b = 0; + + test_struct.a = 1; + pthread_cond_signal (&cv_a); + + if (pthread_mutex_unlock (&mut) == -1) + { + perror ("pthread_mutex_unlock(2)"); + pthread_exit ((void *) -1); + } + } +} + + +void +alarm_handler () +{ + printf ("\tcount1 (%d) \n\tcount2 (%d)\n", count1, count2); + exit (0); +} + +void +alarm_handler1 () +{ + printf ("ALARM thread 1\n"); +} + +void +alarm_handler2 () +{ + printf ("ALARM thread 2\n"); + pthread_exit ((void *) 0); +}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.